Byte Swap (Endian Reversal)
beginner · combinational · 50 XP
Sign in to write your solution, run it in the simulator and submit it for grading.
Sign in or create a free account →Problem
Byte Swap (Endian Reversal)
Input: 32-bit `in[31:0]` representing four bytes. Output: `out[31:0]` with bytes reversed.
```
out = {in[7:0], in[15:8], in[23:16], in[31:24]}
```
**Why this matters:** Big-endian systems store the most-significant byte first; little-endian store it last. When data crosses a network or bus boundary, byte-swapping converts between the two representations.
**Example:** `in=32'h12345678 → out=32'h78563412`
Constraints
- Use concatenation {} — no arithmetic operators.
Examples
Input: in=32'h12345678
Output: out=32'h78563412
Common questions
- What does the Byte Swap (Endian Reversal) problem ask you to build?
- Byte Swap (Endian Reversal) Input: 32-bit `in[31:0]` representing four bytes. Output: `out[31:0]` with bytes reversed. ``` out = {in[7:0], in[15:8], in[23:16], in[31:24]} ``` **Why this matters:** Big-endian systems store the most-significant byte first; little-endian store it last.
- What constraints does Byte Swap (Endian Reversal) have?
- Use concatenation {} — no arithmetic operators.
- What is an example input and output for Byte Swap (Endian Reversal)?
- Input in=32'h12345678 gives output out=32'h78563412.
- Which Verilog concepts does Byte Swap (Endian Reversal) practise?
- combinational, vectors, concatenation, interview.