In this project, a 16-bit pipelined MIPS processor is implemented in Verilog HDL.
MIPS pipeline has five stages, with one step per stage:
• IF: Instruction fetch from memory.
• ID: Instruction decode & register read.
• EX: Execute operation or calculate address.
• MEM: Access memory operand.
• WB: Write result back to register.
Each stage takes in data from that buffer, processes it and write into the next buffer. Also note that as an instruction moves down the pipeline from one buffer to the next, its relevant information also moves along with it.
- Add : R[rd] = R[rs] + R[rt]
- Subtract : R[rd] = R[rs] - R[rt]
- And: R[rd] = R[rs] & R[rt]
- Or : R[rd] = R[rs] | R[rt]
- SLT: R[rd] = 1 if R[rs] < R[rt] else 0
- SLTI: R[rt] = 1 if R[rs] < SignExtImm else 0
- Lw: R[rt] = M[R[rs]+SignExtImm]
- Sw : M[R[rs]+SignExtImm] = R[rt]
- Beq : if(R[rs]==R[rt]) PC=PC+1+BranchAddr
- J : PC=JumpAddr
- With pipelining, multiple instructions are overlapped during execution.
- Latency is the same, but throughput improves.
- Pipeline rate limited by slowest pipeline stage.
- Potential speedup = Number of pipe stages.
This project needs Icarus-Verilog and a VCD viewer.
-
Icarus-Verilog can be installed via Homebrew :
$ brew install icarus-verilog
-
Download Scansion from here.
-
Clone the repository.
-
Run
$ make
and type MIPS code to see it in binary form in rams_init_file.hex file. -
$ make simulate
will:
- compile design+TB
- simulate the verilog design
$ make display
will:
- display waveforms.
📌📌📌 You should use a for loop to dump array words in your test bench. Check out these articles!