Last modified: Thu Feb 25 21:49:10 CST 1999
In step 3 of the project you implement a simple computer, using Verilog HDL at the behavioral level.
Use the basic structure of the simple counter machine provided in Project 1. In particular, keep the 3 instruction execution steps (fetch, increment PC, execute).
PC
register and the IR
register width to deal with the longer addresses needed for a memory
of 256 words.PC
and IR
), takes 1
time step. Using your experience from Project 2 imagine a 16 bit ALU
(similar to the one in Project 2 but on 16 bits and built using these
gates that all have a delay of 1).
Determine the maximum ALU delay from
your new ALU, and apply it to all ALU operations. The delays shown in Table
2 are only for the instruction execution step: you must apply
appropriate delays to the other steps.M[0]
and
M[1]
before your program starts. When your program
terminates, the gcd value must be in M[2]
. Also,
when your program terminates it should display the memory values
M[0], M[1]
and M[3]
. Keep all intermediate
values in registers. You are not
responsible for the behavior of the program on nonpositive inputs.
Use the following version of Euclid's algorithm to compute the gcd:
Compile the algorithm by hand into the most straightforward machine code. Don't do any clever programming.while (b > 0) { c = b; if (a < b) then b = a else b = a - b; a = c; }
Run your program on at least the following inputs: (128, 36) and (55, 21)
ADD
, SUB
, INC
, DEC
operations, instead of specifying them at the behavioral level. Test and demonstrate your computer again with the ALU.3-register format: | opcode | reg 1 | reg 2 | reg 3 | ignored | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |
Load/Store format: | opcode | reg 1 | reg 2 | memory address | ||||||||||||
15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
instruction field | contents |
---|---|
IR[15:12] | opcode |
IR[11:10] |
register 1 (ALU result or Load/Store) |
IR[ 9: 8] |
register 2 (ALU operand or indirect) |
IR[ 7: 6] | register 3 (ALU operand) |
OR | |
IR[ 7: 0] | memory address |
Mnemonic | Binary opcode | Action | Execution delay |
---|---|---|---|
LOADd | 0000 |
R[IR[11:10]] = M[IR[7:0]]
(direct adressing) | 52 |
LOADi | 0001 |
R[IR[11:10]] = M[R[IR[9:8]]]
(indirect adressing) | 53 |
STOREd | 0010 |
M[IR[7:0]] = R[IR[11:10]] | 51 |
STOREi | 0011 |
M[R[IR[9:8]]] = R[IR[11:10]] |
52 |
MV | 0100 |
R[IR[11:10]] = R[IR[9:8]] | 3 |
ADD | 1000 |
R[IR[11:10]] = R[IR[9:8]] + R[IR[7:6]] |
3 + ALUdelay |
SUB | 1001 |
R[IR[11:10]] = R[IR[9:8]] - R[IR[7:6]] |
3 + ALUdelay |
INC | 1010 |
R[IR[11:10]] = R[IR[9:8]] + 1 |
3 + ALUdelay |
DEC | 1011 |
R[IR[11:10]] = R[IR[9:8]] - 1 |
3 + ALUdelay |
JMP | 1110 |
PC = IR[7:0] | 2 |
JMPZ | 1101 |
if (R[IR[9:8]] == 0) then PC = IR[7:0] |
4 |
JMPLZ | 1100 |
if (R[IR[9:8]] < 0) then PC = IR[7:0] |
3 |
HALT | 1111 | 1 |
Hand in: