`timescale 1 ns / 1ps;
module lsfr ( clk,rst,lsfr,cnt);
input clk;
input rst;
//output lfsr;
//output cnt;
output reg [4:0] lsfr;
output reg [4:0] cnt;
always @ ( !rst)
begin
lsfr <= 5'b11111;
cnt <= 'd1;
end
always @ (posedge clk)
begin
if ( lsfr == 5'b11111 )
cnt <= 1'd1;
else
cnt <= cnt + 1'b1;
end
always @ ( posedge clk)
begin
lsfr[0] <= lsfr [1];
lsfr[1] <= lsfr[2];
lsfr[2] <= lsfr[3];
lsfr[3] <= lsfr[4]^lsfr[0];
lsfr[4] <= lsfr[0];
end
endmodule