CS7290 Advanced microarchitecture
Fall 2014
Instructor: Prof. Hyesoon Kim
Project #1.5
Due: September 12 (F) 6 pm
This is an intermediate assignment to make you get used to in CHDL programming. Hence, only this assignment
is an individual project.
In the class, we have constructed a simple demo with 4 instructions. We extend the ISA to have two more instructions, LDW and STW. But since we haven't really discussed constructing/using memory structure, in this assignment you only implement LDW. LDW will just load from the instruction memory, just like loading IR values using PC.
Your job is to build a single cycle CPU processor that handles 5 instructions.
You can start from the demo CHDL code. Please note that the opcode format is slightly different and branch instruction is also slightly different, so you have to make appropriate changes.
Usefu documents: CHDL tutorial , CHDL tutorial 2 , faq , updated demo
What to turn in
You submit a screen print of PC values and Register values.( $t4, $t7, $t0)
You also submit your CHDL code
Note:
You should see the loop is iterated 3 times and $t4 becomes 6 (1+2+3).
However, because there is no halt instruction, the simulation continues
and $t4 value becomes corrupted after 20ns later.
Grading
If you submit a screen shot showing the correct value of register values, you will receive 10 points.
Testing Assembly Code
LDI $t0, 0 // branch condition variable
LDI $t1, 3 // loop iteration counts
LDI $t3, 10 // load base location // data is added right after the instructions
LDI $t4, 0 // sum variable
LDI $t6, 1 // constant value to increase
LOOP LDW $t7, $t3, 0 //
ADD $t4, $t4, $t7 // compute the sum of load values
ADD $t0, $t0, $t6
ADD $t3, $t3, $t6 // increment load index function
BNE $t0, $t1, LOOP
.fill 1 // data value : MEM[10]
.fill 2 // data value : MEM[11]
.fill 3 // data value : MEM[12]
.fill 4 // data value : MEM[13]
.fill 5 // data value : MEM[14]
Please use proj15.hex to initialize your ROM (InstMem in the provided demo code).
To make the assignment easy, you use only instruction memory for this assignment. When you initialize the instruction memory with proj15.hex, the data values are added at the end of instructions.
Summary Opcode Format (16-bit ISA, 8 registers)
bne $t0, $t1, Target // branch to target if $t0 != $t1
Target = next pc + SEXT(#immediate value)
immediate value should be added to the incremented PC
Opcode (000) IR[15:13], $t0: IR[12:10], $t1:IR[9:7], immediate value: IR[6:0]
ADD $t0, $t1, $t2
$t0 = $t1 + $t2
Opcode(001):IR[15:13], $t0:IR[12:10], $t1:IR[9:7], $t2:IR[6:4]
SUB $t0, $t1, $t2
$t0 = $t1 - $t2
Opcode(010):IR[15:13], $t0:IR[12:10], $t1:IR[9:7], $t2:IR[6:4]
LDI $t0, #immediate // Load immediate value
$t0 = SEXT(#immediate)
Opcode(011):IR[15:13], $t0:IR[12:10], immediate value:IR[6:0]
LDW $t0, $t1, offset
$t0 = MEM[$t1+SEXT(offset)]
Opcode(100):IR[15:13], $t0:IR[12:10], $t1:IR[9:7], offset:IR[6:0]
STW $t0, $t1, offset
MEM[$t1+SEXT(offset)] = $t0
Opcode(101):IR[15:13], $t0:IR[12:10], $t1:IR[9:7], offset:IR[6:0]