HDLBits-Vector2

2024. 12. 13. 04:39·HDLBits/Verilog

이제는 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
저작자표시 비영리 변경금지 (새창열림)
'HDLBits/Verilog' 카테고리의 다른 글
  • HDLBits - Gates4
  • HDLBits - Vectorgates
  • HDLBits - Vector1
  • HDLBits - Vectors
Zi_Yoon
Zi_Yoon
머리 속에 정리하는 곳 <전자공학>
  • Zi_Yoon
    ZY_repo
    Zi_Yoon
  • 전체
    오늘
    어제
    • 분류 전체보기 (70)
      • HDLBits (25)
        • Verilog (19)
        • Circuits (4)
        • Verification (0)
      • IDEC 교육 (1)
        • Embedded C (13)
        • Verilog HDL (8)
      • Hardware (8)
        • RISC-V Project (1)
        • Computer Architecture (0)
        • AMBA (2)
        • FPGA (0)
        • 논문 읽기 (1)
        • ETC. (4)
      • 42서울 (13)
        • 리눅스 (12)
        • 네트워크 (1)
      • 생각 (1)
      • 취업 (1)
  • 블로그 메뉴

    • 홈
    • 태그
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    vm
    RISC-V
    Keil
    IDEC
    lsblk
    signal trap
    hdlbits
    bit-wise and
    debian
    axi
    embedded
    ARM
    centos
    fucntion
    verilog
    AMBA
    APT
    비대칭 키
    verilator
    AppArmor
    AXI4
    세션 키
    fpga
    보안 쉘
    charater
    c
    ssh
    QUARTUS
    research rabbit
    pointer
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.1
Zi_Yoon
HDLBits-Vector2
상단으로

티스토리툴바