Bus Width Adapter
A 16-bit backbone bus connects to a stack of older 4- and 8-bit parts, and all the glue between them is pure wiring. You are building the adapter. It packs a header and payload into the backbone's word format, tiles a diagnostic pattern across a 16-LED strip, and fixes the byte order of incoming words.
Optional practice if you already use concatenation and replication.
A test using FFFF cannot reveal swapped bytes. Choose a value that can before running your adapter.
Interface
| Port | Direction | Type | Description |
|---|---|---|---|
hdr_i | in | 4-bit vector | Header nibble |
pay_i | in | 8-bit vector | Payload byte |
word_o | out | 16-bit vector | Packed backbone word |
pat_i | in | 4-bit vector | Diagnostic test pattern |
led_o | out | 16-bit vector | 16-LED strip drive |
bus_i | in | 16-bit vector | Word arriving from the backbone |
swap_o | out | 16-bit vector | bus_i with its bytes swapped |
Behavior
-
word_ofollows the backbone's word layout exactly:Bits Field 15–12 hdr_i11–8 constant 0000(reserved)7–0 pay_i -
led_ocarriespat_irepeated four times: bits 15–12, 11–8, 7–4, and 3–0 each show the pattern -
swap_ocarriesbus_iwith its two bytes exchanged: bits 15–8 ofswap_oare bits 7–0 ofbus_i, and bits 7–0 ofswap_oare bits 15–8 ofbus_i
Constraints
OPERATORS: concatenation (and replication, where your language has it) only; no logic operators, no arithmetic.
STRUCTURE: one assignment outside a procedural block per output; no procedural blocks.
Click Run to execute your code. Output will appear here.