Machine Organization and Assembly Language programming
Problem Set #5 Due: Friday May 9th
In this assignment you'll use the Smok tool to put together
a single cycle implementation of the MIPS data path.
This is a prelude to the pipeline implementation
so you might want to keep this in mind when defining components/containers.
You can work in teams of two if you so desire.
The machine you build should be able to calculate the factorial
of a given number,
i.e., you need to implement the following instructions
(maybe not all of the arithmetic ones
are needed but it won't be extra work to do it!):
- Arithmetic: ADD, ADDU, SUB, SUBU, MUL
(Note that the MUL given by the
Smok tool is different from the one given by the MIPS implementation. Follow
the easy route, i.e., the Smok one. Also, Smok's ALU has different opcodes
than those given by the function bits of the MIPS opcode. It is quite
OK to, again, follow the easy route i.e., follow the Smok
ALU convention).
- Immediate instructions: ADDI and anything you need to implement LI,
e.g., ORI.
- Load Store instructions: LW and SW.
- Transfer of control : JAL, JR, BEQ, BNE.
The code for factorial is given in MIPS assembly language
here
(it computes 5! but we might want
to test your program on different values). The binary, i.e., the
.smokmem file is here
Note that while MIPS programs start with a PC of 0x04000000,
the Smok tool expects a beginning PC of 0x00000000.
Your 32 registers and the PC should be like MIPS's, i.e.,
32-bit long. However, we are going to restrict
the amount of memory to 1024 Bytes, i.e., 256 words.
This explains the beginning of the main program
calling the factorial function, i.e., the top of
the stack is now at address 1024 (minus 4) and will
grow toward address 0.
If you need static and dynamic data, you should start storing
them at the 512 byte (128 word) boundary.
In order for us to test your implementation more easily,
you should include a ``halt'' component that will
be triggered when the self-loop of the main program is reached.
A few Smok-MIPS quirks.
- Beware that SPIM (in the default configuration) doesn't calculate
branch offsets from PC+4 (it calculates them from
PC), and that jump addresses will be different if you assemble the
program with SPIM. The .smokmem file uses a displacement
from PC+4, compatible with the real MIPS implementation.
- In the single cycle implementation of MIPS, there are separate
memories for instruction and data. In Smok you can use the same memory
with different interfaces: an IF for instruction fetch and a regular
Memory Interface for the data memory.
- Although Smok provides limited I/O capabilities through direct
mapped I/O controllers, you are not asked to implement this.
It would require the use of library routines, syscalls, and
more generally the Cebollita system (you are welcomed to try
it for extra credit). At the end of the computation, your result
should be in register $v0.
- When you reinitialize the Smok machine, all registers
are reset to 0. Whether you want to hardwire register 0 to zero
is your choice.
What you have to turnin. More information will be given
to you regarding how to name your files etc. but basically you
should hand-in (e-mail Tapan):
-
a README file indicating briefly how to ``operate'' your
machine in case it is not obvious, i.e., which files to load etc..
In case you are aware of bugs and did not have time to correct them,
indicate it in the README file.
- a .smok file for your implementation (and any .smokcont for
containers), a .smokpla file for the PLA, a .smokmem for the
memory.
- More specifically, send e-mail to Tapan (tapan@cs)
with subject 378ASS5, including files
LASTNAME.README, LASTNAME.smok, LASTNAME.smokmem, and LASTNAME.smokpla.
Also LASTNAME-ComponentType.smokcont for any required containers.
One turnin per set of partners is enough but be sure to indicate
both names.