How jayjain2365/4bit-processor-verilog works
This repository is a small RTL design for a 4-bit processor implemented in Verilog HDL and packaged as a Xilinx Vivado project. The architecture is intentionally narrow: it is a self-contained, simulation-oriented CPU datapath with four classic stages—fetch, decode, execute, and write-back.
The core design lives under Alu_4bit.srcs/sources_1/new/ and is split into clear hardware boundaries:
• fetch_unit.v
• decode_unit.v
• execute_unit.v
• write_back.v
• processor_top.v as the integration point
The top-level module, processor_top.v, is the main architectural boundary. It wires the stage modules together into a single instruction flow, so the diagram should show data moving from fetch to decode to execute to write-back, with control and results feeding back into the register storage.
The fetch stage maintains the program counter (PC) and supplies the next instruction. In the repository’s described model, this stage is responsible for instruction retrieval and PC advancement, so it should be drawn as the entry point of the processor pipeline.
The decode stage interprets the instruction fields—especially opcode and register selectors—and reads source operands from the register file. The README specifies a 4-register file, 4-bit wide, with two read ports and one write port, which is a key architectural feature to capture in the diagram.
The execute stage performs the actual ALU work. Supported operations are limited to simple 4-bit instructions: ADD, SUB, AND, OR, MOV, and NOP. This stage also generates status/condition outputs as described in the README, so it is the arithmetic/logic boundary of the design.
The write-back stage commits the execution result back into the register file. Architecturally, this is the only stage that updates architectural state, so it should be shown as the point where computed results become visible to later instructions.
The design appears to be a single-instruction datapath model, not a superscalar or deeply pipelined CPU. Even though the stages are separated structurally, the repository emphasis is on demonstrating the processor cycle rather than out-of-order execution, hazard handling, or caching.
Validation is done through Alu_4bit.srcs/sim_1/new/processor_tb.v, which is the simulation testbench. The testbench drives the top-level processor and observes PC progression, instruction decode, ALU results, and register updates in Vivado Simulator.
The screenshots/ folder is documentation-only support material for waveform evidence of correct behavior. It does not participate in the hardware architecture, but it supports the verification story.
At the project level, the main external tooling boundary is Xilinx Vivado, which provides synthesis/simulation context and the .xpr project file. There are no signs of software runtime, operating-system services, or external peripherals; this is a pure RTL and simulation repository.
If you are drawing an architecture diagram, the most important boxes are:
1. Fetch/PC
2. Decode/register read
3. Execute/ALU
4. Write-back/register update
5. Testbench around the top-level processor
The overall data flow is linear through those stages, with the register file providing the central state storage that decode reads from and write-back updates.
Main entry points: processor_top.v Processor Top · decode_unit.v Decode · write_back.v Write Back · processor_tb.v Testbench
Components 9
Core RTL
Processor datapath and stage modules
- Processor Top · Integrates fetch, decode, execute, and write-back into one CPU datapath
Alu_4bit.srcs/sources_1/new/processor_top.v - Fetch · Maintains the program counter and supplies the next instruction
Alu_4bit.srcs/sources_1/new/fetch_unit.v - Decode · Decodes opcode and register fields, and reads source operands
Alu_4bit.srcs/sources_1/new/decode_unit.v - Register File · Central 4-register, 4-bit storage with two read ports and one write port
- Execute · Performs ADD, SUB, AND, OR, MOV, and NOP operations and produces status outputs
Alu_4bit.srcs/sources_1/new/execute_unit.v - Write Back · Commits the ALU result back into architectural state
Alu_4bit.srcs/sources_1/new/write_back.v
Simulation
Testbench and verification flow
- Testbench · Drives the processor top module and checks PC, decode, ALU, and register updates
Alu_4bit.srcs/sim_1/new/processor_tb.v
Tooling
Vivado project and project context
- Vivado Project · Xilinx Vivado project container for synthesis and simulation
Alu_4bit.xpr
Docs
Documentation and waveform artifacts
- Waveforms · Captured simulation screenshots used as verification evidence
screenshots/README.md
Connections 12
- Testbench → Processor Top: stimulates · Simulation harness drives the CPU top level
- Processor Top → Fetch: instantiates · Top-level wiring begins with instruction fetch
- Fetch → Decode: instruction · Next instruction and PC flow into decode
- Decode → Register File: reads · Decode extracts source operands from the register file
- Register File → Decode: operands · Read data returns to decode for execution setup
- Decode → Execute: control+operands · Opcode and operands are forwarded into the ALU stage
- Execute → Write Back: result · Computed value and status move to write-back
- Write Back → Register File: commit · Write-back updates the architectural register state
- Write Back → Fetch: next cycle · Completed instruction advances the sequential processor flow
- Processor Top → Testbench: observed by · Testbench monitors top-level outputs and internal progress
- Vivado Project → Processor Top: contains · Vivado project packages the RTL design
- Testbench → Waveforms: verified with · Waveform evidence documents expected simulation behavior