Starting from:
$35

$29

Lab 6: Introduction to Logisim Solution

Submission timestamps will be checked and enforced strictly by the CourseWeb; late submissions will not be accepted. Check the due date of this lab on the CourseWeb. Remember that, per the course syllabus, if you are not marked by your recitation instructor as having attended a recitation, your score will be cut in half.


In this lab, you will experiment with Logisim and build a simple circuit. Logisim is a tool for designing and simulating logic circuits. It is surprisingly powerful, free, runs on Java, and is available online from http://www.cburch.com/logisim.

Build an Adder

First Let’s learn a little bit about Logisim:

Square boxes are input pins. Their values are being used to compute a value.

Circle boxes are output pins. Their values are being computed by the circuit and output to circuitry that wants the result of the one-bit addition.

Triangles with circles are inverters or NOT-gates, as they invert whatever their input is. Lines are wires. Bright green wires are \on" (true, or 1). Dark green wires are \o " (false,

or 0).

Blue wires are unconnected. We often have blue lines (e.g., when a 5-input AND-gate only has 2 inputs connected, the blue inputs will be ignored). If you get blue lines as outputs when you are not expecting them, though, it is probably a good idea to restart Logisim.

You never want to have red wires. These indicate an error, such as two outputs being connected together.

All wiring components are available from the main tool bar (below the \File" menu). Note that, by default, Logisim creates logical gates that can accept up to ve inputs. For a more realistic circuit, you should set the number-of-inputs property to 2. For example, each AND-gate you create should have exactly two inputs. Two-input gates most closely represent what is available when creating real circuits and let us better understanding things like propagation delay and the need to simplify circuits.

Also, be sure to enter a label for each input and output pin in its attribute table. The attribute table is near the lower-left-hand corner of Logisim’s windows. There are two main modes of operation in Logisim:

The poke tool (the hand icon) lets you change the values of input pins to test di erent inputs The edit tool (the arrow icon) lets you add, select, and manipulate wires.

Here are a few more useful tips when building cricuits:

Clicking and dragging creates wires. The point where you start the click and where you let go of the click determines where the wire connects to other things. If, for example, you click then drag the mouse over another wire, the two wires will not be joined. If you clicked to draw a wire, then let go of the mouse while it is positioned over top of an exiting wire, then the new wire are existing wire will be joined. Large dots show where wires connect to other wires.


CS/COE 0447 | Computer Organization and Assembly Language    Page 1
Lab 6: Introduction to Logisim



You can \undraw" wires to shorten them, or use the Delete key to remove the selected wire. To move segments of wires, you may  nd Alt-Click useful. For complicated circuits, this can help you clean up a messy design. But if you are not careful, it can also complicate a
simple one. As usual, undo is your friend and is just a Ctrl-Z away.

You can easily rotate circuit components. For example, when you add an AND-gate to a circuit, it faces \east" by default (that is, the input comes from the left side and the output is on the right side). Clicking on the AND-gate lets you change some of its properties. Changing the \facing" property rotates the gate. You can also click on a gate and use the arrow keys to rotate it.

Optical Illusion: Sometimes, a wire looks like it is connected to a component, but it really is not. Zoom-in on the component to ensure that the wire is connected to the component’s pin. The zoom control is in the lower-left-hand corner of Logisim’s window.

Multi-bit input and output pins are easily confused. To check a pin component, examine the output property in the pin component’s attribute table. You may also notice that input pins have square corners and output pins have rounded corners.

Gates have a size property. Left click an existing gate and change its size. Since the narrow size is usually su ciently large, this can free up space in your circuit.

Gates also have a number-of-inputs property to set how many inputs they can use. Again, this should typically be set to 2.

If you get an \oscillation apparent" error, it indicates that you are in some way crating an invalid \loop" of wires. For example, the output of a gate may indirectly loop back onto the same gate, causing the gate to keep switching (oscillating) between outputting 1 or 0. You should never get this error if you are doing things properly.

If you are still having an unexplained problem after considering the tops above, save your le, and then try to resolve the problem by restarting Logisim.

Now that you know all about the basic functionality of Logisim, now let’s consider building a one-bit adder. Recall that a one-bit adder has three inputs: the rst one-bit number you are adding, the second one-bit number you are adding, and a carry-in bit. There are two output: the answer (result of the addition) and the carry-out bit. Several one-bit adders can be chained together to build an n-bit adder (where n is as large as desired).

Your task is to construct a one-bit adder circuit based on the circuit design discussed in class. If we did not discuss this in class yet, no worry. Just get familiar with the Logisim. First, create a sub-circuit named \One-bit Adder". This can be done by right-click at \Untitled" (if you already saved your le, it will be the le’s name) and select \Add Circuit...". Enter \One-bit Adder" in the \Input Circuit Name" dialog box and press Enter or click OK. Make sure that the new circuit (One-bit Adder) is selected by looking for the magnifying glass on the left pane. It should be at \One-bit Adder". If the magnifying glass is at \Main", double click the \One-bit Adder". Now, here is a circuit of a one-bit adder:






CS/COE 0447 | Computer Organization and Assembly Language    Page 2
Lab 6: Introduction to Logisim




































Name your le as \lab06.circ" when you save it. Make sure you save your work often. Logisim tends to hang once in a while. Also make sure that facing property of each input/output is the same as shown above. For example, the facing of the output \Carry Out" should be \North".

Four-bit Adder

As mentioned earlier that a four-bit adder can be built by four one-bit adder. In this section, we are going to use four one-bit adder implement a four-bit adder. Create a new sub-circuit called \Four-bit Adder" and make sure it is selected. You can use pre-build one-bit adder by simply use the arrow tool to click on the \One-bit Adder" and place it in your sub-circuit. You need the total of four one-bit adder in this case. Now, try this yourself by building the \Four-bit Adder" as shown below:


















CS/COE 0447 | Computer Organization and Assembly Language    Page 3
Lab 6: Introduction to Logisim
























You may notice a couple new components. The one that looks like a fork is called a splitter. A splitter can be used to split a wire with multiple bits to a group of either individual bit or multiple bits. In the above circuit, the inputs A and B are 4-bit inputs. We need to access each individual bit for each one-bit adder. So, we use two splitters as shown above. A splitter can be found under \Wiring" on the right pane. Note that the property (attribute) of all splitters are as follows:

Facing
South



Fan Out
4




Bit Width In
4



Appearance
Centered



Bit 0
0
(Right)



Bit 1
1




Bit 2
2




Bit 3
3
(Left)




Make sure all of your splitters have the same attribute as shown above. Note that the splitter on the top right is used to merge multiple bits into one wire. The other component is a one-bit constant 0 that is connected to the \Carry In" of the top one-bit adder. The \Constant" can be found under \Wiring". Simply set it to face \South" with data bits 1, and value 0x0.

But how do we provide multibit inputs to this adder block? We can add input and output pins to our circuit, just as before, but we will change the \data width" (in bits) to match the number of bits the adder supports and is expecting. When we draw wires coming out from these multibit inputs, we notice that they are black wires. In reality, these black lines represent \bundles" of wires, speci cally one wire to transmit each bit of the value being conveyed. But Logisim lets us handle that by drawing one line.

So, if we have an 4-bit bundle coming from an input into an 4-bit splitter, everything’s great and hooked as expected. However, if you get orange wires and you receive an \Incompatible widths" error, this means that your data widths do not match somewhere. Look for the little orange numbers that appear at the circled pins to nd ou what data widths you have so that you can adjust them in the attribute window to match. For this case, the data width should be 4.

Once you nish building the four-bit adder, you can test it using the hand tool. Click on any bits of inputs A and B and observe the result. Both A and B inputs are consider to be either 4-bit


CS/COE 0447 | Computer Organization and Assembly Language    Page 4
Lab 6: Introduction to Logisim



unsigned numbers or 4-bit two’s complement. Make sure that result is correct. If a result is not correct, check your circuits (both four- and one-bit adder).

Adder and Subtractor

While the one-bit adder we built is undoubtedly beautiful, Logisim also lets us leverage many useful abstractions which make our circuits more understandable, more compact, and easier to design.

Remember how we said that n one-bit adders, chained together, can be used to form an n-bit adder? Well, Logisim has a built-it adder component that we can use under the \Arithmetic" section. We can simply specify the number of bits, n, in the attribute window, and place an adder block into our circuit. It is as easy as that.

For this section, we are going to build a circuit that can perform either 8-bit addition or 8-bit subtraction. In other words, given two 8-bit numbers A and B, this circuit can compute either A + B or A B. The circuit is shown in the gure below:






















First, let’s populate our circuit with the stu    we already know about:

An 8-bit input for the rst number, A An 8-bit input for the second number, B

A 1-bit input to select the operation (addition vs subtraction) An 8-bit output for the result

An 8-bit adder (found under \Arithmetic")

An 8-bit subtractor (also found under \Arithmetic") A 1-bit constant with value 0.




CS/COE 0447 | Computer Organization and Assembly Language    Page 5
Lab 6: Introduction to Logisim



Start by connecting the inputs, A and B, to the input pins of the adder and subtractor as in the g-ure above. How can we be sure we are connecting the wires as expected? When using the edit tool (the arrow icon), not only can we draw wires, we can also mouse over the input and out-put pins of blocks like the adder and subtractor to learn more about their input names and purpose.

For example, while addition is commutative, so it does not matter whether we connect A or B to the adder’s rst input pin as long as we connect the other to the second one, the same is not true for subtraction. A B is a di erent calculation than B A. So, if we mouse over the top-left input pin of the subtractor, we see that that is the pin for the minuend (the number from which to subtract). Since we want to be able to compute A B, this would be A. Likewise, we can discover that the lower-left-input pin is for the subtrahend, B. We can also nd extensive information about any built-in circuit block under \Help ! Library Reference."

Now, we can piece the rest together with the addition of a few more components from the component window:

Wiring ! Pribe: One of the disadvantages of the \black-wire" multibit bundles Logisim gives us is that we cannot see the values transmitted on those wires as easily as we could with the single-bit scheme of light and dark greens. While you can use the poke tool to inspect these bundles one by one, sometimes we would like to have a permanent \window" into the values they carry, and that is exactly what we get when we attach a probe. Attach one to the result of your adder and one to the result of your subtractor.

Plexers ! Multiplexer: Also known as \mux", a multiplexer is used to select one input from many and pass it along as its output. Since we have the results of both A + B and A B computed, we want to use a mux to choose between them for our nal output. Since we have two inputs to choose from, and it takes only one bit to enumerate those choices, this means we need 1 select bit. Since the data width on each input is 8 bits, the mux must support 8 data bits. Now, we can connect each \potential result" to one of the mux inputs, and connect our operation selection input to the select pin of the mux. (Note: We will also generally always set the \Include Enable?" attribute of muxes to \No", both for style and clarity, so that we do not confuse our select signal with the enable signal that is sometimes used with muxes.)

That is it! You should now have a working eight-bit adder-subtractor, which is e ectively a minimal version of the arithmetic-logic unit (ALU) you would see in a real processor! Use the poke tool to poke your inputs, changing the numbers around to see how everything interacts within your circuit.

Submission

Submit your lab06.circ le via CourseWeb before the due date stated on the CourseWeb. Note that your circuit must contain three subcircuits, One-bit Adder, Four-bit Adder, and Adder Sub-tractor. Do not worry that your \main" circuit is blank.










CS/COE 0447 | Computer Organization and Assembly Language    Page 6

More products