본문 바로가기

Verilog/HDLbits

[HDLBits] Shift18

1. 문제 및 설명

  • Lsfr5의 확장이다. 32bit LSFR을 설계하라
    • tap: 32, 22, 2, 1

 

2. 모듈 정의

module top_module(
    input clk,
    input reset,    // Active-high synchronous reset to 32'h1
    output [31:0] q
);

 

 

3. 답

module top_module(
    input clk,
    input reset,    // Active-high synchronous reset to 32'h1
    output [31:0] q
); 
    reg [31:0] q_next;
    
    always@(*)
        begin
            q_next = q[31:1];
            q_next[31] = q[0];
            q_next[21] = q[0]^q[22];
            q_next[1] = q[0]^q[2];
            q_next[0] = q[0]^q[1];
        end
    
    always@(posedge clk)
        begin
            if(reset)
                q <= 32'd1;
            else
                q <= q_next;
        end

endmodule

'Verilog > HDLbits' 카테고리의 다른 글

[HDLBits] Exams/2014 q4b  (0) 2026.01.22
[HDLBits] Exams/m2014 q4k  (0) 2026.01.22
[HDLBits] Mt2015 lfsr  (0) 2026.01.22
[HDLBits] Lfsr5  (0) 2026.01.22
[HDLBits] Shift18  (0) 2026.01.19