Lecture 04 - Combinational Circuits
Goals
- Learn about our next level of abstraction -- logic gates
- Learn how we can combine logic gates to make combinational circuits
- Learn how to test circuits
- Learn how to build some common combinational circuits
Logic gates
The circuits that implement our basic Boolean functions are called logic gates Now that we have built them, we can pack away the transistors with a layer of abstraction and start looking at what we can accomplish with gates
We have some basic diagrams that visually represent this abstraction to indicate negation, we are going to use a bubble -- these can appear on inputs and outputs of our gates
Just as we combined together Boolean expressions to make more complex logic functions, we can plug together logic gates to make more complicated circuits
Combinational Circuits - circuits whose output is purely a function of the combination of their inputs.
Given a truth table, we can build a combinational circuit that implements the function
There are a lot of different ways we could do this, but here is a process that is an nice form
- create input pins for your variables pointing south
- draw wires straight down from these
- for each product term create an AND gate facing east
- stack these vertically in the order of the terms in the truth table
- make sure it has the same number of inputs as you have variables
- add negations to the inputs to match the product term working from top to bottom
- connect the AND gate inputs to the wires from the variables
- add an OR gate in front of all of the ANDs and OR them all together
- add an output on the end of the OR
Let's try this out with the function we came up with last time
f = D'S'H' + DS'H' + DSH'
this isn't the only way recall that we tried simplifying this a couple of different ways here is the simplest form
f = H' • (D + S')
Testing
Poking the inputs for short tests is fine, but we need a robust way to test our circuits that means we won't forget any of the possible tests
Logisim has a tool that allows us to provide test vectors (input values and the expected output values) in a file
For our simple circuits, our tests can be comprehensive (i.e., we can just provide our truth table)
Logisim expects the first row of our test file to list the inputs and outputs by name, separated by spaces
then each test should be on its own line (conveniently looking like our truth table)
Because this can be tedious to write out for larger tables, I've provided you with a tool that will generate blank truth tables -- you just need to supply the variable names and the expected output values
The process is then
- generate the blank truth table
- open the file in a text editor (e.g. VSCode, not Google Docs or Word or a word processor that has its own file format)
- if you rename the file, make sure it ends in
.txt
- if you rename the file, make sure it ends in
- add the pin names to the top
- add 1s in the appropriate places for the output
- In Logisim, go in the "Simulate" menu and select "Test vector..."
- click "Load vector" and find your file in the file system
- Logisim will run all of the tests and report any that are failing
- if some fail, it is time to fix the circuit (or the test)
Important circuits
Multiplexer
A | B | C | Out | |
---|---|---|---|---|
0 | 0 | 0 | 0 | |
0 | 0 | 1 | 0 | |
0 | 1 | 0 | 1 | |
0 | 1 | 1 | 0 | |
1 | 0 | 0 | 0 | |
1 | 0 | 1 | 1 | |
1 | 1 | 0 | 1 | |
1 | 1 | 1 | 1 |
out = A'BC' + AB'C + ABC' + ABC
What is this function doing?
Variable C is selecting the output of the other two inputs
- when C is 0, we get the value of B
- when C is 1, we get the value of A
out = AC + BC'
this is called a multiplexer it is a very important tool for control flow at the circuit level (you can think of this as being like an if statement, though it is more like a ternary operator)
This is our first abstraction built on top of our logic gates, and it is important enough that Logisim has one in its library
This particular example can choose between two different options, what if we wanted to pick between four different inputs?
How many select lines would we need?
Demultiplexer
Another common circuit is the demultiplexer which works in the opposite direction
I think of this like a train yard. We have one signal coming and we need to direct it to the right output
How would we implement this?
This is basically the same circuit as the multiplexer. We have the same number of AND gates, but we tie the input to all of them. Then instead of bundling everything together with an OR, we just have an output per AND gate.
Decoder
The decoder is just a demultiplexer with no input. We could use this for something like a coin operated soda machine. The select line can be seen as a number in binary and it activates the one line associated with the particular number.
Mechanical level
vocabulary
- combinational circuits
Skills
- evaluate a combinational circuit
Last updated 04/05/2023