-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathlfsr.v
30 lines (25 loc) · 877 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
////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020 Akilesh Kannan <[email protected]>
//
// File: lfsr.v
// Modified: 2020-07-15
// Description: Linear Feedback Shift Register (32-bit)
// Used a pseudo-random number generator
//
// License: MIT
//
////////////////////////////////////////////////////////////////////////
`default_nettype None
`timescale 1ns/1ps
module lfsr #(parameter seed = 32'b1) (output reg[31:0] LFSRregister, input clk);
// initially register will contain seed value
initial begin
LFSRregister = seed;
end
// at edge of each clock pulse, shift and XOR required bits
always @(posedge clk) begin
LFSRregister = LFSRregister << 1;
LFSRregister[0] = LFSRregister[31] ^ LFSRregister[29] ^ LFSRregister[25] ^ LFSRregister[24];
end
endmodule