Project 3
DSCPU
The Denison Simple CPU Circuit DesignProject Description
The end-result of this project is to create a circuit design realization of the DSCPU. It builds on the following course elements:
- The instruction-execution knowledge gained in Project 1, wherein the DSCPU simulator explored the fetch/decode/execute cycle of instruction execution and divided the work into execution subphases.
- The ALU circuit design of Project 2, wherein combinational logic was used to create the organization for an ALU appropriate for the arithmetic operations of the DSCPU.
- The knowledge from class in designing combinational and sequential circuits, such that the finite state machine that realizes the instruction execution of the DSCPU can be implemented through control logic, combined with a given datapath.
An initial version of the datapath has been implemented for you, and may be found in the following linked Logisim circuit. You are welcome and encouraged to modify this circuit as needed to implement your CPU.
The CPU is basically the same as that defined for Project 1, with a few simplifications. First, we will only use a single Flag register, the Z flag. Second, we will limit ourselves to 16 instructions plus the HALT instruction. Third, we will replace the CLAC instruction with the MVI instruction. The resultant definition of the DSCPU follows:
Registers
There are 3 registers directly controlled by the programmer:
Programmer Visible Registers | |||
---|---|---|---|
Name | Size (bits) | Description | |
AC |
8 |
Accumulator. AC receives the result of arithmetic and logic instructions. It provides one of the operands for two-operand arithmetic and logic instructions. Data is loaded to/from AC from/to memory. | |
R |
8 |
General purpose register. R supplies the 2nd operand of all two-operand arithmetic and logic instructions. It can also be used as a temporary storage area. | |
Flag |
1 |
Status flag given as follows: | |
Z |
1 |
Zero flag. This bit is set/reset as a result of arithmetic or logic operations. If the result of an arithmetic/logic operation is zero, then Z is set to 1. If the result of an arithmetic/logic operation is not zero, then Z is set to 0. Z is set/reset as a result of ADD, SUB, INAC, CLAC, AND, OR, XOR, NOT. |
The DSCPU also contains several registers in addition to those specified in the instruction set:
CPU Hidden Registers | |||
---|---|---|---|
Name | Size (bits) | Description | |
PC |
16 |
Program counter. PC contains the address of the next instruction to be executed or the address of the next operand of the current instruction. | |
IR |
8 |
Instruction register. IR contains the opcode, as fetched from memory, of the instruction currently being executed. | |
AR |
16 |
Address register. AR is used in the interface to memory and holds the address for a memory request. The AR must be loaded prior to a request to read memory (for a load) or for a write to memory (for a store). | |
DR |
8 |
Data register. DR is also used in the interface to memory. It holds the data value to store on a memory write operation, and must be loaded prior to the write request. It holds the value read from memory following a read request. | |
TR |
8 |
Temporary register. TR holds data during the execution of an instruction. |
Memory
The DSCPU can address up to 65536 bytes of physical memory, mem. Addresses are 16 bits in length, and every memory byte is accessible by an address in the range 0 to 65535. Due to the limit of addresses for memory devices in Logisim, the maximum memory address for the DSCPU circuit is 4095.
Reads and writes from/to memory and achieved through the use of AR and DR. To perform a read, AR is loaded with the desired address, a, and then a memory read is requested. The completion of the read results in the contents, mem[a], in DR. To perform a write, AR is loaded with the desired address, a, and the data value to be written, d, is loaded into DR. The memory write is then requested.
Instruction Set
In the following table, an A operand refers to a 16-bit memory address and is composed of the two bytes (MSB followed by LSB) following the opcode in memory. An I operand refers to an 8-bit immediate value and is found in the byte immediately following the opcode in memory.
Instruction | Opcode (binary) |
Operand | Semantics |
---|---|---|---|
NOP |
0000 0000 |
- |
None (other than advancing PC) |
LDAC |
0000 0001 |
A |
AC <- mem[A] |
STAC |
0000 0010 |
A |
mem[A] <- AC |
MVAC |
0000 0011 |
- |
R <- AC |
MOVR |
0000 0100 |
- |
AC <- R |
JUMP |
0000 0101 |
A |
PC <- A |
JMPZ |
0000 0110 |
A |
if (Z==1) then PC <- A |
JPNZ |
0000 0111 |
A |
if (Z==0) then PC <- A |
ADD |
0000 1000 |
- |
AC <- AC + R; Z update |
SUB |
0000 1001 |
- |
AC <- AC - R; Z update |
INAC |
0000 1010 |
- |
AC <- AC + 1; Z update |
MVI |
0000 1011 |
I |
AC <- I; Z update |
AND |
0000 1100 |
- |
AC <- AC & R; Z update {bitwise AND} |
OR |
0000 1101 |
- |
AC <- AC | R; Z update {bitwise OR} |
XOR |
0000 1110 |
- |
AC <- AC ^ R; Z update {bitwise XOR} |
NOT |
0000 1111 |
- |
AC <- !(AC); Z update {bitwise complement} |
HALT |
1111 1111 |
- |
Halt execution |
Assignment
Use Logisim and the provided DSCPU datapath to combine with your ALU from Project 2 and create the control logic to implement the DSCPU CPU. You may implement the control function either through hardwired or through microprogrammed control.
Program Execution
- Your DSCPU realization must allow a load of Logisim memory from a text file, where the file contains the program to be executed.
- Once loaded, your program should support the execution of the program by use of a Logisim "Ticks Enabled" command. You should also allow single-stepping of the execution by making a single clock device available at the top level circuit submitted, so that testing can occur by using the probe tool to manually advance the clock.
- Begin executing the program, using your designed control circuit. Datapath register values of, at a minimum, AC, R, PC, and Z must be visible at the top level circuit.
- Execution of a HALT instruction terminates the simulation. Subsequent clock ticks (manual or automatic) should not change the state of any register further.
Deliverables
Documentation
Good documentation is an important deliverable for this project. It will involve at least the following elements:
- Datapath and control signal documentation. Part of the project is to complete the datapath by adding the ALU from Project 2 and by adding Muxes and other elements so that every instruction has a realization in the datapath. Your finished datapath should be documented, with a complete datapath picture and sufficient prose so that I can understand your datapath based solely on knowing what your starting point (dscpu2.circ) was. ... this means that I should not have to trace control lines and interpret control values to muxes in order to understand how your datapath operates.
- Control Circuit Design documentation. The substance of this documentation depends on whether you choose a hardwired design or a microprogrammed design. In either case, it should lead me through the design process:
- For hardwired control, the control circuit design documentation should (i) include the finite state machine for execution of the entire instruction set, and clearly indicate every state transition with the input state that causes the transition and the output control signals, (ii) present a truth table that realizes the finite state machine, (iii) documents any auxiliary combinational logic used to simplify the hardwired control implementation.
- For microprogram control, the control circuit design documentation should include (i) the definition of the microinstruction format, (ii) the design of the microsequencer, (iii) a well documented microprogram for the instruction set, (iv) any sequence dispatch or other auxiliary logic to simplify the microprogram control.
- Any other documentation that will help me to understand what you have done and what particulaly important design features your realization may possess.
Logisim Circuit
You obviously need to also submit your actual circuit(s). Make sure you include all circuits required for me to execute your CPU.
Your finished project must be submitted via email.
Best of luck, oh hardware designers of the future!