How harshithajm-vlsi/rsic-5-stage-pipeline works
Purpose and Top-Level Integration
This repository implements a Verilog RISC-V processor organized as a five-stage pipeline for Vivado/Xilinx simulation or synthesis. The primary integration point is processor top.v; its project container is 5_stage_risc_recovery.xpr.
Instruction Fetch (IF)
Fetch owns program-counter sequencing and instruction retrieval:
• program counter.v holds the current PC.
• PC adder.v computes sequential next addresses.
• Instruction memeory.v supplies instructions addressed by the PC.
• IF Stage.v likely composes these fetch-side functions.
• if_id_register.v transfers fetched instruction and PC context into decode.
Decode, Register Read, and Control
The decode boundary interprets the IF/ID instruction and prepares execution inputs:
• register file.v provides architectural register reads and receives write-back updates.
• control unit.v derives pipeline control signals from instruction fields.
• immedate generator.v produces instruction-format-dependent immediates.
• id_ex_register.v captures decoded operands, immediate values, register identifiers, and control signals.
Execute and ALU Control
Execution selects the ALU operation and computes arithmetic, logical, or address results:
• ALU.v is the main datapath compute unit.
• alu control unit.v refines the high-level decode control into an ALU operation.
• id_ex_register.v is the input boundary to execute.
• ex-mem_register.v captures ALU results, store data, destination register, and memory/write-back controls.
Memory Access
The memory stage consumes EX/MEM state and performs data-memory transactions:
• Data Memeory.v implements the load/store memory interface or storage model.
• ex-mem_register.v isolates execute from memory timing.
• mem_wb_register.v captures memory read data and forwarded ALU results for retirement.
Instruction memory and data memory are separate modules (Instruction memeory.v, Data Memeory.v), establishing a Harvard-style pipeline boundary.
Write Back and Architectural State
Retirement selects the value written to the register file:
• Write Back.v chooses between memory data and execution results.
• mem_wb_register.v supplies final-stage state.
• register file.v is the principal architectural state updated by the pipeline.
Hazard Recovery and Forwarding
Pipeline correctness logic handles data dependencies:
• hazard detection unit.v detects hazards that require fetch/decode stalling or pipeline bubbling, especially load-use dependencies.
• forwardimg unit.v selects bypass sources from later pipeline stages to avoid unnecessary stalls.
• These controls cross the decode/execute and execute/memory boundaries represented by if_id_register.v, id_ex_register.v, and ex-mem_register.v.
Runtime and Infrastructure
The design is RTL Verilog, intended for Xilinx Vivado as indicated by 5_stage_risc_recovery.xpr. There are no application services, network interfaces, or external runtime dependencies evident in the repository; execution is hardware-clock-driven simulation or synthesized FPGA logic.
Main entry points: id_ex_register.v ID/EX Register · if_id_register.v IF/ID Register · ex-mem_register.v EX/MEM Register · program counter.v Program Counter
Components 19
Instruction Fetch
- IF Stage
IF Stage.v - Program Counter
program counter.v - PC Adder
PC adder.v - Instruction Memory
Instruction memeory.v - IF/ID Register
if_id_register.v
Decode & Read
- Register File · Supplies decode operands and receives write-back results.
register file.v - Control Unit
control unit.v - Immediate Generator
immedate generator.v - ID/EX Register
id_ex_register.v
Execute
- ALU Control
alu control unit.v - ALU
ALU.v - EX/MEM Register
ex-mem_register.v
Memory & Write Back
- Data Memory
Data Memeory.v - MEM/WB Register
mem_wb_register.v - Write Back
Write Back.v
Hazard Recovery
- Hazard Detection · Detects load-use dependencies.
hazard detection unit.v - Forwarding Unit
forwardimg unit.v
Other components
- Vivado Project
5_stage_risc_recovery.xpr - Processor Top · Integrates the five-stage RISC-V pipeline.
processor top.v
Connections 31
- Vivado Project → Processor Top: contains
- Processor Top → IF Stage: fetch
- IF Stage → Program Counter: updates
- Program Counter → PC Adder: PC
- PC Adder → Program Counter: next PC
- Program Counter → Instruction Memory: address
- Instruction Memory → IF/ID Register: instruction
- IF/ID Register → Control Unit: instruction fields
- IF/ID Register → Immediate Generator: instruction fields
- IF/ID Register → Register File: source registers
- Register File → ID/EX Register: read operands
- Control Unit → ID/EX Register: controls
- Immediate Generator → ID/EX Register: immediate
- ID/EX Register → ALU Control: ALU decode
- ID/EX Register → ALU: operands
- ALU Control → ALU: operation
- ALU → EX/MEM Register: result
- ID/EX Register → EX/MEM Register: store data and controls
- EX/MEM Register → Data Memory: address, store data
- EX/MEM Register → MEM/WB Register: ALU result and controls
- Data Memory → MEM/WB Register: load data
- MEM/WB Register → Write Back: retirement inputs
- Write Back → Register File: register update
- IF/ID Register → Hazard Detection: decode sources
- ID/EX Register → Hazard Detection: load destination
- Hazard Detection → IF Stage: stall PC/fetch
- Hazard Detection → ID/EX Register: bubble control
- ID/EX Register → Forwarding Unit: source registers
- EX/MEM Register → Forwarding Unit: bypass source
- MEM/WB Register → Forwarding Unit: bypass source
- Forwarding Unit → ALU: operand select