CS202 - Assignment Ten
Due: 2018-12-07 9:00a
Objectives
- Get really familiar with the internals of a processor
Building the ∑niac
As I said in class, for this assignment you are going to be implementing a hardware simulation of the Σniac processor. Use the slides as your guide for building the datapath and then for specifying the control logic. To get you started, I am once again going to give you a template file.
Understanding the starter circuit
I have given you some circuits to get you started, but before you dive in, you should understand what you are looking at.
You should see two sub-circuits: main and cpu. All of your work will be in cpu. The main circuit is one that I built for you. It has the RAM, ROM, and an instance of the cpu circuit. The memory is broken up into blocks of 8 to make the addressing easier. Note that I use the low three bits of the address to pick a particular value from within a specific memory and a decoder connected to the select inputs to pick which block of memory is being addressed. The ROM can be edited (to program the machine), by clicking on a byte and typing the new value in. This is the primary interaction you will have with the main circuit.
There are, however, two other important parts to the main circuit. The reset button and the clock. The reset button is pretty self explanatory. AS for the clock, I showed you how that worked in class. Of course, in our usage, we used it like an input pin, clicking it with the poke tool to make it oscillate. However, it can actually oscillate on its own. If you look in the Simulate menu, you will find three menu items that control the clock. 'Tick once' behaves much like clicking the clock pin -- however, the keyboard shortcut makes it more convenient. 'Tick Enabled' starts the clock. It will start oscillating all on its own. The frequency is controlled via the 'Tick Frequency' menu.
Inside the cpu circuit, you will find that I have left you with the input and output pins and the some sample circuitry. There are a number of things to notice:
While Logisim has tristate buffers (controlled buffers) so that we can drive lines from different sources, it does not allow a pin out of a circuit to be both input and output. So, unlike the design I gave you, this has separate input (Mem-in) and output (Mem-out).
I gave you the MB register as a model. Registers can be found in the Memory folder of the library. Please use the 7-segment LEDs the way that I did for all of your registers. While the registers do show their current value, the displays are much easier to read.
All of the little labels you see attached to wires are actually tunnels. If you create another tunnel with the same name, the two will be connected. This will help keep the circuit neat. Notice how I use the
clk
andr
tunnels on the MB register. Most of the tunnels I left in are control signals for which you will be providing the actual signal.I provided the first piece of control logic for you. When we are in state t0, ld_MB is asserted.
You do not have to follow my layout. However, it would be good if you put the datapath at the top and the collection of circuits implementing your control logic down below. Tip: use lots of tunnels for your control logic so that each control signal looks like an isolated circuit rather than trying to tie your state register output to everything.
The Datapath [25 points]
Building the datapath should be fairly straightforward. It should look fairly similar to the picture in the slides (except for the LED displays and the registers that are oriented differently).
For the various registers, you can copy the MB example I gave you. This uses the builtin register circuit (available in Memory). Make sure that you set the bit widths appropriately (values are 8 bit, addresses are 5 bit and the opcode is three bits).
Sadly, Logisim doesn't include and adder/subtractor. You are welcome to add in a ripple carry adder, since you know how to make that pretty easily. However, you can also use the adder and subtractor circuits available in Arithmetic. You will need a multiplexor to switch between the two if you go this route.
Make sure to instrument the datapath with control points (connected to tunnels) so you can control operations.
Control Logic [45 points]
Once you have the datapath, it is time to build the control logic. Start by creating your state registers. Since t0-t3 advance in order with no variation, you can implement this with a counter and decoder. The E state bit can be implemented however you like, but a D-Flip Flop is sufficient.
Now, you will need to create a small circuit that controls each of the tunneled control lines in the circuit. These functions will use t0-t3, E, the opcode, and the high bit of A and a small number of gates to control set the various control lines. You may find it useful to split out the three bits of the opcode into separate tunnels so you can use them individually. I also found it useful to create tunnels for load, store, and branch, since they came up in a couple of places (i.e., I created small functions based on the opcode to give me a signal indicating that the current operation matched). As a hint, pay attention to the bit patterns of the opcode. For example, there is a simple way to tell that you want to advance to the E steps, can you see it?
Remember that to properly drive the datapath you will need these control signals:
- ld_MB
- ld_OP
- ld_IC
- ld_A
- ld_MA
- ld_B
- MB>IC
- MB>MA
- IC>MA
- A>MB
- IC+1>IC
- read (or R)
- write (or W)
- zero
- sub
- halt
Turning in your work
You will resubmit the circuit file on Canvas.
- rename the file to hw10_uid.circ, where uid is your Middlebury ID.
- zip the file (so the actual file you hand in should be hw10_uid.circ.zip)
The assignment should be submitted on Canvas.