G9.5.1 AOI21 From Six Switches

EasyImplementIcarus · browser samples / server checksReview the topic

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

SignalWidthRole
rows24input of each check
Full specification
The module (keep the name, the ports and the two supply nets)
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 bcyWhich network conducts
001pull-up only
010pull-down only
100pull-down only
110pull-down only
switches.sv: the two transistor cells (read-only). The terminals are out, in, ctrl
// 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

RuleDetail
TransistorsOnly nfet and pfet cells, six at most. Use pfet in the pull-up network and nfet in the pull-down network.
Suppliesvdd is always 1 and gnd is always 0. They are declared for you.
Inner nodesA node between two transistors is a wire that you declare.
Resulty 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

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

Every Row in Counting Order

Input
(a, b, c) = 000, 001, 010, 011, 100, 101, 110, 111
Expected 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.

Run samples executes all 3 public checks. Check all tests runs 10 checks on the server.

Icarus · browser samples / server checks