Build the gate y = NOT(a AND b OR c) from six switches, as two networks that are duals.
Hardware context: A six-transistor AND-OR-INVERT gate of a standard-cell library. Build an AOI21 gate from six switches so that exactly one network conducts for every input row.
A cell library offers one gate for the function y = NOT(a AND b OR c). It is called an AND-OR-INVERT gate. It is one CMOS stage: a pull-down network of NMOS switches and a pull-up network of PMOS switches.
This is an Implement problem. Build the gate from six transistor cells: three of type nfet and three of type pfet. For every input row exactly one of the two networks must conduct.
The check walks the input rows and reads y after each one. It also counts your transistors. A design with more than six does not pass, even when every value is right.
Two failures have their own names. If no network conducts, y floats and reads z. If both networks conduct, the supply is shorted to ground and y reads x.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
rows | 24 | input of each check |
Full specification
module aoi (
input logic a,
input logic b,
input logic c,
output wire y
);
supply1 vdd; // the positive supply: always 1
supply0 gnd; // ground: always 0
// your transistors
endmodule
| a AND b | c | y | Which network conducts |
|---|---|---|---|
| 0 | 0 | 1 | pull-up only |
| 0 | 1 | 0 | pull-down only |
| 1 | 0 | 0 | pull-down only |
| 1 | 1 | 0 | pull-down only |
// switches.sv: the two transistor cells (read-only).
// Terminals are (out, in, ctrl), in the order of the nmos and pmos primitives.
// Each cell adds 1 to the transistor counter of the check when the simulation starts.
module nfet (output wire out, input wire in, input wire ctrl); nmos (out, in, ctrl); initial tb.transistors++; endmodule // on when ctrl is 1
module pfet (output wire out, input wire in, input wire ctrl); pmos (out, in, ctrl); initial tb.transistors++; endmodule // on when ctrl is 0
| Rule | Detail |
|---|---|
| Transistors | Only nfet and pfet cells, six at most. Use pfet in the pull-up network and nfet in the pull-down network. |
| Supplies | vdd is always 1 and gnd is always 0. They are declared for you. |
| Inner nodes | A node between two transistors is a wire that you declare. |
| Result | y after each of eight input rows, shown as 0, 1, x or z. Then the transistors over the budget of six, which must be 0. |
Examples
Example 1
Every Row in Counting Order- Input
(a, b, c) = 000, 001, 010, 011, 100, 101, 110, 111
- Output
y_row1 = 1 (1), y_row2 = 0 (0), y_row3 = 1 (1), y_row4 = 0 (0), y_row5 = 1 (1), y_row6 = 0 (0), y_row7 = 0 (0), y_row8 = 0 (0), transistors_over_budget = 0, built_from_switch_cells = yes (1)
The rows 000, 010 and 100 give 1. Every row with c at 1 gives 0, and so does 110, where a and b are both 1.
Example 2
Only c Changes- Input
(a, b, c) = 000, 001, 000, 001, 110, 111, 110, 111
- Output
y_row1 = 1 (1), y_row2 = 0 (0), y_row3 = 1 (1), y_row4 = 0 (0), y_row5 = 0 (0), y_row6 = 0 (0), y_row7 = 0 (0), y_row8 = 0 (0), transistors_over_budget = 0, built_from_switch_cells = yes (1)
With a and b at 0, y is the inverse of c. With a and b at 1, y stays 0 whatever c does: the series pair already pulls it down.
Example 3
Only a and b Change, with c at 0- Input
(a, b, c) = 000, 010, 100, 110, 100, 010, 000, 110
- Output
y_row1 = 1 (1), y_row2 = 1 (1), y_row3 = 1 (1), y_row4 = 0 (0), y_row5 = 1 (1), y_row6 = 1 (1), y_row7 = 1 (1), y_row8 = 0 (0), transistors_over_budget = 0, built_from_switch_cells = yes (1)
With c at 0 the gate is a NAND of a and b. Only the rows with a and b both at 1 give 0.
Constraints and Contract
- Inputs are known 0/1 values; each row is held for one nanosecond and y is read at its end.
- Keep the module name, the ports and the supply nets vdd and gnd.
Hints
Hint 1
Start with the pull-down network. Read the part of the function under the NOT: it says when y is 0.
Hint 2
An AND is two NMOS in series. An OR puts another NMOS in parallel with that pair. That is three of your six transistors.
Hint 3
For the pull-up network swap series and parallel. The PMOS of a and b go side by side. The PMOS of c goes in series with that pair, between them and the supply.
What the grader checks: Five directed and five seeded scripts apply eight input rows each. After every row, y is read as 0, 1, x or z and compared with the function computed in JavaScript. The transistor cells are counted. Switch cells model on and off only: voltages, delays and transistor widths are outside this problem.
10 checks on Icarus · browser samples / server checks. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 2 steps and the final capstone