To
set up your homework environment, please download the ActiveHDL
implementation of our MIPS2001 CPU, unzip it and open the workspace mips2001.aws in ActiveHDL. The mips2000.bde schematic is your CPU,
containing two memories (instruction memory and data memory, drawn in blue),
one register file with 32 registers, an
1. Familiarize
yourself with the components that you have seen in the lecture. Your task is to
implement the controller of the CPU. So have a very thorough look at that
component. Write
down and hand in a list of all the controller inputs and outputs, give
the information to what component they connect, what legal output values they
can have and what control function is enabled by which value. (Hint: Look
at the implementation and the comments in the other parts of the CPU.)
Example:
Port |
Direction |
Connects to |
Value |
Functionality |
srcB |
Out |
|
0 |
Select
RegB as second input |
… |
… |
… |
… |
… |
2. Look
at the imemory_alutest.v
file. This is the CPUs instruction memory with a predefined program that does
just a few operations (it exercises the
Second
part, due 30 May:
3. Your goal is to determine the specific control signals needed for all of the instructions. Finish the skeleton code in controller.v, and replace all of the instances of x with the correct values. When your controller is working print and hand in your controller.v file. Here is a description of the instructions you need to implement.
Name |
Enc |
Abbr |
R Behavior |
PC Behav. |
Arithmetic Op |
Reg |
ADD, |
rd = rs op rt |
PC++ |
Set on less than |
Reg |
SLT |
rd = (rs < rt)? 1:0 |
PC++ |
Jump Register |
Reg |
JR |
No change |
PC=rs |
I-Format Instructions |
||||
Load Word from Memory |
Imm |
LW |
rt = MEM[rs+SE(immed)] |
PC++ |
Store Word to Memory |
Imm |
SW |
MEM[rs+SE(immed)] = rt |
PC++ |
Add Immediate |
Imm |
ADDI |
rt = rs + SE(immed[15:0]) |
PC++ |
Or Immediate |
Imm |
|
rt = rs | {ZERO[15:0],immed} |
PC++ |
Load Upper Immed. |
Imm |
LUI |
rt = immed[15:0],zeros[15:0] |
PC++ |
Branch if equal |
Imm |
BEQ |
No change |
PC = PC+1+((rs == rt)? SE(immed) : 0) |
J-Format Instructions |
||||
Jump |
Jmp |
J |
No change |
PC = {(PC+1)[31:26],Inst[25:0]} |
Jump and Link |
Jmp |
JAL |
r31=PC+1 |
PC = {(PC+1)[31:26],Inst[25:0]} |
4. The
file imemory_hanoi.v
contains an implementation of the "Towers of Hanoi".
It is quite high level
Replace your old
You can experiment with different input values for the number of discs used in
the Towers of Hanoi. The number of discs is read from dmemory[254].
Note: This is a recursive implementation that stores info in dmem for each "call". Therefore, if you use too
many discs, memory will overflow and things will stop working. You can fix this
by increasing the size of memory in dmemory.v, and
the number of bits of address used.