Simulate digital circuits with Logisim

MakerSpace – Circuit Sense

© Lead Image © donatas1205 , 123RF.com

© Lead Image © donatas1205 , 123RF.com

Article from Issue 212/2018
Author(s):

Throw out the cumbersome pencil and paper; you can design, draw, and test digital circuits with Logisim.

Processors are at the heart of every computer – from PCs to tablets to smartphones. Therefore, computer architecture is part of every computer science curriculum. During your studies, you get to peek under the hood of the computer and learn how to design digital circuits, which is exactly where Logisim [1] comes into play. Logisim is a useful tool for learning how to use digital circuits to create electronic designs and simulate small circuits – or even entire microprocessors.

Ubuntu and Fedora offer Logisim as a package of the same name in their repositories, so you can install it through the distribution's package manager and call it up from the menu. For other distributions, you can download the generic version of the software from SourceForge [2] and use the command:

$ java -jar logisim-generic-<Version>.jar

The generic Logisim version is a Java application that requires a working Java Runtime Environment (JRE), which can be obtained either from the repositories of the distribution you use or directly from the Oracle website [3].

Logisim lets you implement simple logical functions like XOR and is capable of creating multiplexers and decoders. Additionally, you can create components that store data, such as flip-flops, memory, and registers [4].

E Is for Entry Level

The basics of Logisim can be better explained using a simple example: an aptitude test with three tasks, at least two of which must be solved to pass the test.

To make a digital circuit of this problem, you first need to identify the inputs and outputs. Here, inputs a1 to a3 represent the three tasks. Two outputs b and d stand for the states passed or failed.

If you were to create the circuit manually, you would determine the functions for the outputs and set up a truth table to define the outputs. For inputs of two or three 1s, you would add a 1 under b and a 0 otherwise. Column d it is exactly the opposite: It is true if b is false and vice versa.

The functions for the two outputs can then be read from the truth table. To set up the respective function correctly, look only at those lines of the inputs in which a 1 results for b or d (Listing 1).

Listing 1

Truth Table Functions

f_b(a1,a2,a3) = (¬a1a2a3)+(a1¬a2a3)+(a1a2¬a3)+(a1a2a3)
f_d(a1,a2,a3) = (a1¬a2¬a3)+(¬a1a2¬a3)+(¬a1¬a2a3)+(¬a1¬a2¬b3)

In Boolean algebra, an addition stands for an OR gate and a multiplication for an AND gate. Because the previous circuit would require three OR gates and eight AND gates for each function, you should check to see whether the function can be minimized according to the laws of Boolean algebra. Fortunately, you can assign this task to Logisim.

Less Is More

To begin, start Logisim and save a new project by clicking File | Save As; then, enter the variables mentioned above in the Inputs and Outputs tabs under Window | Combinational Analysis (Figure 1). In digital circuits, combinational logic does not depend on prior inputs but depends only on the current input.

Figure 1: To build a circuit with Logisim, you first need inputs.

Next, switch to the Table tab, where you determine under which conditions the outputs are true or false by clicking on the placeholders in the output columns until the desired value appears (Figure 2).

Figure 2: Logisim creates the entries for the inputs automatically. All you have to do is look at the results of the outputs.

Finally, you decide how Logisim should minimize the function in the Minimized tab (Figure 3) – you have the choice between Sum of products (a circuit specified in disjunctive normal form, so variables are connected by OR symbols) or Product of sums (a circuit specified in conjunctive normal form, so variables are connected by AND symbols). In this example, I use Sum of products. Once you have determined the minimization format, switch to the Expression tab. The minimized versions of the two functions that implement the circuit appear there (Figure 4).

Figure 3: Define the normal form of the function in the Minimized tab.
Figure 4: Logisim simplifies the function for the example's output b.

Before leaving the Combinational Analysis window, press the Build Circuit button and assign a name to the new circuit (Figure 5). Logisim then draws the circuit on the basis of the truth table. On the left side of the overview window you can access the circuits you create by double-clicking on them if needed.

Figure 5: Logisim can draw the circuit either with two-input gates or NAND gates only.

More Memory

The Combinational Analysis window does not conjure up a circuit for flip-flops, so you must invest a little manual labor. As an example, you can create an edge-triggered D flip-flop. To assign a name to the circuit, right-click on the project name on the left side and select Add Circuit. Logisim then creates an empty canvas onto which you can drag the components.

In the navigation pane on the left, you will find the libraries with components provided by the software (Figure 6). Flip-flops can be found in the Memory library. After opening the library, drag a D flip-flop onto the canvas.

Figure 6: The component libraries appear under the project folder that holds your circuits. When you select a component in the canvas on the right side, the corresponding attribute table appears at the bottom left.

Logisim also provides a place to assign component attributes in a corresponding attribute table that shows up in the lower left section when you select a component. Your D flip-flop should react when the clock has a value of 1, so you need to set the Trigger attribute to rising edge.

Next, select the component and create a duplicate by copying the element with Ctrl+C and pasting it with Ctrl+V. Logisim copies the attributes as well, so you do not need to enter them again.

Your circuit needs input and output pins, as well as a Clock, which can be found in the Wiring library, and a Controlled Inverter (a gate that implements the NOT function and turns a 0 into a 1 and vice versa), from the Gates library. After you have dragged the components onto the canvas, you can change their orientation. Usually the input and output pins point in opposite directions (Figure 7). You should also set the Output? attribute of the output pins to logical Yes.

Figure 7: This D flip-flop has a time control: It only changes its state when the clock switches to 1.

The truth table for a flip-flop does not need manually created circuits. Once all the drawing elements are on the sheet, you just need to connect them. To do so, mouse over the inputs or outputs of a component, click, and drag a line to the next input or output. To draw a line with corners, first create a straight line, then release the mouse button, and continue drawing in a different direction.

Labeling the individual components is also recommended so other users of the circuit can identify the elements: Click the letter icon in the menubar and place the cursor on the canvas to enter a label.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Digital IC Simulation on Linux

    Designing field-programmable gate arrays is only half the job: The hardest part is the simulation, but Linux is the best place to tackle certain challenges.

  • Ubuntu 10.04 Restores Google Search

    The final version of Ubuntu Linux will restore Google as the default search engine in Firefox.

  • Qiskit

    Qiskit is an open source framework that aims to make quantum computing technology both understandable and ready for production.

  • GPIO on Linux Devices

    The general purpose input/output interface is not just for small-board computers anymore: You can use GPIO on your Linux desktop or laptop, too, through the USB port.

  • Mozilla Firefox Blocks Microsoft Add-Ons -- Temporarily

    Mozilla added Microsoft's .NET Framework Assistant to its add-ons blocklist over the weekend. The blocklist blocks programs with evident security vulnerabilities. Before the weekend was over, the app was stricken from the list again.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News