G9.1.1 Build a NOR from Switches

EasyImplementIcarus · browser samples / server checksReview the topic

Build a NOR gate from two PMOS and two NMOS switches whose output never floats and never shorts the supply.

Hardware context: A two-input CMOS NOR gate made of four transistor switches. Build the pull-up and pull-down networks of a NOR gate from PMOS and NMOS switches.

A CMOS gate is two networks of switches. The pull-up network connects the output to the supply. The pull-down network connects it to ground. For every input, exactly one of the two networks must conduct.

This is an Implement problem. Build a two-input NOR gate from four switches: two PMOS and two NMOS. A PMOS switch is on when its control is 0. An NMOS switch is on when its control is 1.

The output y must be 1 only when a and b are both 0. For the three other rows it must be 0. The check walks the input rows and reads y after each one.

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
rows8input of each check
Full specification
The module (keep the name, the ports and the two supply nets)
module nor2 (
  input  logic a,
  input  logic b,
  output wire  y
);
  supply1 vdd;   // the positive supply: always 1
  supply0 gnd;   // ground: always 0
  // your switches
endmodule
abyWhich network conducts
001pull-up only
010pull-down only
100pull-down only
110pull-down only
The two switch primitives: the terminals are output, input, control
pmos p1 (out, in, ctrl);   // connects in to out while ctrl is 0
nmos n1 (out, in, ctrl);   // connects in to out while ctrl is 1
RuleDetail
SwitchesOnly pmos and nmos primitives. Use PMOS in the pull-up network and NMOS in the pull-down network.
Suppliesvdd is always 1 and gnd is always 0. They are declared for you.
Inner nodesA node between two switches in series is a wire that you declare.
Resulty after each of four input rows, shown as 0, 1, x (both networks conduct) or z (the output floats).

Examples

Example 1

Every Row in Counting Order
Input
(a, b) = 00, 01, 10, 11
Output
y_row1 = 1 (1), y_row2 = 0 (0), y_row3 = 0 (0), y_row4 = 0 (0)

Only the first row, a = 0 and b = 0, gives 1. In the three other rows at least one NMOS switch connects y to ground.

Example 2

Every Row from 11 Down to 00
Input
(a, b) = 11, 10, 01, 00
Output
y_row1 = 0 (0), y_row2 = 0 (0), y_row3 = 0 (0), y_row4 = 1 (1)

The same four rows in the other order. The gate has no memory, so each row gives the same value as before.

Example 3

One Input Changes at a Time
Input
(a, b) = 00, 01, 11, 10
Output
y_row1 = 1 (1), y_row2 = 0 (0), y_row3 = 0 (0), y_row4 = 0 (0)

From 00 to 01 the pull-up path breaks and one NMOS turns on. From 11 to 10 nothing changes at y: one NMOS is still on.

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

Write down, for each row, which network must conduct. The pull-up network conducts in one row only.

Hint 2

Switches in series conduct only when all of them are on. Switches in parallel conduct when any one is on. Match those two sentences to the two networks.

Hint 3

The output must reach the supply only when a is 0 and b is 0. That is two PMOS switches in series, with a wire between them. It must reach ground when a is 1 or b is 1: two NMOS switches side by side.

What the grader checks: Eight directed and six seeded scripts apply four input rows each. After every row, y is read as 0, 1, x or z. The values are compared with the NOR truth table computed in JavaScript. Only nmos and pmos switches are accepted inside the module: an assign or procedural code is refused before simulation. Switch primitives model on and off only: voltages, delays and the weak levels of a pass transistor are outside this problem.

14 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) = 00, 01, 10, 11
Expected output
y_row1 = 1 (1), y_row2 = 0 (0), y_row3 = 0 (0), y_row4 = 0 (0)

Only the first row, a = 0 and b = 0, gives 1. In the three other rows at least one NMOS switch connects y to ground.

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

Icarus · browser samples / server checks