R

Chapter 9: PicoBlaze Development Tools

Importing KCPSM3 Code into pBlazIDE

The pBlazIDE syntax and instruction mnemonics are different than the Xilinx KCPSM3 syntax. The pBlazIDE software provides an import function to convert KCPSM3 code to the pBlazIDE syntax.

From the pBlazIDE menu, choose File Æ Import, then select the KCPSM3-format *.psm file, as shown in Figure 9-3. The pBlazIDE software automatically translates and formats the source code, as shown in Figure 9-4.

pBlaze IDE

F ile E dit V iew

New Ctrl+N

Open ... Ctrl+O

Recent Files

Import

Export

UG129_c10_03_051504

Figure 9-3:Converting Xilinx Syntax PicoBlaze Source Code to pBlazIDE Syntax

KCMPSM Source Code

CONSTANT myconstant, A5

NAMEREG s0, count16_lsb

NAMEREG s1, count16_msb

ADDRESS 000

main:

;initialize 16-bit counter, enable interrupts LOAD count16_lsb, myconstant

ENABLE INTERRUPT

loop:

;continuously increment 16-bit counter CALL increment_count JUMP loop

end_main:

increment_count:

;add 1 to LSB of 16-bit counter ADD count16_lsb, 01

;only add one to MSB if carry generated by LSB ADDCY count16_msb, 00

RETURN

isr:

;decrement 16-bit counter by one on interrupt

;subtract 1 from LSB of 16-bit counter

SUB count16_lsb, 01

;only subtract one from MSB if borrow

;generated by LSB

SUBCY count16_msb, 00

RETURNI ENABLE

;interrupt vector is always in last memory location

ADDRESS 3FF

;jump to interrupt service routing (ISR)

JUMP isr

Code Imported/Converted into pBlaze IDE

myconstant EQU $A5

count16_lsb EQU s0

count16_msb EQU s1

ORG 0

main:

; initialize 16-bit counter, enable interrupts

LOAD count16_lsb, myconstant

EINT

loop:

; continuously increment 16-bit counter

CALL increment_count

JUMP loop

end_main:

increment_count:

; add 1 to LSB of 16-bit counter

ADD count16_lsb, 1

;only add one to MSB if carry generated by LSB

ADDC count16_msb, 0

RET

isr:

;decrement 16-bit counter by one on interrupt

;subtract 1 from LSB of 16-bit counter

SUB count16_lsb, 1

;only subtract one from MSB if borrow

;generated by LSB

SUBC count16_msb, 0

RETI ENABLE

; interrupt vector is always in last memory location

ORG $3FF

;jump to interrupt service routing (ISR)

JUMP isr

UG129_c10_04_052004

Figure 9-4:Example of How KCPSM Source Code Converts to pBlazIDE Code

68

www.xilinx.com

PicoBlaze 8-bit Embedded Microcontroller

 

 

UG129 (v1.1.2) June 24, 2008

Page 68
Image 68
Xilinx UG129 manual Importing KCPSM3 Code into pBlazIDE, 4Example of How Kcpsm Source Code Converts to pBlazIDE Code