/* LFSR */
module lfsr(clk, rst, srand, init_srand, rand);
input clk, rst;
input [15:0] srand;
input init_srand;
output reg [15:0] rand;
always @(posedge clk or negedge rst)
begin
if (rst == 1'b0)
rand <= 16'd0a;
else
if(init_srand == 1'b0)
rand <= srand; //This is a constant to initialize it
else
rand <=
{rand[13]^rand[0],rand[14]^rand[15], rand[13:8], (rand[7]^rand[2]^rand[1]), rand[5:0],
rand[6]^rand[7]};
end
endmodule