Even-Parity Link
Two boards in a rack exchange 4-bit sensor readings over a 5-wire ribbon cable. The fifth wire carries an even-parity bit: the transmitter sets it so that the whole 5-bit word always holds an even number of 1s. The receiver flags any word that breaks the promise. That is how a single flipped bit gets caught. You are building one board's endpoint: the transmit side and the receive side, as pure combinational wiring.
Interface
| Port | Direction | Type | Description |
|---|---|---|---|
data_i | in | 4-bit vector | Reading to transmit |
rx_i | in | 5-bit vector | Word arriving from the far end |
tx_o | out | 5-bit vector | Outgoing word: parity bit on top of the reading |
parity_o | out | 1 bit | The transmit parity bit, echoed for a debug LED |
err_o | out | 1 bit | High when rx_i fails the parity check |
Behavior
- The low four bits of
tx_ocarrydata_iunchanged; the top bit, bit 4, is the parity bit - The parity bit is the XOR of the four data bits: 1 exactly when
data_iholds an odd number of 1s. That is what makes the full 5-bit word always even parity_oalways equals the parity bit (bit 4 oftx_o)err_ois high exactly whenrx_iholds an odd number of 1s; a clean word from the far end always has an even count- The two paths are independent: the testbench drives
data_iandrx_itogether and checks all three outputs on every step
Constraints
STRUCTURE: assignment outside a procedural blocks only; no procedural blocks.
- Compute the parity bit once: give it an internal signal and let both
tx_oandparity_oread it - Reading
parity_oback inside the design is legal and produces the same hardware, so the testbench cannot distinguish that shortcut. The internal signal is on your honor: it is the reuse pattern this exercise asks you to practise
Loading editor...
Click Run to execute your code. Output will appear here.