Académique Documents
Professionnel Documents
Culture Documents
=============================================================
Task 1
Create an enhanced single-cycle MIPS processors functionality by extending its instruction support from the initial sub set (ADD, SUB, AND, OR, SLT, LW, SW, BEQ, J, ADDI) to cover the following additional instructions: MULTU, MFHI, MFLO, JR, and JAL.
Task 2
Pipeline the enhanced single-cycle MIPS processor based on the reference design shown below.
For each task of our design, it will be tested via both Verilog simulation and FPGA validation. Two sample test programs (from previous lab assignments) are attached below. Test Program 1: C++ Pseudo Code.
a = 0x51; b = 0x13; Save a to memory address 0x20; Save b to memory address 0x24; x = a - b; a = a + b; // a = 0x64 if(a < 0x25){ Read the word at address 0x20 into $a0; //so a=0x51 a = a + 0x89; } else{ Read the word at address 0x20 into $a0; //so a=0x51 a = a - 0x10; } Store the value of a to memory address 0x30;
#$a0 = a $a1 = b $s0 = x # Variables initialization li $a0, 0x51 #a = 0x51 li $a1, 0x13 #b = 0x13 sw $a0, 0x20($0) #save a to memory address 0x20 sw $a1, 0x24($0) #save b to memory address 0x24 # Arithmetic computations sub $s0, $a0, $a1 #x=a-b add $a0, $a0, $a1 # a = a + b; #IF structure addi $t1, $0, 0x25 # temp1 = 0 + 0x25 slt $t2, $a0, $t1 # set temp2 = 1 if a < 2500 lw $a0, 0x20($0) beq $t2, $0, else # if temp2 = 0, go to else addi $a0, $a0, 137 # a = a + 0x89 j endif #else structure else: addi $a0, $a0, -16 # a = a + 0x9 #endif structure endif: 5
sw $a0, 0x30($0)
main: # addi $sp, $0, 48 not for SPIM addi $a0, $0, 12 # set arg jal factorial # compute the factorial add $s0, $v0, $0 # move result into $s0 j end factorial: addi $sp, $sp, -8 # make room on stack sw $a0, 4($sp) # store $a0 sw $ra, 0($sp) # store $ra addi $t0, $0, 2 # $t0 = 2 slt $t0, $a0, $t0 # a <= 1 ? beq $t0, $0, else # no - goto else addi $v0, $0, 1 # yes - return 1 addi $sp, $sp, 8 # restore $sp jr $ra # return else: addi $a0, $a0, -1 # n = n - 1 jal factorial # recursive call lw $ra, 0($sp) # restore $ra lw $a0, 4($sp) # restore $a0 addi $sp, $sp, 8 # restore $sp multu $a0, $v0 # n * factorial(n-1) mflo $v0 # mv result into $v0 jr $ra end:
Figure Register / Memory content from test program 2 after execution. Verification And Test
Figure ISIM (single cycle using test program 1) The figure above shows simulation of our single cycle. This simulation yields correct results. When executing on MIPS, the last instruction (ac40030) stores value 41 of register a into memory address 0x30. As shown from ISIM figure above, wave length din[31:0] and addr[31:0] of DMEM shows value 30 and 41.