Xilinx UG129 Answering Machine User Manual


 
PicoBlaze 8-bit Embedded Microcontroller www.xilinx.com 89
UG129 (v1.1.2) June 24, 2008
R
Appendix B
Example Program Templates
The following code templates provide the basic recommended structure for PicoBlaze™
processor application programs. Both KCPSM3 and pBlazIDE templates are provided.
KCPSM3 Syntax
Figure B-1 provides a code template for creating PicoBlaze applications using the KCPSM3
assembler.
T
If reading this document in Adobe Acrobat,
use the Select Text tool to select code snippets,
then copy and paste the text into your text editor.
Figure B-1: PicoBlaze Application Program Template for KCPSM3 Assembler
NAMEREG sX, <name> ; Rename register sX with <name>
CONSTANT <name>, 00 ; Define constant <name>, assign value
; ROM output file is always called
; <filename>.vhd
ADDRESS 000 ; Programs always start at reset vector 0
ENABLE INTERRUPT ; If using interrupts, be sure to enable
; the INTERRUPT input
BEGIN:
; <<< your code here >>>
JUMP BEGIN ; Embedded applications never end
ISR: ; An Interrupt Service Routine (ISR) is
; required if using interrupts
; Interrupts are automatically disabled
; when an interrupt is recognized
; Never re-enable interrupts during the ISR
RETURNI ENABLE ; Return from interrupt service routine
; Use RETURNI DISABLE to leave interrupts
; disabled
ADDRESS 3FF ; Interrupt vector is located at highest
; instruction address
JUMP ISR ; Jump to interrupt service routine, ISR