Vector Port Endianness
[7:0] and [0:7] both describe 8 bits, but they disagree on which end is bit 0. Wire one straight into the other and every bit lands in the wrong place, with no warning from the compiler.
The solution module must accept an 8-bit input vector using descending bit indices and drive an 8-bit output vector using ascending bit indices. Connect the input directly to the output using a continuous assignment. Because Verilog matches bits positionally from left to right during assignment, the leftmost bit of the input will automatically map to the leftmost bit of the output, regardless of the index numbers.
To verify that your output vector is declared with the correct index order, you must also expose bit 3 of your output vector on a separate 1-bit probe port.
| Signal | Direction | Width | Description |
|---|---|---|---|
in_vec |
input | 8 | Input vector, declared with descending indices [7:0] |
out_vec |
output | 8 | Output vector, declared with ascending indices [0:7] |
out_vec_3 |
output | 1 | Probe port; must be assigned the exact value of out_vec[3] |
Constraints
- The
in_vecport must be declared with descending indices[7:0]. - The
out_vecport must be declared with ascending indices[0:7]. - The
out_vec_3port must exactly reflect the value ofout_vec[3]. - All outputs must be purely combinational.
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 2 of 25 in the Verilog Syntax and Language Basics track.
Related problems
Browse all problems · Verilog practice problems · Learning tracks