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.

Interface

PortDirectionTypeDescription
hdrin4-bit vectorHeader nibble
payin8-bit vectorPayload byte
wordout16-bit vectorPacked backbone word
patin4-bit vectorDiagnostic test pattern
ledout16-bit vector16-LED strip drive
bus_inin16-bit vectorWord arriving from the backbone
swapout16-bit vectorbus_in with its bytes swapped

Behavior

  • word follows the backbone's word layout exactly:

    BitsField
    15–12hdr
    11–8constant 0000 (reserved)
    7–0pay
  • led carries pat repeated four times: bits 15–12, 11–8, 7–4, and 3–0 each show the pattern

  • swap carries bus_in with its two bytes exchanged: bits 15–8 of swap are bits 7–0 of bus_in, and bits 7–0 of swap are bits 15–8 of bus_in

Constraints

OPERATORS

concatenation (and replication, where your language has it) only; no logic operators, no arithmetic.

STRUCTURE

one concurrent assignment per output; no processes or always blocks.

Loading editor...

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