G9.3.1 Transmission-Gate Mux

MediumImplementIcarus · browser samples / server checksReview the topic

Build a 2-to-1 mux from two transmission gates and one inverter, with an output that never floats and never has two drivers.

Hardware context: A 2-to-1 mux built from two transmission gates and one inverter. Build the mux from six switches so that the output never floats and never has two drivers.

A transmission gate is an NMOS switch and a PMOS switch side by side. With opposite levels on the two gates, the pair is on and passes both 0 and 1 at full strength. With the levels the other way round, the pair is off.

This is an Implement problem. Build a 2-to-1 mux from two transmission gates. While s is 0 the output y must equal a. While s is 1 it must equal b.

The PMOS switches need the inverse of s. Build that signal with an inverter of your own: one PMOS and one NMOS between the supply nets.

Two failures have their own names. If neither pair is on, y floats and reads z. If both pairs are on and the inputs differ, y has two drivers and reads x.

Signals in the Timeline

SignalWidthRole
rows12input of each check
Full specification
The module (keep the name, the ports and the two supply nets)
module tgmux (
  input  logic a,
  input  logic b,
  input  logic s,      // 0: y = a, 1: y = b
  output wire  y
);
  supply1 vdd;   // the positive supply: always 1
  supply0 gnd;   // ground: always 0
  // your switches
endmodule
syWhich pair is on
0athe pair between a and y
1bthe pair between b and y
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: six in all. Two form the inverter, four form the two pairs.
Suppliesvdd is always 1 and gnd is always 0. They are declared for you.
Inner nodesThe inverse of s is a wire that you declare.
Resulty after each of four input rows, shown as 0, 1, x (two inputs drive y) or z (no input drives y).

Examples

Example 1

s = 0: y Follows A
Input
(s, a, b) = 000, 010, 011, 001
Output
y_row1 = 0 (0), y_row2 = 1 (1), y_row3 = 1 (1), y_row4 = 0 (0)

With s at 0 the pair for a is on. The output is 0, 1, 1, 0, the value of a in each row. The changes of b do not reach y.

Example 2

s = 1: y Follows b
Input
(s, a, b) = 100, 101, 111, 110
Output
y_row1 = 0 (0), y_row2 = 1 (1), y_row3 = 1 (1), y_row4 = 0 (0)

With s at 1 the pair for b is on. The output is 0, 1, 1, 0, the value of b in each row.

Example 3

The Inputs Differ and s Switches
Input
(s, a, b) = 010, 110, 001, 101
Output
y_row1 = 1 (1), y_row2 = 0 (0), y_row3 = 0 (0), y_row4 = 1 (1)

The rows put different values on a and b and change s. The output takes a, then b, then a, then b. A design with both pairs on would show x here.

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 inverter of lesson G9.1. A PMOS comes from the supply and an NMOS from ground, both with s on the gate.

Hint 2

For each pair, write down the level each gate needs for the pair to be on. An NMOS needs 1 and a PMOS needs 0.

Hint 3

The pair for a must be on while s is 0. Its NMOS gate takes the inverse of s and its PMOS gate takes s. The pair for b uses the two signals the other way round.

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 and compared with the mux 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. A mux from single NMOS switches would also pass here, although its 1 would be weak on a real chip. Voltages and delays 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 1 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

s = 0: y Follows A

Input
(s, a, b) = 000, 010, 011, 001
Expected output
y_row1 = 0 (0), y_row2 = 1 (1), y_row3 = 1 (1), y_row4 = 0 (0)

With s at 0 the pair for a is on. The output is 0, 1, 1, 0, the value of a in each row. The changes of b do not reach y.

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

Icarus · browser samples / server checks