Left Hand Side Concatenation
Concatenation also works on the left of an assignment. One line can split an instruction word into its opcode and its payload.
This module takes a 16-bit instruction word and splits it into two distinct fields. The most significant 4 bits represent the operation code, and the least significant 12 bits represent the data payload. Instead of assigning each output individually using bit slices on the right side of the assignment, the design assigns both outputs simultaneously using left-hand side concatenation.
This circuit is purely combinational. Output values must reflect the current input values without any clock or reset dependency. For example, if the input inst is 16'hA123, the module isolates the upper 4 bits 4'hA for the opcode and the lower 12 bits 12'h123 for the payload.
| Signal | Direction | Width | Description |
|---|---|---|---|
inst |
input | 16 | The full instruction word to be decoded |
opcode |
output | 4 | The most significant 4 bits of the instruction |
payload |
output | 12 | The least significant 12 bits of the instruction |
Constraints
- The circuit is purely combinational; no registers or latches are permitted
- The
opcodeoutput must continuously reflectinst[15:12] - The
payloadoutput must continuously reflectinst[11:0]
Topics
Solve this problem
Write the module in Verilog, SystemVerilog or VHDL. Your submission is compiled and simulated against the problem's testbench. You get the waveform back, not a stored answer.
Free to solve. A Codiode account keeps your progress.
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.
Part of Verilog Syntax and Language Basics
Problem 18 of 25 in the Verilog Syntax and Language Basics track.
Related problems
Browse all problems · Verilog practice problems · Learning tracks