`timescale 1ns / 1ps module random32 ( input logic clk, input logic rst_n, input logic enable, input logic [31:0] seed, output logic [31:0] out ); function automatic logic [31:0] xorshift32(input logic [31:0] x); logic [31:0] s; s = x; s ^= s << 13; s ^= s >> 17; s ^= s << 5; return s; endfunction always_ff @(posedge clk or negedge rst_n) begin if (!rst_n) begin out <= seed; end else if (enable) begin out <= xorshift32(out); end end endmodule