3.2.3 Sequential Logic - Shift Registers

Kiwoong Nam·2025년 6월 6일

HDLBits

목록 보기
10/11

5-bit LFSR

Lfsr5

module top_module(
    input clk,
    input reset,    // Active-high synchronous reset to 5'h1
    output [4:0] q
); 
    always @(posedge clk) begin
        if (reset) q <= 5'h1;
        else q <= {q[0], q[4], q[3]^q[0], q[2], q[1]};
    end

endmodule

shift register에서 중간에 XOR 게이트를 끼워넣은 놈을 Linear Feedback Shift Regitser라고 부른다.
All zero의 경우 움직이지 않으므로 제외하고, 최대 2n12^n -1개의 상태를 가진다.
LFSR은 대충 난수생성용인거 같다.

32-bit LFSR

Lfsr32

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

endmodule

32, 22, 2, 1번에서 tap해라.
n번을 탭해라 = n-1번 레지스터의 입력을 n번 레지스터의 출려과 0번 레지스터의 출력의 xor로 집어넣어라. 32번은 없으니까 32번째 탭은 0하고 0번출력의 xor = 그냥 0번 출력이고

3-input LUT

Exams/ece241 2013 q12

module top_module (
    input clk,
    input enable,
    input S,
    input A, B, C,
    output Z ); 
    reg [7:0] Q;
    always @(posedge clk) if (enable) Q <= {Q[6:0], S};
    assign Z = Q[{A, B, C}];

endmodule

Concatenation한 놈도 인덱스로 사용할 수 있다는 사실을 알고 계셨나요??

0개의 댓글