1
对于我们的学校项目,我试图使用线性反馈移位寄存器在硬件(七段)上进行伪随机数生成。我写了LFSR和七段模块,但是我无法将两个模块相互连接起来。该项目合成,但HDL图不显示LFSR和七段模块之间的任何连接。以下是代码。在Verilog中将4位移位寄存器输出连接到另一个模块中的4位输入
//main module
module expo(input clock, reset,
output a,b,c,d,e,f,g
);
wire [3:0]connect, clk, a,b,c,d,e,f,g;
LFSR_4_bit lfsr(
.clock(clock),
.LFSR(connect)
);
seven_seg seven(
.in(connect),
.reset(reset),
.a(a),
.b(b),
.c(c),
.d(d),
.e(e),
.f(f),
.g(g)
);
endmodule
//LFSR module
module LFSR_4_bit(
input clock,
output reg[3:0]LFSR = 15
);
wire feedback = LFSR[4];
always @(posedge clock)
begin
LFSR[0] <= feedback;
LFSR[1] <= LFSR[0];
LFSR[2] <= LFSR[1];
LFSR[3] <= LFSR[2]^feedback;
LFSR[4] <= LFSR[3];
end
endmodule
//input and output for seven seg module
module sevenseg(
input reset,
input[3:0] in, //the 4 inputs for each display
output a, b, c, d, e, f, g, //the individual LED output for the seven segment along with the digital point
output [3:0] an // the 4 bit enable signal
);
感谢您的帮助。
我认为最初的陈述通常用于实现测试平台并且不可合成 – aaamourao
并且复位信号会使您的LFSR在每次打开时生成相同的数字序列 – aaamourao
@dasho lfsr在打开时预计会给出相同的序列这就是为什么他们是伪随机的。初始语句是可合成的,用于在fpgas上设置默认值。 – Morgan