This is a multiplication function using RV32I assembly language.
The test handbook can be seen in here.
The debug log file can be seen in here.
Use make all -i
to restart test. Configuration of the test time refers test handbook.
0 * 0 = 'd6 cycles
0xffffffff * 0xffffffff = 'd449 cycles
random * random = 'd331 cycles (avarage 1000 RUNTIME)
In RV32I, only 32 32bits reg files can be used. To implement mul operation through software, we must use two registers to store for the results.
For every bit of the multiplicand, logic shift left the multiplier and accumulate if it is 1. The overall structure of the mul is shown in the folllowing fig.
Two accumulators are used to compute the result. The differences between lower bits and uppper bits are the shift times.
The final problem is the carry out from lower bits accumulator. So if there is a carry out from it, another selfadd need to be done for higher bits accumulator.
CARRY OUT signal is obtained by the following equation:
The program flow chart is shown in below:
C program input the values and call asm to compute the mul results