Microcomputer Architecture
and Logic Design
CST 161-3
Subcircuits
As you build circuits that are more and more
sophisticated, you will want to build
smaller circuits that you can use multiple
times in larger circuits
In Logisim, such a smaller circuit that is
used in a larger circuit is called a
subcircuit
You may familiar with the subprogram concept
(called subroutines, functions, or methods
in different languages)
The subcircuit concept is analogous to the
concept in computer programming
Subcircuits
• It is used for the same purposes
• To break a large job into bite-sized pieces
• Save the effort of defining the same concept multiple times
• Facilitate debugging
Creating circuits
• Every Logisim project is actually a library of circuits
• In its simplest form, each project has only one circuit (called "main" by default)
• But it is easy to add more
• Select Add Circuit... from the Project menu
• Type any name you like for the new circuit you want to create
• Type any name you like for the new circuit you want to create
Right Click On Project
Name
Enter name for Sub
Circuit
Add
Circuit
Example:
Name a sub circuit as XOR
Draw the XOR circuit diagram in XOR subcircuit.
Then select the above XOR circuit.
Drag the selected XOR subcircuit and drop on main subcircuit.
Then the below sub circuit has generated.
It represent XOR gate.
So we can connect input output pins to the circuit.
2 to 1 multiplexer
A multiplexer (or mux) is a common digital circuit used to mix a lot of
signals into just one
If you want multiple sources of data to share a single, common data line,
you’d use a multiplexer
Multiplexers come in all sorts of shapes and sizes
They’re all made out of logic gates
Every multiplexer has at least one select line, which is used to select
which input signal gets relayed to the output
2 to 1 multiplexer
2 to 1 multiplexer
Using subcircuits
Now suppose we want to build a 4x2 multiplexer
We can do it using instances of our 2x1 multiplexer
we would first create a new circuit
which we'll call "4x2 MUX”
To add 2x1 multiplexers into our circuit,
click the 2x1 MUX circuit once in the explorer pane to select it as a tool
Then we can add copies of it, represented as boxes
Using subcircuits
Using subcircuits
Our circuit for a 4x2 multiplexer uses three copies of the 2x1
multiplexer
Each drawn as a box with pins along the side
The pins on this box correspond to the input and output pins in the 2x1
MUX circuit
The two pins on the west side of the box correspond to the two pins that
face east in the 2x1 MUX circuit. Others also same as it
Logisim will display that label in a tip
when the user hovers the mouse over the corresponding location
Using subcircuits
Incidentally, every pin to a circuit must be either an input or an output
Many manufactured chips have pins that behave as an input in some
situations and as an output in others
you cannot construct such chips within Logisim
Logisim will maintain different state information for all subcircuits
appearing in a circuit
For example, if a circuit contains a flip-flop, and that circuit is used as a
subcircuit several times, then each subcircuit's flip-flop will have its own
value when simulating the larger circuit
Using subcircuits
we have the 4x2 multiplexer defined
we can now use it in other circuits
Logisim has no limits on how deeply circuits can be nested
•Note
There's nothing wrong with editing a circuit that is being used as a subcircuit
Be aware, though, that any changes to a circuit's pins (adding, deleting, or moving
them) will rearrange them also in the containing circuit
o Thus, if you change any pins in a circuit, you will also need to edit any circuits using
it as a subcircuit
Debugging subcircuits
you test larger circuits, you will likely find bugs
Exploring what's going on in the subcircuits while running the overall
circuit can help
you can do this by bringing up the subcircuit's popup menu
Debugging subcircuits
Notice that the pins' values in the subcircuit match the values being
sent to them in its containing circuit
While in the subcircuit, you can change it however you want
Any changes to pins' values will be propagated within the containing
circuit
If you attempt to toggle a pin using the Poke Tool, Logisim will pop up a
dialog box asking whether you want to create a new state
Responding Yes will divorce the state viewed with the subcircuit from the
outer circuit’s state.
Thank You !!!