Xilinx UG129 Answering Machine User Manual


 
30 www.xilinx.com PicoBlaze 8-bit Embedded Microcontroller
UG129 (v1.1.2) June 24, 2008
Chapter 3: PicoBlaze Instruction Set
R
Division
The PicoBlaze microcontroller core does not have a dedicated hardware divider. However,
the PicoBlaze microcontroller performs division using the available arithmetic and shift
instructions. Figure 3-17 demonstrates a subroutine that divides an unsigned 8-bit number
by another unsigned 8-bit number to produce an 8-bit quotient and an 8-bit remainder in
60 to 74 instruction cycles, or 120 to 144 clock cycles.
Figure 3-15: 8-bit by 8-bit Hardware Multiplier Using the FPGA’s 18x18 Multipliers
IN_PORT[7:0] OUT_PORT[7:0]
PORT_ID[7:0]
READ_STROBE
WRITE_STROBE
PicoBlaze Microcontroller
[0]
EN
EN
A[7:0]
A[17:8]
B[7:0]
B[17:8]
P[7:0]
P[15:8]
18x18 Multiplier
0
1
SEL
UG129_c3_02_052004
Figure 3-16: 8-bit by 8-bit Multiply Routine Using Hardware Multiplier
; Multiplier Routine (8-bit x 8-bit = 16-bit product)
; ===================================================
; Connects to embedded 18x18 Hardware Multiplier via ports
;
mult_8x8io:
NAMEREG s0, multiplicand ; preserved
NAMEREG s1, multiplier ; preserved
NAMEREG s3, result_msb ; most-significant byte (MSB) of result, modified
NAMEREG s4, result_lsb ;
least-significant byte (LSB) of result, modified
;
; Define the port ID numbers as constants for better clarity
CONSTANT multiplier_lsb, 00
CONSTANT multiplier_msb, 01
;
;
Output multiplicand and multiplier to FPGA registers connected to the inputs of
; the embedded multiplier.
OUTPUT multiplicand, multiplier_lsb
OUTPUT multiplier, multiplier_msb
;
; Input the resulting product from the embedded multiplier.
INPUT result_lsb, multiplier_lsb
INPUT result_msb, multiplier_msb
;
RETURN ; multiplier result now available in result_msb
; and result_lsb