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 | in | 4-bit vector | Reading to transmit |
rx | in | 5-bit vector | Word arriving from the far end |
tx | out | 5-bit vector | Outgoing word: parity bit on top of the reading |
parity | out | 1 bit | The transmit parity bit, echoed for a debug LED |
err | out | 1 bit | High when rx fails the parity check |
Behavior
- The low four bits of
txcarrydataunchanged; the top bit, bit 4, is the parity bit - The parity bit is the XOR of the four data bits: 1 exactly when
dataholds an odd number of 1s. That is what makes the full 5-bit word always even parityalways equals the parity bit (bit 4 oftx)erris high exactly whenrxholds 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
dataandrxtogether and checks all three outputs on every step
Constraints
STRUCTURE
concurrent assignments only; no processes or always blocks.
- Compute the parity bit once: give it an internal signal and let both
txandparityread it
Loading editor...
Click Run to execute your code. Output will appear here.