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

Left Hand Side Concatenation

EasyVerilog / SystemVerilogBuildFree2 solved

Instruction decoding in a microprocessor pipeline requires extracting functional fields like opcodes and immediate values from a fetched instruction word. Assigning slices of a wide bus to individual signals improves readability and prevents off-by-one bit-slicing errors throughout the rest of the decoding logic.

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 opcode output must continuously reflect inst[15:12]
  • The payload output must continuously reflect inst[11:0]

Topics

CombinationalData RoutingSyntax

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.

Free to solve. A Codiode account keeps your progress.

Sign in to solve

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

  • Single Continuous AssignmentEasy
  • Basic Vector ConcatenationEasy
  • Ternary Operator MuxEasy
  • Underscores for ReadabilityEasy
  • Inout Port MechanicsEasy
  • Explicit Binary LiteralsEasy
  • Hexadecimal and Octal LiteralsEasy
  • Vector Port EndiannessEasy

Browse all problems · Learning tracks