mirror of
https://github.com/SikongJueluo/Mini-Nav.git
synced 2026-07-13 04:25:32 +08:00
- Add hw/syn/Makefile with hier/flat/full synth targets and artifact mirroring - Add synth_cam_top_hier.ys for hierarchy-preserving resource estimation on Xilinx 7-series - Add synth_cam_top_flat.ys for flattened Xilinx 7-series synthesis - Add cam-synth just target for convenient invocation - Guard runtime assertions (NUM_ROWS/LANES checks, noise seed checks, NOISE_BITS checks) behind SYNTHESIS guard in cam_core_banked, cam_read_noise, cam_write_noise, and noise_mask_grouped - Fix shadowed 'return' variable in random128 xorshift128 function
58 lines
1.3 KiB
Systemverilog
58 lines
1.3 KiB
Systemverilog
`timescale 1ns / 1ps
|
||
|
||
module random128 (
|
||
input logic clk,
|
||
input logic rst_n,
|
||
input logic enable,
|
||
input logic [127:0] seed,
|
||
output logic [127:0] out
|
||
);
|
||
|
||
// xorshift128:
|
||
// state = {x, y, z, w}
|
||
//
|
||
// t = x ^ (x << 11)
|
||
// x = y
|
||
// y = z
|
||
// z = w
|
||
// w = w ^ (w >> 19) ^ t ^ (t >> 8)
|
||
//
|
||
// 注意:seed 不能为全 0,否则会永久输出 0。
|
||
function automatic logic [127:0] xorshift128(input logic [127:0] state);
|
||
logic [31:0] x;
|
||
logic [31:0] y;
|
||
logic [31:0] z;
|
||
logic [31:0] w;
|
||
logic [31:0] t;
|
||
logic [31:0] next_x;
|
||
logic [31:0] next_y;
|
||
logic [31:0] next_z;
|
||
logic [31:0] next_w;
|
||
|
||
begin
|
||
x = state[127:96];
|
||
y = state[95:64];
|
||
z = state[63:32];
|
||
w = state[31:0];
|
||
|
||
t = x ^ (x << 11);
|
||
|
||
next_x = y;
|
||
next_y = z;
|
||
next_z = w;
|
||
next_w = w ^ (w >> 19) ^ t ^ (t >> 8);
|
||
|
||
xorshift128 = {next_x, next_y, next_z, next_w};
|
||
end
|
||
endfunction
|
||
|
||
always_ff @(posedge clk or negedge rst_n) begin
|
||
if (!rst_n) begin
|
||
out <= seed;
|
||
end else if (enable) begin
|
||
out <= xorshift128(out);
|
||
end
|
||
end
|
||
|
||
endmodule
|