-
Notifications
You must be signed in to change notification settings - Fork 0
/
lfsr.v
41 lines (36 loc) · 922 Bytes
/
lfsr.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// --------------------------------------------------------------------------
// File : lfsr.v
//
// Module : lfsr
// Author : Carter Nesbitt
// Created : 15 September 2019
// Modified : 15 September 2019
//
// Language : Verilog
// Description : Linear-Feedback Shift Register implementation with
// asynchronous reset and parallel output.
// --------------------------------------------------------------------------
module lfsr
(
i_Clk,
i_Rst,
o_Data
);
parameter DEPTH = 12;
parameter TAP1 = 4;
parameter TAP2 = 7;
parameter INIT = 1;
input wire i_Clk;
input wire i_Rst;
output reg [DEPTH-1:0] o_Data;
integer idx;
always @ (posedge(i_Clk) or posedge(i_Rst))
if (i_Rst) begin
o_Data <= INIT;
end else begin
o_Data[0] <= o_Data[TAP1] ^ o_Data[TAP2];
for (idx = 1; idx < DEPTH; idx = idx + 1) begin
o_Data[idx] <= o_Data[idx-1];
end
end
endmodule