Master the fundamental concepts of cpu design through this focused micro-challenge.
A register file holds the CPU's working set: eight general-purpose registers in this emulator. Real cores expose two read ports and one write port per cycle so a single instruction can fetch two operands and store a result simultaneously.
cLoading…
Register R0 is often hardwired to zero in RISC ISAs; your toy CPU may treat all eight as general purpose.
Accessing a register takes one cycle and no address calculation. Reading the same data from RAM might cost 50 to 200 cycles if it misses cache. Compilers fight to keep hot variables in registers for this reason.
For this exercise, you will add eight addressable registers and hook them into fetch-decode-execute. You will need two independent read ports for three-operand-style instructions before implementing stack and call instructions.
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 register file with 8 general-purpose registers.
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