Contents
Your task
-
Make an HCL file
irrr.hclthat implements a single-cycle processor with the following instructions:nophaltirmovqrrmovq- unconditional
jmp
-
For instructions not in Y86, make your HCL file set
StattoSTAT_INS(invalid instruction error). If an instruction is in Y86 and not listed above, we do not care how your simulator works on it. -
Test your file using
make test-irrr. -
Submit your result to kytos
Hints
Suggested method
-
We suggest implementing and testing one instruction at a time, in the order they’re listed above.
-
Start with an HCL which has a program counter register and increments it based on the instruction
icodelike yourpc.hclfrom the last lab.
Adding nop/halt
- Set
Statbased on theicode. It should beSTAT_HLTif theicodeishalt,STAT_INSfor an icode not in Y86 (e.g., > 0xb),STAT_AOKotherwise.
Test nop/halt
- If you run your simulator on
y86/halt.yo, and it should halt after one cycle, and if you run it ony86/nophalt.yo, it should halt after 4 cycles.
Adding irmovq
-
Extract the
rBandvalCfields of the instruction into a wire. -
Send
valCto the register file (reg_inputEorreg_inputM) as the new value for register numberrB(reg_dstEorreg_dstM). -
Make sure you do not write to the register file when the
icodeis not anIRMOVQorRRMOVQ. (SpecifyREG_NONEforreg_dstEand/orreg_dstM.)
Testing irmovq
-
If you run your simulator with the
-qflag ony86/irmovq.yo, you should see something like:+----------------------- halted in state: ------------------------------+ | RAX: 222 RCX: 2 RDX: 22 | | RBX: 0 RSP: 0 RBP: 0 | | RSI: 0 RDI: 0 R8: 0 | | R9: 0 R10: 0 R11: 0 | | R12: 0 R13: 0 R14: fedcba9876543210 | | register pP(N) { pc=0000000000000033 } | | used memory: _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _a _b _c _d _e _f | | 0x0000000_: 30 f0 01 00 00 00 00 00 00 00 30 f1 02 00 00 00 | | 0x0000001_: 00 00 00 00 30 f2 22 00 00 00 00 00 00 00 30 f0 | | 0x0000002_: 22 02 00 00 00 00 00 00 30 fe 10 32 54 76 98 ba | | 0x0000003_: dc fe | +--------------------- (end of halted state) ---------------------------+ Cycles run: 6(It’s okay if your
pcregister and register bank has a different name.) -
If you see
0inRAXinstead of222fromy86/irmovq.yo, it is likely that you’re writing to the register file forhaltas well asirmovq.
Implement rrmovq
-
Extract the
rAfield from the instruction. -
When the instruction is
RRMOVQ, sendrAto one of the register file source inputs so it reads from this register. -
Add
rBto the one of the register file destination inputs so it writes to that register. -
When the instruction is
RRMOVQ, send the value just read fromrAinto the register file data input signal (reg_inputEorreg_inputM). -
Since you already implemented
irmovq, several of the above changes will probably require modifying an existing MUX rather than writing new assignments.
Testing rrmovq
-
If you run your simulator with the
-qflag ony86/rrmovq.yo, you should see these register values:| RAX: 22 RCX: 22 RDX: 162e | -
Your simulator’s register values should agree with
tools/yisony86/prog8.yo.
Implement unconditional jmp
-
Add a MUX for
valC. ThejXXimmediate value is bits8..72, not16..80. -
Add a MUX for the PC register value (or to an existing PC register value MUX) to select
valCif theicodeisJXX. (You don’t need to handle conditional jmps in the lab.)
Testing unconditional jmp
-
If you run your simulator on
y86/jmp.yo, you should end up withaceand notbadinraxand nothing inrbx. -
If you have trouble with the
y86/jmp.yotest case, see the source code iny86/jmp.ysand a trace of the expected cycle-by-cycle output intestdata/seq-traces/jmp.txt.
More complete testing
- Run
make test-irrr. This comapres your simulators output to our references over the files listed intestdata/irrr-tests.txt.
Debugging Test Failures
-
You can see the expected cycle-by-cycle of a single-cycle procesor on any failing test in
testdata/seq-traces/TESTNAME.yo. This is our recommendation for debugging test failures -
You can run your simulator with the
-dflag to see the values of all wires during each cycle, which can be helpful when debugging.