logicgate: decoder level brief as a per-output list, not a paragraph
- Commit
1f99c26f5a2e9e1232dc07292aa0cc5c8299c2eb- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-03 04:08 UTC (1 month ago)
- Parents
d3a377d
The instruction decoder brief packed the opcode table and all seven
control lines into one dense paragraph ('Drive the ALU op ... load acc
for LDA/ADD/SUB/LDI, ...'), which players found hard to turn into a
circuit.
The same information is now one bullet per output pin: the aluOp1/
aluOp0 encoding (00 add, 01 subtract, 11 pass b, checked only when
accLoad is 1), then accLoad, memWrite, useImm, jump and halt, each
with the exact opcodes that raise it. Wording matches the test-row
titles ('LDA -> ALU pass b, load acc') so the brief and the rows use
the same terms, and the don't-care behaviour of the combinational
tests is stated explicitly. The text is a multi-line string; the
brief sheet already scrolls. The hint (split, decode to eight lines,
OR per control) is unchanged.
Verified with :games:logicgate:compileDevKotlin,
:games:logicgate:testDevUnitTest and ./check games/logicgate.Diff
games/logicgate/src/main/java/com/vayunmathur/games/logicgate/domain/levels/CpuLevels.kt
diff --git a/games/logicgate/src/main/java/com/vayunmathur/games/logicgate/domain/levels/CpuLevels.kt b/games/logicgate/src/main/java/com/vayunmathur/games/logicgate/domain/levels/CpuLevels.ktindex 51572296f9..b2576a3591 100644--- a/games/logicgate/src/main/java/com/vayunmathur/games/logicgate/domain/levels/CpuLevels.kt+++ b/games/logicgate/src/main/java/com/vayunmathur/games/logicgate/domain/levels/CpuLevels.kt@@ -52,9 +52,15 @@ internal val cpuLevels: List<LevelDef> = listOf( Chapter.CPU, "decoder", Chips.DECODER, LevelText( "Instruction decoder",- "Opcodes: 0 LDA · 1 STA · 2 ADD · 3 SUB · 4 LDI · 5 JMP · 6 JZ · 7 HLT. Drive the ALU op " +- "(LDA and LDI pass b), load acc for LDA/ADD/SUB/LDI, write memory for STA, use the immediate " +- "for LDI, jump for JMP (and JZ when z is 1), halt for HLT. op's top bit is unused.",+ "op is a 4-bit opcode (top bit unused): 0 LDA · 1 STA · 2 ADD · 3 SUB · 4 LDI · 5 JMP · 6 JZ · 7 HLT.\n" ++ "What each output does:\n" ++ "• aluOp1 aluOp0 — ALU operation: 00 add · 01 subtract · 11 pass b. ADD adds, SUB subtracts, " ++ "LDA and LDI pass b. Only checked when accLoad is 1.\n" ++ "• accLoad — 1 for LDA, ADD, SUB, LDI: the ALU result is stored into acc.\n" ++ "• memWrite — 1 for STA: acc is written to memory.\n" ++ "• useImm — 1 for LDI: the ALU takes the operand itself, not memory.\n" ++ "• jump — 1 for JMP; for JZ only when z is 1.\n" ++ "• halt — 1 for HLT.", "Split op, decode its low three bits into eight lines, then OR together the lines each control needs.", ), tests = decoderTests,