EveryCircuit
Powering up...
Circuit
Public
Private
Unlisted
Save

Mini 4-Bit CPU Core Architecture

@Tamas1234
20 hours ago
https://everycircuit.com/circuit/6195030817636352
@Muse - This mini 4-bit CPU core implements an arithmetic datapath with an accumulator register, status flag detection, and real-time output visualization. ### Architecture Overview 1. **Operand & Mode Input**: - Operand **B** ($B_3 B_2 B_1 B_0$) is set via logic toggles #B3 through #B0. - Operand **A** ($A_3 A_2 A_1 A_0$) is fed back dynamically from the 4-bit accumulator register outputs (#a3, #a2, #a1, #a0). - Mode switch #OP controls the arithmetic operation: - #OP = $0$: **Addition** ($A + B$, with initial carry $C_{\text{in}} = 0$). - #OP = $1$: **Subtraction** ($A - B = A + \overline{B} + 1$, using 2's complement by XOR-inverting $B$ and setting $C_{\text{in}} = 1$). 2. **4-Bit Arithmetic Logic Unit (ALU)**: - Built from a 4-stage full adder/subtractor array using XOR, AND, and OR gates. - Computes sum/difference bits #s0, #s1, #s2, and #s3. - Produces the carry/borrow-out line #cout and detects the zero state (#zero) via NOR gate logic across all sum bits ($Z = \overline{S_0 + S_1 + S_2 + S_3}$). 3. **Accumulator Register (#REG0–#REG3)**: - Four edge-triggered D flip-flops capture and hold the ALU result bus on the rising edge of #CLK. - The stored values immediately feed back to the ALU's **A** operand port, enabling iterative accumulation, counting, and subtraction loops. 4. **Output & Status Indicators**: - **7-Segment Display (#DISP)**: Driven by the BCD/hexadecimal decoder #DEC, rendering the current accumulated value in hexadecimal ($0$ to $\text{F}$). - **Carry/Borrow LED (#FLAG_C)**: Illuminates red when the ALU generates an arithmetic carry or borrow out. - **Zero Flag LED (#FLAG_Z)**: Illuminates green whenever the current ALU computation results in $0000_2$.
Comments
Post