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.
Optional slice-and-concatenation practice. Keep the field boundaries exact; no gates or arithmetic are needed.
- Drive
header_owith separate concurrent assignments to its disjoint slices.
Interface
| Port | Direction | Type | Description |
|---|---|---|---|
raw_i | in | 16-bit vector | Raw telemetry word |
valid_o | out | 1 bit | Copy of bit 15 |
sample_o | out | 8-bit vector | The sample field, bits 11..4 |
header_o | out | 8-bit vector | Valid + channel + sequence, repacked |
Declare raw_i as std_logic_vector(15 downto 0), the byte outputs as std_logic_vector(7 downto 0), and valid_o as std_logic.
Behavior
valid_ofollows bit 15 ofraw_isample_ofollows bits 11..4 ofraw_iheader_ocarries: 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
raw_iimmediately
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
OPERATORS: selection only: indexing and slices; no gates, no arithmetic.
- Three separate assignments build
header_o's slices
Click Run to execute your code. Output will appear here.