Master the fundamental concepts of cpu design through this focused micro-challenge.
Every processor, from a 6502 emulator to a server Xeon, repeats fetch-decode-execute. The program counter (PC) points at the next instruction byte; the decoder maps opcode bits to control signals; execute updates registers, memory, or flags.
cLoading…
| Opcode | Mnemonic | Effect |
|---|---|---|
| 0x01 | LOAD | R[d] = imm |
| 0x02 | ADD | R[d] += R[s] |
| 0x04 | HALT | stop |
A tiny program:
cLoading…
For this exercise, you will implement this loop for the teaching ISA in the starter code. You will need correct PC advancement and operand decoding before adding the ALU, register file, and branches in later CPU design tasks.
Keep the relevant datasheet, ISA manual, or architecture textbook chapter open while you implement. When your output disagrees with the reference trace on the same program, the bug is usually a mis-decoded opcode, a stale register read, or a flag bit left unchanged after arithmetic.
For this exercise, you will use those habits while implementing the requirement in the starter code. Microarchitectural product names change across CPU generations, but the control ideas (fetch, bypass, cache lines, vector lanes) stay stable enough to debug from first principles.
Implement fetch-decode-execute cycle for toy ISA.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github