Simulate digital circuits with Logisim
MakerSpace – Circuit Sense
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.
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).
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).
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.
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.
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.
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
(incl. VAT)
Buy Linux Magazine
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.
News
-
New Slimbook EVO with Raw AMD Ryzen Power
If you're looking for serious power in a 14" ultrabook that is powered by Linux, Slimbook has just the thing for you.
-
The Gnome Foundation Struggling to Stay Afloat
The foundation behind the Gnome desktop environment is having to go through some serious belt-tightening due to continued financial problems.
-
Thousands of Linux Servers Infected with Stealth Malware Since 2021
Perfctl is capable of remaining undetected, which makes it dangerous and hard to mitigate.
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.
-
Valve and Arch Linux Announce Collaboration
Valve and Arch have come together for two projects that will have a serious impact on the Linux distribution.
-
Hacker Successfully Runs Linux on a CPU from the Early ‘70s
From the office of "Look what I can do," Dmitry Grinberg was able to get Linux running on a processor that was created in 1971.
-
OSI and LPI Form Strategic Alliance
With a goal of strengthening Linux and open source communities, this new alliance aims to nurture the growth of more highly skilled professionals.
-
Fedora 41 Beta Available with Some Interesting Additions
If you're a Fedora fan, you'll be excited to hear the beta version of the latest release is now available for testing and includes plenty of updates.
-
AlmaLinux Unveils New Hardware Certification Process
The AlmaLinux Hardware Certification Program run by the Certification Special Interest Group (SIG) aims to ensure seamless compatibility between AlmaLinux and a wide range of hardware configurations.
-
Wind River Introduces eLxr Pro Linux Solution
eLxr Pro offers an end-to-end Linux solution backed by expert commercial support.