IFT 201 HW4

profilefoooq55
IFT201lab4.doc

<[IFT 201]>

Computer and Network Systems: Organization and Administration

Lab 4: Logic Circuits

Score: 60 pts.

Objectives:

· Design Combinational Circuits and a 4-bit Register

· Implement and simulate using digital logic software that is easy to use and easy to understand.

· Be sure to go to the Help menu to familiarize yourself with the program.

I. Full Adder (This was adapted from David M. and Sarah L. Harris, 2012)

In this section, you will design a simple digital circuit called a full adder. You will

use the simulation software tool to enter a schematic and simulate your design.

Background: Adders

An adder, not surprisingly, is a circuit whose output is the binary sum of its inputs. Since adders are needed to perform arithmetic, they are an essential part of any computer. The full adder will be an integral part of the microprocessor that you design in later labs.

A full adder has three inputs (A, B, Cin) and two outputs (S, Cout), as shown in Figure 1 below. Inputs A and B each represent 1-bit binary numbers that are being added, and S represents a bit of the resulting sum.

image1.emf

The Cin (carry in) and Cout (carry out) signals are used when adding numbers that are more than one bit long. To understand how these signals are used, consider how you would add the binary numbers 101 and 001 by hand:

image2.emf

As with decimal addition, you first add the two least significant bits. Since 1+1=10 (in binary), you place a zero in the least significant bit of the sum and carry the 1. Then you add the next two bits with the carry, and place a 1 in the second bit of the sum. Finally, you add the most significant bits (with no carry) and get a 1 in the most significant bit of the sum.

When a sum is performed using full adders, each adder handles a single column of the sum. Figure 2 below shows how to build a circuit that adds two 3-digit binary numbers using three full adders. The Cout for each bit is connected to the Cin of the next most significant bit. Each bit of the 3-bit numbers being added is connected to the appropriate adder’s inputs and the three sum outputs (S2:0) make up the full 3-bit sum result.

image3.emf

Note that the rightmost Cin input is unnecessary, since there can never be a carry into the first column of the sum. This would allow us to use a half adder for the first bit of the sum. A half adder (shown in Figure 3 below) is similar to a full adder, except that it lacks a Cin and is thus simpler to implement. To save you design time, however, you will only build a full adder in this lab.

image4.emf

1. Design

A partially completed truth table for a full adder is given in Table 1 below. The table indicates the values of the outputs for every possible input, and thus completely specifies the operation of a full adder. As is common, the inputs are shown in binary numeric order. The values for S (sum) are given, but the Cout (carry out) column is left blank. Complete the table by filling in the correct values for Cout so that adders connected as in Figure 2 will perform valid addition.

image5.emf

From the truth table, we now want to implement our design using logic gates. The sum output (S) can be produced from the inputs by connecting two 2-input XOR gates as shown in Figure 4.

You should convince yourself that this circuit produces the outputs for S as given in the table.

image6.emf

2. Schematic

Using only two-input logic gates (AND, OR, XOR) and inverters (NOT), design a circuit that takes A, B, and Cin as its inputs and produces the Cout output. Try to use the fewest number of gates possible. Sketch your schematic.

Now that you know how to produce both the sum (S) and carry out (Cout) outputs using simple logic gates, you will now construct a working full adder circuit. However, you’ll build and simulate the circuit in Figure 5 below, that uses only AND, OR, and NOT gates.

image7.png

Figure 5: Full Adder

II. Simulations

We’ll make use of a package called Digital Works. This package not only lets us draw circuits, but also to ‘run’ them so we can see if they do what we think they do.

1. Digital Works

Digital Works is a tool that allows you to not only create digital circuitry, but to also test it in a simulation mode. The aim of this brief introduction is to show how Digital Works can be used to understand the fundamental aspects of digital circuitry.

Installing Digital Works

The Digital Works package is copyright Mechanique and is distributed by Matrix Multimedia Ltd. Their website is http://www.matrixmultimedia.co.uk

The Digital Works distribution is provided in the form of a standard self-extracting archive and installer for Microsoft Windows. Simply run the executable file and follow the on-screen menus - as part of this they will ask you for an installation directory.

You can run the executable file provided to install Digital Works on your computer, or download a demo version from the website.

On starting Digital Works for the first time you see the application as it is shown

image8.png

As you can see, Digital Works has a menu bar and three button bars for the user to create and run digital circuits. You can find out the use of each button by holding the mouse pointer over the button - a useful message pops over the button describing what it does. The main part of Digital Works is the drawing area, where circuits can be designed and run.

Digital Objects

The digital objects buttons allow the user to place components into the drawing area. To place a component into the drawing area you need to first click on the relevant button and then on the point in the drawing area where you wish the component to be placed. Each component needs to be selected individually, even if you wished to place multiple copies of the same component into the drawing area.

image9.png

These buttons allow the user to select the following components:

· AND gate;

· OR gate;

· NOT gate;

· NAND gate;

· NOR gate;

· XOR gate;

· XNOR gate;

· Tri-state gate;

· D flip-flop;

· JK flip-flop;

· RS flip-flop;

· Memory device;

· Switch;

· Macro tag;

Input Devices

The input devices buttons allow the user to place input components into the drawing area.

image10.png

These buttons allow the user to select the following components:

· Sequence generator;

· Clock;

· Interactive input;

· Ground;

· Power supply

Output Devices

The output devices buttons allow the user to place output components into the drawing area.

image11.png

These buttons allow the user to select the following components:

· LED;

· Seven segment LED;

· Numeric output device.

Additional

Finally, the additional buttons give the user the ability to add labels to components to describe their use, and provides the ability to wire up components to form a digital circuit.

image12.png

The Control Button Bar

It is with the control button bar that users can then run their completed circuits.

image13.png

These buttons are described here:

· Run the circuit;

· Stop the circuit;

· Pause the circuit;

· Step through the circuit;

· Object selector - the arrow pointer;

· Object interaction selector - the hand pointer;

· logic probe - to check the logic level on a particular wire;

· Access to the parts centre - a useful set of pre-created circuits that you can make use of.

The Parts Centre

In addition, Digital Works has a very powerful facility known as a macro facility. Within this facility it is possible to embed one circuit into another.

You can make use of the pre-created circuits by using the parts centre menu - as shown in figure F.8. To use any of the pre-created macros you click on the particular macro, and holding the left mouse button down, you drag the macro to the drawing area.

image14.png

2. Creating your circuit

We will now provide the first few steps to create and run the circuit in Figure 5.

Step 1

The first thing we need to do is make use of the objects and devices buttons to place all the required components into the drawing area

image15.png

Step 2

Next we need to set all components to have the correct number of inputs - for example, the OR gate requires four inputs. These are changed by clicking on the components with the right mouse button and selecting the ‘inputs’ option.

Additionally, we need to add three interactive inputs, so we can change the values of the X, Y and C inputs. Also, we need to add tag devices to anchor the wire that do not have end points that are connected to components.

Lastly, a single LED is added to display the output.

We now have the circuit displayed in figure below

image16.png

Step 3

Next we use the wiring tool to wire the individual components together, starting with the lines that carry X, Y, C, X’, Y’, and C’. Once the wiring tool is selected, you can join up components - the message ‘attach’ appears when you place the wiring tool over a point that it can connect a wire. The wiring tool is a virtual soldering iron.

It is very easy to delete wires that you have wired incorrectly, you merely need to select them with the arrow pointer and then hit the delete button on your keyboard. You can either wire two components directly together, or with intermediate mouse clicks you can specify the route that the wire is to take - again, it is easy to move points just by selecting them with the arrow pointer and moving each point individually.

Once all wiring is completed we should now have the circuit displayed in figure below.

image17.png

Step 4

We can now complete the circuit design by adding labels, using the annotation button; which results in the circuit displayed in figure below.

image18.png

Of course, we haven’t finished yet:

First it is only the S output of a full-adder you’re to create. So you still need to add the Cout. Then you need to run it to see what it does.

3. Testing your circuit

To run our circuit we first select the hand pointer and then we click on the run button. Once we do this our circuit is running - and we can see that with X, Y and C all set to zero, the output S is set to a logical zero because it is grey.

Later on, when we change the inputs to our circuit we will see the LED turn red, to indicate that the output is a logical one. In fact, try clicking with the hand pointer on the interactive input for X. You should see the circuit as it is displayed in figure below

image19.png

III. Building a Register

Using D flip-flops, we can build registers. A register is a finite storage element in a processor. We’ll build a 4-bit register. A 4-bit register consists of four D flip-flops wired as you can see in Figure 6.

image20.png

Figure 6: 4-bit Register

The inputs consist of four data values labelled from D0 to D3 and the C input for the clock. The C input is wired to all the C inputs on the flip-flops, so that they can all be triggered at the same time. Getting back to the data inputs, D0 will be the least significant bit (LSB, the rightmost bit in the number) moving up to the most significant bit (MSB, the leftmost bit in the number) in D3. If we wanted to store the value 1210 (11002) we would store the bits as in table below. The outputs to the circuit, R0 through to R3 are the outputs from our register - these outputs show the value we have stored in our register.

So, assuming that the bit pattern to be placed inside the register is on the data lines (inputs D0 to D3), all we have to do is clock the register for it to store the bit pattern from the data lines in the register.

image21.png

IV. Submissions

Please submit your lab report through Blackboard.

Your report must include:

1. A few sentences describing the purpose of this lab

2. Your completed truth table (section I.1)

3. Your completed schematics (section I.2) using only two-input logic gates (AND, OR, XOR) and inverters (NOT), including the logic gate from both S and Cout. You must show the equations derived from the truth table, optimizations with KMap, and build the schematics from the optimized equations

4. Your simulation of the full adder, including all inputs and outputs. This means your report should include 8 screenshots, corresponding to the 8 entries in the truth table. Also, you must also submit your .dwm simulation file

5. Your simulation of the 4-bit Register showing the output of the value 14.

Page | 2