Decoder V2 (instruction decoder V2)

Inputs

PinTypeDescription
Instrbus8Instruction byte from ROM — bits 7:4 = opcode, bits 3:0 = operand

Outputs

PinTypeDescription
ALUOp0bitALU operation select, bit 0
ALUOp1bitALU operation select, bit 1
MemWrbitMemory write enable (1 = write to RAM)
JumpUncondbitUnconditional jump (JMP)
JumpZerobitJump on zero (JZ), dedicated output
JumpNegbitJump on negative (JN), dedicated output
RegLoadbitSelect the accumulator data source (operand or RAM)
ACC_WEbitAccumulator write enable (register WE)
ImmOpbitSelect the immediate operand from ROM (LDA)
IXLoadbitLoad index register (LDX)
IXIncbitIncrement index register (INX)
UseIXbitTake 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

OpcodeCommandActive signals
0NOPnone
1ADDACC_WE
2SUBALUOp0, ACC_WE
3ANDALUOp1, ACC_WE
4ORALUOp0, ALUOp1, ACC_WE
5LDARegLoad, ACC_WE, ImmOp
6STAMemWr
7JMPJumpUncond
8JZJumpZero
9LDXIXLoad
10LDAXRegLoad, ACC_WE, UseIX
11STAXMemWr, UseIX
12JNJumpNeg
13INXIXInc
14reservednone
15HLTnone

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.

Build it yourself →

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.