2024-10-08 11:23:42 +08:00
|
|
|
module TB();
|
|
|
|
|
|
|
|
initial
|
|
|
|
begin
|
|
|
|
$fsdbDumpfile("TB.fsdb");
|
|
|
|
$fsdbDumpvars(0, TB);
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
reg rstn;
|
|
|
|
|
|
|
|
reg [31:0] a0_re;
|
|
|
|
reg [31:0] a0_im;
|
2025-02-26 15:50:49 +08:00
|
|
|
reg [31:0] ab0_re;
|
|
|
|
reg [31:0] ab0_im;
|
2024-10-08 11:23:42 +08:00
|
|
|
reg [31:0] a1_re;
|
|
|
|
reg [31:0] a1_im;
|
2025-02-26 15:50:49 +08:00
|
|
|
reg [31:0] ab1_re;
|
|
|
|
reg [31:0] ab1_im;
|
2024-10-08 11:23:42 +08:00
|
|
|
reg [31:0] a2_re;
|
|
|
|
reg [31:0] a2_im;
|
2025-02-26 15:50:49 +08:00
|
|
|
reg [31:0] ab2_re;
|
|
|
|
reg [31:0] ab2_im;
|
2024-10-08 11:23:42 +08:00
|
|
|
reg [31:0] a3_re;
|
|
|
|
reg [31:0] a3_im;
|
2025-02-26 15:50:49 +08:00
|
|
|
reg [31:0] ab3_re;
|
|
|
|
reg [31:0] ab3_im;
|
2024-10-08 11:23:42 +08:00
|
|
|
reg [31:0] a4_re;
|
|
|
|
reg [31:0] a4_im;
|
2025-02-26 15:50:49 +08:00
|
|
|
reg [31:0] ab4_re;
|
|
|
|
reg [31:0] ab4_im;
|
2024-10-08 11:23:42 +08:00
|
|
|
reg [31:0] a5_re;
|
|
|
|
reg [31:0] a5_im;
|
2025-02-26 15:50:49 +08:00
|
|
|
reg [31:0] ab5_re;
|
|
|
|
reg [31:0] ab5_im;
|
|
|
|
reg [31:0] bb0_re;
|
|
|
|
reg [31:0] bb1_re;
|
|
|
|
reg [31:0] bb2_re;
|
|
|
|
reg [31:0] bb3_re;
|
|
|
|
reg [31:0] bb4_re;
|
|
|
|
reg [31:0] bb5_re;
|
|
|
|
reg [31:0] bb0_im;
|
|
|
|
reg [31:0] bb1_im;
|
|
|
|
reg [31:0] bb2_im;
|
|
|
|
reg [31:0] bb3_im;
|
|
|
|
reg [31:0] bb4_im;
|
|
|
|
reg [31:0] bb5_im;
|
2024-10-08 11:23:42 +08:00
|
|
|
|
|
|
|
reg [47:0] fcw;
|
|
|
|
|
|
|
|
reg [21:0] cnt;
|
|
|
|
reg [15:0] din_rect;
|
|
|
|
reg [15:0] din_cos;
|
|
|
|
reg [15:0] iir_in;
|
|
|
|
|
2025-02-26 15:50:49 +08:00
|
|
|
reg [1 :0] source_mode;
|
2024-10-08 11:23:42 +08:00
|
|
|
wire [15:0] cos;
|
|
|
|
wire [15:0] sin;
|
|
|
|
|
|
|
|
|
2024-11-04 19:03:02 +08:00
|
|
|
reg clk;
|
|
|
|
reg clk_div2;
|
|
|
|
reg clk_div4;
|
|
|
|
|
2024-10-08 11:23:42 +08:00
|
|
|
initial
|
|
|
|
begin
|
|
|
|
#0;
|
|
|
|
rstn = 1'b0;
|
|
|
|
clk = 1'b0;
|
2024-11-04 19:03:02 +08:00
|
|
|
clk_div2 = 1'b0;
|
|
|
|
clk_div4 = 1'b0;
|
2024-10-08 11:23:42 +08:00
|
|
|
|
2024-11-25 20:26:22 +08:00
|
|
|
|
|
|
|
a0_re = 32'd55007237 ;
|
2025-02-26 15:50:49 +08:00
|
|
|
a1_re = 1*32'd32690030 ;
|
|
|
|
a2_re = 1*32'd429516;
|
2024-11-25 20:26:22 +08:00
|
|
|
a3_re = 32'd0;
|
|
|
|
a4_re = 32'd0;
|
|
|
|
a5_re = 32'd0;
|
|
|
|
|
2024-10-08 11:23:42 +08:00
|
|
|
a0_im = 32'd0;
|
|
|
|
a1_im = 32'd0;
|
|
|
|
a2_im = 32'd0;
|
|
|
|
a3_im = 32'd0;
|
|
|
|
a4_im = 32'd0;
|
|
|
|
a5_im = 32'd0;
|
2024-11-25 20:26:22 +08:00
|
|
|
|
2025-02-26 15:50:49 +08:00
|
|
|
ab0_re = 32'd54894517;
|
|
|
|
ab1_re = 1*32'd32664510;
|
|
|
|
ab2_re = 1*32'd429381;
|
|
|
|
ab3_re = 32'd0;
|
|
|
|
ab4_re = 32'd0;
|
|
|
|
ab5_re = 32'd0;
|
|
|
|
|
|
|
|
ab0_im = 32'd0;
|
|
|
|
ab1_im = 32'd0;
|
|
|
|
ab2_im = 32'd0;
|
|
|
|
ab3_im = 32'd0;
|
|
|
|
ab4_im = 32'd0;
|
|
|
|
ab5_im = 32'd0;
|
|
|
|
|
|
|
|
bb0_re = 32'd2138691506;
|
|
|
|
bb1_re = 32'd2144132133;
|
|
|
|
bb2_re = 32'd2146141622;
|
|
|
|
bb3_re = 32'd0;
|
|
|
|
bb4_re = 32'd0;
|
|
|
|
bb5_re = 32'd0;
|
|
|
|
|
|
|
|
bb0_im = 32'd0;
|
|
|
|
bb1_im = 32'd0;
|
|
|
|
bb2_im = 32'd0;
|
|
|
|
bb3_im = 32'd0;
|
|
|
|
bb4_im = 32'd0;
|
|
|
|
bb5_im = 32'd0;
|
2024-10-08 11:23:42 +08:00
|
|
|
|
|
|
|
fcw = 48'h0840_0000_0000;
|
|
|
|
|
|
|
|
din_rect = 16'd0;
|
|
|
|
din_cos = 16'd0;
|
|
|
|
|
|
|
|
#300;
|
|
|
|
rstn = 1'b1;
|
|
|
|
#16600300;
|
|
|
|
// din_rect = 16'd30000;
|
|
|
|
// en = 1'b1;
|
|
|
|
#6400;
|
|
|
|
#64000;
|
|
|
|
// din_rect = 16'd0;
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
always #200 clk = ~clk;
|
2024-11-04 19:03:02 +08:00
|
|
|
always #400 clk_div2 = ~clk_div2;
|
|
|
|
always #800 clk_div4 = ~clk_div4;
|
2024-10-08 11:23:42 +08:00
|
|
|
|
2025-02-26 15:50:49 +08:00
|
|
|
always@(posedge clk_div2 or negedge rstn)
|
2024-10-08 11:23:42 +08:00
|
|
|
if(!rstn)
|
|
|
|
cnt <= 22'd0;
|
|
|
|
else
|
|
|
|
cnt <= cnt + 22'd1;
|
|
|
|
|
|
|
|
initial
|
|
|
|
begin
|
|
|
|
wait(cnt[16]==1'b1)
|
|
|
|
$finish(0);
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2025-02-26 15:50:49 +08:00
|
|
|
always@(posedge clk or negedge rstn)
|
2024-10-08 11:23:42 +08:00
|
|
|
if(!rstn)
|
|
|
|
din_rect <= 22'd0;
|
|
|
|
else if(cnt >= 100 && cnt <=10100)
|
|
|
|
begin
|
|
|
|
din_rect <= 16'd30000;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
din_rect <= 16'd0;
|
|
|
|
end
|
|
|
|
|
2025-02-26 15:50:49 +08:00
|
|
|
always@(posedge clk or negedge rstn)
|
2024-10-08 11:23:42 +08:00
|
|
|
if(!rstn)
|
|
|
|
begin
|
|
|
|
iir_in <= 16'd0;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
|
2024-11-04 19:03:02 +08:00
|
|
|
assign source_mode = 2'b01;
|
2024-10-08 11:23:42 +08:00
|
|
|
|
|
|
|
always @(*)
|
|
|
|
|
|
|
|
case(source_mode)
|
|
|
|
2'b01 : iir_in = din_rect;
|
|
|
|
endcase
|
|
|
|
|
2025-02-26 15:50:49 +08:00
|
|
|
wire [1:0] intp_mode;
|
|
|
|
assign intp_mode = 2'b10;
|
2024-10-08 11:23:42 +08:00
|
|
|
|
2025-02-26 15:50:49 +08:00
|
|
|
wire [1:0] dac_mode_sel;
|
|
|
|
assign dac_mode_sel = 2'b00;
|
2024-10-08 11:23:42 +08:00
|
|
|
|
2025-02-26 15:50:49 +08:00
|
|
|
wire tc_bypass;
|
|
|
|
wire vldo;
|
2024-10-08 11:23:42 +08:00
|
|
|
|
2025-02-26 15:50:49 +08:00
|
|
|
assign tc_bypass = 1'b0;
|
2024-10-08 11:23:42 +08:00
|
|
|
|
2025-02-26 15:50:49 +08:00
|
|
|
reg en;
|
|
|
|
always @(posedge clk or negedge rstn)begin
|
|
|
|
if(rstn==1'b0)begin
|
|
|
|
en <= 0;
|
|
|
|
end
|
|
|
|
else begin
|
|
|
|
en <= ~en;
|
|
|
|
end
|
|
|
|
end
|
2024-10-08 11:23:42 +08:00
|
|
|
|
|
|
|
wire [15:0] dout_p0;
|
|
|
|
wire [15:0] dout_p1;
|
|
|
|
wire [15:0] dout_p2;
|
|
|
|
wire [15:0] dout_p3;
|
2024-10-17 17:29:11 +08:00
|
|
|
|
2025-02-26 15:50:49 +08:00
|
|
|
z_dsp inst_z_dsp_en
|
2024-10-08 11:23:42 +08:00
|
|
|
(
|
2025-02-26 15:50:49 +08:00
|
|
|
.clk (clk ),
|
|
|
|
.en (en ),
|
2024-10-08 11:23:42 +08:00
|
|
|
.rstn (rstn ),
|
2024-10-17 17:29:11 +08:00
|
|
|
.tc_bypass (tc_bypass ),
|
2024-11-25 23:05:43 +08:00
|
|
|
.vldi (iir_in[14] ),
|
2024-10-08 11:23:42 +08:00
|
|
|
.dac_mode_sel (dac_mode_sel ),
|
|
|
|
.intp_mode (intp_mode ),
|
2025-02-26 15:50:49 +08:00
|
|
|
.din (iir_in ),
|
2024-10-08 11:23:42 +08:00
|
|
|
.a0_re (a0_re ),
|
|
|
|
.a0_im (a0_im ),
|
2025-02-26 15:50:49 +08:00
|
|
|
.ab0_re (ab0_re ),
|
|
|
|
.ab0_im (ab0_im ),
|
|
|
|
.bb0_re (bb0_re ),
|
|
|
|
.bb0_im (bb0_im ),
|
2024-10-08 11:23:42 +08:00
|
|
|
.a1_re (a1_re ),
|
|
|
|
.a1_im (a1_im ),
|
2025-02-26 15:50:49 +08:00
|
|
|
.ab1_re (ab1_re ),
|
|
|
|
.ab1_im (ab1_im ),
|
|
|
|
.bb1_re (bb1_re ),
|
|
|
|
.bb1_im (bb1_im ),
|
2024-10-08 11:23:42 +08:00
|
|
|
.a2_re (a2_re ),
|
|
|
|
.a2_im (a2_im ),
|
2025-02-26 15:50:49 +08:00
|
|
|
.ab2_re (ab2_re ),
|
|
|
|
.ab2_im (ab2_im ),
|
|
|
|
.bb2_re (bb2_re ),
|
|
|
|
.bb2_im (bb2_im ),
|
2024-10-08 11:23:42 +08:00
|
|
|
.a3_re (a3_re ),
|
|
|
|
.a3_im (a3_im ),
|
2025-02-26 15:50:49 +08:00
|
|
|
.ab3_re (ab3_re ),
|
|
|
|
.ab3_im (ab3_im ),
|
|
|
|
.bb3_re (bb3_re ),
|
|
|
|
.bb3_im (bb3_im ),
|
2024-10-08 11:23:42 +08:00
|
|
|
.a4_re (a4_re ),
|
|
|
|
.a4_im (a4_im ),
|
2025-02-26 15:50:49 +08:00
|
|
|
.ab4_re (ab4_re ),
|
|
|
|
.ab4_im (ab4_im ),
|
|
|
|
.bb4_re (bb4_re ),
|
|
|
|
.bb4_im (bb4_im ),
|
2024-10-08 11:23:42 +08:00
|
|
|
.a5_re (a5_re ),
|
|
|
|
.a5_im (a5_im ),
|
2025-02-26 15:50:49 +08:00
|
|
|
.ab5_re (ab5_re ),
|
|
|
|
.ab5_im (ab5_im ),
|
|
|
|
.bb5_re (bb5_re ),
|
|
|
|
.bb5_im (bb5_im ),
|
|
|
|
.dout0 (dout_p0 ),
|
|
|
|
.dout1 (dout_p1 ),
|
|
|
|
.dout2 (dout_p2 ),
|
|
|
|
.dout3 (dout_p3 ),
|
|
|
|
.vldo (vldo )
|
2024-10-17 17:29:11 +08:00
|
|
|
|
2024-10-08 11:23:42 +08:00
|
|
|
);
|
|
|
|
|
2024-11-04 19:03:02 +08:00
|
|
|
wire [15:0] dout_clkl_p0;
|
|
|
|
wire [15:0] dout_clkl_p1;
|
|
|
|
wire [15:0] dout_clkl_p2;
|
|
|
|
wire [15:0] dout_clkl_p3;
|
|
|
|
wire [15:0] dout_clkl_p4;
|
|
|
|
wire [15:0] dout_clkl_p5;
|
|
|
|
wire [15:0] dout_clkl_p6;
|
|
|
|
wire [15:0] dout_clkl_p7;
|
|
|
|
|
|
|
|
|
2024-10-08 11:23:42 +08:00
|
|
|
integer signed In_fid;
|
2024-11-25 20:26:22 +08:00
|
|
|
integer signed OrgOut_fid;
|
2024-11-25 23:05:43 +08:00
|
|
|
integer signed dout0_fid;
|
|
|
|
integer signed dout1_fid;
|
|
|
|
integer signed dout2_fid;
|
|
|
|
integer signed dout3_fid;
|
2024-10-08 11:23:42 +08:00
|
|
|
|
|
|
|
initial begin
|
2024-11-25 20:26:22 +08:00
|
|
|
#0;
|
2025-02-26 15:50:49 +08:00
|
|
|
In_fid = $fopen("./in.dat") ;
|
|
|
|
OrgOut_fid = $fopen("./OrgOut.dat");
|
2024-11-25 23:05:43 +08:00
|
|
|
dout0_fid = $fopen("./dout0.dat");
|
|
|
|
dout1_fid = $fopen("./dout1.dat");
|
|
|
|
dout2_fid = $fopen("./dout2.dat");
|
|
|
|
dout3_fid = $fopen("./dout3.dat");
|
2024-10-08 11:23:42 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2025-02-26 15:50:49 +08:00
|
|
|
always@(posedge clk)
|
2024-11-25 20:26:22 +08:00
|
|
|
if(cnt >= 90) begin
|
2025-02-26 15:50:49 +08:00
|
|
|
$fwrite(In_fid, "%d\n",$signed(TB.inst_z_dsp_en.inst_TailCorr_top.din));
|
|
|
|
$fwrite(OrgOut_fid,"%d\n",$signed(TB.inst_z_dsp_en.inst_TailCorr_top.Ysum));
|
2024-11-25 20:26:22 +08:00
|
|
|
end
|
2024-10-08 11:23:42 +08:00
|
|
|
|
2025-02-26 15:50:49 +08:00
|
|
|
always@(posedge clk)
|
|
|
|
if(cnt >= 90 )
|
2024-11-25 23:05:43 +08:00
|
|
|
begin
|
|
|
|
$fwrite(dout0_fid,"%d\n",$signed(dout_p0));
|
|
|
|
$fwrite(dout1_fid,"%d\n",$signed(dout_p1));
|
|
|
|
$fwrite(dout2_fid,"%d\n",$signed(dout_p2));
|
|
|
|
$fwrite(dout3_fid,"%d\n",$signed(dout_p3));
|
|
|
|
end
|
2024-10-08 11:23:42 +08:00
|
|
|
|
|
|
|
|
2025-02-26 15:50:49 +08:00
|
|
|
integer signed doutp0_fid;
|
|
|
|
integer signed doutp1_fid;
|
|
|
|
|
|
|
|
initial begin
|
|
|
|
#0;
|
|
|
|
doutp0_fid = $fopen("./doutp0.dat");
|
|
|
|
doutp1_fid = $fopen("./doutp1.dat");
|
|
|
|
end
|
|
|
|
|
|
|
|
always@(posedge clk)
|
|
|
|
if(cnt >= 90 && en)
|
|
|
|
begin
|
|
|
|
$fwrite(doutp0_fid,"%d\n",$signed(TB.inst_z_dsp_en.inst_TailCorr_top.dout_p0));
|
|
|
|
$fwrite(doutp1_fid,"%d\n",$signed(TB.inst_z_dsp_en.inst_TailCorr_top.dout_p1));
|
|
|
|
end
|
2024-10-08 11:23:42 +08:00
|
|
|
|
2025-02-26 15:50:49 +08:00
|
|
|
endmodule
|
|
|
|
|