传送门:
Lfsr32 - HDLBits (01xz.net)https://hdlbits.01xz.net/wiki/Lfsr32
题目:
设计一个32bit Galois LFSR
“tap”点为32,22,2,1。
提示:使用向量实现,而不是例化 32 个触发器。
module top_module(
input clk,
input reset, // Active-high synchronous reset to 32'h1
output [31:0] q
);
always@(posedge clk)
begin
if(reset)
q[31:0]<= 32'h1;
else begin
q<= {1'b0^q[0], q[31-:9], q[22]^q[0], q[21-:19], q[2]^q[0], q[1]^q[0]};
// 32 31-23 q[30]-q[22] 22 q[21] 3-21 q[20]-q[2] 2 q[1] 1 q[0]
end
end
endmodule