Picoblaze Interrupt Interface & Assembly Code Development: Ece 448 - Fpga and Asic Design With VHDL
Picoblaze Interrupt Interface & Assembly Code Development: Ece 448 - Fpga and Asic Design With VHDL
JUMP AAA
PC <= AAA
JUMP C, AAA
if C=1 then PC <= AAA else PC <= PC + 1
JUMP NC, AAA
if C=0 then PC <= AAA else PC <= PC + 1
JUMP Z, AAA
if Z=1 then PC <= AAA else PC <= PC + 1
JUMP NC, AAA
if Z=0 then PC <= AAA else PC <= PC + 1
Program Flow Control Instructions (2)
CALL AAA
TOS <= TOS+1; STACK[TOS] <= PC; PC <= AAA
CALL C | Z , AAA
if C | Z =1 then
TOS <= TOS+1; STACK[TOS] <= PC; PC <= AAA
else
PC <= PC + 1
CALL NC | NZ , AAA
if C | Z =0 then
TOS <= TOS+1; STACK[TOS] <= PC; PC <= AAA
else
PC <= PC + 1
Program Flow Control Instructions (3)
RETURN (RET)
PC <= STACK[TOS] + 1; TOS <= TOS - 1
RETURN C | Z (RET C | Z )
if C | Z =1 then
PC <= STACK[TOS] + 1; TOS <= TOS - 1
else
PC <= PC + 1
RETURN NC | NZ (RET NC | NZ )
if C | Z =0 then
PC <= STACK[TOS] + 1; TOS <= TOS - 1
else
PC <= PC + 1
Interrupt Related Instructions
RETURNI ENABLE (RETI ENABLE)
PC <= STACK[TOS] ; TOS <= TOS – 1;
I <= 1; C<= PRESERVED C; Z<= PRESERVED Z
k-1
p = a x = a x i 2i =
i=0
k times
p(0) = 0
p(j+1) = (p(j) + xj a 2k) / 2 j=0..k-1
p = p(k)
Unsigned Multiplication Computations
8 bits 8 bits
pH pL p p(j)
+ xj a + xj a 28
pH pL
2 p(j+1)
>> 1
0 pH pL p(j+1)
pH = s5 pL = s6
PicoBlaze Registers
a = s3
x = s4
Unsigned Multiplication Subroutine (1)
;=========================================================
; routine: mult_soft
; function: 8-bit unsigned multiplier using
; shift-and-add algorithm
; input register:
; s3: multiplicand
; s4: multiplier
; output register:
; s5: upper byte of product
; s6: lower byte of product
; temp register: i
;=========================================================
Unsigned Multiplication Subroutine (2)
mult_soft:
load s5, 00 ;clear s5
load i, 08 ;initialize loop index
mult_loop:
sr0 s4 ;shift lsb to carry
jump nc, shift_prod ;lsb is 0
add s5, s3 ;lsb is 1
shift_prod:
sra s5 ;shift upper byte right,
;carry to MSB, LSB to carry
sra s6 ;shift lower byte right,
;lsb of s5 to MSB of s6
sub i, 01 ;dec loop index
jump nz, mult_loop ;repeat until i=0
return