A fully functional 16-bit processor implemented in Verilog, featuring a custom ISA with a register file, ALU, bus multiplexer, and FSM-based control unit. Simulated in ModelSim and synthesized in Intel Quartus Prime.
The processor operates on 16-bit data loaded through a DIN input. Instructions are 9-bit encoded and executed over up to 4 clock cycles using a 2-bit time-step counter (T0–T3). Execution begins when run is asserted and signals completion via a done pulse.
- Language: Verilog
- Simulation: ModelSim
- Synthesis: Intel Quartus Prime
| Instruction | Operation | Clock Cycles |
|---|---|---|
mv Rx, Ry |
Rx ← Ry | 2 |
mvi Rx, #D |
Rx ← D (immediate) | 2 |
add Rx, Ry |
Rx ← Rx + Ry | 4 |
sub Rx, Ry |
Rx ← Rx − Ry | 4 |
Instruction encoding: 9-bit format III XXX YYY
III— opcodeXXX— destination register (Rx)YYY— source register (Ry)
reg_file8 — Register File
- 8 general-purpose 16-bit registers (R0–R7)
- Per-register write enable (
we[7:0]) - Asynchronous reset
alu_addsub — ALU
- Combinational add/subtract unit
sub=0→ addition,sub=1→ subtraction- Operates on register A (first operand) and the Bus (second operand)
bus_mux — Bus Multiplexer
- 16-bit wide, 10-input mux
- Sources: R0–R7 (sel 0–7), DIN (sel 8), G register (sel 9)
- Drives the shared data Bus
control_unit — FSM Control Unit
- 2-bit time-step counter T (T0–T3)
- Generates all control signals:
ir_load,a_load,g_load,r_we,bus_sel,alu_sub doneasserted as a 1-cycle pulse at instruction completion
proc_top — Top Level
- Instantiates and wires all submodules
- Contains internal registers: IR (instruction), A (ALU operand), G (ALU result)
Short instructions (mv, mvi) — 2 cycles:
T0— Fetch: load IR from DINT1— Execute: route source to Bus, write to Rx, assert Done
Long instructions (add, sub) — 4 cycles:
T0— Fetch: load IR from DINT1— Load A: route Rx to Bus, latch into register AT2— Compute: route Ry to Bus, ALU computes A ± Ry, latch result into GT3— Writeback: route G to Bus, write to Rx, assert Done
The testbench validates all instruction types:
MVI R0, 4— load immediate value 4 into R0MVI R1, 3— load immediate value 3 into R1ADD R0, R1— R0 ← R0 + R1- Asserts R0 == 7 and prints PASS/FAIL