Learn

0/8
0/6
0/6
0/6

Practice

Repack the Telemetry Word

A telemetry receiver hands you raw 16-bit words from a weather probe. The wire format packs four fields:

BitsField
15valid flag
14..12channel number
11..4sample value
3..0sequence 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_o with separate concurrent assignments to its disjoint slices.

Interface

PortDirectionTypeDescription
raw_iin16-bit vectorRaw telemetry word
valid_oout1 bitCopy of bit 15
sample_oout8-bit vectorThe sample field, bits 11..4
header_oout8-bit vectorValid + 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_o follows bit 15 of raw_i
  • sample_o follows bits 11..4 of raw_i
  • header_o carries: 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_i immediately

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
Loading editor...

Click Run to execute your code. Output will appear here.