Codiode

Byte Swapping via Concatenation

MediumVerilog / SystemVerilogBuild2 solved

Network byte order is big-endian and most processors are little-endian, so bridges between them reverse the bytes of every word.

The module receives a 32-bit data word and reverses the order of its four bytes. This operation swaps the most significant byte with the least significant byte, and the second-most significant byte with the second-least significant byte. The bits within each byte must remain in their original order.

This is a purely combinational logic circuit. The output updates immediately when the input changes.

Signal Direction Width Description
in_word input 32 The 32-bit input data word to be swapped.
out_word output 32 The 32-bit output data word with reversed byte order.

Constraints

  • The design must be strictly combinational; do not use clocks, registers, or latches.
  • The implementation must use the Verilog concatenation operator {}.
  • The bit order within each individual 8-bit byte must remain unchanged.

Topics

combinationalendiannessconcatenation

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.

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

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 17 of 25 in the Verilog Syntax and Language Basics track.

Related problems

Browse all problems · Verilog practice problems · Learning tracks

Solve this on a laptopSend yourself the link and continue there.