Project, Phase 3

CMSC 411 / Olano, Fall 2015

In this phase of the project, you will simulate your multi-cycle design from phase 2

Simulation Changes

As soon as your simulator is started, it should output a line with your integer clock cycle time.

Each cycle, you will read a line with one integer. Most of the time this will be 0. This will be your indicator that it is time to proceed to the next clock cycle.

You should print a robot control command each clock cycle, just as you did in phase 1. The only cycle when you should print anything other than "N" is the cycle when the robot operation is to begin. So even a robot instruction will have multiple cycles where you print "N", and just one where where you print one of the robot commands.

For scan instructions, the driver program will print your scan result exactly once, as the integer for cycle after the robot unit completes. Since the robot unit result may be in the middle of a cycle in your datapath, each time you read an integer from driver program (or from the keyboard in your testing) your simulator should wrap up one cycle and start the next. In other words, you will print one robot code and read one integer each cycle, but neither of these are necessarily at exactly the beginning or end of the cycle. Their location within the cycle is based on where they occur in your datapath, and your simulation should follow that timing.

Fix your data path and RTL if necessary from the previous phase, and be sure your simulation does only what is specified in the RTL. You only need to simulate the functional behavior within each cycle, so you can still use C++ code (switch statements, addition or subtraction, logical operations, ifs, etc.) to implement behavior equivalent to what the RTL says, but the only values you should keep between clock cycles are control state and explicit registers shown in your data path.

Note that the robot driver program does not currently support the changes described here. As with the first phase, grading will primarily be done by running on the console with me hitting "0/enter" over and over again. Meanwhile, I will be updating the robot driver program, which will be necessary for the next phase. I will notify the class on piazza when these changes are complete.

Sample I/O

Here is an example to give you the idea. Say your cycle time was 89 and part of your RTL looked like this:

State Name RTL Comment
0 if0 MemData=Mem[PC]; NPC = PC + 4; state = 1 Start instruction fetch
1 if1 state = 2 Waiting for memory
2 if2 state = 3 Waiting for memory
3 if3 IR = MemData; state = 4 Instruction fetch done
4 id R1 = reg[IR(25-21)]; R2 = reg[IR(20-16)]; Imm = SExt(IR(15-0)); state = decode(IR) Register fetch and decode
5 wb reg[RD] = X; PC = NPC; state = 0 Shared state to write back to a register
... ... ... ...
20 ascn0 RobotFunc=A; state = 21 Start scan
21 ascn1 state = 22 Waiting for scan
22 ascn2 state = 23 Waiting for scan
23 ascn3 state = 24 Waiting for scan
24 ascn4 state = 25 Waiting for scan
25 ascn5 X = RobotOut; RD = IR(20-16); state = 5 Scan complete, prepare for WB

Then if your first instruction was ascn, your communication with the driver program might look something like this:

You print You read State
(not printed)
Comment
89     Print clock speed
  0 0 1st cycle. Start if0
N   0 if0
  0 0/1 2nd cycle. Finish if0, start if1
N   1 if1
  0 1/2 3rd cycle. Finish if1, start if2
N   2 if2
  0 2/3 4th cycle. Finish if2, start id
N   3 id
  0 3/20 3rd cycle. Finish id, start ascn0
A   20 ascn0, start scan
  0 20/21 4th cycle (89 since scan started). Finish ascn0, start ascn1
N   21 ascn1
  0 21/22 5th cycle (178 since scan started). Finish ascn1, start ascn2
N   22 ascn2
  0 22/23 6th cycle (267 since scan started). Finish ascn2, start ascn3
N   23 ascn3
  0 23/24 7th cycle (356 since scan started). Finish ascn3, start ascn4
N   24 ascn4
  0 24/25 8th cycle (445 since scan started). Finish ascn4, start ascn5
N   25 ascn5
  12 25/5 9th cycle (534 since scan started, scan results available). Finish ascn5, start wb
N   5 wb
  0 5/0 10th cycle. Finish wb, start if0
N   0 if0 for second instruction
... ... ... ...

 

Submitting

Commit and push everything for this assignment in the same directory you used for phase 1 and 2. Write a new readme called readme-3.txt with anything you think I should know. Definitely include notes on any chages to your datapath and RTL, in addition to notes about your simulation.