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의 경우 움직이지 않으므로 제외하고, 최대 개의 상태를 가진다.
LFSR은 대충 난수생성용인거 같다.
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번 출력이고
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한 놈도 인덱스로 사용할 수 있다는 사실을 알고 계셨나요??