File size: 1,051 Bytes
e3c2ab6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
42
43
44
45
46
47
48
49
50
51
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: HDLForBeginners
// Engineer: Stacey
// 
// Create Date: 14.07.2021 13:47:50
// Design Name: lfsr_4bit
// Module Name: lfsr_4bit_top
// Project Name: lfsr_4bit
// Target Devices: 
// Tool Versions: 
// Description: 
// Increments a counter and and drives an output gpio pin
// 
// Dependencies: 
// 
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
// 
//////////////////////////////////////////////////////////////////////////////////


module lfsr_4bit_top(
    input clk,
    input rst,
    output logic led
    );
    
    
    logic [3:0] lfsr;
    
    always @(posedge clk)
    begin
       if(rst) begin
           lfsr <= 4'b1111;
 
       end
       else begin
           lfsr[3] <= lfsr[2]; 
           lfsr[2] <= lfsr[1]; 
           lfsr[1] <= lfsr[0]; 
           lfsr[0] <= lfsr[2]^lfsr[3];           
       end
    end
    
    
    assign led = (lfsr > 4'd10) ? 1'b1 : 1'b0;
            
endmodule