Due 3 November 2017 (Friday) by 11:59 pm
Requirements
Each student should independently accomplish this laboratory assignment. You are allowed to discuss with your friends to solve the coding problems.
You must submit your partially assembled code, the source code of your simulator (see Part 1 and Part 2), a README file, and the values of C, IC, and speed-up (see Part 3).
Once you submit this assignment by email, please immediately schedule a demo session with the Grader during which you will walk him through your simulator in operation.
Grading Criteria
Demonstration: 15%
In Lab 1, you created two simulators - one for a stack-based machine and one for an accumulator-based machine. In this lab assignment you will be extending your accumulator-based machine into a General Purpose Register (GPR) machine that runs different instructions in different numbers of cycles (i.e. a multi-cycle machine). You must perform each part as described, answer all related questions, submit your programs and schedule a demo session with the Grader during which you will walk him through your simulator in operation.
The starting point is your accumulator-based machine. It has only one register which is the accumulator, and that is referenced implicitly in all instructions. Now you need to add 32 general-purpose registers, which can be named $0 through $31. The more complex part is that you will need to parse the instruction stream to find out which registers are being used in each instruction. Let's assume that the only place in the instruction stream that a "$" will appear is right before a register number.
Instruction |
Instruction
Memory |
Register
file |
ALU |
Data Memory |
Register
file |
Total |
ADDI |
2 |
1 |
2 |
|
1 |
6 |
B |
2 |
|
2 |
|
|
4 |
BEQZ, BGE, BNE |
2 |
1 |
2 |
|
|
5 |
LA |
2 |
|
2 |
|
1 |
5 |
LB |
2 |
1 |
2 |
|
1 |
6 |
LI |
2 |
|
|
|
1 |
3 |
SUBI |
2 |
1 |
2 |
|
1 |
6 |
SYSCALL |
2 |
1 |
2 |
2 |
1 |
8 |
Detailed syntax:
As in Lab 1, your
simulator will just be a big case statement inside a loop that reads
instructions one by one and simulates the action(s) of each instruction. Of
course, before dropping into the main loop you have to "load" your
source code into memory and perform any necessary initializations of the data
segment. Next you need to initialize the program counter, and start up the main
loop.
This simulator
requires what we call "instrumentation". As you execute the code, you
need to keep track of the total number of instructions executed (IC),
and the total number of cycles spent in execution (C).
The ratio [8*IC] / C is the speed-up of
the multi-cycle implementation. Report your values for IC,
C, and [8*IC]
/ C.
We've added branches
to the instruction set, so thorough testing of both your simulator and your
"partially assembled" code will be very important. The debugger is
your friend - get to know and love it.
Open source code fileYou will have to demo your simulator to the Grader and convince him that it is behaving correctly (as well as producing the correct final result). You could use the debugger to do a very convincing demo.
Load source code and data into memory (using all-powerful initialization routine)
Initialize PC
Initialize IC = 0
Initialize C = 0
user_mode = true;
while ( user_mode ) {read memory at PC}
increment PC
increment IC
case ADDI: do something; add cycles for ADDI to C; break;
case another_instruction_type: do something; add cycles for this_type to C; break;
etc.
Print summary statistics (including C and IC !) and selected memory locations
E-mail the four files to chinmayk93@gmail.com and txie@mail.sdsu.edu with the subject line of "CS 572 Lab Assignment 2". In your Email, please indicate your name and your student ID. Note that this assignment counts 10% towards your course grade.