Starting from:

$30

CS224-Lab 4 Solved

Determine the assembly language equivalent of the machine codes given in the imem module in the “Complete MIPS model.txt” file posted on Unilica for this lab.  In the given System Verilog module for imem, the hex values are the MIPS machine language instructions for a small test program. Dis-assemble these codes into the equivalent assembly language instructions and give a 3-column table for the program, with one line per instruction, containing its location, machine instruction (in hex) and its assembly language equivalent. [Note: you may dis-assembly by hand or use a program tool like the one in Unilica.]

 

c) Register Transfer Level (RTL) expressions for each of the new instructions that you are adding (see list below for your section), including the fetch and the updating of the PC.

d) Make any additions or changes to the datapath which are needed in order to make the RTLs for the instructions possible. The base datapath should be in black, with changes marked in red and other colors (one color per new instruction).

e)  Make a new row in the main control table for each new instruction being added, and if necessary, add new columns for any new control signals that are needed (input or output). Be sure to completely fill in the table—all values must be specified.  If any changes are needed in the ALU decoder table, give this table in its new form (with new rows, columns, etc). The base table should be in black, with changes marked in red and other colors.  {Note: if you need new ALUOp bits to encode new values, you should also give a new version of Table 7.1, showing the new encodings}

f)  Write a test program in MIPS assembly language, that will show whether the new instructions are working or not, and that will confirm that all existing old instructions still continue to work. Don’t use any pseudo-instructions; use only real MIPS instructions that will be recognized by the new control unit.

 


Table of instructions to implement-- by section

Section
MIPS instructions
Sec 1
Base: Original10

New: “lui”, “jalm”
Sec 2
Base: Original10

New: “ble”, “push”
Sec 3
Base: Original10

New: “jm”, ”subi”
Sec 4
Base: Original10

New: “sw+”, “bge”
 

The Original10 instructions in “MIPS-lite” are add, sub, and, or, slt, lw, sw, beq, addi and j.

 

Instructions in quotes (e.g. ”push”) are not defined in the MIPS instruction set. They don’t exist in any MIPS documentation; they are completely new to MIPS.  You will create them, according to the definitions below, then implement them.

 

ble, bge: these I-type instructions do what you would expect—branch to the target address, if the condition is met. Otherwise, the branch is not taken. Example: ble $t2, $t7, TopLoop

 

jm: this I-type instruction is a jump, to the address stored in the memory location indicated in the standard way. Example: jm 40($s3)

 

subi: this I-type instruction subtracts, using a sign-extended immediate value. subi $t2, $t7, 4

 

sw+: this I-type instruction does the normal store, as expected, plus an increment (by 4, since it is a word transfer) of the base address in RF[rs]. {Note: this kind of auto-increment instructions are useful when moving through an array of data words.}

jalm: this I-type instruction is a jump, to the address stored in the memory location indicated in the standard way.  But it also puts the return address into the register specified.  Example: jalm $t5, 40($s3)

 

push: this I-type instruction does what you would expect—push a register value onto stack. Example: push $a3 {Note: the assembler automatically puts 29 in the rs field, and 0 into the immediate field, of the machine code instruction.}

 


Part 2:  Simulation and Implementation

a) Complete the System Verilog model of single-cycle MIPS by designing a 32-bit ALU module (one is partly specified already in “Complete MIPS model.txt”) and save this ALU module by itself in a new file with a meaningful name. Make this file the basis of a new Xilinx Vivado project.  In simulation, check its syntax, and then simulate this ALU, using a testbench that you will write.  When you are sure that the 32-bit ALU is working correctly in simulation, you can now use it in the MIPS-lite datapath.  When you have integrated your working 32-bit ALU into the “Complete MIPS model.txt” file, you are ready to simulate the MIPS-lite single-cycle processor in Xilinx Vivado. 

b) Make a New Project, giving it a meaningful name, for your single-cycle MIPS-lite. Do Add Source for the System Verilog modules given in “Complete MIPS model.txt” (modified with your working ALU), and Save everything (you don’t have to use Complete MIPS model.txt, you can write your code if you find it more convenient).  Make the necessary changes in order to support newly added instructions.

c) Study the small test program loaded into instruction memory (in the imem module) that you dis-assembled in part b) of your Preliminary Design Report. What is the program attempting to do? Extend the imem module so that it will also include newly added instructions as well.

d) Now make a System Verilog testbench file and using Xilinx Vivado, simulate your MIPS-lite processor executing the test program. Study the results given in the simulation window.  Find each instruction, and understand its values. Why is writedata undefined for some of the early instructions in the program? 

e) Now modify the simulation, in order to show more information. Make changes to the System Verilog modules as needed so that the 32-bit values of PC and the Instruction are made to be outputs of the top-level module. Then modify the testbench file, so that they are displayed in the simulation.

f) When you have studied the simulation results and can explain, for any instruction, the values of PC, instruction, writedata, dataaddr, and the memwrite signal, then call the TA, show your simulation demo and answer questions for grade. The purpose of the questions is to determine your knowledge level and test your ability to explain your demo, the System Verilog code and the reasons behind it, and to see if you can explain what would happen if certain changes were made to it. 

More products