10 / 63 · Praktikum
Design lab: from a requirement to a three-input voter
Translate a requirement into a complete truth table, implementation and exhaustive check.
Pelajaran dapat dibaca gratis. Daftar untuk menyimpan progres.
Terjemahan belum tersedia. Pelajaran asli ditampilkan. (English)
Fix the requirement first
Design y=1 when at least two of a, b and c are 1. Assume stable binary inputs, equal weights and no memory. “Exactly two” differs from “at least two” at 111.
| abc | 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 |
|---|---|---|---|---|---|---|---|---|
| y | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 1 |
Each product recognizes a pair of asserted inputs. Equivalent equations do not guarantee identical physical delay.
Majority is the full-adder carry
Read cin as c and cout as y in this experiment. Sum is odd parityparity Whether the number of one bits is odd or even. Parity detects an odd number of bit flips but can miss an even number. Learn more, a different function. Test all eight rows, especially 001 and 111.
a + b + cin = sum + 2 × cout
Derive the reference independently
A suitable DUT expression is (a & b) | (a & c) | (b & c). Instead of copying it into the reference, count the one bits as integers and compare with two.
// Inside a testbench with signals a, b, c and DUT output y:
for (int v = 0; v < 8; v++) begin
{a, b, c} = v[2:0];
#1;
assert (y === ((int'(a) + int'(b) + int'(c)) >= 2))
else $fatal(1, "voter mismatch at %03b", {a,b,c});
endThe casts prevent confusion about narrow arithmetic. The testbench needs an appropriate timeunit; the delay lets its combinational logic settle and does not prove a physical 1 ns timing limit.
Adding enable e changes the requirement to and expands exhaustive coveragecoverage A measure of which planned conditions were exercised. A high percentage alone is not proof that a design is correct. Learn more to 16 input combinations. Check the invariantinvariant A property that must hold throughout every permitted execution, such as FIFO occupancy staying between zero and its capacity. Learn more e=0 implies y=0 independently.
Coba sendiri
List all inputs that distinguish majority from a XOR b XOR c. Which row changes if the requirement becomes “exactly two ones”?
Baca penjelasan
The distinguishing rows are 001,010,100,011,101,110. Parity wrongly returns 1 on the first three and 0 on the last three. “Exactly two” changes only majority row 111 to zero.