Repack the Telemetry Word
A telemetry receiver hands you raw 16-bit words from a weather probe. The wire format packs four fields:
| Bits | Field |
|---|---|
| 15 | valid flag |
| 14..12 | channel number |
| 11..4 | sample value |
| 3..0 | sequence counter |
Downstream units want the word taken apart and partly reassembled. The 8-bit sample goes to the display driver as-is, and the valid flag is needed on its own wire. The logger wants a compact header byte: valid flag on top, then the channel, then the sequence counter, with the sample dropped.
This is selection only. No gates, no arithmetic, pure wiring. The two languages build the header differently, each in its own idiom:
- VHDL: drive
headerslice by slice with separate concurrent assignments; disjoint slices are one driver per wire. - SystemVerilog: build the byte in one
assignwith the{}glue, MSB first. One variable, one defining expression.
Interface
| Port | Direction | Type | Description |
|---|---|---|---|
raw | in | 16-bit vector | Raw telemetry word |
valid | out | 1 bit | Copy of bit 15 |
sample | out | 8-bit vector | The sample field, bits 11..4 |
header | out | 8-bit vector | Valid + channel + sequence, repacked |
Declarations: VHDL, std_logic_vector(15 downto 0) for raw, std_logic_vector(7 downto 0) for the byte outputs, std_logic for valid; SystemVerilog, logic [15:0], logic [7:0], and logic.
Behavior
validfollows bit 15 ofrawsamplefollows bits 11..4 ofrawheadercarries: bit 7 = the valid flag, bits 6..4 = the channel (raw bits 14..12), bits 3..0 = the sequence counter (raw bits 3..0)- Pure combinational wiring: every output follows
rawimmediately
The testbench probes single set bits at the field boundaries (bits 15, 12, 11, 4, and 3). An off-by-one slice puts a bit in the wrong place, and the failure message names the boundary that leaked.
Constraints
selection only: indexing and slices (plus {} glue in SystemVerilog); no gates, no arithmetic.
- VHDL: three separate assignments build
header's slices; SystemVerilog: a singleassignbuilds the wholeheader
Click Run to execute your code. Output will appear here.