2018-02-15 18:31:32 +00:00
|
|
|
`ifndef LFSR_V
|
|
|
|
`define LFSR_V
|
2017-11-15 00:12:52 +00:00
|
|
|
|
2018-02-14 01:04:52 +00:00
|
|
|
module LFSR(clk,reset,enable,lfsr);
|
|
|
|
|
|
|
|
parameter NBITS = 8;
|
|
|
|
parameter TAPS = 8'b11101;
|
|
|
|
parameter INVERT = 0;
|
|
|
|
|
|
|
|
input clk, reset;
|
|
|
|
input enable;
|
|
|
|
output reg [NBITS-1:0] lfsr;
|
|
|
|
|
|
|
|
wire feedback = lfsr[NBITS-1] ^ INVERT;
|
|
|
|
|
|
|
|
always @(posedge clk)
|
|
|
|
begin
|
2018-07-15 04:29:27 +00:00
|
|
|
if (reset)
|
|
|
|
lfsr <= {lfsr[NBITS-2:0], ~lfsr[0]};
|
2018-02-14 01:04:52 +00:00
|
|
|
else if (enable)
|
|
|
|
lfsr <= {lfsr[NBITS-2:0], 1'b0} ^ (feedback ? TAPS : 0);
|
|
|
|
end
|
|
|
|
|
2018-02-15 18:31:32 +00:00
|
|
|
endmodule
|
2017-11-15 00:12:52 +00:00
|
|
|
|
2018-02-15 18:31:32 +00:00
|
|
|
`endif
|