Project 1
Project 1
Spring 2015
Requirements
Download VirtualBox VM Image on T-Square and follow the instructions to set it up.
Alternatively, use 32-bit Ubuntu or Debian. Click here to download.
Download build essentials for linux as needed. If you are using Mint/Ubuntu/Debian type in sudo
apt-get install build-essential.
Download the proper version of Logisim. Be sure to use the most updated version. DO NOT USE
BRANDONSIM FROM CS 2110! Click here to go to the download page. The VM image we
provide you has Logisim ready to go.
Logisim is not perfect and does have small bugs. In certain scenarios, files have been corrupted and
students have had to re-do the entire project. Please back up your work using some form of version
control, such as a local git repository.
Project 1 is designed to give you a good feel for exactly how a processor works. In Phase I, you will design
a datapath in Logisim to implement a supplied instruction set architecture. You will use the datapath as
a tool to determine the control signals needed to execute each instruction. In Phases II and III you are
required to build a simple finite state machine (AKA control-unit) to control your computer and actually
run programs on it.
Note: You will need to have a working knowledge of Logisim. Make sure that you know how to make basic
circuits as well as subcircuits before proceeding. Always remember to see the TAs if you need help.
Project 1
Spring 2015
In this phase of the project, you must learn the Instruction Set Architecture (ISA) for the processor we will
be implementing. Afterwards, we will implement a complete LC 2200 16 bit datapath in Logisim using what
you have just learned.
You must do the following:
1. Learn and understand the LC 2200 16 ISA. Simply read and understand Appendix B: LC 2200 Instruction Set Architecture. DO NOT MOVE ON UNTIL YOU HAVE FULLY READ AND
UNDERSTOOD THE ISA AS IT WILL BE IMPOSSIBLE TO IMPLEMENT THE DATAPATH IF YOU DO NOT!
2. Using Logisim, implement the LC 2200 datapath. The basic operation of the datapath will be discussed
in the class and is delineated in the book. As you build the datapath, you should consider adding
functionality that will allow you to operate the whole datapath by hand. This will make testing
individual operations quite simple. We suggest your datapath include devices that will allow you to
put arbitrary values on the bus and to view the current value of the bus. Feel free to add any additional
hardware that will help you understand what is going on.
Please use figure 1 while constructing your datapath in Logisim.
Project 1
Spring 2015
In this phase of the project, you will use Logisim to implement the microcontrol unit for the LC 2200 processor. This component is referred to as the Control Logic in the images and schematics. The microcontroller
will contain all of the signal lines to the various parts of the datapath.
You must do the following:
1. Read and understand the microcontroller logic:
Please refer to Appendix A: Microcontrol Unit for details.
Note: You will be required to write the microcode for the microcontrol unit that you implement
in Phase 3 so please read the README file in the microcontrol unit folder for more details.
2. Implement the Microcontrol Unit using Logisim. The above link contains all of the necessary information. Take note that the input and output signals on the schematics directly match the signals marked
in the LC 2200 datapath schematic (see figure 1).
In this final stage of the project, you will write the microcode control program that will be loaded into the
microcontrol unit you implemented in Phase 2. Then, you will hook up the control unit you built in Phase 2
of the project to the datapath you implemented in Phase 1. Finally, you will test your completed computer
using a simple test program and ensure that it properly executes.
You must do the following:
1. Write the microcode control program for the microcontrol unit from Phase 2. Please see the README
file located in the microcontrol folder for more information and instructions on how to implement the
microcode.
2. After the microcode has been written, use the provided tools to convert it into hex. This should then
be loaded into your microcontrol units ROM. The tools to convert the microcode into hex can be
found in the microcontroller folder.
3. Connect the completed control unit to the datapath you implemented in Phase 1. Using the figure 1
and the microcontrol unit schematic, connect the control signals to their appropriate spots.
4. Finally, it is time to test your completed computer. Use the provided assembler (found in the assembler folder) to convert a test program from assembly to hex (see the README for help). We
recommend using test programs that contain a single instruction since you are bound to have a few
bugs at this stage of the project. Finally, try running your factorial program you wrote for Homework
1 as an ultimate test.
Deliverables
Please submit all of the following files in a .tar archive. You must turn in:
Logisim Datapath File (LC-2200-16.circ)
Microcontrol Unit Logisim File (you can implement this in the same file as the datapath if you wish)
Microcode (<filename>.xml, NOT THE HEX FILES!)
Project 1
Spring 2015
We do not accept late submissions. If your assignment is not submitted on T-Square by the deadline, you will receive a 0.
Precaution: You should always re-download your assignment from
T-Square after submitting to ensure that all necessary files were
properly uploaded. If what we download does not work, you will
get a 0 regardless of what is on your machine.
Project 1
Spring 2015
You will make a microcontrol unit which will drive all of the control signals to various items on the datapath.
This Finite State Machine (FSM) can be constructed in a variety of ways. You could implement it with
combinational logic and Flip Flops, or you could hardwire signals using a single ROM. The signle ROM
solution will waste a tremendous amount of space since most of the microstates do not depend on the opcode
or the Z register to determine which signals to assert. For example, since Z register is an input for the
address, every microstate would have to have an address for Z = 0 as well as Z = 1, even though this only
matters for one particular microstate.
To solve this problem, we will use a three ROM microcontroller. In this arrangement, we will have three
ROMs:
the main ROM, which outputs the control signals,
the sequencer ROM, which helps to determine which microsotate to go at the end of the FETCH state,
and the OnZ ROM, which helps determine whether or not to branch during the BEQ instruction.
Examine the following:
Project 1
Spring 2015
these sources gets through to the state register. If the previous states next state field determines where
to go, neither the OPTest nor chkZ signals will be asserted. If the Op Code from the IR determines the
next state (such as at the end of the Fetch state), the OpTest signal will be asserted. If the zero-detection
circuitry determines the next state (such as in the BEQ instruction), the TestZ signal will be asserted. Note
that these two signals should never be asserted at the same time since nothing is input into the 11 pin on
the MUX.
The OpCheck ROM should have one address per instruction, and the OnZ ROM should have one address
for taking the branch and one for not taking the branch.
Note: Logisim has a minimum of two address bits for a ROM (i.e. four addresses), even though only one
address bit (two addresses) is needed for the OnZ ROM. Just ignore the other two addresses. You should
design it so that the high address bit for this ROM is permanently set to zero.
Before getting down to specifics you need to determine the control scheme for the datapath. To do this
examine each instruction, one by one, and construct a finite state bubble diagram showing exactly what
control signals will be set in each state. Also determine what are the conditions necessary to pass from one
state to the next. You can experiment by manually controlling your control signals on the bus youve created
in part 1 to make sure that your logic is sound.
Once the finite state bubble diagram is produced, the next step is to encode the contents of the Control Unit
ROM with a tool we are providing. Then you must design and build (in Logisim) the Control Unit circuit
which will contain the three ROMs, a MUX, and a state register. Your design will be better if it allows you
to single step and insure that it is working properly. Finally, you will load the Control Units ROMs with
the output of the tool.
Note that the input address to the ROM uses bit 0 for the lowest bit of the current state and 5 for the
highest bit for the current state.
Bit
0
1
2
3
4
Purpose
NextState[0]
NextState[1]
NextState[2]
NextState[3]
NextState[4]
Bit
5
6
7
8
9
Purpose
LdB
LdZ
WrREG
WrMEM
RegSelLo
Bit
20
21
22
23
24
Purpose
RegSelHi
ALULo
ALUHi
OPTest
chkZ
Project 1
Spring 2015
Project 1
Spring 2015
The LC-2200-16 (Little Computer 2200-16 bits) is very simple, but it is general enough to solve complex
problems. (Note: This is a 16-bit version of the ISA specification you will find in the Ramachandran & Leahy
textbook for CS 2200.) This section describes the instruction set and instruction format of the LC-2200. The
LC-2200-16 is a 16-register, 16-bit computer. All addresses are word-addresses. Although the 16 registers
are for general purpose use, we will assign then special duties for convention (and for all that is good on this
Earth).
Register Number
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Callee Save?
NA
NA
No
No
No
No
No
No
No
Yes
Yes
Yes
NA
No
Yes
No
1. Register 0 is always read as zero. Any values written to it are discarded. Note: for the purposes of
this project, you must implement the zero register. Regardless of what is written to this register, it
should always output zero.
2. Register 1 is a general purpose register. You should not use it because the assembler will use it in
processing pseudo-instructions.
3. Register 2 is where you should store any returned value from a subroutine call.
4. Registers 3 - 5 are used to store temporary values. Note: registers 2 through 8 should be placed
on the stack if the caller wants to retain those values. These registers are fair game for the callee
(subroutine) to trash.
5. Registers 6- 8 are designated for temporary variables. The caller must save these registers if they
want these values to be retained.
6. Registers 9 - 11 are saved registers. The caller may assume that these registers are never tampered
with by the subroutine. if the subroutine needs these registers, then it should place them on the stack
and restore them before they jump back to the caller.
7. Register 12 is used to handle interrupts.
8. Register 13 is your anchor on the stack. It keeps track of the top of the activation record for a
subroutine.
9. Register 14 is used to point to the first address on the activation record for the currently executing
process. Dont worry about using this register.
Project 1
Spring 2015
10. Register 15 is used to store the address a subroutine should return to when it is finsihed executing.
It is only supposed to be used by the JALR (Jump And Link Register) instruction.
There are four types of instructions: R-Type (Register Type), I-Type (Immediate value Type), J-Type
(Jump Type), and S-Type (Stack Type).
Here is the instruction format for R-Type instructions (ADD, NAND):
Bits
Purpose
15 - 13
opcode
12 - 9
RX
8-5
RY
4-1
RZ
0
Unused
Here is the instruction format for I-Type instructions (ADDI, LW, SW, BEQ):
Bits
Purpose
15 - 13
opcode
12 - 9
RX
8-5
RY
4-0
2s Complement Offset
15 - 13
opcode
12 - 9
RX
8-5
RY
4-0
Unused (all 0s)
Name
add
Type
R
nand
addi
lw
sw
beq
jalr
halt
15 - 13
opcode
12 - 2
Unused (all 0s)
1-0
Control Code
Project 1
Spring 2015
Finally, the assembler supports labels which represent the address of the line it is on. If a label is used in a
BEQ instruction, it will evaluate to some relative offset.
For example:
(address 0):
(address 1):
(address 2):
(address 3):
(address 4):
Becomes:
(address
(address
(address
(address
(address
0):
1):
2):
3):
4):
loop:
end:
000
010
101
101
111
1001
1001
1001
0000
0000
0000
1001
0000
0000
0000
00000
11111
00001
11101
00000
or
or
or
or
or
0x1200
0x533F
0xB201
0xA01D
oxE000