Analysing a Combinational Circuit
Find what an unknown gate circuit computes by naming every net, writing its equation and building the truth table.
You Will Be Able To
- Label every internal net of a gate circuit.
- Write the equation of each net from the inputs to the outputs.
- Build the truth table one net at a time and simplify the result.
- Check an analysis by simulation.
- Lesson
- G2.9
- Time
- 20 min
- Runs on
- Your browser
- Check
- 5 questions
A netlist of four NAND gates arrives with no comment. A reviewer has to say what it does before it ships. Naming each net and writing its column, one net at a time, answers the question.
- Cycle 0
s is 0, so n1 = 1. Then n2 = a' and n3 = 1, and y = a. Here y is 0.
- Cycle 1
s is 1, so n1 = 0 and n2 = 1. Then n3 = b', and y = b. Here b is 0, so y is 0.
- Cycle 4
a is 1 and s is 0: y is 1. With s = 0 the output follows a.
- Cycle 7
Every row agrees with as' + bs: s selects b, and s' selects a.
Computed from the net equations and confirmed by the lab below on Icarus.
The Method in Four Steps
Analysis is the opposite of design. You have the gates and you want the function. The same four steps work for any circuit without feedback.
- Step
- Structure
- Label
Give every gate output a name. Here: n1, n2, n3 and y.
Follow the calls, values and waits
- data n1 n2 n3 y: Label → Equations
- Equations
Write each net from its gate, using only inputs and nets already written.
Follow the calls, values and waits
- data y = (n2·n3)': Equations → Truth table
- Table and check
Fill one column per net. The y column, 00011011, must match a simulation of the netlist.
Follow the calls, values and waits
- data 00011011: Truth table → Simulate
Read the diagram as text
- Label: name every internal net
- Equations: one per net, in level order
- Truth table: one column per net
- Simulate: the same columns from a run
- Label → Equations: names
- Equations → Truth table: evaluate
- Truth table → Simulate: compare
The level of a gate is one more than the highest level among its inputs. Inputs are level 0.
Equations Net by Net
Write the nets in level order. Each equation first uses the names of the nets it reads. Then substitute until only inputs are left.
| Net | Gate | In nets | In inputs | Level |
|---|---|---|---|---|
| n1 | NAND(s, s) | (ss)' | s' | 1 |
| n3 | NAND(b, s) | (bs)' | (bs)' | 1 |
| n2 | NAND(a, n1) | (a·n1)' | (as')' | 2 |
| y | NAND(n2, n3) | (n2·n3)' | ((as')'(bs)')' | 3 |
n1 and n3 are fed only by inputs, so they come first. y comes last.
Now simplify y by De Morgan: ((as')'(bs)')' = as' + bs. When s is 0, y = a. When s is 1, y = b. The circuit is a 2:1 multiplexer.
The Truth Table, One Column per Net
Fill the table column by column, in the same order as the equations. Each column needs only the columns to its left.
| a b s | n1 | n3 | n2 | y |
|---|---|---|---|---|
| 000 | 1 | 1 | 1 | 0 |
| 001 | 0 | 1 | 1 | 0 |
| 010 | 1 | 1 | 1 | 0 |
| 011 | 0 | 0 | 1 | 1 |
| 100 | 1 | 1 | 0 | 1 |
| 101 | 0 | 1 | 1 | 0 |
| 110 | 1 | 1 | 0 | 1 |
| 111 | 0 | 0 | 1 | 1 |
The y column is 00011011: Σm(3, 4, 6, 7). The lab prints the same columns.
Asked in interviews
How do you find what an unknown gate circuit does?
Name every gate output, write each one's equation in level order, and fill a truth table one net at a time. Then simplify, name the function and confirm it with a simulation.
What makes a circuit combinational?
Its outputs depend only on the present inputs. It has no feedback loop and no storage, so the analysis can go level by level from the inputs.
Four NAND gates: s feeds an inverter, two NANDs combine the data with s and s', and a last NAND joins them. What is it?
A 2:1 multiplexer: y = as' + bs. It is the NAND-NAND form of a sum of products, so bubble pushing turns it into AND-OR directly.
Try It
The program builds the four NAND gates as primitives and prints every net on every row.
Compare each line with your own table. n1 is s', n2 is (as')', n3 is (bs)', and y is as' + bs.
Change g2 to and and run again. Watch which rows of y change: misreading one gate spoils every net after it.
Reorder the loop to {s, a, b} = m[2:0];. The same circuit now prints its rows in a different order.
a b s = 000: n1 1 n2 1 n3 1 y 0 a b s = 001: n1 0 n2 1 n3 1 y 0 a b s = 010: n1 1 n2 1 n3 1 y 0 a b s = 011: n1 0 n2 1 n3 0 y 1 a b s = 100: n1 1 n2 0 n3 1 y 1 a b s = 101: n1 0 n2 1 n3 1 y 0 a b s = 110: n1 1 n2 0 n3 1 y 1 a b s = 111: n1 0 n2 1 n3 0 y 1Check Yourself
Common Mistakes
Wrong Work on the output equation before the nets that feed it.
An equation can only use nets that are already known. Starting at the output leaves unknowns in it.
Fix Go in level order: first the gates fed only by inputs, then the gates fed by those, and so on.
Wrong Misread one gate, for example a NAND as an AND.
One wrong net spoils every net after it. Here a misread g2 inverts n2 and changes six of the eight rows of y.
Fix Write each gate's equation beside the gate, then check its column on two rows by hand.
Wrong Number the rows in a different variable order from the one stated.
The column of y depends on the order of the inputs. With s first, the same table lists the rows differently.
Fix Fix the order before you start, and keep it in the table and in the bench.
Wrong Stop at the raw equation.
((as')'(bs)')' is correct but hides the job of the circuit. Simplified, it is as' + bs: a multiplexer.
Fix Push the bubbles and simplify. Then name the function if you can.
Remember
- Label every net, then write the equations in level order: inputs first, outputs last.
- Fill the truth table one column per net, left to right.
- Simplify the output equation and name the function if you can.
- Check the analysis with a simulation of the same netlist.