이제는 Vector의 그냥 활용이 문제로 나오는듯? 하다
A 32-bit vector can be viewed as containing 4 bytes (bits [31:24], [23:16], etc.).
Build a circuit that will reverse the byte ordering of the 4-byte word.
32-bit Vector는 4 bytes를 포함한다. byte는 8bit니까..
AaaaaaaaBbbbbbbbCcccccccDddddddd => DdddddddCcccccccBbbbbbbbAaaaaaaa
이걸 이렇게 만들라는 문제다.
8bit 단위로 떼서 옮기면 될 것 같다.
물론 바로 in에서 out으로 assign하면 되지만
이렇게 하면 좀더 가독성이 좋고 나중에 기억하거나 수정할때 편해서 선호한다.
module top_module(
input [31:0] in,
output [31:0] out
);//
wire [7:0] byte_a;
wire [7:0] byte_b;
wire [7:0] byte_c;
wire [7:0] byte_d;
assign byte_d = in[ 7: 0];
assign byte_c = in[15: 8];
assign byte_b = in[23:16];
assign byte_a = in[31:24];
assign out = {byte_d, byte_c, byte_b, byte_a};
endmodule