ISP/rtl/isp_Pipeline_tb.sv

110 lines
2.6 KiB
Systemverilog

`timescale 1ns / 1ps
module isp_tb();
parameter IN_WIDTH = 50;
parameter IN_HEIGHT = 50;
parameter OFFSET_X = 7;
parameter OFFSET_Y = 3;
parameter OUT_WIDTH = 30;
parameter OUT_HEIGHT = 30;
parameter COLOR_DEPTH = 8;
parameter RAW_TYPE = 3;
reg clk;
initial clk = 0;
always #20 clk <= ~clk;
reg[31:0] cnt_www;
reg reset;
initial begin
reset = 1;
cnt_www = 700;
#500
reset = 0;
#5000000
reset = 1;
cnt_www = 2000;
#500
reset = 0;
end
reg [15:0] in_data[3];
wire [23:0]out_data;
reg in_valid;
wire out_valid;
reg in_ready;
wire out_ready;
reg[31:0] cnt_valid, cnt_ready;
integer i;
always @(posedge clk) begin
if(reset) begin
in_valid <= 0;
in_ready <= 0;
cnt_valid <= 10;
cnt_ready <= 0;
for(i=0;i<3;i=i+1) in_data[i] <= 0;
end else begin
cnt_valid <= cnt_valid+1;
cnt_ready <= cnt_ready+1;
if(cnt_ready==cnt_www)begin
cnt_ready <= 0;
in_ready <= ~in_ready;
end
if(cnt_valid==500)begin
cnt_valid <= 200;
in_valid <= ~in_valid;
end
if(in_valid && out_ready)begin
in_data[0] <= in_data[0] + 1;
for(i=1;i<3;i=i+1) in_data[i] <= in_data[i-1];
end
end
end
reg [23:0] data_out_temp[8192*5];
reg [31:0] now;
reg flag_ifdataerror;
always @(posedge clk) begin
if(reset) begin
flag_ifdataerror <= 0;
if(cnt_www==700) for(i=0;i<(1<<32);i=i+1) data_out_temp[i] <= 0;
now <= 0;
end else if(out_valid && in_ready)begin
now <= now + 1;
if(cnt_www==700)begin
data_out_temp[now] <= out_data;
end else if(cnt_www==2000)begin
flag_ifdataerror <= (data_out_temp[now] != out_data);
end else flag_ifdataerror <= flag_ifdataerror;
end
end
isp_nofifo
#(
.IN_WIDTH (IN_WIDTH ),
.IN_HEIGHT (IN_HEIGHT ),
.OFFSET_X (OFFSET_X ),
.OFFSET_Y (OFFSET_Y ),
.OUT_WIDTH (OUT_WIDTH ),
.OUT_HEIGHT (OUT_HEIGHT ),
.COLOR_DEPTH (COLOR_DEPTH ),
.RAW_TYPE (RAW_TYPE )
)
u_isp(
.clk (clk ),
.reset (reset ),
.in_data (in_data ),
.out_data (out_data ),
.in_valid (in_valid ),
.out_valid (out_valid ),
.in_ready (in_ready ),
.out_ready (out_ready ),
.gain_red (50 ),
.gain_green (50 ),
.gain_blue (50 ),
.blender_enable (0 )
);
endmodule