Add the consensus terms that hold a two-level AND-OR circuit steady, so that no single-input change makes its output glitch.
Hardware context: A warning-lamp driver made of unit-delay AND-OR cells that latches every pulse it sees. Add the two consensus terms that remove both static-1 hazards of a lamp driver.
A warning lamp is driven by y = a'b + ac + c'd, built from unit-delay cells. The function is right, but the lamp driver latches every pulse it sees. On some single input changes, y drops to 0 for one gate delay while it should stay 1. The lamp then flashes a false alarm.
This is a Fix problem. Keep the function. Add cells so that y changes once when the function changes, and not at all when it stays the same.
Use only cell instances and wire or logic declarations without initial values. Operators, assignments and procedural code are refused before simulation. The cell count must be from 6 to 14.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
script | 20 | input of each check |
Full specification
module lamp (
input logic a, b, c, d,
output wire y
);
// your netlist
endmodule
// cells.sv: the unit-delay cell library (read-only).
// Every cell takes 1 time unit, whatever its fan-in, except INV: it takes tb.inv_delay units (1, or 2 in some cases). Ports are (y, inputs...): output first.
// Each cell adds 1 to the bench's cell counter when the simulation starts.
module AND2 (output wire y, input wire a, b); and #1 (y, a, b); initial tb.cells++; endmodule
module AND3 (output wire y, input wire a, b, c); and #1 (y, a, b, c); initial tb.cells++; endmodule
module OR2 (output wire y, input wire a, b); or #1 (y, a, b); initial tb.cells++; endmodule
module OR3 (output wire y, input wire a, b, c); or #1 (y, a, b, c); initial tb.cells++; endmodule
module OR4 (output wire y, input wire a, b, c, d); or #1 (y, a, b, c, d); initial tb.cells++; endmodule
module INV (output logic y, input wire a); always begin y <= #(tb.inv_delay) ~a; @(a); end initial tb.cells++; endmodule
| Rule | Detail |
|---|---|
| Function | y = a'b + ac + c'd for every input. |
| No glitches | After any change of the inputs, y changes once if the function changes and not at all if it stays the same. |
| Gate delay | Every cell takes 1 time unit, whatever its number of inputs. In some cases INV takes 2 units: real delays vary. |
| Cells | Only instances of the library cells, from 6 to 14 of them. |
Each case sets a starting input and then makes four changes, one input at a time, 10 time units apart. The result shows y after each change and how many times y moved. The last field says whether the cell count is out of range.
Examples
Example 1
Changes That Move y Once- Input
start at a0b1c0d0; then a0b1c0d1, a0b1c1d1, a0b0c1d1, a0b0c1d0
- Output
y_after_change1 = yes, y_moves_change1 = 0, y_after_change2 = yes, y_moves_change2 = 0, y_after_change3 = no, y_moves_change3 = 1, y_after_change4 = no, y_moves_change4 = 0, cell_count_out_of_range = no
From a = 0, b = 1, c = 0, d = 0, the term a'b holds y at 1. Raising d, then c, keeps y at 1. Dropping b turns off a'b and y falls once. Dropping d moves nothing.
Example 2
A Falls While b and c Are 1- Input
start at a1b1c1d0; then a0b1c1d0, a1b1c1d0, a0b1c1d0, a0b1c1d1
- Output
y_after_change1 = yes, y_moves_change1 = 0, y_after_change2 = yes, y_moves_change2 = 0, y_after_change3 = yes, y_moves_change3 = 0, y_after_change4 = yes, y_moves_change4 = 0, cell_count_out_of_range = no
Here the function is 1 before and after every change, so y must never move. The starter moves y twice when a falls: once down, once back up.
Example 3
c Falls While a and d Are 1- Input
start at a1b0c1d1; then a1b0c0d1, a1b0c1d1, a1b0c0d1, a1b0c0d0
- Output
y_after_change1 = yes, y_moves_change1 = 0, y_after_change2 = yes, y_moves_change2 = 0, y_after_change3 = yes, y_moves_change3 = 0, y_after_change4 = no, y_moves_change4 = 1, cell_count_out_of_range = no
Again the function stays 1. When c falls, ac turns off one gate delay before c'd turns on, so the starter glitches here too.
Constraints and Contract
- Inputs are known 0/1 values. Each change is held for 10 time units before y is read.
- Keep the module name and the ports.
Hints
Hint 1
Draw the K-map of f. Each term is a group of 1s. Look for two groups that touch across one variable but do not overlap.
Hint 2
When that variable changes, one term turns off before the other turns on, because the inverted input arrives one gate delay late. A third term that covers both cells holds y at 1.
Hint 3
That third term is the consensus of the two groups. Drop the variable that changes and keep the other literals of both terms. There are two such pairs here.
What the grader checks: Four directed scripts and sixteen scripts that walk all 64 single-input changes are checked. The walk is then run again with INV at 2 units. After each change, y is compared with the function computed in JavaScript. The number of times y moved is compared with 0 or 1. The model has no wire delay and no fan-out effect.
37 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