Performance Summary
ID: LAB-04
Architecture Width
4-Bit
Standard
Instruction Capacity
7 Ops
New High
Clock Efficiency
Variable
1-2 Steps
Memory Type
Harvard
Hybrid
System Logic Flow
PC
Counter
ROM
Controller
ALU
Brainless
RAM
Memory

Data flows from the Counter to the RAM to fetch instructions. These go to the Controller, which sends signals to the ALU to manipulate data.

Core Components

The physical assets required to run the trading engine.

The Controller (The Broker)

A ROM-based Finite State Machine. It holds the "Microcode." It decides, based on the Opcode, which wires to turn on/off. It breaks macro-instructions (like STORE) into micro-steps.

Address Generator (The Navigator)

Composed of the Program Counter (PC) and Memory Address Register (MAR). It determines where in the memory vault we are looking. Usually acts sequentially, but can jump randomly for data storage.

Brainless CPU (The Quant)

Pure muscle. Contains the ALU (Math) and Accumulator (Short-term storage). It has no free will; it only does exactly what the Controller's wires tell it to do.

Instruction Set Architecture (ISA)
Opcode Mnemonic Type Analyst Note (Function)
0 (0000) LOAD DATA IN Writes RAM data into Accumulator.
1 (0001) ADD MATH Accumulator + RAM Data.
2 (0010) STOP HALT Freezes the PC. End of simulation.
3 (0011) AND LOGIC Bitwise AND. Filters bits. (5 & 3 = 1).
4 (0100) ZERO RESET Subtracts Accumulator from itself (A - A = 0).
5 (0101) SUB MATH 2's Complement Subtraction (A - B).
6 (0110) STORE DATA OUT The only op that writes TO memory. 2 Steps.
Signal Logic & Debugging
Wait State
1 NS
Crash Point

Where the testbench killed the sim because output didn't match Lab 3. Fixed by disabling $finish.

Cycle Time
320 NS
Target Reached

The full duration of the program execution after fixing micro_stim.v.


The "Ghost Code" Phenomenon

A critical lesson from this course: Digital (GUI) and Verilog (Code) represent two parallel realities.

  • ROM Hazard: Changing rom_vals.hex doesn't automatically update the simulator. You must "Reload" in Digital and "Export" to push changes to Verilog.
  • RAM Hazard: Digital uses .hex. Verilog uses .txt. You must maintain both, or the simulation reads empty memory (Red 'X' Waves).
Signal Dictionary

A comprehensive guide to every wire, register, and control signal in your architecture.

System & Global
clk 1-bit
The Clock. The heartbeat of the system. Triggers all register updates on its rising edge.
reset 1-bit
System Reset. Forces all registers (PC, Accumulator, Steps) back to 0.
data_bus 4-bit
The main highway for data. Transfers numbers between RAM, CPU, and Registers.
addr_bus 4-bit
The pointer. Tells the RAM which memory cell address (0-15) to look at.
Controller (The Brains)
load_ir 1-bit
Fetch command. Tells the Instruction Register to grab the current value from the Data Bus.
instr_reg 4-bit
Instruction Register. Holds the current "Opcode" (e.g., 3 for AND) being executed.
step_reg 2-bit
The Micro-step counter. Tracks progress (0, 1, 2, 3) within a single instruction.
rom_out 14-bit
The raw Microcode. The 14 control wires coming out of the ROM that drive the whole CPU.
Address Generator (Navigation)
pc 4-bit
Program Counter. Points to the next instruction address in memory. Increments automatically.
mar 4-bit
Memory Address Register. Temporarily holds a target address (used in STORE/JUMP instructions).
load_mar 1-bit
Command to capture the Data Bus value into the MAR.
use_pc 1-bit
Selector. 1 = Use PC address (Normal). 0 = Use MAR address (Special ops).
Brainless CPU (Muscle)
accum 4-bit
Accumulator. The primary working register. Holds the result of all math/logic operations.
alu_out 4-bit
The instant result from the ALU logic gates, waiting to be saved to the Accumulator.
arith 1-bit
ALU Mode. 1 = Math (Add/Sub). 0 = Logic (AND/OR).
invert 1-bit
ALU Flag. Inverts the input B. Essential for Subtraction (2's Complement).
load_acc 1-bit
Command to save the current ALU result into the Accumulator.
acc_to_db 1-bit
Gatekeeper. If 1, puts Accumulator value onto the Data Bus (for writing to RAM).
read / write 1-bit
RAM Controls. Read: Fetch data from address. Write: Save data to address.