Build a 2-bit CPU

Objectives


The best way to learn about microprocessors is to build one. In this lab, you are going to learn a one-bit CPU and build a 2-bit CPU in LogicWorks. Through the building process, you will learn the CPU organization. It also prepares you for the next week's lab - learn a more complicated 8-bit CPU.

1. Description of a One-bit CPU

In the above diagram you notice that there is no address buffer or data buffer, no flags coming out of the ALU and are ignoring many of the registers. These simplifications make the problem manageable while still illustrating many principles. In addition, an external input (a switch) has been added to allow us to input values to the CPU bus for testing purposes. With the CPU built we will execute micro-operations to make the circuit execute instructions. Each register stores one bit of data and requires two control signals. Register-in loads the register with the contents of the bus. Register-out enables the tri-state buffer in the register which lets the register's output onto the bus. The ALU performs two operations, XOR and AND. The operation to be performed is to be determined by the code in the IR. A 0 in the IR indicates a XOR operation and a 1 indicates an AND operation.

The following control signals will be required for our one bit CPU in this lab:

        ACCout, ACCin, TEMPout, TEMPin, ALUout,

        IRin, Bout, Bin, Cout, Cin, EXTout.

A control unit would normally generate these control signals but in our case switches will be used for these control signals.

2. TRI-STATE BUFFER

In order to be able to do the second part of the lab assignment, we will have to look at how several
registers/devices are connected to a common bus without causing short circuits and blown chips.
The diagram below illustrates several registers all hooked up to a common bus.
If one device is outputting a one and the other a 0 then what will be the output on bus?

To avoid this problem we use a device called a tri-state buffer, which besides the states 0 and 1 has a floating third state.
These can be used to connect several devices to a bus as the diagram below illustrates.

The tri-state buffers (buffer-1 T.S. in Simulation Logic library) are held in the floating
state except when that device wants to take control of the bus.
If more than one device tries to take control of the bus there will still be a conflict problem.

Here is the truth table and the symbol of a tri-state buffer:

Use the LogicWorks Signal tool to draw a bus line and then incorporate tri-state devices in the circuit.

Here is how part of the circuit for the 1 bit CPU should appear.

      

3. Build a 1-bit CPU

 
Many devices may be connected to a common bus by using tri-state buffers. 
You may build a 1-bit CPU as described above to get ready for your lab
assignment - Build a 2-bit CPU.

  1. A portion of the CPU is given below. Build it in LogicWorks and test it.

          

    What are control signals EXTout and Cin for?

  2. Design the rest of the CPU according to the description of the CPU in the section one of the lab notes and implement the circuit.

    Some Relevant Details:

    The ALU performs two operations, XOR and AND. The operation to be performed is to be determined by the code in the IR. A 0 in the IR indicates an XOR operation and a 1 indicates an AND operation.

    The following control signals will be required for our one bit CPU in this lab:

    
            ACCout, ACCin, TEMPout, TEMPin, ALUout,
    
            IRin, Bout, Bin, Cout, Cin, EXTout, EXTin.
    
    

  3. To implement the operation AND, let's assume that it uses the operands in registers B and C, and then stores the result in C,
    The following instructions would have to be executed.
    (assume the external input switch is set to the value 'one' - the pre-condition for the AND operation):
            At the beginning, switch all the "out" switches to 1 so that
            the bus will be available for use without conflicts.
    
            1. EXTout, IRin.
    
            2. Bout, ACCin.
    
            3. Cout, TEMPin.
    
            4. ALUout, Cin.
    
    
    Practice these microinstructions with your newly built CPU.

  4. Do the following experienment:
    
            Write out the steps necessary to implement the operation XOR
            that uses the operands in the accumulator and register C, and then
            stores the result in register B.
    
    

4. Lab Assignment



Copyright: Department of Computer Science, University of Regina.