COSC 201: Computer Organization

Lab 7: Single Cycle CPU -- part 2

Learn how to put together components to create a single cycle MIPS (simplified) CPU
Complete the circuits for a single cycle MIPS CPU, given several components.
Read Chapter 4 from H&P, 4.1-4.4
Files to Use
           MiscComponents.circ, CPUComponents.circ, control.circ, SingleCycleCPU.circ, fileSpecs.pdf , controls.pdf (completed for homework)
           test.s, arraySum.s, arraysum.mem, arraydata.mem 
What to Hand In
           Week 2: Completed SingleCycleCPU.circ and control.circ. Explain if the datapath has been changed from week one.


This is a two week lab. In the first week, you should complete the datapath circuit for a MIPS CPU that supports several basic instructions. The control part of this circuit will be filled in with controls that can be set by the user to test the data-path. The instructions to be supported are listed in the file controls.rtf that was to be completed for homework 4.

The second week of the lab will be to complete the control part of the CPU circuit. Then this will be tested by using code that does a simple operation on arrays.

The circuit files that are used are described in the file filespecs.rtf.

Week 2

1. Complete the control circuits to implement all the instructions given in the file controls.rtf. Open you datapath.circ and use Project-Load Library-LogiSim library to load your completed control circuits into your datapath.

Note: the order of the control outputs is not the same as in the powerpoint or book diagrams. See filespecs.rtf

2. Read the file arraySum.s that implements an assembly program that given an array (with four entries) replaces the entries in the array with the partial sums:

A[0] = original A[0]; A[1] = original A[0] + A[1]; A[2] = original A[0] + A[1] + A[2]; A[3] = original A[0] + A[1] +A[2] + A[3}

Note: the first two lines in this code (lui and ori) place the start address of the array into register $t4.

Run this code using MARS.

3. Use the MARS file instruction dump memory, selecting hex representation, to a memory file, arraySum.mem.

4. The datapath has separate instruction and data memory. Both start from address 0, using 8-bit addresses, and addressed by words. The circuitry does a shift on data addresses to get these word boundaries, so using the byte addresses in the code is correct. However, the start address must be zero, not the loaded address. This can be accomplished by deleting the first instruction in the file arraySum.mem (use a text editor). That eliminates the lui and the ori leaves the register at value 0.

The next to last line is the jump back to the start of the loop: 08100005. Because the data memory starts at address 0, not 1000000 as in MARS, you need to change this code to 08000005.

Then add these two lines to the beginning of the file arraySum.mem (no blank lines allowed):

v2.0 raw

The first line specifies the format for LogiSim and the second makes the code start with a nop, since the first instruction does not get executed anyway.

5. In LogiSim,
          a. Under the Simulation menu reset simulation.
          b. Right click on the data memory and load image, selecting the file arraydata.mem. The data memory should show:
                00       00000003
                00       0000000f
                00       00000014
                00       00000002
          c. Right click on the instruction memory and load image, selecting the file arraySum.mem. The instruction memory should now have the code from

6. Single step through the program by repeatedly clicking the clock symbol, until the program gets stuck on the last instruction. You can also set the clock rate to something like 1 hertz and enable ticks to see the program run automatically under control of the clock. It ends by spinning on the last instruction. The memory contents should be (in hex).

00       00000003
01       00000012
02       00000026
03       00000028

If you think you have the right circuit but results are off a bit, try restarting LogiSim and reloading the memory files.