Learn

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

Practice

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

PortDirectionTypeDescription
hdr_iin4-bit vectorHeader nibble
pay_iin8-bit vectorPayload byte
word_oout16-bit vectorPacked backbone word
pat_iin4-bit vectorDiagnostic test pattern
led_oout16-bit vector16-LED strip drive
bus_iin16-bit vectorWord arriving from the backbone
swap_oout16-bit vectorbus_i with its bytes swapped

Behavior

  • word_o follows the backbone's word layout exactly:

    BitsField
    15–12hdr_i
    11–8constant 0000 (reserved)
    7–0pay_i
  • led_o carries pat_i repeated four times: bits 15–12, 11–8, 7–4, and 3–0 each show the pattern

  • swap_o carries bus_i with its two bytes exchanged: bits 15–8 of swap_o are bits 7–0 of bus_i, and bits 7–0 of swap_o are bits 15–8 of bus_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.

Loading editor...

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