Decoder V2 (instruction decoder V2)
Inputs
| Pin | Type | Description |
|---|---|---|
| Instr | bus8 | Instruction byte from ROM — bits 7:4 = opcode, bits 3:0 = operand |
Outputs
| Pin | Type | Description |
|---|---|---|
| ALUOp0 | bit | ALU operation select, bit 0 |
| ALUOp1 | bit | ALU operation select, bit 1 |
| MemWr | bit | Memory write enable (1 = write to RAM) |
| JumpUncond | bit | Unconditional jump (JMP) |
| JumpZero | bit | Jump on zero (JZ), dedicated output |
| JumpNeg | bit | Jump on negative (JN), dedicated output |
| RegLoad | bit | Select the accumulator data source (operand or RAM) |
| ACC_WE | bit | Accumulator write enable (register WE) |
| ImmOp | bit | Select the immediate operand from ROM (LDA) |
| IXLoad | bit | Load index register (LDX) |
| IXInc | bit | Increment index register (INX) |
| UseIX | bit | Take the RAM address from IX (LDAX, STAX) |
How Decoder V2 Differs from the Base Decoder
The protocol is the same: Decoder V2 reads the opcode (the high bits 7:4 of the Instr byte) and stays a combinational circuit with no clock and no memory. What changed is the signal set: twelve outputs instead of nine.
Three differences. First, JZ and JN now have dedicated outputs, JumpZero and JumpNeg. The base Decoder serves both codes (8 and 12) with a single JumpCond output, which makes the two commands indistinguishable in a finished circuit. Second, the ACC_WE signal connects to the accumulator's WE input and enables writes only on the cycles that need them. In the base wiring the accumulator had no load enable and latched a result on every cycle, so programs had to police it by hand. Third, the ready-made ImmOp output selects the immediate operand for LDA; the base wiring assembled the same effect from external NOT and AND gates.
Signal Table
| Opcode | Command | Active signals |
|---|---|---|
| 0 | NOP | none |
| 1 | ADD | ACC_WE |
| 2 | SUB | ALUOp0, ACC_WE |
| 3 | AND | ALUOp1, ACC_WE |
| 4 | OR | ALUOp0, ALUOp1, ACC_WE |
| 5 | LDA | RegLoad, ACC_WE, ImmOp |
| 6 | STA | MemWr |
| 7 | JMP | JumpUncond |
| 8 | JZ | JumpZero |
| 9 | LDX | IXLoad |
| 10 | LDAX | RegLoad, ACC_WE, UseIX |
| 11 | STAX | MemWr, UseIX |
| 12 | JN | JumpNeg |
| 13 | INX | IXInc |
| 14 | reserved | none |
| 15 | HLT | none |
Each row is the complete signal set for one cycle: the accumulator is written only where the table lists ACC_WE, and memory is written only by MemWr.
Wiring the Conditional Jumps
The flags come from the ACC register outputs, not from the live ALU output. The N flag: a Splitter on the ACC bus feeds bit 7 into an AND gate together with JumpNeg. The Z flag: a zero detector (BusZero) on the ACC output, combined by AND with JumpZero. Both conditions and JumpUncond then merge through two OR gates into the program counter's Load input:
AND(JumpNeg, ACC[7]) → OR(JumpUncond, ·) → OR(·, AND(JumpZero, Zero(ACC))) → PC.Load
On a jump cycle ACC_WE is zero, the accumulator holds its value, and the flags are exactly what the last arithmetic left behind. With the base Decoder the flag was tapped from the ALU output during the JN cycle itself: the ALU computed ACC + RAM[label address], so the jump depended on the contents of the cell the label pointed to.
Usage
Decoder V2 is available in the sandbox palette: the "Processor with Assembly" recipe is built on it and executes all 15 commands, including JZ, IX-based indirect addressing, and the LDX/INX family. The base Decoder remains in levels 25–29 and in every saved schematic: old wirings keep working, nothing needs copying over.
Related components
Related articles
Frequently Asked Questions
How does Decoder V2 differ from the base Decoder?
Twelve outputs instead of nine: JZ and JN have separate outputs, JumpZero and JumpNeg, plus two new signals, ACC_WE (accumulator write enable) and ImmOp (immediate operand select).
What is the ACC_WE signal for?
It connects to the WE input of the accumulator register. A write happens only on cycles where ACC_WE = 1: the STA, JMP, JZ, JN, NOP and HLT commands leave the accumulator unchanged.
Where do the JZ and JN flags come from?
From the ACC register outputs: a zero detector (BusZero) produces the Z flag, and bit 7 through a Splitter produces the N flag. On a jump cycle the accumulator does not change, so the flags stay stable.