ISP/rtl/BayerProcess/Windows_tb.sv

87 lines
1.8 KiB
Systemverilog
Raw Permalink Normal View History

2024-11-03 20:38:29 +08:00
`default_nettype none
module Windows_tb ();
// Related Paras
parameter int CLK_PERIOD = 20;
parameter int DATA_WIDTH = 16;
parameter int WINDOWS_WIDTH = 5;
parameter int DATA_LENGTH = 100;
parameter int DATA_HEIGHT = 100;
parameter int DATA_FLAMES = 3;
// Related Ports
bit clk = 1;
bit rst = 0;
logic in_valid = 0;
logic [DATA_WIDTH - 1:0] in_data = 0;
logic [7:0] in_user = 0;
logic out_valid = 0;
logic [DATA_WIDTH - 1:0] out_data[WINDOWS_WIDTH ** 2] = '{default: 0};
logic [7:0] out_user = 0;
logic in_ready = 0;
logic out_ready = 0;
// Generate Clk
always #(CLK_PERIOD / 2) clk = ~clk;
// Reset Module
initial begin
rst = 1;
#(10 * CLK_PERIOD);
rst = 0;
end
// Send Data
initial begin
#(12 * CLK_PERIOD);
in_ready = 1;
#(3 * CLK_PERIOD);
for (int f = 0; f < DATA_FLAMES; ++f) begin
for (int j = 0; j < DATA_HEIGHT; ++j) begin
for (int i = 0; i < DATA_LENGTH; ++i) begin
in_user[1] = (j == 0 && i == 0) ? 1'b1 : 1'b0;
in_user[0] = (i == 0) ? 1'b1 : 1'b0;
in_data = j * DATA_LENGTH + i;
in_valid = 1;
#CLK_PERIOD;
end
end
in_valid = 0;
in_user = 0;
#(50 * CLK_PERIOD);
end
$finish(100 * CLK_PERIOD);
end
// Connect to modules
GSR GSR (.GSRI(1'b1));
Windows #(
.DATA_WIDTH (DATA_WIDTH),
.WINDOWS_WIDTH (WINDOWS_WIDTH),
.WINDOWS_ANCHOR_X(2),
.WINDOWS_ANCHOR_Y(2)
) Windows_inst (
.clk (clk),
.reset(rst),
.in_valid(in_valid),
.in_data (in_data),
.in_user (in_user),
.out_valid(out_valid),
.out_data (out_data),
.out_user (out_user),
.in_ready (in_ready),
.out_ready(out_ready)
);
endmodule