A small 8-bit RISC-style processor core written in Verilog, with a full design specification, a verification plan, and a self-checking testbench. The project is set up to run in Xilinx Vivado .
This is a learning project that contains the main parts of a real CPU (instruction fetch, decode, register file, ALU, control) while staying small enough to read end-to-end.
- 8-bit data path, 8-bit program counter
- 16-instruction RISC-style instruction set (4-bit opcode)
- Shared 256-byte memory for program and data
- Four general-purpose registers (R0–R3)
- ALU: AND, OR, ADD, SUB
- 1 / 2 / 3 clock cycles per instruction depending on type
- Synchronous, active-low reset
The core has three blocks:
| Block | Responsibility |
|---|---|
| FETCH | Memory, Program Counter (PC), Instruction Register (IR), Data Register (DR) |
| DECODER | Decodes the opcode, generates control signals, holds the register file R0–R3 |
| EXECUTE | ALU (AND / OR / ADD / SUB) |
The instruction format is two bytes: the first byte holds the opcode, Rd and Rs; the second byte (when used) holds an 8-bit immediate.
.
├── rtl/ # Synthesizable RTL
│ ├── scpu_top.v # Top module (connects the 3 blocks)
│ ├── scpu_fetch.v # FETCH: memory, PC, IR, DR
│ ├── scpu_decoder.v # DECODER: control + register file
│ ├── scpu_execute.v # EXECUTE: ALU
│ ├── scpu_define.vh # Global `define
│ └── scpu_parameter.vh # Opcode parameters
├── sim/
│ ├── scpu_tb.v # Self-checking testbench
│ └── scpu.romcode # Demo program (binary, loaded by $readmemb)
├── scripts/
│ ├── create_vivado_project.tcl # One-command Vivado project setup
│ └── run_iverilog.sh # Quick command-line simulation
├── doc/
│ ├── SCPU_Design_Specification.pdf / .docx
│ ├── SCPU_register_checklist.xlsx # Verification plan
│ └── img/ # Diagrams
└── README.md
The included program (sim/scpu.romcode) computes 3 + 2 + 1 = 6 with a
counting loop. It exercises immediate load, the ALU, a conditional branch, and
an unconditional jump:
LI R0, 3 ; counter = 3
LI R1, 0 ; sum = 0
LI R2, 1 ; step = 1
loop: ADD R1, R0 ; sum = sum + counter
SUB R0, R2 ; counter = counter - 1
JNE R0, loop ; repeat while counter != 0
NOP
done: JMP done ; haltExpected final state: R0 = 0x00, R1 = 0x06, R2 = 0x01.
# From the repo root, in the Vivado Tcl console:
source scripts/create_vivado_project.tcl
launch_simulationOr from a terminal:
vivado -mode batch -source scripts/create_vivado_project.tclThe script adds all sources, sets rtl/ as a Verilog include directory (so the
.vh headers resolve), marks the headers as Verilog Header, and copies the
program file into the simulation run directory. See
doc/VIVADO_SETUP.md for the manual GUI steps.
./scripts/run_iverilog.shExpected output:
*** TEST PASSED *** 3 + 2 + 1 = 6
- Design specification:
doc/SCPU_Design_Specification.pdf - Verification plan / register checklist:
doc/SCPU_register_checklist.xlsx
SCPU is a teaching core and keeps the hardware simple:
- It uses a single memory port, so a memory-access instruction
(
LWR/SWR/LWI/SWI) or a taken jump needs one extra realignment cycle before the next instruction is fetched cleanly. Demo programs are written with this in mind. LWR/SWR(register-addressed memory) are the recommended way to access data memory.- Registers are unsigned, so
JLT(Rd < 0) never takes the branch in this version. UseJEQ,JNE, orJGT.
See section 4.6 of the design specification for details.
|
Integrated Circuit Design · FPT University 📬 Connect with me |
||
|
|
|
|

