Project 4
CS 345
Computer Organization
20 Points
Due Friday, Apr. 24, 2015 at 11:59:59 pm
Late submissions will not be accepted for this assignment!

Creating components for a 4-bit CPU

Objective:  To learn about CPUs, ALUs, Control Units, Program Counters, Instruction Registers, Memory, and JLS.

Specification:

For this project, you will create components for a 4-bit CPU that utilizes three registers - A, B, and S.  Your first component to create is an ALU that must provide the proper result on the following function codes:

000 - add A and B
001 - bitwise A and B
010 - bitwise A or B
011 - bit shift left of A
100 - bit shift right of A
101 - bitwise NOT of A
110 - determine if A < B
111 - subtract A from B

You may assume that all values are in two's complement.  You may also assume that all results will be stored in register S.  Store your diagram for the ALU in a file called ALU.jls.

The second component you must create is for the Program Counter.  Assume that you are working with 8-bit instructions.  The program counter must be incremented by one with each clock tick.  Additionally, a value from memory must be fetched from memory that corresponds to the address stored in the Program counter.  Be sure to use an adder, a memory component, an 8-bit instruction register, and a 4-bit program counter register as part of this component.  Store your diagram for this component in a file called PC.jls.

The third and final component you must create is the Control Unit.  This portion of the CPU must decode an 8 bit instruction and decide what to do with it.  You may assume that the first two bits of an instruction are an opcode.  When using the ALU, the last three bits are a function code for the ALU.  When using a load or store operation, you may use the remaining six bits to choose a memory address.  Your Control Unit should allow you to select from performing the following operations on the appropriate opcode:

00 - utilize the ALU
01 - move the contents of register S to register A
10 - load a value from memory into register A
11 - store a value from register S in memory

Store your Control Unit in a file called CU.jls.  Hint: it may help you to use a state machine to select which operation you wish to perform.

For 5 bonus points connect these three components together, include a system clock, and ensure your completed circuit works properly using appropriate test cases.

Submitting Your Program:

To turn in your program use the dropbox for Project 4 on eCompanion.  You must submit the .jls files for your circuits.  The .jls files must include a component and logic circuit simulation that will produce outputs necessary to simulate parts of a 4-bit CPU as explained above.  It is recommended that you not attempt to test all of the possible outputs.  Rather, you should determine reasonable boundary cases to ensure your simulation works properly.