CodiodeCodiode
Home
Problem Solving
Skill Tracks
My Assignments
Contests
Leaderboard
Community
Settings
Codiode/Problems/Sequential Logic

Unpacked Struct Compilation Failure

MediumVerilog / SystemVerilogBuild

Hardware designs frequently group related signals into structures for cleaner routing across the hierarchy. A data router module registers a 64-bit bus into a structured format on the rising clock edge. The upper 32 bits map to an address field and the lower 32 bits map to a payload field. Both fields are driven continuously to output ports.

The solution module captures bus_in into an internal struct on the positive clock edge. Synchronous active-high reset clears both outputs to 0. When reset is de-asserted, address_out receives bits 63 to 32 of bus_in and payload_out receives bits 31 to 0.

Simulation fails with a compilation error. The compiler reports an illegal assignment when attempting to drive the 64-bit bus_in vector directly into the internal struct variable. Inspect the module and correct the fault.

| Signal | Direction | Width | Description | |----------------|-----------|-------|-------------| | clk | input | 1 | Positive-edge triggered clock | | rst | input | 1 | Synchronous active-high reset; clears both outputs to 0 | | bus_in | input | 64 | Input bus; upper 32 bits are address, lower 32 bits are payload | | address_out | output | 32 | Registered address field; resets to 0 | | payload_out | output | 32 | Registered payload field; resets to 0 |

Constraints

  • Clock is positive-edge triggered.
  • Reset is synchronous and active-high.
  • Both outputs reset to 0.
  • The struct fields must be named address and payload, each 32 bits wide.
  • The struct must be assigned from bus_in in a single statement inside the always_ff block.
  • Do not modify the module port list.

Topics

DebugSystemVerilogStructsTypes

Solve this problem

Write the module in Verilog, SystemVerilog or VHDL. Your submission is compiled and simulated against a real testbench — you get the waveform back, not a stored answer.

This problem is part of Codiode Pro. The statement above is free to read.

Sign in to solveSee what Pro unlocks

The circuit builder and code editor need a desktop screen. On a phone, read the problem here and open it on a laptop to solve.

Related problems

  • Basic D Flip FlopEasy
  • Debug: Missing Edge in Sensitivity ListMedium
  • Read After Write Hazard DetectionEasy
  • Parameterized Interface with ModportsHard
  • Struct Array PipelineHard
  • T Flip Flop from D Flip Flop TemplateEasy
  • Recursive Generate Reduction TreeHard
  • Four Stage Shift RegisterEasy

Browse all problems · Learning tracks