Compare commits

..

5 Commits

Author SHA1 Message Date
futh0403 bcd12f7063 复数乘法器资源优化
乘法器开销由4个优化至3个
2025-05-26 18:19:26 +08:00
futh0403 c2e7492c21 Merge branch 'b2' 2025-05-26 15:29:33 +08:00
futh0403 ad84ffcd89 与b2支路合并 -TailCorr_top.v需要b系数,其它模块做出对应修改 2025-04-15 16:15:48 +08:00
thfu 728532bd61 降低位宽
采用求最优解的方法求解位宽;
不同的系数采用不同的位宽
2025-03-19 15:59:00 +08:00
futh0403 6e386a2743 合并main分支的部分修改
-尽量避免使用for循环
2025-03-13 22:39:05 +08:00
21 changed files with 3908 additions and 4889 deletions

View File

@ -1,2 +0,0 @@
//`define COMPLEX 0

View File

@ -1,2 +0,0 @@
`undef COMPLEX 0

File diff suppressed because it is too large Load Diff

View File

@ -1,138 +1,134 @@
module IIR_Filter_p1 #( //+FHDR--------------------------------------------------------------------------------------------------------
parameter coef_width = 32 // Company:
,parameter a_width = 18 //-----------------------------------------------------------------------------------------------------------------
,parameter b_width = 18 // File Name : IIR_Filter_p1.v
,parameter data_in_width = 16 // Department :
,parameter cascade_in_width = 16 // Author : hdzhang
,parameter data_out_width = 16 // Author's Tel :
,parameter temp_var_width = data_out_width + 1 //-----------------------------------------------------------------------------------------------------------------
) // Relese History
//H(z) = a / (1 - b*z^-1) // Version Date Author Description
( // 0.0 2025-03-09 hdzhang
input rstn //2024-05-28 10:22:49
,input clk //-----------------------------------------------------------------------------------------------------------------
,input en // Keywords :
,input signed [data_in_width-1 :0] din_re // Re(x(t)) //
,input signed [cascade_in_width-1:0] dout_r1_re // Re(y(t-1)) //-----------------------------------------------------------------------------------------------------------------
,input signed [coef_width-1 :0] a_re // Parameter
,input signed [coef_width-1 :0] b_re //
`ifdef COMPLEX //-----------------------------------------------------------------------------------------------------------------
input signed [cascade_in_width-1:0] dout_r1_im; // Im(y(t-1)) // Purpose :
input signed [coef_width-1 :0] a_im; //
input signed [coef_width-1 :0] b_im; //-----------------------------------------------------------------------------------------------------------------
output signed [data_out_width-1:0] dout_im; // Im(y(t-16)) // Target Device:
`endif // Tool versions:
//-----------------------------------------------------------------------------------------------------------------
,output signed [data_out_width-1:0] dout_re // Re(y(t-16)) // Reuse Issues
); // Reset Strategy:
wire signed [temp_var_width-1 :0] x1_re; // Clock Domains:
wire signed [temp_var_width-1 :0] y1_re; // Critical Timing:
wire signed [temp_var_width :0] y_re; // Asynchronous I/F:
wire signed [data_out_width-1:0] y_re_trunc; // Synthesizable (y/n):
`ifdef COMPLEX // Other:
wire signed [temp_var_width-1 :0] x1_im; //-FHDR--------------------------------------------------------------------------------------------------------
wire signed [temp_var_width-1 :0] y1_im; module IIR_Filter_p1 #(
wire signed [temp_var_width :0] y_im; parameter coef_width = 32
wire signed [data_out_width-1:0] y_im_trunc; ,parameter a_width = 18
// x1 = a * din delay M = a*x(t-8) ,parameter b_width = 18
mult_x ,parameter data_in_width = 16
#( ,parameter cascade_in_width = 16
.A_width (data_in_width ) ,parameter data_out_width = 16
,.C_width (coef_width ) ,parameter temp_var_width = data_out_width + 1
,.D_width (coef_width ) )
,.o_width (temp_var_width ) //H(z) = a / (1 - b*z^-1)
) (
inst_c1 ( input rstn
.clk (clk ), ,input clk
.rstn (rstn ), ,input en
.en (en ), ,input signed [data_in_width-1 :0] din_re // Re(x(t))
.a (din_re ), ,input signed [cascade_in_width-1:0] dout_r1_re // Re(y(t-1))
.c (a_re ), ,input signed [cascade_in_width-1:0] dout_r1_im // Im(y(t-1))
.d (a_im ), ,input signed [coef_width-1 :0] a_re
.Re (x1_re ), ,input signed [coef_width-1 :0] a_im
.Im (x1_im ) ,input signed [coef_width-1 :0] b_re
); ,input signed [coef_width-1 :0] b_im
// y1 = b * dout_r1 delay M = b*y(t-9)
mult_C ,output signed [data_out_width-1:0] dout_re // Re(y(t-16))
#( ,output signed [data_out_width-1:0] dout_im // Im(y(t-16))
.A_width (cascade_in_width ) );
,.B_width (cascade_in_width )
,.C_width (coef_width )
,.D_width (coef_width ) wire signed [temp_var_width-1 :0] x1_re;
,.o_width (temp_var_width ) wire signed [temp_var_width-1 :0] x1_im;
)
inst_c3 ( wire signed [temp_var_width-1 :0] y1_re;
.clk (clk ), wire signed [temp_var_width-1 :0] y1_im;
.rstn (rstn ), wire signed [temp_var_width :0] y_re;
.en (en ), wire signed [temp_var_width :0] y_im;
.a (dout_r1_re ),
.b (dout_r1_im ), wire signed [data_out_width-1:0] y_re_trunc;
.c (b_re ), wire signed [data_out_width-1:0] y_im_trunc;
.d (b_im ),
.Re (y1_re ),
.Im (y1_im ) // x1 = a * din delay M = a*x(t-8)
); mult_x
assign y_re = x1_re + y1_re; #(
assign y_im = x1_im + y1_im; .A_width (data_in_width )
// dout = round(y) delay M = round(y(t-16)) ,.C_width (a_width )
trunc #( ,.D_width (a_width )
.diw (temp_var_width+1 ) ,.o_width (temp_var_width )
,.msb (temp_var_width-1 ) )
,.lsb (temp_var_width-data_out_width ) inst_c1 (
) round_u1 (clk, rstn, en, y_re, y_re_trunc); .clk (clk ),
trunc #( .rstn (rstn ),
.diw (temp_var_width+1 ) .en (en ),
,.msb (temp_var_width-1 ) .a (din_re ),
,.lsb (temp_var_width-data_out_width ) .c (a_re[coef_width-1 : coef_width-a_width]),
) round_u2 (clk, rstn, en, y_im, y_im_trunc); .d (a_im[coef_width-1 : coef_width-a_width]),
assign dout_re = y_re_trunc; .Re (x1_re ),
assign dout_im = y_im_trunc; .Im (x1_im )
`else );
// x1 = a * din delay M = a*x(t-8)
mult_real
#( // y1 = b * dout_r1 delay M = b*y(t-9)
.A_width (data_in_width ) // y = y1+x1 = a*x(t-8)+b*y(t-9) = y(t-8)
,.C_width (a_width ) mult_C
,.o_width (temp_var_width ) #(
) .A_width (cascade_in_width )
inst_c1 ( ,.B_width (cascade_in_width )
.clk (clk ), ,.C_width (b_width )
.rstn (rstn ), ,.D_width (b_width )
.en (en ), ,.o_width (temp_var_width )
.din (din_re ), )
.coef (a_re[coef_width-1 : coef_width-a_width]), inst_c3 (
.dout (x1_re ) .clk (clk ),
); .rstn (rstn ),
.en (en ),
.a (dout_r1_re ),
// y1 = b * dout_r1 delay M = b*y(t-9) .b (dout_r1_im ),
// y = y1+x1 = a*x(t-8)+b*y(t-9) = y(t-8) .c (b_re[coef_width-1 : coef_width-b_width]),
mult_real .d (b_im[coef_width-1 : coef_width-b_width]),
#( .Re (y1_re ),
.A_width (cascade_in_width ) .Im (y1_im )
,.C_width (b_width ) );
,.o_width (temp_var_width )
) assign y_re = x1_re + y1_re;
inst_c2 ( assign y_im = x1_im + y1_im;
.clk (clk ),
.rstn (rstn ),
.en (en ), // dout = round(y) delay M = round(y(t-16))
.din (dout_r1_re ), trunc #(
.coef (b_re[coef_width-1 : coef_width-b_width]), .diw (temp_var_width+1 )
.dout (y1_re ) ,.msb (temp_var_width-1 )
); ,.lsb (temp_var_width-data_out_width )
) round_u1 (clk, rstn, en, y_re, y_re_trunc);
// dout = round(y) delay M = round(y(t-16)) trunc #(
.diw (temp_var_width+1 )
trunc #( ,.msb (temp_var_width-1 )
.diw (temp_var_width+1 ) ,.lsb (temp_var_width-data_out_width )
,.msb (temp_var_width-1 ) ) round_u2 (clk, rstn, en, y_im, y_im_trunc);
,.lsb (temp_var_width-data_out_width )
) round_u1 (clk, rstn, en, y_re, y_re_trunc); assign dout_re = y_re_trunc;
assign dout_im = y_im_trunc;
`endif
endmodule
assign y_re = x1_re + y1_re;
assign dout_re = y_re_trunc;
endmodule

View File

@ -1,272 +0,0 @@
module IIR_Filter_p16 #(
parameter coef_width = 32
,parameter b_pow16_width = 29
,parameter ab_pow_width = 32
,parameter data_in_width = 16
,parameter data_out_width = 16
,parameter temp_var_width = 29
)
// H(z) = a(1 + b*z^-1 + b^2*z^-2 + b^3*z^-3 + b^4*z^-4 + b^5*z^-5 + b^6*z^-6 + b^7*z^-7) / (1 - b^8*z^-8)
(
input rstn
,input clk
,input en
,input signed [data_in_width-1 :0] dinp0 //x(8n+16)
,input signed [data_in_width-1 :0] dinp1 //x(8n+15)
,input signed [data_in_width-1 :0] dinp2 //x(8n+14)
,input signed [data_in_width-1 :0] dinp3 //x(8n+13)
,input signed [data_in_width-1 :0] dinp4 //x(8n+12)
,input signed [data_in_width-1 :0] dinp5 //x(8n+11)
,input signed [data_in_width-1 :0] dinp6 //x(8n+10)
,input signed [data_in_width-1 :0] dinp7 //x(8n+9)
,input signed [data_in_width-1 :0] dinp8
,input signed [data_in_width-1 :0] dinp9
,input signed [data_in_width-1 :0] dinpa
,input signed [data_in_width-1 :0] dinpb
,input signed [data_in_width-1 :0] dinpc
,input signed [data_in_width-1 :0] dinpd
,input signed [data_in_width-1 :0] dinpe
,input signed [data_in_width-1 :0] dinpf
,input signed [coef_width-1 :0] a_re
,input signed [coef_width-1 :0] ab_re
,input signed [coef_width-1 :0] abb_re
,input signed [coef_width-1 :0] ab_pow3_re
,input signed [coef_width-1 :0] ab_pow4_re
,input signed [coef_width-1 :0] ab_pow5_re
,input signed [coef_width-1 :0] ab_pow6_re
,input signed [coef_width-1 :0] ab_pow7_re
,input signed [coef_width-1 :0] ab_pow8_re
,input signed [coef_width-1 :0] ab_pow9_re
,input signed [coef_width-1 :0] ab_powa_re
,input signed [coef_width-1 :0] ab_powb_re
,input signed [coef_width-1 :0] ab_powc_re
,input signed [coef_width-1 :0] ab_powd_re
,input signed [coef_width-1 :0] ab_powe_re
,input signed [coef_width-1 :0] ab_powf_re
,input signed [coef_width-1 :0] b_pow16_re
,output signed [data_out_width-1:0] dout_re // Re(y(8n-8))
`ifdef COMPLEX
input signed [coef_width-1 :0] a_im;
input signed [coef_width-1 :0] ab_im;
input signed [coef_width-1 :0] abb_im;
input signed [coef_width-1 :0] ab_pow3_im;
input signed [coef_width-1 :0] ab_pow4_im;
input signed [coef_width-1 :0] ab_pow5_im;
input signed [coef_width-1 :0] ab_pow6_im;
input signed [coef_width-1 :0] ab_pow7_im;
input signed [coef_width-1 :0] ab_pow8_im;
input signed [coef_width-1 :0] ab_pow9_im;
input signed [coef_width-1 :0] ab_powa_im;
input signed [coef_width-1 :0] ab_powb_im;
input signed [coef_width-1 :0] ab_powc_im;
input signed [coef_width-1 :0] ab_powd_im;
input signed [coef_width-1 :0] ab_powe_im;
input signed [coef_width-1 :0] ab_powf_im;
input signed [coef_width-1 :0] b_pow16_im;
output signed [data_out_width-1:0] dout_im; // Im(y(8n-8))
`endif
);
wire signed [data_in_width-1 :0] dinp [15:0];
assign dinp[15] = dinpf;
assign dinp[14] = dinpe;
assign dinp[13] = dinpd;
assign dinp[12] = dinpc;
assign dinp[11] = dinpb;
assign dinp[10] = dinpa;
assign dinp[9 ] = dinp9;
assign dinp[8 ] = dinp8;
assign dinp[7 ] = dinp7;
assign dinp[6 ] = dinp6;
assign dinp[5 ] = dinp5;
assign dinp[4 ] = dinp4;
assign dinp[3 ] = dinp3;
assign dinp[2 ] = dinp2;
assign dinp[1 ] = dinp1;
assign dinp[0 ] = dinp0;
wire signed [ab_pow_width-1 :0] ab_pow_re [15:0];
`ifdef COMPLEX
wire signed [ab_pow_width-1 :0] ab_pow_im [15:0];
`endif
assign ab_pow_re[15] = ab_powf_re[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_re[coef_width-ab_pow_width-1];
assign ab_pow_re[14] = ab_powe_re[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_re[coef_width-ab_pow_width-1];
assign ab_pow_re[13] = ab_powd_re[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_re[coef_width-ab_pow_width-1];
assign ab_pow_re[12] = ab_powc_re[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_re[coef_width-ab_pow_width-1];
assign ab_pow_re[11] = ab_powb_re[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_re[coef_width-ab_pow_width-1];
assign ab_pow_re[10] = ab_powa_re[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_re[coef_width-ab_pow_width-1];
assign ab_pow_re[9 ] = ab_pow9_re[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_re[coef_width-ab_pow_width-1];
assign ab_pow_re[8 ] = ab_pow8_re[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_re[coef_width-ab_pow_width-1];
assign ab_pow_re[7 ] = ab_pow7_re[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_re[coef_width-ab_pow_width-1];
assign ab_pow_re[6 ] = ab_pow6_re[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_re[coef_width-ab_pow_width-1];
assign ab_pow_re[5 ] = ab_pow5_re[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_re[coef_width-ab_pow_width-1];
assign ab_pow_re[4 ] = ab_pow4_re[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_re[coef_width-ab_pow_width-1];
assign ab_pow_re[3 ] = ab_pow3_re[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_re[coef_width-ab_pow_width-1];
assign ab_pow_re[2 ] = abb_re[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_re[coef_width-ab_pow_width-1];
assign ab_pow_re[1 ] = ab_re[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_re[coef_width-ab_pow_width-1];
assign ab_pow_re[0 ] = a_re[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_re[coef_width-ab_pow_width-1];
`ifdef COMPLEX
assign ab_pow_im[15] = ab_powf_im[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_im[coef_width-ab_pow_width-1];
assign ab_pow_im[14] = ab_powe_im[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_im[coef_width-ab_pow_width-1];
assign ab_pow_im[13] = ab_powd_im[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_im[coef_width-ab_pow_width-1];
assign ab_pow_im[12] = ab_powc_im[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_im[coef_width-ab_pow_width-1];
assign ab_pow_im[11] = ab_powb_im[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_im[coef_width-ab_pow_width-1];
assign ab_pow_im[10] = ab_powa_im[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_im[coef_width-ab_pow_width-1];
assign ab_pow_im[9 ] = ab_pow9_im[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_im[coef_width-ab_pow_width-1];
assign ab_pow_im[8 ] = ab_pow8_im[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_im[coef_width-ab_pow_width-1];
assign ab_pow_im[7 ] = ab_pow7_im[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_im[coef_width-ab_pow_width-1];
assign ab_pow_im[6 ] = ab_pow6_im[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_im[coef_width-ab_pow_width-1];
assign ab_pow_im[5 ] = ab_pow5_im[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_im[coef_width-ab_pow_width-1];
assign ab_pow_im[4 ] = ab_pow4_im[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_im[coef_width-ab_pow_width-1];
assign ab_pow_im[3 ] = ab_pow3_im[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_im[coef_width-ab_pow_width-1];
assign ab_pow_im[2 ] = abb_im[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_im[coef_width-ab_pow_width-1];
assign ab_pow_im[1 ] = ab_im[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_im[coef_width-ab_pow_width-1];
assign ab_pow_im[0 ] = a_im[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_im[coef_width-ab_pow_width-1];
`endif
wire signed [temp_var_width-1 :0] x_re [0:15];
wire signed [temp_var_width+3 :0] v_re;
reg signed [temp_var_width+3 :0] v1_re;
wire signed [temp_var_width+3 :0] y_re;
wire signed [temp_var_width+3 :0] y1_re;
wire signed [data_out_width-1:0] y_re_trunc;
`ifdef COMPLEX
wire signed [temp_var_width-1 :0] x_im [0:15];
wire signed [temp_var_width+3 :0] v_im;
reg signed [temp_var_width+3 :0] v1_im;
wire signed [temp_var_width+3 :0] y_im;
wire signed [temp_var_width+3 :0] y1_im;
wire signed [data_out_width-1:0] y_im_trunc;
`endif
// x[0] = (dinp0 * a_re) delay M = a*x(8n+8)
// x[1] = (dinp1 * ab_re) delay M = a*b*x(8n+7)
// x[2] = (dinp2 * abb_re) delay M = a*b^2*x(8n+6)
// x[3] = (dinp3 * ab_pow3_re) delay M = a*b^3*x(8n+5)
// x[4] = (dinp4 * ab_pow4_re) delay M = a*b^4*x(8n+4)
// x[5] = (dinp5 * ab_pow5_re) delay M = a*b^5*x(8n+3)
// x[6] = (dinp6 * ab_pow6_re) delay M = a*b^6*x(8n+2)
// x[7] = (dinp7 * ab_pow7_re) delay M = a*b^7*x(8n+1)
genvar i;
generate
`ifdef COMPLEX
for (i = 0; i < 16; i = i + 1) begin: mult_c_inst
mult_x #(
.A_width (data_in_width ),
.C_width (coef_width ),
.D_width (coef_width ),
.o_width (temp_var_width )
) inst_c (
.clk (clk ),
.rstn (rstn ),
.en (en ),
.a (dinp[i] ),
.c (ab_pow_re[i] ),
.d (ab_pow_im[i] ),
.Re (x_re[i] ),
.Im (x_im[i] )
);
end
`else
for (i = 0; i < 16; i = i + 1) begin: mult_c_inst
mult_real #(
.A_width (data_in_width ),
.C_width (coef_width ),
.o_width (temp_var_width )
) inst_c (
.clk (clk ),
.rstn (rstn ),
.en (en ),
.din (dinp[i] ),
.coef (ab_pow_re[i]),
.dout (x_re[i] )
);
end
`endif
endgenerate
// v1 = sum_{i=0,1,...,7}{x[i]} delay M = sum_{i=0,1,...,7}{a*b^i*x(8n-i)}
assign v_re = x_re[0] + x_re[1] +x_re[2] +x_re[3] +x_re[4] +x_re[5] +x_re[6] +x_re[7] + x_re[8] + x_re[9] + x_re[10] + x_re[11] + x_re[12] + x_re[13] + x_re[14] + x_re[15] ;
`ifdef COMPLEX
assign v_im = x_im[0] + x_im[1] +x_im[2] +x_im[3] +x_im[4] +x_im[5] +x_im[6] +x_im[7] + x_im[8] + x_im[9] + x_im[10] + x_im[11] + x_im[12] + x_im[13] + x_im[14] + x_im[15] ;
`endif
always @(posedge clk or negedge rstn)
begin
if (!rstn)
begin
v1_re <= 'h0;
`ifdef COMPLEX
v1_im <= 'h0;
`endif
end
else if(en)
begin
v1_re <= v_re;
`ifdef COMPLEX
v1_im <= v_im;
`endif
end
else
begin
v1_re <= v1_re;
`ifdef COMPLEX
v1_im <= v1_im;
`endif
end
end
// y1 = (b^8 * y) delay M = b^8*y(8n-8)
// y = v1 + y1 = sum_{i=0,1,...,7}{a*b^i*x(8n-i)} + b^8*y(8n-8) = y(8n)
mult_real
#(
.A_width (temp_var_width+4 )
,.C_width (b_pow16_width )
,.o_width (temp_var_width+4 )
)
inst_c17 (
.clk (clk ),
.rstn (rstn ),
.en (en ),
.din (y_re ),
.coef (b_pow16_re[coef_width-1 : coef_width-b_pow16_width] ),
.dout (y1_re )
);
assign y_re = v1_re + y1_re;
`ifdef COMPLEX
assign y_im = v1_im + y1_im;
`endif
// dout = round(y) delay M = round(y(8n-8))
trunc #(
.diw (temp_var_width+4 )
,.msb (temp_var_width-1 )
,.lsb (temp_var_width-data_out_width )
) round_u1 (clk, rstn, en, y_re, y_re_trunc);
`ifdef COMPLEX
trunc #(
.diw (temp_var_width+4 )
,.msb (temp_var_width-1 )
,.lsb (temp_var_width-data_out_width )
) round_u2 (clk, rstn, en, y_im, y_im_trunc);
`endif
assign dout_re = y_re_trunc;
`ifdef COMPLEX
assign dout_im = y_im_trunc;
`endif
endmodule

187
rtl/z_dsp/IIR_Filter_p8.v Normal file
View File

@ -0,0 +1,187 @@
module IIR_Filter_p8 #(
parameter coef_width = 32
,parameter b_pow8_width = 29
,parameter ab_pow_width = 32
,parameter data_in_width = 16
,parameter data_out_width = 16
,parameter temp_var_width = 29
)
// H(z) = a(1 + b*z^-1 + b^2*z^-2 + b^3*z^-3 + b^4*z^-4 + b^5*z^-5 + b^6*z^-6 + b^7*z^-7) / (1 - b^8*z^-8)
(
input rstn
,input clk
,input en
,input signed [data_in_width-1 :0] dinp0 //x(8n+16)
,input signed [data_in_width-1 :0] dinp1 //x(8n+15)
,input signed [data_in_width-1 :0] dinp2 //x(8n+14)
,input signed [data_in_width-1 :0] dinp3 //x(8n+13)
,input signed [data_in_width-1 :0] dinp4 //x(8n+12)
,input signed [data_in_width-1 :0] dinp5 //x(8n+11)
,input signed [data_in_width-1 :0] dinp6 //x(8n+10)
,input signed [data_in_width-1 :0] dinp7 //x(8n+9)
,input signed [coef_width-1 :0] a_re
,input signed [coef_width-1 :0] a_im
,input signed [coef_width-1 :0] ab_re
,input signed [coef_width-1 :0] ab_im
,input signed [coef_width-1 :0] abb_re
,input signed [coef_width-1 :0] abb_im
,input signed [coef_width-1 :0] ab_pow3_re
,input signed [coef_width-1 :0] ab_pow3_im
,input signed [coef_width-1 :0] ab_pow4_re
,input signed [coef_width-1 :0] ab_pow4_im
,input signed [coef_width-1 :0] ab_pow5_re
,input signed [coef_width-1 :0] ab_pow5_im
,input signed [coef_width-1 :0] ab_pow6_re
,input signed [coef_width-1 :0] ab_pow6_im
,input signed [coef_width-1 :0] ab_pow7_re
,input signed [coef_width-1 :0] ab_pow7_im
,input signed [coef_width-1 :0] b_pow8_re
,input signed [coef_width-1 :0] b_pow8_im
,output signed [data_out_width-1:0] dout_re // Re(y(8n-8))
,output signed [data_out_width-1:0] dout_im // Im(y(8n-8))
);
wire signed [data_in_width-1 :0] dinp [7:0];
assign dinp[7] = dinp7;
assign dinp[6] = dinp6;
assign dinp[5] = dinp5;
assign dinp[4] = dinp4;
assign dinp[3] = dinp3;
assign dinp[2] = dinp2;
assign dinp[1] = dinp1;
assign dinp[0] = dinp0;
wire signed [ab_pow_width-1 :0] ab_pow_re [7:0];
assign ab_pow_re[7] = ab_pow7_re[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_re[coef_width-ab_pow_width-1];
assign ab_pow_re[6] = ab_pow6_re[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_re[coef_width-ab_pow_width-1];
assign ab_pow_re[5] = ab_pow5_re[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_re[coef_width-ab_pow_width-1];
assign ab_pow_re[4] = ab_pow4_re[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_re[coef_width-ab_pow_width-1];
assign ab_pow_re[3] = ab_pow3_re[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_re[coef_width-ab_pow_width-1];
assign ab_pow_re[2] = abb_re[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_re[coef_width-ab_pow_width-1];
assign ab_pow_re[1] = ab_re[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_re[coef_width-ab_pow_width-1];
assign ab_pow_re[0] = a_re[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_re[coef_width-ab_pow_width-1];
wire signed [ab_pow_width-1 :0] ab_pow_im [7:0];
assign ab_pow_im[7] = ab_pow7_im[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_im[coef_width-ab_pow_width-1];
assign ab_pow_im[6] = ab_pow6_im[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_im[coef_width-ab_pow_width-1];
assign ab_pow_im[5] = ab_pow5_im[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_im[coef_width-ab_pow_width-1];
assign ab_pow_im[4] = ab_pow4_im[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_im[coef_width-ab_pow_width-1];
assign ab_pow_im[3] = ab_pow3_im[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_im[coef_width-ab_pow_width-1];
assign ab_pow_im[2] = abb_im[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_im[coef_width-ab_pow_width-1];
assign ab_pow_im[1] = ab_im[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_im[coef_width-ab_pow_width-1];
assign ab_pow_im[0] = a_im[coef_width-1 : coef_width-ab_pow_width];//+ab_pow7_im[coef_width-ab_pow_width-1];
wire signed [temp_var_width-1 :0] x_re [0:7];
wire signed [temp_var_width-1 :0] x_im [0:7];
wire signed [temp_var_width+3 :0] v_re;
wire signed [temp_var_width+3 :0] v_im;
reg signed [temp_var_width+3 :0] v1_re;
reg signed [temp_var_width+3 :0] v1_im;
wire signed [temp_var_width+3 :0] y_re;
wire signed [temp_var_width+3 :0] y_im;
wire signed [temp_var_width+3 :0] y1_re;
wire signed [temp_var_width+3 :0] y1_im;
wire signed [data_out_width-1:0] y_re_trunc;
wire signed [data_out_width-1:0] y_im_trunc;
// x[0] = (dinp0 * a_re) delay M = a*x(8n+8)
// x[1] = (dinp1 * ab_re) delay M = a*b*x(8n+7)
// x[2] = (dinp2 * abb_re) delay M = a*b^2*x(8n+6)
// x[3] = (dinp3 * ab_pow3_re) delay M = a*b^3*x(8n+5)
// x[4] = (dinp4 * ab_pow4_re) delay M = a*b^4*x(8n+4)
// x[5] = (dinp5 * ab_pow5_re) delay M = a*b^5*x(8n+3)
// x[6] = (dinp6 * ab_pow6_re) delay M = a*b^6*x(8n+2)
// x[7] = (dinp7 * ab_pow7_re) delay M = a*b^7*x(8n+1)
genvar i;
generate
for (i = 0; i < 8; i = i + 1) begin: mult_c_inst
mult_x #(
.A_width (data_in_width ),
.C_width (ab_pow_width ),
.D_width (ab_pow_width ),
.o_width (temp_var_width )
) inst_c (
.clk (clk ),
.rstn (rstn ),
.en (en ),
.a (dinp[i] ),
.c (ab_pow_re[i] ),
.d (ab_pow_im[i] ),
.Re (x_re[i] ),
.Im (x_im[i] )
);
end
endgenerate
// v1 = sum_{i=0,1,...,7}{x[i]} delay M = sum_{i=0,1,...,7}{a*b^i*x(8n-i)}
assign v_re = x_re[0] + x_re[1] +x_re[2] +x_re[3] +x_re[4] +x_re[5] +x_re[6] +x_re[7];
assign v_im = x_im[0] + x_im[1] +x_im[2] +x_im[3] +x_im[4] +x_im[5] +x_im[6] +x_im[7];
always @(posedge clk or negedge rstn)
if (!rstn)
begin
v1_re <= 'h0;
v1_im <= 'h0;
end
else if(en)
begin
v1_re <= v_re;
v1_im <= v_im;
end
else
begin
v1_re <= v1_re;
v1_im <= v1_im;
end
// y1 = (b^8 * y) delay M = b^8*y(8n-8)
// y = v1 + y1 = sum_{i=0,1,...,7}{a*b^i*x(8n-i)} + b^8*y(8n-8) = y(8n)
mult_C
#(
.A_width (temp_var_width+4 )
,.B_width (temp_var_width+4 )
,.C_width (b_pow8_width )
,.D_width (b_pow8_width )
,.o_width (temp_var_width+4 )
)
inst_c9 (
.clk (clk ),
.rstn (rstn ),
.en (en ),
.a (y_re ),
.b (y_im ),
.c (b_pow8_re[coef_width-1 : coef_width-b_pow8_width]),//+b_pow8_re[coef_width-b_pow8_width-1]),
.d (b_pow8_im[coef_width-1 : coef_width-b_pow8_width]),//+b_pow8_im[coef_width-b_pow8_width-1]),
.Re (y1_re ),
.Im (y1_im )
);
assign y_re = v1_re + y1_re;
assign y_im = v1_im + y1_im;
// dout = round(y) delay M = round(y(8n-8))
trunc #(
.diw (temp_var_width+4 )
,.msb (temp_var_width-1 )
,.lsb (temp_var_width-data_out_width )
) round_u1 (clk, rstn, en, y_re, y_re_trunc);
trunc #(
.diw (temp_var_width+4 )
,.msb (temp_var_width-1 )
,.lsb (temp_var_width-data_out_width )
) round_u2 (clk, rstn, en, y_im, y_im_trunc);
assign dout_re = y_re_trunc;
assign dout_im = y_im_trunc;
endmodule

View File

@ -1,655 +1,298 @@
module IIR_top #(
parameter data_out_width = 18 module IIR_top #(
,parameter coef_width = 32 parameter data_out_width = 18
,parameter a0_width = 32 ,parameter coef_width = 32
,parameter b0_width = 29 ,parameter a0_width = 32
,parameter b0_i_width = 29 ,parameter b0_width = 29
,parameter b0_o_width = 19 ,parameter b0_i_width = 29
,parameter a1_width = 19 ,parameter b0_o_width = 19
,parameter b1_width = 19 ,parameter a1_width = 19
,parameter b1_i_width = 19 ,parameter b1_width = 19
,parameter b1_o_width = 19 ,parameter b1_i_width = 19
,parameter a2_width = 21 ,parameter b1_o_width = 19
,parameter b2_width = 21 ,parameter a2_width = 21
,parameter b2_i_width = 19 ,parameter b2_width = 21
,parameter b2_o_width = 19 ,parameter b2_i_width = 19
,parameter a3_width = 21 ,parameter b2_o_width = 19
,parameter b3_width = 21 ,parameter a3_width = 21
,parameter b3_i_width = 19 ,parameter b3_width = 21
,parameter b3_o_width = 19 ,parameter b3_i_width = 19
,parameter a4_width = 20 ,parameter b3_o_width = 19
,parameter b4_width = 20 ,parameter a4_width = 20
,parameter b4_i_width = 19 ,parameter b4_width = 20
,parameter b4_o_width = 18 ,parameter b4_i_width = 19
,parameter a5_width = 21 ,parameter b4_o_width = 18
,parameter b5_width = 21 ,parameter a5_width = 21
,parameter b5_i_width = 18 ,parameter b5_width = 21
,parameter b5_o_width = 18 ,parameter b5_i_width = 18
,parameter a6_width = 21 ,parameter b5_o_width = 18
,parameter b6_width = 21 ,parameter a6_width = 21
,parameter b6_i_width = 18 ,parameter b6_width = 21
,parameter b6_o_width = 18 ,parameter b6_i_width = 18
,parameter a7_width = 22 ,parameter b6_o_width = 18
,parameter b7_width = 22 ,parameter a7_width = 22
,parameter b7_i_width = 18 ,parameter b7_width = 22
,parameter b7_o_width = 18 ,parameter b7_i_width = 18
,parameter a8_width = 23 ,parameter b7_o_width = 18
,parameter b8_width = 23 )
,parameter b8_i_width = 18 (
,parameter b8_o_width = 18 input rstn
,parameter a9_width = 24 ,input clk
,parameter b9_width = 24 ,input en
,parameter b9_i_width = 18 ,input signed [15 :0] IIRin_p0 // x(8n+9)
,parameter b9_o_width = 18 ,input signed [15 :0] IIRin_p1 // x(8n+10)
,parameter a10_width = 25 ,input signed [15 :0] IIRin_p2 // x(8n+11)
,parameter b10_width = 25 ,input signed [15 :0] IIRin_p3 // x(8n+12)
,parameter b10_i_width = 18 ,input signed [15 :0] IIRin_p4 // x(8n+13)
,parameter b10_o_width = 18 ,input signed [15 :0] IIRin_p5 // x(8n+14)
,parameter a11_width = 26 ,input signed [15 :0] IIRin_p6 // x(8n+15)
,parameter b11_width = 26 ,input signed [15 :0] IIRin_p7 // x(8n+16)
,parameter b11_i_width = 18 ,input signed [15 :0] IIRin_p0_r2 // x(8n+9) delay 2M -> x(8n- 7)
,parameter b11_o_width = 18 ,input signed [15 :0] IIRin_p1_r4 // x(8n+10) delay 4M -> x(8n-22)
,parameter a12_width = 27 ,input signed [15 :0] IIRin_p2_r6 // x(8n+11) delay 6M -> x(8n-37)
,parameter b12_width = 27 ,input signed [15 :0] IIRin_p3_r8 // x(8n+12) delay 8M -> x(8n-52)
,parameter b12_i_width = 18 ,input signed [15 :0] IIRin_p4_r10 // x(8n+13) delay 10M -> x(8n-67)
,parameter b12_o_width = 18 ,input signed [15 :0] IIRin_p5_r12 // x(8n+14) delay 12M -> x(8n-82)
,parameter a13_width = 28 ,input signed [15 :0] IIRin_p6_r14 // x(8n+15) delay 14M -> x(8n-97)
,parameter b13_width = 28 ,input signed [31 :0] a_re
,parameter b13_i_width = 18 ,input signed [31 :0] a_im
,parameter b13_o_width = 18 ,input signed [31 :0] b_re
,parameter a14_width = 29 ,input signed [31 :0] b_im
,parameter b14_width = 29 ,input signed [31 :0] ab_re
,parameter b14_i_width = 18 ,input signed [31 :0] ab_im
,parameter b14_o_width = 18 ,input signed [31 :0] abb_re
,parameter a15_width = 29 ,input signed [31 :0] abb_im
,parameter b15_width = 29 ,input signed [31 :0] ab_pow3_re
,parameter b15_i_width = 18 ,input signed [31 :0] ab_pow3_im
,parameter b15_o_width = 18 ,input signed [31 :0] ab_pow4_re
) ,input signed [31 :0] ab_pow4_im
( ,input signed [31 :0] ab_pow5_re
input rstn ,input signed [31 :0] ab_pow5_im
,input clk ,input signed [31 :0] ab_pow6_re
,input en ,input signed [31 :0] ab_pow6_im
,input signed [15 :0] IIRin_p0 // x(8n+9) ,input signed [31 :0] ab_pow7_re
,input signed [15 :0] IIRin_p1 // x(8n+10) ,input signed [31 :0] ab_pow7_im
,input signed [15 :0] IIRin_p2 // x(8n+11) ,input signed [31 :0] b_pow8_re
,input signed [15 :0] IIRin_p3 // x(8n+12) ,input signed [31 :0] b_pow8_im
,input signed [15 :0] IIRin_p4 // x(8n+13)
,input signed [15 :0] IIRin_p5 // x(8n+14) ,output signed [data_out_width-1 :0] IIRout_p0 // y(8n-8)
,input signed [15 :0] IIRin_p6 // x(8n+15) ,output signed [data_out_width-1 :0] IIRout_p1 // y(8n-23)
,input signed [15 :0] IIRin_p7 // x(8n+16) ,output signed [data_out_width-1 :0] IIRout_p2 // y(8n-38)
,input signed [15 :0] IIRin_p8 // x(8n+9) ,output signed [data_out_width-1 :0] IIRout_p3 // y(8n-53)
,input signed [15 :0] IIRin_p9 // x(8n+10) ,output signed [data_out_width-1 :0] IIRout_p4 // y(8n-68)
,input signed [15 :0] IIRin_pa // x(8n+11) ,output signed [data_out_width-1 :0] IIRout_p5 // y(8n-83)
,input signed [15 :0] IIRin_pb // x(8n+12) ,output signed [data_out_width-1 :0] IIRout_p6 // y(8n-98)
,input signed [15 :0] IIRin_pc // x(8n+13) ,output signed [data_out_width-1 :0] IIRout_p7 // y(8n-113)
,input signed [15 :0] IIRin_pd // x(8n+14) );
,input signed [15 :0] IIRin_pe // x(8n+15)
,input signed [15 :0] IIRin_pf // x(8n+16) wire signed [b0_o_width- 1:0] IIRout_p0_re;
,input signed [15 :0] IIRin_p0_r2 // x(8n+9) delay 2M -> x(8n- 7) wire signed [b1_o_width- 1:0] IIRout_p1_re;
,input signed [15 :0] IIRin_p1_r4 // x(8n+10) delay 4M -> x(8n-22) wire signed [b2_o_width- 1:0] IIRout_p2_re;
,input signed [15 :0] IIRin_p2_r6 // x(8n+11) delay 6M -> x(8n-37) wire signed [b3_o_width- 1:0] IIRout_p3_re;
,input signed [15 :0] IIRin_p3_r8 // x(8n+12) delay 8M -> x(8n-52) wire signed [b4_o_width- 1:0] IIRout_p4_re;
,input signed [15 :0] IIRin_p4_r10 // x(8n+13) delay 10M -> x(8n-67) wire signed [b5_o_width- 1:0] IIRout_p5_re;
,input signed [15 :0] IIRin_p5_r12 // x(8n+14) delay 12M -> x(8n-82) wire signed [b6_o_width- 1:0] IIRout_p6_re;
,input signed [15 :0] IIRin_p6_r14 // x(8n+15) delay 14M -> x(8n-97) wire signed [b7_o_width- 1:0] IIRout_p7_re;
,input signed [15 :0] IIRin_p7_r16 // x(8n+16) delay 16M -> x(8n-112) wire signed [b0_o_width- 1:0] IIRout_p0_im;
,input signed [15 :0] IIRin_p8_r18 // x(8n+15) delay 18M -> x(8n-127) wire signed [b1_o_width- 1:0] IIRout_p1_im;
,input signed [15 :0] IIRin_p9_r20 // x(8n+14) delay 20M -> x(8n-142) wire signed [b2_o_width- 1:0] IIRout_p2_im;
,input signed [15 :0] IIRin_pa_r22 // x(8n+13) delay 22M -> x(8n-157) wire signed [b3_o_width- 1:0] IIRout_p3_im;
,input signed [15 :0] IIRin_pb_r24 // x(8n+12) delay 24M -> x(8n-172) wire signed [b4_o_width- 1:0] IIRout_p4_im;
,input signed [15 :0] IIRin_pc_r26 // x(8n+11) delay 26M -> x(8n-187) wire signed [b5_o_width- 1:0] IIRout_p5_im;
,input signed [15 :0] IIRin_pd_r28 // x(8n+10) delay 28M -> x(8n-202) wire signed [b6_o_width- 1:0] IIRout_p6_im;
,input signed [15 :0] IIRin_pe_r30 // x(8n+9) delay 30M -> x(8n-217) wire signed [b7_o_width- 1:0] IIRout_p7_im;
,input signed [31 :0] a_re
,input signed [31 :0] b_re
,input signed [31 :0] ab_re
,input signed [31 :0] abb_re IIR_Filter_p8 #(
,input signed [31 :0] ab_pow3_re .coef_width (coef_width ),
,input signed [31 :0] ab_pow4_re .b_pow8_width (b0_width ),
,input signed [31 :0] ab_pow5_re .ab_pow_width (a0_width ),
,input signed [31 :0] ab_pow6_re .temp_var_width (b0_i_width ),
,input signed [31 :0] ab_pow7_re .data_out_width (b0_o_width )
,input signed [31 :0] ab_pow8_re ) inst_iir_p0 (
,input signed [31 :0] ab_pow9_re .clk (clk ),
,input signed [31 :0] ab_powa_re .rstn (rstn ),
,input signed [31 :0] ab_powb_re .en (en ),
,input signed [31 :0] ab_powc_re .dinp0 (IIRin_p7 ), // x(8n+16)
,input signed [31 :0] ab_powd_re .dinp1 (IIRin_p6 ), // x(8n+15)
,input signed [31 :0] ab_powe_re .dinp2 (IIRin_p5 ), // x(8n+14)
,input signed [31 :0] ab_powf_re .dinp3 (IIRin_p4 ), // x(8n+13)
,input signed [31 :0] b_pow16_re .dinp4 (IIRin_p3 ), // x(8n+12)
`ifdef COMPLEX .dinp5 (IIRin_p2 ), // x(8n+11)
,input signed [31 :0] a_im .dinp6 (IIRin_p1 ), // x(8n+10)
,input signed [31 :0] b_im .dinp7 (IIRin_p0 ), // x(8n+9)
,input signed [31 :0] ab_im .a_re (a_re ),
,input signed [31 :0] abb_im .a_im (a_im ),
,input signed [31 :0] ab_pow3_im .ab_re (ab_re ),
,input signed [31 :0] ab_pow4_im .ab_im (ab_im ),
,input signed [31 :0] ab_pow5_im .abb_re (abb_re ),
,input signed [31 :0] ab_pow6_im .abb_im (abb_im ),
,input signed [31 :0] ab_pow7_im .ab_pow3_re (ab_pow3_re ),
,input signed [31 :0] ab_pow8_im .ab_pow3_im (ab_pow3_im ),
,input signed [31 :0] ab_pow9_im .ab_pow4_re (ab_pow4_re ),
,input signed [31 :0] ab_powa_im .ab_pow4_im (ab_pow4_im ),
,input signed [31 :0] ab_powb_im .ab_pow5_re (ab_pow5_re ),
,input signed [31 :0] ab_powc_im .ab_pow5_im (ab_pow5_im ),
,input signed [31 :0] ab_powd_im .ab_pow6_re (ab_pow6_re ),
,input signed [31 :0] ab_powe_im .ab_pow6_im (ab_pow6_im ),
,input signed [31 :0] ab_powf_im .ab_pow7_re (ab_pow7_re ),
,input signed [31 :0] b_pow16_im .ab_pow7_im (ab_pow7_im ),
`endif .b_pow8_re (b_pow8_re ),
,output signed [data_out_width-1 :0] IIRout_p0 // y(8n-8) .b_pow8_im (b_pow8_im ),
,output signed [data_out_width-1 :0] IIRout_p1 // y(8n-23) .dout_re (IIRout_p0_re ), // Re(y(8n-8))
,output signed [data_out_width-1 :0] IIRout_p2 // y(8n-38) .dout_im (IIRout_p0_im ) // Im(y(8n-8))
,output signed [data_out_width-1 :0] IIRout_p3 // y(8n-53) );
,output signed [data_out_width-1 :0] IIRout_p4 // y(8n-68)
,output signed [data_out_width-1 :0] IIRout_p5 // y(8n-83) IIR_Filter_p1 #(
,output signed [data_out_width-1 :0] IIRout_p6 // y(8n-98) .coef_width (coef_width ),
,output signed [data_out_width-1 :0] IIRout_p7 // y(8n-113) .a_width (a1_width ),
,output signed [data_out_width-1 :0] IIRout_p8 // y(8n-128) .b_width (b1_width ),
,output signed [data_out_width-1 :0] IIRout_p9 // y(8n-143) .cascade_in_width (b1_i_width ),
,output signed [data_out_width-1 :0] IIRout_pa // y(8n-158) .data_out_width (b1_o_width )
,output signed [data_out_width-1 :0] IIRout_pb // y(8n-173) ) inst_iir_p1(
,output signed [data_out_width-1 :0] IIRout_pc // y(8n-188) .clk (clk ),
,output signed [data_out_width-1 :0] IIRout_pd // y(8n-203) .rstn (rstn ),
,output signed [data_out_width-1 :0] IIRout_pe // y(8n-218) .en (en ),
,output signed [data_out_width-1 :0] IIRout_pf // y(8n-233) .din_re (IIRin_p0_r2 ), // x(8n-7)
); .dout_r1_re (IIRout_p0_re ), // Re(y(8n-8))
.dout_r1_im (IIRout_p0_im ), // Im(y(8n-8))
.a_re (a_re ),
.a_im (a_im ),
wire signed [b0_o_width- 1:0] IIRout_p0_re; .b_re (b_re ),
wire signed [b1_o_width- 1:0] IIRout_p1_re; .b_im (b_im ),
wire signed [b2_o_width- 1:0] IIRout_p2_re; .dout_re (IIRout_p1_re ), // Re(y(8n-23))
wire signed [b3_o_width- 1:0] IIRout_p3_re; .dout_im (IIRout_p1_im ) // Im(y(8n-23))
wire signed [b4_o_width- 1:0] IIRout_p4_re; );
wire signed [b5_o_width- 1:0] IIRout_p5_re; IIR_Filter_p1 #(
wire signed [b6_o_width- 1:0] IIRout_p6_re; .coef_width (coef_width ),
wire signed [b7_o_width- 1:0] IIRout_p7_re; .a_width (a2_width ),
wire signed [b8_o_width- 1:0] IIRout_p8_re; .b_width (b2_width ),
wire signed [b9_o_width- 1:0] IIRout_p9_re; .cascade_in_width (b2_i_width ),
wire signed [b10_o_width- 1:0] IIRout_pa_re; .data_out_width (b2_o_width )
wire signed [b11_o_width- 1:0] IIRout_pb_re; ) inst_iir_p2 (
wire signed [b12_o_width- 1:0] IIRout_pc_re; .clk (clk ),
wire signed [b13_o_width- 1:0] IIRout_pd_re; .rstn (rstn ),
wire signed [b14_o_width- 1:0] IIRout_pe_re; .en (en ),
wire signed [b15_o_width- 1:0] IIRout_pf_re; .din_re (IIRin_p1_r4 ), // x(8n-22)
`ifdef COMPLEX .dout_r1_re (IIRout_p1_re ), // Re(y(8n-23))
wire signed [b0_o_width- 1:0] IIRout_p0_im; .dout_r1_im (IIRout_p1_im ), // Im(y(8n-23))
wire signed [b1_o_width- 1:0] IIRout_p1_im; .a_re (a_re ),
wire signed [b2_o_width- 1:0] IIRout_p2_im; .a_im (a_im ),
wire signed [b3_o_width- 1:0] IIRout_p3_im; .b_re (b_re ),
wire signed [b4_o_width- 1:0] IIRout_p4_im; .b_im (b_im ),
wire signed [b5_o_width- 1:0] IIRout_p5_im; .dout_re (IIRout_p2_re ), // Re(y(8n-38))
wire signed [b6_o_width- 1:0] IIRout_p6_im; .dout_im (IIRout_p2_im ) // Im(y(8n-38))
wire signed [b7_o_width- 1:0] IIRout_p7_im; );
wire signed [b8_o_width- 1:0] IIRout_p8_im; IIR_Filter_p1 #(
wire signed [b9_o_width- 1:0] IIRout_p9_im; .coef_width (coef_width ),
wire signed [b10_o_width- 1:0] IIRout_pa_im; .a_width (a3_width ),
wire signed [b11_o_width- 1:0] IIRout_pb_im; .b_width (b3_width ),
wire signed [b12_o_width- 1:0] IIRout_pc_im; .cascade_in_width (b3_i_width ),
wire signed [b13_o_width- 1:0] IIRout_pd_im; .data_out_width (b3_o_width )
wire signed [b14_o_width- 1:0] IIRout_pe_im; ) inst_iir_p3 (
wire signed [b15_o_width- 1:0] IIRout_pf_im; .clk (clk ),
`endif .rstn (rstn ),
.en (en ),
IIR_Filter_p16#( .din_re (IIRin_p2_r6 ), // x(8n-37)
.coef_width ( coef_width ) .dout_r1_re (IIRout_p2_re ), // Re(y(8n-38))
,.b_pow16_width ( b0_width ) .dout_r1_im (IIRout_p2_im ), // Im(y(8n-38))
,.ab_pow_width ( a0_width ) .a_re (a_re ),
,.temp_var_width ( b0_i_width ) .a_im (a_im ),
,.data_out_width ( b0_o_width ) .b_re (b_re ),
)inst_iir_p0( .b_im (b_im ),
.rstn ( rstn ) .dout_re (IIRout_p3_re ), // Re(y(8n-53))
,.clk ( clk ) .dout_im (IIRout_p3_im ) // Im(y(8n-53))
,.en ( en ) );
,.dinp0 ( IIRin_pf ) IIR_Filter_p1 #(
,.dinp1 ( IIRin_pe ) .coef_width (coef_width ),
,.dinp2 ( IIRin_pd ) .a_width (a4_width ),
,.dinp3 ( IIRin_pc ) .b_width (b4_width ),
,.dinp4 ( IIRin_pb ) .cascade_in_width (b4_i_width ),
,.dinp5 ( IIRin_pa ) .data_out_width (b4_o_width )
,.dinp6 ( IIRin_p9 ) ) inst_iir_p4 (
,.dinp7 ( IIRin_p8 ) .clk (clk ),
,.dinp8 ( IIRin_p7 ) .rstn (rstn ),
,.dinp9 ( IIRin_p6 ) .en (en ),
,.dinpa ( IIRin_p5 ) .din_re (IIRin_p3_r8 ), // x(8n-52)
,.dinpb ( IIRin_p4 ) .dout_r1_re (IIRout_p3_re ), // Re(y(8n-53))
,.dinpc ( IIRin_p3 ) .dout_r1_im (IIRout_p3_im ), // Im(y(8n-53))
,.dinpd ( IIRin_p2 ) .a_re (a_re ),
,.dinpe ( IIRin_p1 ) .a_im (a_im ),
,.dinpf ( IIRin_p0 ) .b_re (b_re ),
,.a_re ( a_re ) .b_im (b_im ),
,.ab_re ( ab_re ) .dout_re (IIRout_p4_re ), // Re(y(8n-68))
,.abb_re ( abb_re ) .dout_im (IIRout_p4_im ) // Im(y(8n-68))
,.ab_pow3_re ( ab_pow3_re ) );
,.ab_pow4_re ( ab_pow4_re ) IIR_Filter_p1 #(
,.ab_pow5_re ( ab_pow5_re ) .coef_width (coef_width ),
,.ab_pow6_re ( ab_pow6_re ) .a_width (a5_width ),
,.ab_pow7_re ( ab_pow7_re ) .b_width (b5_width ),
,.ab_pow8_re ( ab_pow8_re ) .cascade_in_width (b5_i_width ),
,.ab_pow9_re ( ab_pow9_re ) .data_out_width (b5_o_width )
,.ab_powa_re ( ab_powa_re ) ) inst_iir_p5 (
,.ab_powb_re ( ab_powb_re ) .clk (clk ),
,.ab_powc_re ( ab_powc_re ) .rstn (rstn ),
,.ab_powd_re ( ab_powd_re ) .en (en ),
,.ab_powe_re ( ab_powe_re ) .din_re (IIRin_p4_r10 ), // x(8n-67)
,.ab_powf_re ( ab_powf_re ) .dout_r1_re (IIRout_p4_re ), // Re(y(8n-68))
,.b_pow16_re ( b_pow16_re ) .dout_r1_im (IIRout_p4_im ), // Im(y(8n-68))
`ifdef COMPLEX .a_re (a_re ),
,.a_im ( a_im ) .a_im (a_im ),
,.ab_im ( ab_im ) .b_re (b_re ),
,.abb_im ( abb_im ) .b_im (b_im ),
,.ab_pow3_im ( ab_pow3_im ) .dout_re (IIRout_p5_re ), // Re(y(8n-83))
,.ab_pow4_im ( ab_pow4_im ) .dout_im (IIRout_p5_im ) // Im(y(8n-83))
,.ab_pow5_im ( ab_pow5_im ) );
,.ab_pow6_im ( ab_pow6_im ) IIR_Filter_p1 #(
,.ab_pow7_im ( ab_pow7_im ) .coef_width (coef_width ),
,.ab_pow8_im ( ab_pow8_im ) .a_width (a6_width ),
,.ab_pow9_im ( ab_pow9_im ) .b_width (b6_width ),
,.ab_powa_im ( ab_powa_im ) .cascade_in_width (b6_i_width ),
,.ab_powb_im ( ab_powb_im ) .data_out_width (b6_o_width )
,.ab_powc_im ( ab_powc_im ) ) inst_iir_p6 (
,.ab_powd_im ( ab_powd_im ) .clk (clk ),
,.ab_powe_im ( ab_powe_im ) .rstn (rstn ),
,.ab_powf_im ( ab_powf_im ) .en (en ),
,.b_pow16_im ( b_pow16_im ) .din_re (IIRin_p5_r12 ), // x(8n-82)
,.dout_im ( IIRout_p0_im ) .dout_r1_re (IIRout_p5_re ), // Re(y(8n-83))
`endif .dout_r1_im (IIRout_p5_im ), // Im(y(8n-83))
,.dout_re ( IIRout_p0_re ) .a_re (a_re ),
); .a_im (a_im ),
.b_re (b_re ),
IIR_Filter_p1 #( .b_im (b_im ),
.coef_width ( coef_width ) .dout_re (IIRout_p6_re ), // Re(y(8n-98))
,.a_width ( a1_width ) .dout_im (IIRout_p6_im ) // Im(y(8n-98))
,.b_width ( b1_width ) );
,.cascade_in_width ( b1_i_width ) IIR_Filter_p1 #(
,.data_out_width ( b1_o_width ) .coef_width (coef_width ),
) inst_iir_p1 ( .a_width (a7_width ),
.clk ( clk ) .b_width (b7_width ),
,.rstn ( rstn ) .cascade_in_width (b7_i_width ),
,.en ( en ) .data_out_width (b7_o_width )
,.din_re ( IIRin_p0_r2 ) // x(8n-7) ) inst_iir_p7 (
,.dout_r1_re ( IIRout_p0_re ) // Re(y(8n-8)) .clk (clk ),
`ifdef COMPLEX .rstn (rstn ),
,.dout_r1_im ( IIRout_p0_im ) // Re(y(8n-8)) .en (en ),
`endif .din_re (IIRin_p6_r14 ), // x(8n-97)
,.a_re ( a_re ) .dout_r1_re (IIRout_p6_re ), // Re(y(8n-98))
,.b_re ( b_re ) .dout_r1_im (IIRout_p6_im ), // Im(y(8n-98))
,.dout_re ( IIRout_p1_re ) // Re(y(8n-23)) .a_re (a_re ),
`ifdef COMPLEX .a_im (a_im ),
,.a_im ( a_im ) .b_re (b_re ),
,.b_im ( b_im ) .b_im (b_im ),
,.dout_im ( IIRout_p1_im ) // Re(y(8n-23)) .dout_re (IIRout_p7_re ), // Re(y(8n-113))
`endif .dout_im (IIRout_p7_im ) // Im(y(8n-113))
); );
IIR_Filter_p1 #( assign IIRout_p0 = IIRout_p0_re[b0_o_width-1 : b0_o_width-data_out_width]; // y(8n-8)
.coef_width ( coef_width ) assign IIRout_p1 = IIRout_p1_re[b1_o_width-1 : b1_o_width-data_out_width]; // y(8n-23)
,.a_width ( a2_width ) assign IIRout_p2 = IIRout_p2_re[b2_o_width-1 : b2_o_width-data_out_width]; // y(8n-38)
,.b_width ( b2_width ) assign IIRout_p3 = IIRout_p3_re[b3_o_width-1 : b3_o_width-data_out_width]; // y(8n-53)
,.cascade_in_width ( b2_i_width ) assign IIRout_p4 = IIRout_p4_re[b4_o_width-1 : b4_o_width-data_out_width]; // y(8n-68)
,.data_out_width ( b2_o_width ) assign IIRout_p5 = IIRout_p5_re[b5_o_width-1 : b5_o_width-data_out_width]; // y(8n-83)
) inst_iir_p2 ( assign IIRout_p6 = IIRout_p6_re[b6_o_width-1 : b6_o_width-data_out_width]; // y(8n-98)
.clk ( clk ) assign IIRout_p7 = IIRout_p7_re[b7_o_width-1 : b7_o_width-data_out_width]; // y(8n-113)
,.rstn ( rstn )
,.en ( en ) endmodule
,.din_re ( IIRin_p1_r4 ) // x(8n-22)
,.dout_r1_re ( IIRout_p1_re ) // Re(y(8n-23))
`ifdef COMPLEX
,.dout_r1_im ( IIRout_p1_im ) // Re(y(8n-23))
`endif
,.a_re ( a_re )
,.b_re ( b_re )
,.dout_re ( IIRout_p2_re ) // Re(y(8n-38))
`ifdef COMPLEX
,.a_im ( a_im )
,.b_im ( b_im )
,.dout_im ( IIRout_p2_im ) // Re(y(8n-38))
`endif
);
IIR_Filter_p1 #(
.coef_width ( coef_width )
,.a_width ( a3_width )
,.b_width ( b3_width )
,.cascade_in_width ( b3_i_width )
,.data_out_width ( b3_o_width )
) inst_iir_p3 (
.clk ( clk )
,.rstn ( rstn )
,.en ( en )
,.din_re ( IIRin_p2_r6 ) // x(8n-37)
,.dout_r1_re ( IIRout_p2_re ) // Re(y(8n-38))
`ifdef COMPLEX
,.dout_r1_im ( IIRout_p2_im ) // Re(y(8n-38))
`endif
,.a_re ( a_re )
,.b_re ( b_re )
,.dout_re ( IIRout_p3_re ) // Re(y(8n-53))
`ifdef COMPLEX
,.a_im ( a_im )
,.b_im ( b_im )
,.dout_im ( IIRout_p3_im ) // Re(y(8n-53))
`endif
);
IIR_Filter_p1 #(
.coef_width ( coef_width )
,.a_width ( a4_width )
,.b_width ( b4_width )
,.cascade_in_width ( b4_i_width )
,.data_out_width ( b4_o_width )
) inst_iir_p4 (
.clk ( clk )
,.rstn ( rstn )
,.en ( en )
,.din_re ( IIRin_p3_r8 ) // x(8n-52)
,.dout_r1_re ( IIRout_p3_re ) // Re(y(8n-53))
`ifdef COMPLEX
,.dout_r1_im ( IIRout_p3_im ) // Re(y(8n-53))
`endif
,.a_re ( a_re )
,.b_re ( b_re )
,.dout_re ( IIRout_p4_re ) // Re(y(8n-68))
`ifdef COMPLEX
,.a_im ( a_im )
,.b_im ( b_im )
,.dout_im ( IIRout_p4_im ) // Re(y(8n-68))
`endif
);
IIR_Filter_p1 #(
.coef_width ( coef_width )
,.a_width ( a5_width )
,.b_width ( b5_width )
,.cascade_in_width ( b5_i_width )
,.data_out_width ( b5_o_width )
) inst_iir_p5 (
.clk ( clk )
,.rstn ( rstn )
,.en ( en )
,.din_re ( IIRin_p4_r10 ) // x(8n-67)
,.dout_r1_re ( IIRout_p4_re ) // Re(y(8n-68))
`ifdef COMPLEX
,.dout_r1_im ( IIRout_p4_im ) // Re(y(8n-68))
`endif
,.a_re ( a_re )
,.b_re ( b_re )
,.dout_re ( IIRout_p5_re ) // Re(y(8n-83))
`ifdef COMPLEX
,.a_im ( a_im )
,.b_im ( b_im )
,.dout_im ( IIRout_p5_im ) // Re(y(8n-83))
`endif
);
IIR_Filter_p1 #(
.coef_width ( coef_width )
,.a_width ( a6_width )
,.b_width ( b6_width )
,.cascade_in_width ( b6_i_width )
,.data_out_width ( b6_o_width )
) inst_iir_p6 (
.clk ( clk )
,.rstn ( rstn )
,.en ( en )
,.din_re ( IIRin_p5_r12 ) // x(8n-82)
,.dout_r1_re ( IIRout_p5_re ) // Re(y(8n-83))
`ifdef COMPLEX
,.dout_r1_im ( IIRout_p5_im ) // Re(y(8n-83))
`endif
,.a_re ( a_re )
,.b_re ( b_re )
,.dout_re ( IIRout_p6_re ) // Re(y(8n-98))
`ifdef COMPLEX
,.a_im ( a_im )
,.b_im ( b_im )
,.dout_im ( IIRout_p6_im ) // Re(y(8n-98))
`endif
);
IIR_Filter_p1 #(
.coef_width ( coef_width )
,.a_width ( a7_width )
,.b_width ( b7_width )
,.cascade_in_width ( b7_i_width )
,.data_out_width ( b7_o_width )
) inst_iir_p7 (
.clk ( clk )
,.rstn ( rstn )
,.en ( en )
,.din_re ( IIRin_p6_r14 ) // x(8n-97)
,.dout_r1_re ( IIRout_p6_re ) // Re(y(8n-98))
,.a_re ( a_re )
,.b_re ( b_re )
,.dout_re ( IIRout_p7_re ) // Re(y(8n-113))
`ifdef COMPLEX
,.dout_r1_im ( IIRout_p6_im ) // Re(y(8n-98))
,.a_im ( a_im )
,.b_im ( b_im )
,.dout_im ( IIRout_p7_im ) // Re(y(8n-113))
`endif
);
IIR_Filter_p1 #(
.coef_width ( coef_width )
,.a_width ( a8_width )
,.b_width ( b8_width )
,.cascade_in_width ( b8_i_width )
,.data_out_width ( b8_o_width )
) inst_iir_p8 (
.clk ( clk )
,.rstn ( rstn )
,.en ( en )
,.din_re ( IIRin_p7_r16 ) // x(8n-112)
,.dout_r1_re ( IIRout_p7_re ) // Re(y(8n-113))
`ifdef COMPLEX
,.dout_r1_im ( IIRout_p7_im ) // Re(y(8n-113))
`endif
,.a_re ( a_re )
,.b_re ( b_re )
,.dout_re ( IIRout_p8_re ) // Re(y(8n-128))
`ifdef COMPLEX
,.a_im ( a_im )
,.b_im ( b_im )
,.dout_im ( IIRout_p8_im ) // Re(y(8n-128))
`endif
);
IIR_Filter_p1 #(
.coef_width ( coef_width )
,.a_width ( a9_width )
,.b_width ( b9_width )
,.cascade_in_width ( b9_i_width )
,.data_out_width ( b9_o_width )
) inst_iir_p9 (
.clk ( clk )
,.rstn ( rstn )
,.en ( en )
,.din_re ( IIRin_p8_r18 ) // x(8n-127)
,.dout_r1_re ( IIRout_p8_re ) // Re(y(8n-128))
`ifdef COMPLEX
,.dout_r1_im ( IIRout_p8_im ) // Re(y(8n-128))
`endif
,.a_re ( a_re )
,.b_re ( b_re )
,.dout_re ( IIRout_p9_re ) // Re(y(8n-143))
`ifdef COMPLEX
,.a_im ( a_im )
,.b_im ( b_im )
,.dout_im ( IIRout_p9_im ) // Re(y(8n-143))
`endif
);
IIR_Filter_p1 #(
.coef_width ( coef_width )
,.a_width ( a10_width )
,.b_width ( b10_width )
,.cascade_in_width ( b10_i_width )
,.data_out_width ( b10_o_width )
) inst_iir_pa (
.clk ( clk )
,.rstn ( rstn )
,.en ( en )
,.din_re ( IIRin_p9_r20 ) // x(8n-142)
,.dout_r1_re ( IIRout_p9_re ) // Re(y(8n-143))
`ifdef COMPLEX
,.dout_r1_im ( IIRout_p9_im ) // Re(y(8n-143))
`endif
,.a_re ( a_re )
,.b_re ( b_re )
,.dout_re ( IIRout_pa_re ) // Re(y(8n-158))
`ifdef COMPLEX
,.a_im ( a_im )
,.b_im ( b_im )
,.dout_im ( IIRout_pa_im ) // Re(y(8n-158))
`endif
);
IIR_Filter_p1 #(
.coef_width ( coef_width )
,.a_width ( a11_width )
,.b_width ( b11_width )
,.cascade_in_width ( b11_i_width )
,.data_out_width ( b11_o_width )
) inst_iir_pb (
.clk ( clk )
,.rstn ( rstn )
,.en ( en )
,.din_re ( IIRin_pa_r22 ) // x(8n-157)
,.dout_r1_re ( IIRout_pa_re ) // Re(y(8n-158))
`ifdef COMPLEX
,.dout_r1_im ( IIRout_pa_im ) // Re(y(8n-158))
`endif
,.a_re ( a_re )
,.b_re ( b_re )
,.dout_re ( IIRout_pb_re ) // Re(y(8n-173))
`ifdef COMPLEX
,.a_im ( a_im )
,.b_im ( b_im )
,.dout_im ( IIRout_pb_im ) // Re(y(8n-173))
`endif
);
IIR_Filter_p1 #(
.coef_width ( coef_width )
,.a_width ( a12_width )
,.b_width ( b12_width )
,.cascade_in_width ( b12_i_width )
,.data_out_width ( b12_o_width )
) inst_iir_pc (
.clk ( clk )
,.rstn ( rstn )
,.en ( en )
,.din_re ( IIRin_pb_r24 ) // x(8n-172)
,.dout_r1_re ( IIRout_pb_re ) // Re(y(8n-173))
`ifdef COMPLEX
,.dout_r1_im ( IIRout_pb_im ) // Re(y(8n-173))
`endif
,.a_re ( a_re )
,.b_re ( b_re )
,.dout_re ( IIRout_pc_re ) // Re(y(8n-188))
`ifdef COMPLEX
,.a_im ( a_im )
,.b_im ( b_im )
,.dout_im ( IIRout_pc_im ) // Re(y(8n-188))
`endif
);
IIR_Filter_p1 #(
.coef_width ( coef_width )
,.a_width ( a13_width )
,.b_width ( b13_width )
,.cascade_in_width ( b13_i_width )
,.data_out_width ( b13_o_width )
) inst_iir_pd (
.clk ( clk )
,.rstn ( rstn )
,.en ( en )
,.din_re ( IIRin_pc_r26 ) // x(8n-187)
,.dout_r1_re ( IIRout_pc_re ) // Re(y(8n-188))
`ifdef COMPLEX
,.dout_r1_im ( IIRout_pc_im ) // Re(y(8n-188))
`endif
,.a_re ( a_re )
,.b_re ( b_re )
,.dout_re ( IIRout_pd_re ) // Re(y(8n-203))
`ifdef COMPLEX
,.a_im ( a_im )
,.b_im ( b_im )
,.dout_im ( IIRout_pd_im ) // Re(y(8n-203))
`endif
);
IIR_Filter_p1 #(
.coef_width ( coef_width )
,.a_width ( a14_width )
,.b_width ( b14_width )
,.cascade_in_width ( b14_i_width )
,.data_out_width ( b14_o_width )
) inst_iir_pe (
.clk ( clk )
,.rstn ( rstn )
,.en ( en )
,.din_re ( IIRin_pd_r28 ) // x(8n-202)
,.dout_r1_re ( IIRout_pd_re ) // Re(y(8n-203))
`ifdef COMPLEX
,.dout_r1_im ( IIRout_pd_im ) // Re(y(8n-203))
`endif
,.a_re ( a_re )
,.b_re ( b_re )
,.dout_re ( IIRout_pe_re ) // Re(y(8n-218))
`ifdef COMPLEX
,.a_im ( a_im )
,.b_im ( b_im )
,.dout_im ( IIRout_pe_im ) // Re(y(8n-218))
`endif
);
IIR_Filter_p1 #(
.coef_width ( coef_width )
,.a_width ( a15_width )
,.b_width ( b15_width )
,.cascade_in_width ( b15_i_width )
,.data_out_width ( b15_o_width )
) inst_iir_pf (
.clk ( clk )
,.rstn ( rstn )
,.en ( en )
,.din_re ( IIRin_pe_r30 ) // x(8n-217)
,.dout_r1_re ( IIRout_pe_re ) // Re(y(8n-218))
`ifdef COMPLEX
,.dout_r1_im ( IIRout_pe_im ) // Re(y(8n-218))
`endif
,.a_re ( a_re )
,.b_re ( b_re )
,.dout_re ( IIRout_pf_re ) // Re(y(8n-233))
`ifdef COMPLEX
,.a_im ( a_im )
,.b_im ( b_im )
,.dout_im ( IIRout_pf_im ) // Re(y(8n-233))
`endif
);
assign IIRout_p0 = IIRout_p0_re[b0_o_width-1 : b0_o_width-data_out_width]; // y(8n-8)
assign IIRout_p1 = IIRout_p1_re[b1_o_width-1 : b1_o_width-data_out_width]; // y(8n-23)
assign IIRout_p2 = IIRout_p2_re[b2_o_width-1 : b2_o_width-data_out_width]; // y(8n-38)
assign IIRout_p3 = IIRout_p3_re[b3_o_width-1 : b3_o_width-data_out_width]; // y(8n-53)
assign IIRout_p4 = IIRout_p4_re[b4_o_width-1 : b4_o_width-data_out_width]; // y(8n-68)
assign IIRout_p5 = IIRout_p5_re[b5_o_width-1 : b5_o_width-data_out_width]; // y(8n-83)
assign IIRout_p6 = IIRout_p6_re[b6_o_width-1 : b6_o_width-data_out_width]; // y(8n-98)
assign IIRout_p7 = IIRout_p7_re[b7_o_width-1 : b7_o_width-data_out_width]; // y(8n-113)
assign IIRout_p8 = IIRout_p8_re[b8_o_width-1 : b8_o_width-data_out_width]; // y(8n-128)
assign IIRout_p9 = IIRout_p9_re[b9_o_width-1 : b9_o_width-data_out_width]; // y(8n-143)
assign IIRout_pa = IIRout_pa_re[b10_o_width-1 : b10_o_width-data_out_width]; // y(8n-158)
assign IIRout_pb = IIRout_pb_re[b11_o_width-1 : b11_o_width-data_out_width]; // y(8n-173)
assign IIRout_pc = IIRout_pc_re[b12_o_width-1 : b12_o_width-data_out_width]; // y(8n-188)
assign IIRout_pd = IIRout_pd_re[b13_o_width-1 : b13_o_width-data_out_width]; // y(8n-203)
assign IIRout_pe = IIRout_pe_re[b14_o_width-1 : b14_o_width-data_out_width]; // y(8n-218)
assign IIRout_pf = IIRout_pf_re[b15_o_width-1 : b15_o_width-data_out_width]; // y(8n-233)
endmodule

File diff suppressed because it is too large Load Diff

View File

@ -1,56 +1,56 @@
module trunc #( module trunc #(
parameter integer diw = 8 parameter integer diw = 8
//,parameter integer dow = msb - (lsb -1) //,parameter integer dow = msb - (lsb -1)
,parameter integer msb = 7 ,parameter integer msb = 7
,parameter integer lsb = 1 ,parameter integer lsb = 1
,parameter integer half_precision = 1 ,parameter integer half_precision = 1
) )
( (
input clk input clk
,input rstn ,input rstn
,input en ,input en
,input signed [diw - 1 :0] din ,input signed [diw - 1 :0] din
,output signed [msb - lsb:0] dout ,output signed [msb - lsb:0] dout
); );
reg signed [msb - lsb : 0] d_tmp; reg signed [msb - lsb : 0] d_tmp;
generate generate
if(lsb!=0 && half_precision != 0) begin if(lsb!=0 && half_precision != 0) begin
always @(posedge clk or negedge rstn) begin always @(posedge clk or negedge rstn) begin
if (!rstn) begin if (!rstn) begin
d_tmp <= 'h0; d_tmp <= 'h0;
end end
else if(en) begin else if(en) begin
if(din[diw-1 : msb] != {(diw-msb){din[diw-1]}}) if(din[diw-1 : msb] != {(diw-msb){din[diw-1]}})
d_tmp <= {{din[diw-1]}, {(msb-lsb){!din[diw-1]}}}; d_tmp <= {{din[diw-1]}, {(msb-lsb){!din[diw-1]}}};
else else
d_tmp <= din[msb:lsb] + {{(msb-lsb){1'b0}},din[lsb-1]}; d_tmp <= din[msb:lsb] + {{(msb-lsb){1'b0}},din[lsb-1]};
end end
else begin else begin
d_tmp <= d_tmp; d_tmp <= d_tmp;
end end
end end
end end
else begin else begin
always @(posedge clk or negedge rstn) begin always @(posedge clk or negedge rstn) begin
if (!rstn) begin if (!rstn) begin
d_tmp <= 'h0; d_tmp <= 'h0;
end end
else if(en) begin else if(en) begin
if(din[diw-1 : msb] != {(diw-msb){din[diw-1]}}) if(din[diw-1 : msb] != {(diw-msb){din[diw-1]}})
d_tmp <= {{din[diw-1]}, {(msb-lsb){!din[diw-1]}}}; d_tmp <= {{din[diw-1]}, {(msb-lsb){!din[diw-1]}}};
else else
d_tmp <= din[msb:lsb]; d_tmp <= din[msb:lsb];
end end
else begin else begin
d_tmp <= d_tmp; d_tmp <= d_tmp;
end end
end end
end end
endgenerate endgenerate
assign dout = d_tmp; assign dout = d_tmp;
endmodule endmodule

View File

@ -1,141 +1,159 @@
module diff_p module diff_p
(
input rstn (
,input clk input rstn
,input en ,input clk
,input vldi ,input en
,input signed [15:0] din0 ,input vldi
,input signed [15:0] din1 ,input signed [15:0] din0
,input signed [15:0] din2 ,input signed [15:0] din1
,input signed [15:0] din3 ,input signed [15:0] din2
,input signed [15:0] din4 ,input signed [15:0] din3
,input signed [15:0] din5 ,output vldo
,input signed [15:0] din6 ,output signed [15:0] dout_p0
,input signed [15:0] din7 ,output signed [15:0] dout_p1
,input signed [15:0] din8 ,output signed [15:0] dout_p2
,input signed [15:0] din9 ,output signed [15:0] dout_p3
,input signed [15:0] dina ,output signed [15:0] dout_p4
,input signed [15:0] dinb ,output signed [15:0] dout_p5
,input signed [15:0] dinc ,output signed [15:0] dout_p6
,input signed [15:0] dind ,output signed [15:0] dout_p7
,input signed [15:0] dine ,output signed [15:0] diff_p0
,input signed [15:0] dinf ,output signed [15:0] diff_p1
,output vldo ,output signed [15:0] diff_p2
,output signed [15:0] diff_p0 ,output signed [15:0] diff_p3
,output signed [15:0] diff_p1 ,output signed [15:0] diff_p4
,output signed [15:0] diff_p2 ,output signed [15:0] diff_p5
,output signed [15:0] diff_p3 ,output signed [15:0] diff_p6
,output signed [15:0] diff_p4 ,output signed [15:0] diff_p7
,output signed [15:0] diff_p5
,output signed [15:0] diff_p6 );
,output signed [15:0] diff_p7
,output signed [15:0] diff_p8 wire signed [15:0] din_p0_r0;
,output signed [15:0] diff_p9 wire signed [15:0] din_p1_r0;
,output signed [15:0] diff_pa wire signed [15:0] din_p2_r0;
,output signed [15:0] diff_pb wire signed [15:0] din_p3_r0;
,output signed [15:0] diff_pc wire signed [15:0] din_p4_r0;
,output signed [15:0] diff_pd wire signed [15:0] din_p5_r0;
,output signed [15:0] diff_pe wire signed [15:0] din_p6_r0;
,output signed [15:0] diff_pf wire signed [15:0] din_p7_r0;
wire vldo_0;
); wire vldo_1;
wire signed [15:0] dinf_r1; wire vldo_2;
wire vldo_3;
sirv_gnrl_dfflr #(16) din_pf_1(en,dinf, dinf_r1 ,clk,rstn); wire vldo_r0;
assign vldo_r0 = vldo_0 || vldo_1 || vldo_2 || vldo_3;
reg signed [15:0] diff_p0_r1; sirv_gnrl_dffr #(1) dff_vldo_1(vldo_r0, vldo ,clk,rstn);
reg signed [15:0] diff_p1_r1; s2p_2 inst1_s2p_2 (
reg signed [15:0] diff_p2_r1; .clk (clk),
reg signed [15:0] diff_p3_r1; .rst_n (rstn),
reg signed [15:0] diff_p4_r1; .din (din0),
reg signed [15:0] diff_p5_r1; .en (vldi),
reg signed [15:0] diff_p6_r1; .dout0 (din_p0_r0),
reg signed [15:0] diff_p7_r1; .dout1 (din_p4_r0)
reg signed [15:0] diff_p8_r1; ,.vldo( vldo_0)
reg signed [15:0] diff_p9_r1; );
reg signed [15:0] diff_pa_r1; s2p_2 inst2_s2p_2 (
reg signed [15:0] diff_pb_r1; .clk (clk),
reg signed [15:0] diff_pc_r1; .rst_n (rstn),
reg signed [15:0] diff_pd_r1; .din (din1),
reg signed [15:0] diff_pe_r1; .en (vldi),
reg signed [15:0] diff_pf_r1; .dout0 (din_p1_r0),
.dout1 (din_p5_r0)
always @(posedge clk or negedge rstn)begin ,.vldo( vldo_1)
if(rstn==1'b0)begin );
diff_p0_r1 <= 0; s2p_2 inst3_s2p_2 (
diff_p1_r1 <= 0; .clk (clk),
diff_p2_r1 <= 0; .rst_n (rstn),
diff_p3_r1 <= 0; .din (din2),
diff_p4_r1 <= 0; .en (vldi),
diff_p5_r1 <= 0; .dout0 (din_p2_r0),
diff_p6_r1 <= 0; .dout1 (din_p6_r0)
diff_p7_r1 <= 0; ,.vldo( vldo_2)
diff_p8_r1 <= 0; );
diff_p9_r1 <= 0; s2p_2 inst4_s2p_2 (
diff_pa_r1 <= 0; .clk (clk),
diff_pb_r1 <= 0; .rst_n (rstn),
diff_pc_r1 <= 0; .din (din3),
diff_pd_r1 <= 0; .en (vldi),
diff_pe_r1 <= 0; .dout0 (din_p3_r0),
diff_pf_r1 <= 0; .dout1 (din_p7_r0)
end ,.vldo( vldo_3)
else if(en)begin );
diff_p0_r1 <= din0 - dinf_r1;
diff_p1_r1 <= din1 - din0;
diff_p2_r1 <= din2 - din1; wire signed [15:0] din_p0_r1;
diff_p3_r1 <= din3 - din2; wire signed [15:0] din_p1_r1;
diff_p4_r1 <= din4 - din3; wire signed [15:0] din_p2_r1;
diff_p5_r1 <= din5 - din4; wire signed [15:0] din_p3_r1;
diff_p6_r1 <= din6 - din5; wire signed [15:0] din_p4_r1;
diff_p7_r1 <= din7 - din6; wire signed [15:0] din_p5_r1;
diff_p8_r1 <= din8 - din7; wire signed [15:0] din_p6_r1;
diff_p9_r1 <= din9 - din8 ; wire signed [15:0] din_p7_r1;
diff_pa_r1 <= dina - din9 ;
diff_pb_r1 <= dinb - dina; sirv_gnrl_dfflr #(16) din_p7_1(en,din_p7_r0, din_p7_r1 ,clk,rstn);
diff_pc_r1 <= dinc - dinb;
diff_pd_r1 <= dind - dinc; assign dout_p0 = din_p0_r0;
diff_pe_r1 <= dine - dind; assign dout_p1 = din_p1_r0;
diff_pf_r1 <= dinf - dine; assign dout_p2 = din_p2_r0;
end assign dout_p3 = din_p3_r0;
else begin assign dout_p4 = din_p4_r0;
diff_p0_r1 <= diff_p0_r1; assign dout_p5 = din_p5_r0;
diff_p1_r1 <= diff_p1_r1; assign dout_p6 = din_p6_r0;
diff_p2_r1 <= diff_p2_r1; assign dout_p7 = din_p7_r0;
diff_p3_r1 <= diff_p3_r1;
diff_p4_r1 <= diff_p4_r1; reg signed [15:0] diff_p0_r1;
diff_p5_r1 <= diff_p5_r1; reg signed [15:0] diff_p1_r1;
diff_p6_r1 <= diff_p6_r1; reg signed [15:0] diff_p2_r1;
diff_p7_r1 <= diff_p7_r1; reg signed [15:0] diff_p3_r1;
diff_p8_r1 <= diff_p8_r1; reg signed [15:0] diff_p4_r1;
diff_p9_r1 <= diff_p9_r1; reg signed [15:0] diff_p5_r1;
diff_pa_r1 <= diff_pa_r1; reg signed [15:0] diff_p6_r1;
diff_pb_r1 <= diff_pb_r1; reg signed [15:0] diff_p7_r1;
diff_pc_r1 <= diff_pc_r1;
diff_pd_r1 <= diff_pd_r1; always @(posedge clk or negedge rstn)begin
diff_pe_r1 <= diff_pe_r1; if(rstn==1'b0)begin
diff_pf_r1 <= diff_pf_r1; diff_p0_r1 <= 0;
end diff_p1_r1 <= 0;
end diff_p2_r1 <= 0;
diff_p3_r1 <= 0;
assign diff_p0 = diff_p0_r1; diff_p4_r1 <= 0;
assign diff_p1 = diff_p1_r1; diff_p5_r1 <= 0;
assign diff_p2 = diff_p2_r1; diff_p6_r1 <= 0;
assign diff_p3 = diff_p3_r1; diff_p7_r1 <= 0;
assign diff_p4 = diff_p4_r1;
assign diff_p5 = diff_p5_r1; end
assign diff_p6 = diff_p6_r1; else if(en)begin
assign diff_p7 = diff_p7_r1; diff_p0_r1 <= din_p0_r0 - din_p7_r1;
assign diff_p8 = diff_p8_r1; diff_p1_r1 <= din_p1_r0 - din_p0_r0;
assign diff_p9 = diff_p9_r1; diff_p2_r1 <= din_p2_r0 - din_p1_r0;
assign diff_pa = diff_pa_r1; diff_p3_r1 <= din_p3_r0 - din_p2_r0;
assign diff_pb = diff_pb_r1; diff_p4_r1 <= din_p4_r0 - din_p3_r0;
assign diff_pc = diff_pc_r1; diff_p5_r1 <= din_p5_r0 - din_p4_r0;
assign diff_pd = diff_pd_r1; diff_p6_r1 <= din_p6_r0 - din_p5_r0;
assign diff_pe = diff_pe_r1; diff_p7_r1 <= din_p7_r0 - din_p6_r0;
assign diff_pf = diff_pf_r1; end
else begin
sirv_gnrl_dffr #(1) vldo_1(vldi, vldo ,clk,rstn); diff_p0_r1 <= diff_p0_r1;
diff_p1_r1 <= diff_p1_r1;
endmodule diff_p2_r1 <= diff_p2_r1;
diff_p3_r1 <= diff_p3_r1;
diff_p4_r1 <= diff_p4_r1;
diff_p5_r1 <= diff_p5_r1;
diff_p6_r1 <= diff_p6_r1;
diff_p7_r1 <= diff_p7_r1;
end
end
assign diff_p0 = diff_p0_r1;
assign diff_p1 = diff_p1_r1;
assign diff_p2 = diff_p2_r1;
assign diff_p3 = diff_p3_r1;
assign diff_p4 = diff_p4_r1;
assign diff_p5 = diff_p5_r1;
assign diff_p6 = diff_p6_r1;
assign diff_p7 = diff_p7_r1;
endmodule

View File

@ -1,86 +1,86 @@
module mult_C #( module mult_C #(
parameter integer A_width = 8 parameter integer A_width = 8
,parameter integer B_width = 8 ,parameter integer B_width = 8
,parameter integer C_width = 8 ,parameter integer C_width = 8
,parameter integer D_width = 8 ,parameter integer D_width = 8
,parameter integer o_width = 31//division ,parameter integer o_width = 31//division
) )
( (
clk, clk,
rstn, rstn,
en, en,
a, a,
b, b,
c, c,
d, d,
Re, Re,
Im Im
); );
input rstn; input rstn;
input clk; input clk;
input en; input en;
input signed [A_width-1 :0] a; input signed [A_width-1 :0] a;
input signed [B_width-1 :0] b; input signed [B_width-1 :0] b;
input signed [C_width-1 :0] c; input signed [C_width-1 :0] c;
input signed [D_width-1 :0] d; input signed [D_width-1 :0] d;
output signed [o_width-1 :0] Re; output signed [o_width-1 :0] Re;
output signed [o_width-1 :0] Im; output signed [o_width-1 :0] Im;
wire signed [A_width+C_width-1:0] ac; wire signed [A_width+C_width-1:0] ac;
wire signed [B_width+D_width-1:0] bd; wire signed [B_width+D_width-1:0] bd;
wire signed [A_width+D_width-1:0] ad; wire signed [A_width+D_width-1:0] ad;
wire signed [B_width+C_width-1:0] bc; wire signed [B_width+C_width-1:0] bc;
wire signed [A_width+C_width :0] Re_tmp; wire signed [A_width+C_width :0] Re_tmp;
wire signed [A_width+D_width :0] Im_tmp; wire signed [A_width+D_width :0] Im_tmp;
wire signed [o_width-1 :0] Re_trunc; wire signed [o_width-1 :0] Re_trunc;
wire signed [o_width-1 :0] Im_trunc; wire signed [o_width-1 :0] Im_trunc;
wire signed [A_width:0] sum_ab; wire signed [A_width:0] sum_ab;
wire signed [C_width:0] sum_cd; wire signed [C_width:0] sum_cd;
wire signed [A_width+C_width+1:0] product_of_sums; wire signed [A_width+C_width+1:0] product_of_sums;
assign sum_ab = a + b; assign sum_ab = a + b;
assign sum_cd = c + d; assign sum_cd = c + d;
DW02_mult #(A_width,C_width) inst_c1( .A (a ), DW02_mult #(A_width,C_width) inst_c1( .A (a ),
.B (c ), .B (c ),
.TC (1'b1 ), .TC (1'b1 ),
.PRODUCT (ac ) .PRODUCT (ac )
); );
DW02_mult #(B_width,D_width) inst_c2( .A (b ), DW02_mult #(B_width,D_width) inst_c2( .A (b ),
.B (d ), .B (d ),
.TC (1'b1 ), .TC (1'b1 ),
.PRODUCT (bd ) .PRODUCT (bd )
); );
DW02_mult #(A_width+1,D_width+1) inst_c3( .A (sum_ab ), DW02_mult #(A_width+1,D_width+1) inst_c3( .A (sum_ab ),
.B (sum_cd ), .B (sum_cd ),
.TC (1'b1 ), .TC (1'b1 ),
.PRODUCT (product_of_sums) .PRODUCT (product_of_sums)
); );
assign Re_tmp = ac - bd; assign Re_tmp = ac - bd;
assign Im_tmp = product_of_sums - ac - bd; assign Im_tmp = product_of_sums - ac - bd;
trunc #( trunc #(
.diw (A_width+C_width+1 ) .diw (A_width+C_width+1 )
,.msb (A_width+C_width-2 ) ,.msb (A_width+C_width-2 )
,.lsb (A_width+C_width-o_width-1 ) ,.lsb (A_width+C_width-o_width-1 )
) u_round1 (clk, rstn, en, Re_tmp, Re_trunc); ) u_round1 (clk, rstn, en, Re_tmp, Re_trunc);
trunc #( trunc #(
.diw (A_width+D_width+1 ) .diw (A_width+D_width+1 )
,.msb (A_width+D_width-2 ) ,.msb (A_width+D_width-2 )
,.lsb (A_width+C_width-o_width-1 ) ,.lsb (A_width+C_width-o_width-1 )
) u_round2 (clk, rstn, en, Im_tmp, Im_trunc); ) u_round2 (clk, rstn, en, Im_tmp, Im_trunc);
// Since this is complex multiplication, the output bit width needs to be increased by one compared to the input. // Since this is complex multiplication, the output bit width needs to be increased by one compared to the input.
assign Re = Re_trunc; assign Re = Re_trunc;
assign Im = Im_trunc; assign Im = Im_trunc;
endmodule endmodule

View File

@ -1,38 +0,0 @@
module mult_real #(
parameter integer A_width = 8
,parameter integer C_width = 8
,parameter integer o_width = 31//division
)
(
input rstn
,input clk
,input en
,input signed [A_width-1 :0] din
,input signed [C_width-1 :0] coef
,output signed [o_width-1 :0] dout
);
wire signed [A_width+C_width-1:0] ac;
wire signed [o_width-1 :0] Re_trunc;
DW02_mult #(A_width,C_width) inst_c1 (
.A (din ),
.B (coef ),
.TC (1'b1 ),
.PRODUCT (ac )
);
trunc #(
.diw (A_width+C_width )
,.msb (A_width+C_width-2 )
,.lsb (A_width+C_width-o_width-1 )
) u_round1 (clk, rstn, en, ac, Re_trunc);
assign dout = Re_trunc;
endmodule

View File

@ -1,66 +1,99 @@
module mult_x #( //+FHDR--------------------------------------------------------------------------------------------------------
parameter integer A_width = 8 // Company:
,parameter integer C_width = 8 //-----------------------------------------------------------------------------------------------------------------
,parameter integer D_width = 8 // File Name : mult_C.v
,parameter integer o_width = 31//division // Department :
// Author : thfu
) // Author's Tel :
//-----------------------------------------------------------------------------------------------------------------
( // Relese History
clk, // Version Date Author Description
rstn, // 0.1 2024-05-28 thfu
en, //2024-05-28 10:22:18
a, //-----------------------------------------------------------------------------------------------------------------
c, // Keywords :
d, //
Re, //-----------------------------------------------------------------------------------------------------------------
Im // Parameter
); //
//-----------------------------------------------------------------------------------------------------------------
input rstn; // Purpose :
input clk; //
input en; //-----------------------------------------------------------------------------------------------------------------
input signed [A_width-1 :0] a; // Target Device:
input signed [C_width-1 :0] c; // Tool versions:
input signed [D_width-1 :0] d; //-----------------------------------------------------------------------------------------------------------------
// Reuse Issues
output signed [o_width-1 :0] Re; // Reset Strategy:
output signed [o_width-1 :0] Im; // Clock Domains:
// Critical Timing:
wire signed [A_width+C_width-1:0] ac; // Asynchronous I/F:
wire signed [A_width+D_width-1:0] ad; // Synthesizable (y/n):
wire signed [o_width-1 :0] Re_trunc; // Other:
wire signed [o_width-1 :0] Im_trunc; //-FHDR--------------------------------------------------------------------------------------------------------
module mult_x #(
parameter integer A_width = 8
,parameter integer C_width = 8
DW02_mult #(A_width,C_width) inst_c1( .A (a ), ,parameter integer D_width = 8
.B (c ), ,parameter integer o_width = 31//division
.TC (1'b1 ),
.PRODUCT (ac ) )
);
(
DW02_mult #(A_width,D_width) inst_c3( .A (a ), clk,
.B (d ), rstn,
.TC (1'b1 ), en,
.PRODUCT (ad ) a,
); c,
d,
Re,
Im
trunc #( );
.diw (A_width+C_width )
,.msb (A_width+C_width-2 ) input rstn;
,.lsb (A_width+C_width-o_width-1 ) input clk;
) u_round1 (clk, rstn, en, ac, Re_trunc); input en;
trunc #( input signed [A_width-1 :0] a;
.diw (A_width+D_width ) input signed [C_width-1 :0] c;
,.msb (A_width+D_width-2 ) input signed [D_width-1 :0] d;
,.lsb (A_width+D_width-o_width-1 )
) u_round2 (clk, rstn, en, ad, Im_trunc); output signed [o_width-1 :0] Re;
output signed [o_width-1 :0] Im;
// Since this is complex multiplication, the output bit width needs to be increased by one compared to the input.
assign Re = Re_trunc; wire signed [A_width+C_width-1:0] ac;
assign Im = Im_trunc; wire signed [A_width+D_width-1:0] ad;
wire signed [o_width-1 :0] Re_trunc;
endmodule wire signed [o_width-1 :0] Im_trunc;
DW02_mult #(A_width,C_width) inst_c1( .A (a ),
.B (c ),
.TC (1'b1 ),
.PRODUCT (ac )
);
DW02_mult #(A_width,D_width) inst_c3( .A (a ),
.B (d ),
.TC (1'b1 ),
.PRODUCT (ad )
);
trunc #(
.diw (A_width+C_width )
,.msb (A_width+C_width-2 )
,.lsb (A_width+C_width-o_width-1 )
) u_round1 (clk, rstn, en, ac, Re_trunc);
trunc #(
.diw (A_width+D_width )
,.msb (A_width+D_width-2 )
,.lsb (A_width+D_width-o_width-1 )
) u_round2 (clk, rstn, en, ad, Im_trunc);
// Since this is complex multiplication, the output bit width needs to be increased by one compared to the input.
assign Re = Re_trunc;
assign Im = Im_trunc;
endmodule

57
rtl/z_dsp/rate_adapter.v Normal file
View File

@ -0,0 +1,57 @@
module rate_adapter
(
input rstn
,input clk
,input en
,input vldi
,input signed [15:0] din0
,input signed [15:0] din1
,input signed [15:0] din2
,input signed [15:0] din3
,input signed [15:0] din4
,input signed [15:0] din5
,input signed [15:0] din6
,input signed [15:0] din7
,output signed [15:0] dout0
,output signed [15:0] dout1
,output signed [15:0] dout2
,output signed [15:0] dout3
,output vldo
);
reg signed [15:0] doutf_0;
reg signed [15:0] doutf_1;
reg signed [15:0] doutf_2;
reg signed [15:0] doutf_3;
always@(posedge clk or negedge rstn)
if(!rstn) begin
doutf_0 <= 0;
doutf_1 <= 0;
doutf_2 <= 0;
doutf_3 <= 0;
end
else if(!en) begin
doutf_0 <= din0;
doutf_1 <= din1;
doutf_2 <= din2;
doutf_3 <= din3;
end
else begin
doutf_0 <= din4;
doutf_1 <= din5;
doutf_2 <= din6;
doutf_3 <= din7;
end
assign dout0 = doutf_0;
assign dout1 = doutf_1;
assign dout2 = doutf_2;
assign dout3 = doutf_3;
//sirv_gnrl_dffr #(1) dff_vldi_or_1(vldi, vldo ,clk,rstn);
assign vldo = vldi;
endmodule

84
rtl/z_dsp/s2p_2.v Normal file
View File

@ -0,0 +1,84 @@
module s2p_2 (
input clk,
input rst_n,
input [15:0] din,
input en,
output [15:0] dout0,
output [15:0] dout1,
output vldo
);
reg cnt;
wire add_cnt;
wire end_cnt;
always @(posedge clk or negedge rst_n)begin
if(!rst_n)begin
cnt <= 0;
end
else if(add_cnt)begin
if(end_cnt)
cnt <= 0;
else
cnt <= cnt + 1;
end
else begin
cnt <= 0;
end
end
assign add_cnt = en == 1'b1;
assign end_cnt = add_cnt && cnt== 2 - 1 ;
wire en_r1;
wire en_r2;
reg [ 15: 0] dout0_r0;
reg [ 15: 0] dout1_r0;
wire dout0_en;
wire dout1_en;
wire dout0_hold;
wire dout1_hold;
always @(posedge clk or negedge rst_n)begin
if(!rst_n)begin
dout0_r0 <= 16'b0;
dout1_r0 <= 16'b0;
end
else if(dout0_en)begin
dout0_r0 <= din;
end
else if(dout1_en)begin
dout1_r0 <= din;
end
else if(dout0_hold)begin
dout0_r0 <= dout0_r0;
dout1_r0 <= 16'd0;
end
else if(dout1_hold)begin
dout0_r0 <= 16'd0;
dout1_r0 <= dout1_r0;
end
else begin
dout0_r0 <= 16'd0;
dout1_r0 <= 16'd0;
end
end
assign dout0_en = add_cnt && cnt == 0;
assign dout1_en = add_cnt && cnt == 1;
assign dout0_hold = en == 0 && en_r1 == 1 && cnt == 1;
assign dout1_hold = en == 0 && en_r1 == 1 && cnt == 0;
sirv_gnrl_dffr #(1) dff_en_1(en , en_r1 ,clk,rst_n);
sirv_gnrl_dffr #(1) dff_en_2(en_r1, en_r2 ,clk,rst_n);
assign vldo = en_r2;
wire [ 15: 0] dout0_r1;
sirv_gnrl_dfflr #(16) dff_dout0_1(1'b1,dout0_r0, dout0_r1 ,clk,rst_n);
assign dout0 = dout0_r1;
assign dout1 = dout1_r0;
endmodule

View File

@ -1,326 +1,326 @@
/* /*
Copyright 2018-2020 Nuclei System Technology, Inc. Copyright 2018-2020 Nuclei System Technology, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
//===================================================================== //=====================================================================
// //
// Designer : Bob Hu // Designer : Bob Hu
// //
// Description: // Description:
// All of the general DFF and Latch modules // All of the general DFF and Latch modules
// //
// ==================================================================== // ====================================================================
// //
// //
// =========================================================================== // ===========================================================================
// //
// Description: // Description:
// Verilog module sirv_gnrl DFF with Load-enable and Reset // Verilog module sirv_gnrl DFF with Load-enable and Reset
// Default reset value is 1 // Default reset value is 1
// //
// =========================================================================== // ===========================================================================
`define DISABLE_SV_ASSERTION `define DISABLE_SV_ASSERTION
`define dly #0.2 `define dly #0.2
module sirv_gnrl_dfflrs # ( module sirv_gnrl_dfflrs # (
parameter DW = 32 parameter DW = 32
) ( ) (
input lden, input lden,
input [DW-1:0] dnxt, input [DW-1:0] dnxt,
output [DW-1:0] qout, output [DW-1:0] qout,
input clk, input clk,
input rst_n input rst_n
); );
reg [DW-1:0] qout_r; reg [DW-1:0] qout_r;
always @(posedge clk or negedge rst_n) always @(posedge clk or negedge rst_n)
begin : DFFLRS_PROC begin : DFFLRS_PROC
if (rst_n == 1'b0) if (rst_n == 1'b0)
qout_r <= {DW{1'b1}}; qout_r <= {DW{1'b1}};
else if (lden == 1'b1) else if (lden == 1'b1)
qout_r <= `dly dnxt; qout_r <= `dly dnxt;
end end
assign qout = qout_r; assign qout = qout_r;
`ifndef FPGA_SOURCE//{ `ifndef FPGA_SOURCE//{
`ifndef DISABLE_SV_ASSERTION//{ `ifndef DISABLE_SV_ASSERTION//{
//synopsys translate_off //synopsys translate_off
sirv_gnrl_xchecker # ( sirv_gnrl_xchecker # (
.DW(1) .DW(1)
) sirv_gnrl_xchecker( ) sirv_gnrl_xchecker(
.i_dat(lden), .i_dat(lden),
.clk (clk) .clk (clk)
); );
//synopsys translate_on //synopsys translate_on
`endif//} `endif//}
`endif//} `endif//}
endmodule endmodule
// =========================================================================== // ===========================================================================
// //
// Description: // Description:
// Verilog module sirv_gnrl DFF with Load-enable and Reset // Verilog module sirv_gnrl DFF with Load-enable and Reset
// Default reset value is 0 // Default reset value is 0
// //
// =========================================================================== // ===========================================================================
module sirv_gnrl_dfflr # ( module sirv_gnrl_dfflr # (
parameter DW = 32 parameter DW = 32
) ( ) (
input lden, input lden,
input [DW-1:0] dnxt, input [DW-1:0] dnxt,
output [DW-1:0] qout, output [DW-1:0] qout,
input clk, input clk,
input rst_n input rst_n
); );
reg [DW-1:0] qout_r; reg [DW-1:0] qout_r;
always @(posedge clk or negedge rst_n) always @(posedge clk or negedge rst_n)
begin : DFFLR_PROC begin : DFFLR_PROC
if (rst_n == 1'b0) if (rst_n == 1'b0)
qout_r <= {DW{1'b0}}; qout_r <= {DW{1'b0}};
else if (lden == 1'b1) else if (lden == 1'b1)
qout_r <= `dly dnxt; qout_r <= `dly dnxt;
end end
assign qout = qout_r; assign qout = qout_r;
`ifndef FPGA_SOURCE//{ `ifndef FPGA_SOURCE//{
`ifndef DISABLE_SV_ASSERTION//{ `ifndef DISABLE_SV_ASSERTION//{
//synopsys translate_off //synopsys translate_off
sirv_gnrl_xchecker # ( sirv_gnrl_xchecker # (
.DW(1) .DW(1)
) sirv_gnrl_xchecker( ) sirv_gnrl_xchecker(
.i_dat(lden), .i_dat(lden),
.clk (clk) .clk (clk)
); );
//synopsys translate_on //synopsys translate_on
`endif//} `endif//}
`endif//} `endif//}
endmodule endmodule
// =========================================================================== // ===========================================================================
// //
// Description: // Description:
// Verilog module sirv_gnrl DFF with Load-enable and Reset // Verilog module sirv_gnrl DFF with Load-enable and Reset
// Default reset value is input // Default reset value is input
// //
// =========================================================================== // ===========================================================================
module sirv_gnrl_dfflrd # ( module sirv_gnrl_dfflrd # (
parameter DW = 32 parameter DW = 32
) ( ) (
input [DW-1:0] init, input [DW-1:0] init,
input lden, input lden,
input [DW-1:0] dnxt, input [DW-1:0] dnxt,
output [DW-1:0] qout, output [DW-1:0] qout,
input clk, input clk,
input rst_n input rst_n
); );
reg [DW-1:0] qout_r; reg [DW-1:0] qout_r;
always @(posedge clk or negedge rst_n) always @(posedge clk or negedge rst_n)
begin : DFFLR_PROC begin : DFFLR_PROC
if (rst_n == 1'b0) if (rst_n == 1'b0)
qout_r <= init; qout_r <= init;
else if (lden == 1'b1) else if (lden == 1'b1)
qout_r <= `dly dnxt; qout_r <= `dly dnxt;
end end
assign qout = qout_r; assign qout = qout_r;
`ifndef FPGA_SOURCE//{ `ifndef FPGA_SOURCE//{
`ifndef DISABLE_SV_ASSERTION//{ `ifndef DISABLE_SV_ASSERTION//{
//synopsys translate_off //synopsys translate_off
sirv_gnrl_xchecker # ( sirv_gnrl_xchecker # (
.DW(1) .DW(1)
) sirv_gnrl_xchecker( ) sirv_gnrl_xchecker(
.i_dat(lden), .i_dat(lden),
.clk (clk) .clk (clk)
); );
//synopsys translate_on //synopsys translate_on
`endif//} `endif//}
`endif//} `endif//}
endmodule endmodule
// =========================================================================== // ===========================================================================
// //
// Description: // Description:
// Verilog module sirv_gnrl DFF with Load-enable, no reset // Verilog module sirv_gnrl DFF with Load-enable, no reset
// //
// =========================================================================== // ===========================================================================
module sirv_gnrl_dffl # ( module sirv_gnrl_dffl # (
parameter DW = 32 parameter DW = 32
) ( ) (
input lden, input lden,
input [DW-1:0] dnxt, input [DW-1:0] dnxt,
output [DW-1:0] qout, output [DW-1:0] qout,
input clk input clk
); );
reg [DW-1:0] qout_r; reg [DW-1:0] qout_r;
always @(posedge clk) always @(posedge clk)
begin : DFFL_PROC begin : DFFL_PROC
if (lden == 1'b1) if (lden == 1'b1)
qout_r <= `dly dnxt; qout_r <= `dly dnxt;
end end
assign qout = qout_r; assign qout = qout_r;
`ifndef FPGA_SOURCE//{ `ifndef FPGA_SOURCE//{
`ifndef DISABLE_SV_ASSERTION//{ `ifndef DISABLE_SV_ASSERTION//{
//synopsys translate_off //synopsys translate_off
sirv_gnrl_xchecker # ( sirv_gnrl_xchecker # (
.DW(1) .DW(1)
) sirv_gnrl_xchecker( ) sirv_gnrl_xchecker(
.i_dat(lden), .i_dat(lden),
.clk (clk) .clk (clk)
); );
//synopsys translate_on //synopsys translate_on
`endif//} `endif//}
`endif//} `endif//}
endmodule endmodule
// =========================================================================== // ===========================================================================
// //
// Description: // Description:
// Verilog module sirv_gnrl DFF with Reset, no load-enable // Verilog module sirv_gnrl DFF with Reset, no load-enable
// Default reset value is 1 // Default reset value is 1
// //
// =========================================================================== // ===========================================================================
module sirv_gnrl_dffrs # ( module sirv_gnrl_dffrs # (
parameter DW = 32 parameter DW = 32
) ( ) (
input [DW-1:0] dnxt, input [DW-1:0] dnxt,
output [DW-1:0] qout, output [DW-1:0] qout,
input clk, input clk,
input rst_n input rst_n
); );
reg [DW-1:0] qout_r; reg [DW-1:0] qout_r;
always @(posedge clk or negedge rst_n) always @(posedge clk or negedge rst_n)
begin : DFFRS_PROC begin : DFFRS_PROC
if (rst_n == 1'b0) if (rst_n == 1'b0)
qout_r <= {DW{1'b1}}; qout_r <= {DW{1'b1}};
else else
qout_r <= `dly dnxt; qout_r <= `dly dnxt;
end end
assign qout = qout_r; assign qout = qout_r;
endmodule endmodule
// =========================================================================== // ===========================================================================
// //
// Description: // Description:
// Verilog module sirv_gnrl DFF with Reset, no load-enable // Verilog module sirv_gnrl DFF with Reset, no load-enable
// Default reset value is 0 // Default reset value is 0
// //
// =========================================================================== // ===========================================================================
module sirv_gnrl_dffr # ( module sirv_gnrl_dffr # (
parameter DW = 32 parameter DW = 32
) ( ) (
input [DW-1:0] dnxt, input [DW-1:0] dnxt,
output [DW-1:0] qout, output [DW-1:0] qout,
input clk, input clk,
input rst_n input rst_n
); );
reg [DW-1:0] qout_r; reg [DW-1:0] qout_r;
always @(posedge clk or negedge rst_n) always @(posedge clk or negedge rst_n)
begin : DFFR_PROC begin : DFFR_PROC
if (rst_n == 1'b0) if (rst_n == 1'b0)
qout_r <= {DW{1'b0}}; qout_r <= {DW{1'b0}};
else else
qout_r <= `dly dnxt; qout_r <= `dly dnxt;
end end
assign qout = qout_r; assign qout = qout_r;
endmodule endmodule
// =========================================================================== // ===========================================================================
// //
// Description: // Description:
// Verilog module for general latch // Verilog module for general latch
// //
// =========================================================================== // ===========================================================================
module sirv_gnrl_ltch # ( module sirv_gnrl_ltch # (
parameter DW = 32 parameter DW = 32
) ( ) (
//input test_mode, //input test_mode,
input lden, input lden,
input [DW-1:0] dnxt, input [DW-1:0] dnxt,
output [DW-1:0] qout output [DW-1:0] qout
); );
reg [DW-1:0] qout_r; reg [DW-1:0] qout_r;
always @ * always @ *
begin : LTCH_PROC begin : LTCH_PROC
if (lden == 1'b1) if (lden == 1'b1)
qout_r <= dnxt; qout_r <= dnxt;
end end
//assign qout = test_mode ? dnxt : qout_r; //assign qout = test_mode ? dnxt : qout_r;
assign qout = qout_r; assign qout = qout_r;
`ifndef FPGA_SOURCE//{ `ifndef FPGA_SOURCE//{
`ifndef DISABLE_SV_ASSERTION//{ `ifndef DISABLE_SV_ASSERTION//{
//synopsys translate_off //synopsys translate_off
always_comb always_comb
begin begin
CHECK_THE_X_VALUE: CHECK_THE_X_VALUE:
assert (lden !== 1'bx) assert (lden !== 1'bx)
else $fatal ("\n Error: Oops, detected a X value!!! This should never happen. \n"); else $fatal ("\n Error: Oops, detected a X value!!! This should never happen. \n");
end end
//synopsys translate_on //synopsys translate_on
`endif//} `endif//}
`endif//} `endif//}
endmodule endmodule

View File

@ -1,58 +1,58 @@
//+FHDR-------------------------------------------------------------------------------------------------------- //+FHDR--------------------------------------------------------------------------------------------------------
// Company: // Company:
//----------------------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------------------
// File Name : syncer.v // File Name : syncer.v
// Department : // Department :
// Author : PWY // Author : PWY
// Author's Tel : // Author's Tel :
//----------------------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------------------
// Relese History // Relese History
// Version Date Author Description // Version Date Author Description
// 0.1 2024-03-13 PWY AWG dedicated register file // 0.1 2024-03-13 PWY AWG dedicated register file
// 0.2 2024-05-13 PWY // 0.2 2024-05-13 PWY
//----------------------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------------------
// Keywords : // Keywords :
// //
//----------------------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------------------
// Parameter // Parameter
// //
//----------------------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------------------
// Purpose : // Purpose :
// //
//----------------------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------------------
// Target Device: // Target Device:
// Tool versions: // Tool versions:
//----------------------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------------------
// Reuse Issues // Reuse Issues
// Reset Strategy: // Reset Strategy:
// Clock Domains: // Clock Domains:
// Critical Timing: // Critical Timing:
// Asynchronous I/F: // Asynchronous I/F:
// Synthesizable (y/n): // Synthesizable (y/n):
// Other: // Other:
//-FHDR-------------------------------------------------------------------------------------------------------- //-FHDR--------------------------------------------------------------------------------------------------------
module syncer # ( module syncer # (
parameter width = 1 parameter width = 1
,parameter stage = 2 ,parameter stage = 2
) )
( (
input clk_d input clk_d
,input rstn_d ,input rstn_d
,input [width-1:0] data_s ,input [width-1:0] data_s
,output [width-1:0] data_d ,output [width-1:0] data_d
); );
generate generate
genvar i; genvar i;
wire [width-1:0] data_temp[stage-1:0]; wire [width-1:0] data_temp[stage-1:0];
sirv_gnrl_dffr #(width) data_temp0_dffr (data_s ,data_temp[0], clk_d, rstn_d); sirv_gnrl_dffr #(width) data_temp0_dffr (data_s ,data_temp[0], clk_d, rstn_d);
for(i=1;i<stage;i=i+1) begin: SYNCER for(i=1;i<stage;i=i+1) begin: SYNCER
sirv_gnrl_dffr #(width) data_tempn0_dffr (data_temp[i-1] ,data_temp[i], clk_d, rstn_d); sirv_gnrl_dffr #(width) data_tempn0_dffr (data_temp[i-1] ,data_temp[i], clk_d, rstn_d);
end end
endgenerate endgenerate
assign data_d = data_temp[stage-1]; assign data_d = data_temp[stage-1];
endmodule endmodule

View File

@ -1,480 +1,396 @@
module z_dsp
( module z_dsp
input rstn (
,input clk input rstn
,input en ,input clk
//,input tc_bypass //NC ,input en
,input [ 3:0] vldi_coef //,input tc_bypass
,input vldi_data ,input [ 5:0] vldi_coef
//,input [1:0] intp_mode //NC ,input vldi_data
//,input [1:0] dac_mode_sel //NC //,input [1:0] intp_mode
,input signed [15:0] din0 //,input [1:0] dac_mode_sel
,input signed [15:0] din1 ,input signed [15:0] din0
,input signed [15:0] din2 ,input signed [15:0] din1
,input signed [15:0] din3 ,input signed [15:0] din2
,input signed [15:0] din4 ,input signed [15:0] din3
,input signed [15:0] din5 ,input signed [31:0] a0_re
,input signed [15:0] din6 ,input signed [31:0] a0_im
,input signed [15:0] din7 ,input signed [31:0] b0_re
,input signed [15:0] din8 ,input signed [31:0] b0_im
,input signed [15:0] din9 ,input signed [31:0] a1_re
,input signed [15:0] dina ,input signed [31:0] a1_im
,input signed [15:0] dinb ,input signed [31:0] b1_re
,input signed [15:0] dinc ,input signed [31:0] b1_im
,input signed [15:0] dind ,input signed [31:0] a2_re
,input signed [15:0] dine ,input signed [31:0] a2_im
,input signed [15:0] dinf ,input signed [31:0] b2_re
,input signed [31:0] a0_re ,input signed [31:0] b2_im
,input signed [31:0] b0_re ,input signed [31:0] a3_re
,input signed [31:0] a1_re ,input signed [31:0] a3_im
,input signed [31:0] b1_re ,input signed [31:0] b3_re
,input signed [31:0] a2_re ,input signed [31:0] b3_im
,input signed [31:0] b2_re ,input signed [31:0] a4_re
,input signed [31:0] a3_re ,input signed [31:0] a4_im
,input signed [31:0] b3_re ,input signed [31:0] b4_re
// 复数端口 ,input signed [31:0] b4_im
`ifdef COMPLEX ,input signed [31:0] a5_re
input signed [31:0] a0_im; ,input signed [31:0] a5_im
input signed [31:0] b0_im; ,input signed [31:0] b5_re
input signed [31:0] a1_im; ,input signed [31:0] b5_im
input signed [31:0] b1_im; ,output signed [15:0] dout0
input signed [31:0] a2_im; ,output signed [15:0] dout1
input signed [31:0] b2_im; ,output signed [15:0] dout2
input signed [31:0] a3_im; ,output signed [15:0] dout3
input signed [31:0] b3_im; ,output vldo
`endif );
,output signed [15:0] dout0
,output signed [15:0] dout1
,output signed [15:0] dout2 wire signed [15:0] IIR_out;
,output signed [15:0] dout3
,output signed [15:0] dout4
,output signed [15:0] dout5 wire signed [31:0] ao_re [5:0];
,output signed [15:0] dout6 wire signed [31:0] ao_im [5:0];
,output signed [15:0] dout7 wire signed [31:0] ab_re [5:0];
,output signed [15:0] dout8 wire signed [31:0] ab_im [5:0];
,output signed [15:0] dout9 wire signed [31:0] abb_re [5:0];
,output signed [15:0] douta wire signed [31:0] abb_im [5:0];
,output signed [15:0] doutb wire signed [31:0] ab_pow3_re [5:0];
,output signed [15:0] doutc wire signed [31:0] ab_pow3_im [5:0];
,output signed [15:0] doutd wire signed [31:0] ab_pow4_re [5:0];
,output signed [15:0] doute wire signed [31:0] ab_pow4_im [5:0];
,output signed [15:0] doutf wire signed [31:0] ab_pow5_re [5:0];
,output vldo wire signed [31:0] ab_pow5_im [5:0];
); wire signed [31:0] ab_pow6_re [5:0];
wire signed [31:0] ab_pow6_im [5:0];
wire signed [31:0] ab_pow7_re [5:0];
wire signed [15:0] IIR_out; wire signed [31:0] ab_pow7_im [5:0];
wire signed [31:0] bo_re [5:0];
wire signed [31:0] bo_im [5:0];
wire signed [31:0] ao_re [3:0]; wire signed [31:0] b_pow8_re [5:0];
wire signed [31:0] ab_re [3:0]; wire signed [31:0] b_pow8_im [5:0];
wire signed [31:0] abb_re [3:0];
wire signed [31:0] ab_pow3_re [3:0]; CoefGen inst_CoefGen(
wire signed [31:0] ab_pow4_re [3:0]; .clk (clk ),
wire signed [31:0] ab_pow5_re [3:0]; .rstn (rstn ),
wire signed [31:0] ab_pow6_re [3:0]; .vldi (vldi_coef ),
wire signed [31:0] ab_pow7_re [3:0]; .a0_re (a0_re ),
wire signed [31:0] ab_pow8_re [3:0]; .a0_im (a0_im ),
wire signed [31:0] ab_pow9_re [3:0]; .b0_re (b0_re ),
wire signed [31:0] ab_powa_re [3:0]; .b0_im (b0_im ),
wire signed [31:0] ab_powb_re [3:0]; .a1_re (a1_re ),
wire signed [31:0] ab_powc_re [3:0]; .a1_im (a1_im ),
wire signed [31:0] ab_powd_re [3:0]; .b1_re (b1_re ),
wire signed [31:0] ab_powe_re [3:0]; .b1_im (b1_im ),
wire signed [31:0] ab_powf_re [3:0]; .a2_re (a2_re ),
wire signed [31:0] bo_re [3:0]; .a2_im (a2_im ),
wire signed [31:0] b_pow16_re [3:0]; .b2_re (b2_re ),
// 复数信号 .b2_im (b2_im ),
`ifdef COMPLEX .a3_re (a3_re ),
wire signed [31:0] ao_im [3:0]; .a3_im (a3_im ),
wire signed [31:0] ab_im [3:0]; .b3_re (b3_re ),
wire signed [31:0] abb_im [3:0]; .b3_im (b3_im ),
wire signed [31:0] ab_pow3_im [3:0]; .a4_re (a4_re ),
wire signed [31:0] ab_pow4_im [3:0]; .a4_im (a4_im ),
wire signed [31:0] ab_pow5_im [3:0]; .b4_re (b4_re ),
wire signed [31:0] ab_pow6_im [3:0]; .b4_im (b4_im ),
wire signed [31:0] ab_pow7_im [3:0]; .a5_re (a5_re ),
wire signed [31:0] ab_pow8_im [3:0]; .a5_im (a5_im ),
wire signed [31:0] ab_pow9_im [3:0]; .b5_re (b5_re ),
wire signed [31:0] ab_powa_im [3:0]; .b5_im (b5_im ),
wire signed [31:0] ab_powb_im [3:0]; .a_re0 (ao_re[0] ),
wire signed [31:0] ab_powc_im [3:0]; .a_im0 (ao_im[0] ),
wire signed [31:0] ab_powd_im [3:0]; .b_re0 (bo_re[0] ),
wire signed [31:0] ab_powe_im [3:0]; .b_im0 (bo_im[0] ),
wire signed [31:0] ab_powf_im [3:0]; .ab_re0 (ab_re[0] ),
wire signed [31:0] bo_im [3:0]; .ab_im0 (ab_im[0] ),
wire signed [31:0] b_pow16_im [3:0]; .abb_re0 (abb_re[0] ),
`endif .abb_im0 (abb_im[0] ),
CoefGen#( .ab_pow3_re0 (ab_pow3_re[0]),
.data_in_width ( 32 ) .ab_pow3_im0 (ab_pow3_im[0]),
,.coef_width ( 32 ) .ab_pow4_re0 (ab_pow4_re[0]),
,.frac_data_out_width ( 20 ) .ab_pow4_im0 (ab_pow4_im[0]),
,.frac_coef_width ( 31 ) .ab_pow5_re0 (ab_pow5_re[0]),
) u_CoefGen( .ab_pow5_im0 (ab_pow5_im[0]),
.rstn ( rstn ) .ab_pow6_re0 (ab_pow6_re[0]),
,.clk ( clk ) .ab_pow6_im0 (ab_pow6_im[0]),
,.vldi ( vldi_coef ) .ab_pow7_re0 (ab_pow7_re[0]),
,.a0_re ( a0_re ) .ab_pow7_im0 (ab_pow7_im[0]),
,.b0_re ( b0_re ) .b_pow8_re0 (b_pow8_re[0] ),
,.a1_re ( a1_re ) .b_pow8_im0 (b_pow8_im[0] ),
,.b1_re ( b1_re ) .a_re1 (ao_re[1] ),
,.a2_re ( a2_re ) .a_im1 (ao_im[1] ),
,.b2_re ( b2_re ) .b_re1 (bo_re[1] ),
,.a3_re ( a3_re ) .b_im1 (bo_im[1] ),
,.b3_re ( b3_re ) .ab_re1 (ab_re[1] ),
`ifdef COMPLEX .ab_im1 (ab_im[1] ),
,.a0_im ( a0_im ) .abb_re1 (abb_re[1] ),
,.b0_im ( b0_im ) .abb_im1 (abb_im[1] ),
,.a1_im ( a1_im ) .ab_pow3_re1 (ab_pow3_re[1]),
,.b1_im ( b1_im ) .ab_pow3_im1 (ab_pow3_im[1]),
,.a2_im ( a2_im ) .ab_pow4_re1 (ab_pow4_re[1]),
,.b2_im ( b2_im ) .ab_pow4_im1 (ab_pow4_im[1]),
,.a3_im ( a3_im ) .ab_pow5_re1 (ab_pow5_re[1]),
,.b3_im ( b3_im ) .ab_pow5_im1 (ab_pow5_im[1]),
`endif .ab_pow6_re1 (ab_pow6_re[1]),
,.a_re0 ( ao_re[0] ) .ab_pow6_im1 (ab_pow6_im[1]),
,.b_re0 ( bo_re[0] ) .ab_pow7_re1 (ab_pow7_re[1]),
,.ab_re0 ( ab_re[0] ) .ab_pow7_im1 (ab_pow7_im[1]),
,.abb_re0 ( abb_re[0] ) .b_pow8_re1 (b_pow8_re[1] ),
,.ab_pow3_re0 ( ab_pow3_re[0] ) .b_pow8_im1 (b_pow8_im[1] ),
,.ab_pow4_re0 ( ab_pow4_re[0] ) .a_re2 (ao_re[2] ),
,.ab_pow5_re0 ( ab_pow5_re[0] ) .a_im2 (ao_im[2] ),
,.ab_pow6_re0 ( ab_pow6_re[0] ) .b_re2 (bo_re[2] ),
,.ab_pow7_re0 ( ab_pow7_re[0] ) .b_im2 (bo_im[2] ),
,.ab_pow8_re0 ( ab_pow8_re[0] ) .ab_re2 (ab_re[2] ),
,.ab_pow9_re0 ( ab_pow9_re[0] ) .ab_im2 (ab_im[2] ),
,.ab_powa_re0 ( ab_powa_re[0] ) .abb_re2 (abb_re[2] ),
,.ab_powb_re0 ( ab_powb_re[0] ) .abb_im2 (abb_im[2] ),
,.ab_powc_re0 ( ab_powc_re[0] ) .ab_pow3_re2 (ab_pow3_re[2]),
,.ab_powd_re0 ( ab_powd_re[0] ) .ab_pow3_im2 (ab_pow3_im[2]),
,.ab_powe_re0 ( ab_powe_re[0] ) .ab_pow4_re2 (ab_pow4_re[2]),
,.ab_powf_re0 ( ab_powf_re[0] ) .ab_pow4_im2 (ab_pow4_im[2]),
,.b_pow16_re0 ( b_pow16_re[0] ) .ab_pow5_re2 (ab_pow5_re[2]),
,.a_re1 ( ao_re[1] ) .ab_pow5_im2 (ab_pow5_im[2]),
,.b_re1 ( bo_re[1] ) .ab_pow6_re2 (ab_pow6_re[2]),
,.ab_re1 ( ab_re[1] ) .ab_pow6_im2 (ab_pow6_im[2]),
,.abb_re1 ( abb_re[1] ) .ab_pow7_re2 (ab_pow7_re[2]),
,.ab_pow3_re1 ( ab_pow3_re[1] ) .ab_pow7_im2 (ab_pow7_im[2]),
,.ab_pow4_re1 ( ab_pow4_re[1] ) .b_pow8_re2 (b_pow8_re[2] ),
,.ab_pow5_re1 ( ab_pow5_re[1] ) .b_pow8_im2 (b_pow8_im[2] ),
,.ab_pow6_re1 ( ab_pow6_re[1] ) .a_re3 (ao_re[3] ),
,.ab_pow7_re1 ( ab_pow7_re[1] ) .a_im3 (ao_im[3] ),
,.ab_pow8_re1 ( ab_pow8_re[1] ) .b_re3 (bo_re[3] ),
,.ab_pow9_re1 ( ab_pow9_re[1] ) .b_im3 (bo_im[3] ),
,.ab_powa_re1 ( ab_powa_re[1] ) .ab_re3 (ab_re[3] ),
,.ab_powb_re1 ( ab_powb_re[1] ) .ab_im3 (ab_im[3] ),
,.ab_powc_re1 ( ab_powc_re[1] ) .abb_re3 (abb_re[3] ),
,.ab_powd_re1 ( ab_powd_re[1] ) .abb_im3 (abb_im[3] ),
,.ab_powe_re1 ( ab_powe_re[1] ) .ab_pow3_re3 (ab_pow3_re[3]),
,.ab_powf_re1 ( ab_powf_re[1] ) .ab_pow3_im3 (ab_pow3_im[3]),
,.b_pow16_re1 ( b_pow16_re[1] ) .ab_pow4_re3 (ab_pow4_re[3]),
,.a_re2 ( ao_re[2] ) .ab_pow4_im3 (ab_pow4_im[3]),
,.b_re2 ( bo_re[2] ) .ab_pow5_re3 (ab_pow5_re[3]),
,.ab_re2 ( ab_re[2] ) .ab_pow5_im3 (ab_pow5_im[3]),
,.abb_re2 ( abb_re[2] ) .ab_pow6_re3 (ab_pow6_re[3]),
,.ab_pow3_re2 ( ab_pow3_re[2] ) .ab_pow6_im3 (ab_pow6_im[3]),
,.ab_pow4_re2 ( ab_pow4_re[2] ) .ab_pow7_re3 (ab_pow7_re[3]),
,.ab_pow5_re2 ( ab_pow5_re[2] ) .ab_pow7_im3 (ab_pow7_im[3]),
,.ab_pow6_re2 ( ab_pow6_re[2] ) .b_pow8_re3 (b_pow8_re[3] ),
,.ab_pow7_re2 ( ab_pow7_re[2] ) .b_pow8_im3 (b_pow8_im[3] ),
,.ab_pow8_re2 ( ab_pow8_re[2] ) .a_re4 (ao_re[4] ),
,.ab_pow9_re2 ( ab_pow9_re[2] ) .a_im4 (ao_im[4] ),
,.ab_powa_re2 ( ab_powa_re[2] ) .b_re4 (bo_re[4] ),
,.ab_powb_re2 ( ab_powb_re[2] ) .b_im4 (bo_im[4] ),
,.ab_powc_re2 ( ab_powc_re[2] ) .ab_re4 (ab_re[4] ),
,.ab_powd_re2 ( ab_powd_re[2] ) .ab_im4 (ab_im[4] ),
,.ab_powe_re2 ( ab_powe_re[2] ) .abb_re4 (abb_re[4] ),
,.ab_powf_re2 ( ab_powf_re[2] ) .abb_im4 (abb_im[4] ),
,.b_pow16_re2 ( b_pow16_re[2] ) .ab_pow3_re4 (ab_pow3_re[4]),
,.a_re3 ( ao_re[3] ) .ab_pow3_im4 (ab_pow3_im[4]),
,.b_re3 ( bo_re[3] ) .ab_pow4_re4 (ab_pow4_re[4]),
,.ab_re3 ( ab_re[3] ) .ab_pow4_im4 (ab_pow4_im[4]),
,.abb_re3 ( abb_re[3] ) .ab_pow5_re4 (ab_pow5_re[4]),
,.ab_pow3_re3 ( ab_pow3_re[3] ) .ab_pow5_im4 (ab_pow5_im[4]),
,.ab_pow4_re3 ( ab_pow4_re[3] ) .ab_pow6_re4 (ab_pow6_re[4]),
,.ab_pow5_re3 ( ab_pow5_re[3] ) .ab_pow6_im4 (ab_pow6_im[4]),
,.ab_pow6_re3 ( ab_pow6_re[3] ) .ab_pow7_re4 (ab_pow7_re[4]),
,.ab_pow7_re3 ( ab_pow7_re[3] ) .ab_pow7_im4 (ab_pow7_im[4]),
,.ab_pow8_re3 ( ab_pow8_re[3] ) .b_pow8_re4 (b_pow8_re[4] ),
,.ab_pow9_re3 ( ab_pow9_re[3] ) .b_pow8_im4 (b_pow8_im[4] ),
,.ab_powa_re3 ( ab_powa_re[3] ) .a_re5 (ao_re[5] ),
,.ab_powb_re3 ( ab_powb_re[3] ) .a_im5 (ao_im[5] ),
,.ab_powc_re3 ( ab_powc_re[3] ) .b_re5 (bo_re[5] ),
,.ab_powd_re3 ( ab_powd_re[3] ) .b_im5 (bo_im[5] ),
,.ab_powe_re3 ( ab_powe_re[3] ) .ab_re5 (ab_re[5] ),
,.ab_powf_re3 ( ab_powf_re[3] ) .ab_im5 (ab_im[5] ),
,.b_pow16_re3 ( b_pow16_re[3] ) .abb_re5 (abb_re[5] ),
`ifdef COMPLEX .abb_im5 (abb_im[5] ),
,.a_im0 ( ao_im[0] ) .ab_pow3_re5 (ab_pow3_re[5]),
,.b_im0 ( bo_im[0] ) .ab_pow3_im5 (ab_pow3_im[5]),
,.ab_im0 ( ab_im[0] ) .ab_pow4_re5 (ab_pow4_re[5]),
,.abb_im0 ( abb_im[0] ) .ab_pow4_im5 (ab_pow4_im[5]),
,.ab_pow3_im0 ( ab_pow3_im[0] ) .ab_pow5_re5 (ab_pow5_re[5]),
,.ab_pow4_im0 ( ab_pow4_im[0] ) .ab_pow5_im5 (ab_pow5_im[5]),
,.ab_pow5_im0 ( ab_pow5_im[0] ) .ab_pow6_re5 (ab_pow6_re[5]),
,.ab_pow6_im0 ( ab_pow6_im[0] ) .ab_pow6_im5 (ab_pow6_im[5]),
,.ab_pow7_im0 ( ab_pow7_im[0] ) .ab_pow7_re5 (ab_pow7_re[5]),
,.ab_pow8_im0 ( ab_pow8_im[0] ) .ab_pow7_im5 (ab_pow7_im[5]),
,.ab_pow9_im0 ( ab_pow9_im[0] ) .b_pow8_re5 (b_pow8_re[5] ),
,.ab_powa_im0 ( ab_powa_im[0] ) .b_pow8_im5 (b_pow8_im[5] )
,.ab_powb_im0 ( ab_powb_im[0] ) );
,.ab_powc_im0 ( ab_powc_im[0] )
,.ab_powd_im0 ( ab_powd_im[0] ) wire signed [15:0] dout_0;
,.ab_powe_im0 ( ab_powe_im[0] ) wire signed [15:0] dout_1;
,.ab_powf_im0 ( ab_powf_im[0] ) wire signed [15:0] dout_2;
,.b_pow16_im0 ( b_pow16_im[0] ) wire signed [15:0] dout_3;
,.a_im1 ( ao_im[1] ) wire signed [15:0] dout_4;
,.b_im1 ( bo_im[1] ) wire signed [15:0] dout_5;
,.ab_im1 ( ab_im[1] ) wire signed [15:0] dout_6;
,.abb_im1 ( abb_im[1] ) wire signed [15:0] dout_7;
,.ab_pow3_im1 ( ab_pow3_im[1] ) wire vldo_TC;
,.ab_pow4_im1 ( ab_pow4_im[1] ) TailCorr_top inst_TailCorr_top
,.ab_pow5_im1 ( ab_pow5_im[1] ) (
,.ab_pow6_im1 ( ab_pow6_im[1] ) .clk (clk ),
,.ab_pow7_im1 ( ab_pow7_im[1] ) .en (en ),
,.ab_pow8_im1 ( ab_pow8_im[1] ) .rstn (rstn ),
,.ab_pow9_im1 ( ab_pow9_im[1] ) .vldi (vldi_data ),
,.ab_powa_im1 ( ab_powa_im[1] ) // .dac_mode_sel (dac_mode_sel ),
,.ab_powb_im1 ( ab_powb_im[1] ) // .intp_mode (intp_mode ),
,.ab_powc_im1 ( ab_powc_im[1] ) .din0 (din0 ),
,.ab_powd_im1 ( ab_powd_im[1] ) .din1 (din1 ),
,.ab_powe_im1 ( ab_powe_im[1] ) .din2 (din2 ),
,.ab_powf_im1 ( ab_powf_im[1] ) .din3 (din3 ),
,.b_pow16_im1 ( b_pow16_im[1] ) .a_re0 (ao_re[0] ),
,.a_im2 ( ao_im[2] ) .a_im0 (ao_im[0] ),
,.b_im2 ( bo_im[2] ) .b_re0 (bo_re[0] ),
,.ab_im2 ( ab_im[2] ) .b_im0 (bo_im[0] ),
,.abb_im2 ( abb_im[2] ) .ab_re0 (ab_re[0] ),
,.ab_pow3_im2 ( ab_pow3_im[2] ) .ab_im0 (ab_im[0] ),
,.ab_pow4_im2 ( ab_pow4_im[2] ) .abb_re0 (abb_re[0] ),
,.ab_pow5_im2 ( ab_pow5_im[2] ) .abb_im0 (abb_im[0] ),
,.ab_pow6_im2 ( ab_pow6_im[2] ) .ab_pow3_re0 (ab_pow3_re[0]),
,.ab_pow7_im2 ( ab_pow7_im[2] ) .ab_pow3_im0 (ab_pow3_im[0]),
,.ab_pow8_im2 ( ab_pow8_im[2] ) .ab_pow4_re0 (ab_pow4_re[0]),
,.ab_pow9_im2 ( ab_pow9_im[2] ) .ab_pow4_im0 (ab_pow4_im[0]),
,.ab_powa_im2 ( ab_powa_im[2] ) .ab_pow5_re0 (ab_pow5_re[0]),
,.ab_powb_im2 ( ab_powb_im[2] ) .ab_pow5_im0 (ab_pow5_im[0]),
,.ab_powc_im2 ( ab_powc_im[2] ) .ab_pow6_re0 (ab_pow6_re[0]),
,.ab_powd_im2 ( ab_powd_im[2] ) .ab_pow6_im0 (ab_pow6_im[0]),
,.ab_powe_im2 ( ab_powe_im[2] ) .ab_pow7_re0 (ab_pow7_re[0]),
,.ab_powf_im2 ( ab_powf_im[2] ) .ab_pow7_im0 (ab_pow7_im[0]),
,.b_pow16_im2 ( b_pow16_im[2] ) .b_pow8_re0 (b_pow8_re[0] ),
,.a_im3 ( ao_im[3] ) .b_pow8_im0 (b_pow8_im[0] ),
,.b_im3 ( bo_im[3] ) .a_re1 (ao_re[1] ),
,.ab_im3 ( ab_im[3] ) .a_im1 (ao_im[1] ),
,.abb_im3 ( abb_im[3] ) .b_re1 (bo_re[1] ),
,.ab_pow3_im3 ( ab_pow3_im[3] ) .b_im1 (bo_im[1] ),
,.ab_pow4_im3 ( ab_pow4_im[3] ) .ab_re1 (ab_re[1] ),
,.ab_pow5_im3 ( ab_pow5_im[3] ) .ab_im1 (ab_im[1] ),
,.ab_pow6_im3 ( ab_pow6_im[3] ) .abb_re1 (abb_re[1] ),
,.ab_pow7_im3 ( ab_pow7_im[3] ) .abb_im1 (abb_im[1] ),
,.ab_pow8_im3 ( ab_pow8_im[3] ) .ab_pow3_re1 (ab_pow3_re[1]),
,.ab_pow9_im3 ( ab_pow9_im[3] ) .ab_pow3_im1 (ab_pow3_im[1]),
,.ab_powa_im3 ( ab_powa_im[3] ) .ab_pow4_re1 (ab_pow4_re[1]),
,.ab_powb_im3 ( ab_powb_im[3] ) .ab_pow4_im1 (ab_pow4_im[1]),
,.ab_powc_im3 ( ab_powc_im[3] ) .ab_pow5_re1 (ab_pow5_re[1]),
,.ab_powd_im3 ( ab_powd_im[3] ) .ab_pow5_im1 (ab_pow5_im[1]),
,.ab_powe_im3 ( ab_powe_im[3] ) .ab_pow6_re1 (ab_pow6_re[1]),
,.ab_powf_im3 ( ab_powf_im[3] ) .ab_pow6_im1 (ab_pow6_im[1]),
,.b_pow16_im3 ( b_pow16_im[3] ) .ab_pow7_re1 (ab_pow7_re[1]),
`endif .ab_pow7_im1 (ab_pow7_im[1]),
); .b_pow8_re1 (b_pow8_re[1] ),
.b_pow8_im1 (b_pow8_im[1] ),
wire signed [15:0] dout_0; .a_re2 (ao_re[2] ),
wire signed [15:0] dout_1; .a_im2 (ao_im[2] ),
wire signed [15:0] dout_2; .b_re2 (bo_re[2] ),
wire signed [15:0] dout_3; .b_im2 (bo_im[2] ),
wire signed [15:0] dout_4; .ab_re2 (ab_re[2] ),
wire signed [15:0] dout_5; .ab_im2 (ab_im[2] ),
wire signed [15:0] dout_6; .abb_re2 (abb_re[2] ),
wire signed [15:0] dout_7; .abb_im2 (abb_im[2] ),
wire vldo_TC; .ab_pow3_re2 (ab_pow3_re[2]),
.ab_pow3_im2 (ab_pow3_im[2]),
TailCorr_top u_TailCorr_top( .ab_pow4_re2 (ab_pow4_re[2]),
.rstn ( rstn ) .ab_pow4_im2 (ab_pow4_im[2]),
,.clk ( clk ) .ab_pow5_re2 (ab_pow5_re[2]),
,.en ( en ) .ab_pow5_im2 (ab_pow5_im[2]),
,.vldi ( vldi_data ) .ab_pow6_re2 (ab_pow6_re[2]),
,.din0 ( din0 ) .ab_pow6_im2 (ab_pow6_im[2]),
,.din1 ( din1 ) .ab_pow7_re2 (ab_pow7_re[2]),
,.din2 ( din2 ) .ab_pow7_im2 (ab_pow7_im[2]),
,.din3 ( din3 ) .b_pow8_re2 (b_pow8_re[2] ),
,.din4 ( din4 ) .b_pow8_im2 (b_pow8_im[2] ),
,.din5 ( din5 ) .a_re3 (ao_re[3] ),
,.din6 ( din6 ) .a_im3 (ao_im[3] ),
,.din7 ( din7 ) .b_re3 (bo_re[3] ),
,.din8 ( din8 ) .b_im3 (bo_im[3] ),
,.din9 ( din9 ) .ab_re3 (ab_re[3] ),
,.dina ( dina ) .ab_im3 (ab_im[3] ),
,.dinb ( dinb ) .abb_re3 (abb_re[3] ),
,.dinc ( dinc ) .abb_im3 (abb_im[3] ),
,.dind ( dind ) .ab_pow3_re3 (ab_pow3_re[3]),
,.dine ( dine ) .ab_pow3_im3 (ab_pow3_im[3]),
,.dinf ( dinf ) .ab_pow4_re3 (ab_pow4_re[3]),
,.a_re0 ( ao_re[0] ) .ab_pow4_im3 (ab_pow4_im[3]),
,.b_re0 ( bo_re[0] ) .ab_pow5_re3 (ab_pow5_re[3]),
,.ab_re0 ( ab_re[0] ) .ab_pow5_im3 (ab_pow5_im[3]),
,.abb_re0 ( abb_re[0] ) .ab_pow6_re3 (ab_pow6_re[3]),
,.ab_pow3_re0 ( ab_pow3_re[0] ) .ab_pow6_im3 (ab_pow6_im[3]),
,.ab_pow4_re0 ( ab_pow4_re[0] ) .ab_pow7_re3 (ab_pow7_re[3]),
,.ab_pow5_re0 ( ab_pow5_re[0] ) .ab_pow7_im3 (ab_pow7_im[3]),
,.ab_pow6_re0 ( ab_pow6_re[0] ) .b_pow8_re3 (b_pow8_re[3] ),
,.ab_pow7_re0 ( ab_pow7_re[0] ) .b_pow8_im3 (b_pow8_im[3] ),
,.ab_pow8_re0 ( ab_pow8_re[0] ) .a_re4 (ao_re[4] ),
,.ab_pow9_re0 ( ab_pow9_re[0] ) .a_im4 (ao_im[4] ),
,.ab_powa_re0 ( ab_powa_re[0] ) .b_re4 (bo_re[4] ),
,.ab_powb_re0 ( ab_powb_re[0] ) .b_im4 (bo_im[4] ),
,.ab_powc_re0 ( ab_powc_re[0] ) .ab_re4 (ab_re[4] ),
,.ab_powd_re0 ( ab_powd_re[0] ) .ab_im4 (ab_im[4] ),
,.ab_powe_re0 ( ab_powe_re[0] ) .abb_re4 (abb_re[4] ),
,.ab_powf_re0 ( ab_powf_re[0] ) .abb_im4 (abb_im[4] ),
,.b_pow16_re0 ( b_pow16_re[0] ) .ab_pow3_re4 (ab_pow3_re[4]),
,.a_re1 ( ao_re[1] ) .ab_pow3_im4 (ab_pow3_im[4]),
,.b_re1 ( bo_re[1] ) .ab_pow4_re4 (ab_pow4_re[4]),
,.ab_re1 ( ab_re[1] ) .ab_pow4_im4 (ab_pow4_im[4]),
,.abb_re1 ( abb_re[1] ) .ab_pow5_re4 (ab_pow5_re[4]),
,.ab_pow3_re1 ( ab_pow3_re[1] ) .ab_pow5_im4 (ab_pow5_im[4]),
,.ab_pow4_re1 ( ab_pow4_re[1] ) .ab_pow6_re4 (ab_pow6_re[4]),
,.ab_pow5_re1 ( ab_pow5_re[1] ) .ab_pow6_im4 (ab_pow6_im[4]),
,.ab_pow6_re1 ( ab_pow6_re[1] ) .ab_pow7_re4 (ab_pow7_re[4]),
,.ab_pow7_re1 ( ab_pow7_re[1] ) .ab_pow7_im4 (ab_pow7_im[4]),
,.ab_pow8_re1 ( ab_pow8_re[1] ) .b_pow8_re4 (b_pow8_re[4] ),
,.ab_pow9_re1 ( ab_pow9_re[1] ) .b_pow8_im4 (b_pow8_im[4] ),
,.ab_powa_re1 ( ab_powa_re[1] ) .a_re5 (ao_re[5] ),
,.ab_powb_re1 ( ab_powb_re[1] ) .a_im5 (ao_im[5] ),
,.ab_powc_re1 ( ab_powc_re[1] ) .b_re5 (bo_re[5] ),
,.ab_powd_re1 ( ab_powd_re[1] ) .b_im5 (bo_im[5] ),
,.ab_powe_re1 ( ab_powe_re[1] ) .ab_re5 (ab_re[5] ),
,.ab_powf_re1 ( ab_powf_re[1] ) .ab_im5 (ab_im[5] ),
,.b_pow16_re1 ( b_pow16_re[1] ) .abb_re5 (abb_re[5] ),
,.a_re2 ( ao_re[2] ) .abb_im5 (abb_im[5] ),
,.b_re2 ( bo_re[2] ) .ab_pow3_re5 (ab_pow3_re[5]),
,.ab_re2 ( ab_re[2] ) .ab_pow3_im5 (ab_pow3_im[5]),
,.abb_re2 ( abb_re[2] ) .ab_pow4_re5 (ab_pow4_re[5]),
,.ab_pow3_re2 ( ab_pow3_re[2] ) .ab_pow4_im5 (ab_pow4_im[5]),
,.ab_pow4_re2 ( ab_pow4_re[2] ) .ab_pow5_re5 (ab_pow5_re[5]),
,.ab_pow5_re2 ( ab_pow5_re[2] ) .ab_pow5_im5 (ab_pow5_im[5]),
,.ab_pow6_re2 ( ab_pow6_re[2] ) .ab_pow6_re5 (ab_pow6_re[5]),
,.ab_pow7_re2 ( ab_pow7_re[2] ) .ab_pow6_im5 (ab_pow6_im[5]),
,.ab_pow8_re2 ( ab_pow8_re[2] ) .ab_pow7_re5 (ab_pow7_re[5]),
,.ab_pow9_re2 ( ab_pow9_re[2] ) .ab_pow7_im5 (ab_pow7_im[5]),
,.ab_powa_re2 ( ab_powa_re[2] ) .b_pow8_re5 (b_pow8_re[5] ),
,.ab_powb_re2 ( ab_powb_re[2] ) .b_pow8_im5 (b_pow8_im[5] ),
,.ab_powc_re2 ( ab_powc_re[2] ) .dout_p0 (dout_0 ),
,.ab_powd_re2 ( ab_powd_re[2] ) .dout_p1 (dout_1 ),
,.ab_powe_re2 ( ab_powe_re[2] ) .dout_p2 (dout_2 ),
,.ab_powf_re2 ( ab_powf_re[2] ) .dout_p3 (dout_3 ),
,.b_pow16_re2 ( b_pow16_re[2] ) .dout_p4 (dout_4 ),
,.a_re3 ( ao_re[3] ) .dout_p5 (dout_5 ),
,.b_re3 ( bo_re[3] ) .dout_p6 (dout_6 ),
,.ab_re3 ( ab_re[3] ) .dout_p7 (dout_7 ),
,.abb_re3 ( abb_re[3] ) .vldo (vldo_TC )
,.ab_pow3_re3 ( ab_pow3_re[3] )
,.ab_pow4_re3 ( ab_pow4_re[3] ) );
,.ab_pow5_re3 ( ab_pow5_re[3] )
,.ab_pow6_re3 ( ab_pow6_re[3] ) //assign vldo = vldo_TC;
,.ab_pow7_re3 ( ab_pow7_re[3] ) rate_adapter inst_rate_adapter(
,.ab_pow8_re3 ( ab_pow8_re[3] ) .rstn (rstn ),
,.ab_pow9_re3 ( ab_pow9_re[3] ) .clk (clk ),
,.ab_powa_re3 ( ab_powa_re[3] ) .en (en ),
,.ab_powb_re3 ( ab_powb_re[3] ) .vldi (vldo_TC ),
,.ab_powc_re3 ( ab_powc_re[3] ) .din0 (dout_0 ),
,.ab_powd_re3 ( ab_powd_re[3] ) .din1 (dout_1 ),
,.ab_powe_re3 ( ab_powe_re[3] ) .din2 (dout_2 ),
,.ab_powf_re3 ( ab_powf_re[3] ) .din3 (dout_3 ),
,.b_pow16_re3 ( b_pow16_re[3] ) .din4 (dout_4 ),
`ifdef COMPLEX .din5 (dout_5 ),
,.a_im0 ( ao_im[0] ) .din6 (dout_6 ),
,.b_im0 ( bo_im[0] ) .din7 (dout_7 ),
,.ab_im0 ( ab_im[0] ) .dout0 (dout0 ),
,.abb_im0 ( abb_im[0] ) .dout1 (dout1 ),
,.ab_pow3_im0 ( ab_pow3_im[0] ) .dout2 (dout2 ),
,.ab_pow4_im0 ( ab_pow4_im[0] ) .dout3 (dout3 ),
,.ab_pow5_im0 ( ab_pow5_im[0] ) .vldo (vldo )
,.ab_pow6_im0 ( ab_pow6_im[0] ) );
,.ab_pow7_im0 ( ab_pow7_im[0] )
,.ab_pow8_im0 ( ab_pow8_im[0] ) endmodule
,.ab_pow9_im0 ( ab_pow9_im[0] )
,.ab_powa_im0 ( ab_powa_im[0] )
,.ab_powb_im0 ( ab_powb_im[0] )
,.ab_powc_im0 ( ab_powc_im[0] )
,.ab_powd_im0 ( ab_powd_im[0] )
,.ab_powe_im0 ( ab_powe_im[0] )
,.ab_powf_im0 ( ab_powf_im[0] )
,.b_pow16_im0 ( b_pow16_im[0] )
,.a_im1 ( ao_im[1] )
,.b_im1 ( bo_im[1] )
,.ab_im1 ( ab_im[1] )
,.abb_im1 ( abb_im[1] )
,.ab_pow3_im1 ( ab_pow3_im[1] )
,.ab_pow4_im1 ( ab_pow4_im[1] )
,.ab_pow5_im1 ( ab_pow5_im[1] )
,.ab_pow6_im1 ( ab_pow6_im[1] )
,.ab_pow7_im1 ( ab_pow7_im[1] )
,.ab_pow8_im1 ( ab_pow8_im[1] )
,.ab_pow9_im1 ( ab_pow9_im[1] )
,.ab_powa_im1 ( ab_powa_im[1] )
,.ab_powb_im1 ( ab_powb_im[1] )
,.ab_powc_im1 ( ab_powc_im[1] )
,.ab_powd_im1 ( ab_powd_im[1] )
,.ab_powe_im1 ( ab_powe_im[1] )
,.ab_powf_im1 ( ab_powf_im[1] )
,.b_pow16_im1 ( b_pow16_im[1] )
,.a_im2 ( ao_im[2] )
,.b_im2 ( bo_im[2] )
,.ab_im2 ( ab_im[2] )
,.abb_im2 ( abb_im[2] )
,.ab_pow3_im2 ( ab_pow3_im[2] )
,.ab_pow4_im2 ( ab_pow4_im[2] )
,.ab_pow5_im2 ( ab_pow5_im[2] )
,.ab_pow6_im2 ( ab_pow6_im[2] )
,.ab_pow7_im2 ( ab_pow7_im[2] )
,.ab_pow8_im2 ( ab_pow8_im[2] )
,.ab_pow9_im2 ( ab_pow9_im[2] )
,.ab_powa_im2 ( ab_powa_im[2] )
,.ab_powb_im2 ( ab_powb_im[2] )
,.ab_powc_im2 ( ab_powc_im[2] )
,.ab_powd_im2 ( ab_powd_im[2] )
,.ab_powe_im2 ( ab_powe_im[2] )
,.ab_powf_im2 ( ab_powf_im[2] )
,.b_pow16_im2 ( b_pow16_im[2] )
,.a_im3 ( ao_im[3] )
,.b_im3 ( bo_im[3] )
,.ab_im3 ( ab_im[3] )
,.abb_im3 ( abb_im[3] )
,.ab_pow3_im3 ( ab_pow3_im[3] )
,.ab_pow4_im3 ( ab_pow4_im[3] )
,.ab_pow5_im3 ( ab_pow5_im[3] )
,.ab_pow6_im3 ( ab_pow6_im[3] )
,.ab_pow7_im3 ( ab_pow7_im[3] )
,.ab_pow8_im3 ( ab_pow8_im[3] )
,.ab_pow9_im3 ( ab_pow9_im[3] )
,.ab_powa_im3 ( ab_powa_im[3] )
,.ab_powb_im3 ( ab_powb_im[3] )
,.ab_powc_im3 ( ab_powc_im[3] )
,.ab_powd_im3 ( ab_powd_im[3] )
,.ab_powe_im3 ( ab_powe_im[3] )
,.ab_powf_im3 ( ab_powf_im[3] )
,.b_pow16_im3 ( b_pow16_im[3] )
`endif
,.dout_p0 ( dout0 )
,.dout_p1 ( dout1 )
,.dout_p2 ( dout2 )
,.dout_p3 ( dout3 )
,.dout_p4 ( dout4 )
,.dout_p5 ( dout5 )
,.dout_p6 ( dout6 )
,.dout_p7 ( dout7 )
,.dout_p8 ( dout8 )
,.dout_p9 ( dout9 )
,.dout_pa ( douta )
,.dout_pb ( doutb )
,.dout_pc ( doutc )
,.dout_pd ( doutd )
,.dout_pe ( doute )
,.dout_pf ( doutf )
,.vldo ( vldo_TC )
);
assign vldo = vldo_TC;
endmodule

View File

@ -2,17 +2,17 @@
clc;clear;close all clc;clear;close all
% addpath("/data/work/thfu/TailCorr/script_m"); % addpath("/data/work/thfu/TailCorr/script_m");
data_source = 'matlab'; data_source = 'matlab';
file_path = "/home/thfu/work/TailCorr/sim/z_dsp/"; file_path = "/home/thfu/work/TailCorr/sim/";
rng('shuffle'); rng('shuffle');
max_error = zeros(100,1); max_error = zeros(100,1);
for time = 1 for time = 1:100
if strcmp(data_source, 'matlab') if strcmp(data_source, 'matlab')
in = floor(cat(1,0,3000*randn(16*2500-1,1))); in = floor(cat(1,0,30000*rand(4*2579+4,1)));
for i = 0:15 for i = 0:3
filename = strcat(file_path, "in", num2str(i), "_matlab.dat"); filename = strcat(file_path, "in", num2str(i), "_matlab.dat");
subset = in(i+1:16:end); subset = in(i+1:4:end);
fileID = fopen(filename, 'w'); fileID = fopen(filename, 'w');
fprintf(fileID, '%d\n', subset); fprintf(fileID, '%d\n', subset);
fclose(fileID); fclose(fileID);
@ -20,7 +20,7 @@ if strcmp(data_source, 'matlab')
in = [in; zeros(6e4,1)]; in = [in; zeros(6e4,1)];
system('make all'); system('make all');
elseif strcmp(data_source, 'verdi') elseif strcmp(data_source, 'verdi')
system('make all'); % system('make all');
in = []; in = [];
for i = 0:3 for i = 0:3
filename = strcat(file_path, "in", num2str(i), ".dat"); filename = strcat(file_path, "in", num2str(i), ".dat");
@ -36,14 +36,14 @@ end
cs_wave = []; cs_wave = [];
for i = 0:15 for i = 0:7
filename = strcat(file_path, "dout", num2str(i), ".dat"); filename = strcat(file_path, "dout", num2str(i), ".dat");
dout_data = importdata(filename); dout_data = importdata(filename);
if isempty(cs_wave) if isempty(cs_wave)
N = length(dout_data); N = length(dout_data);
cs_wave = zeros(16*N, 1); cs_wave = zeros(8*N, 1);
end end
cs_wave(i+1:16:end) = dout_data; cs_wave(i+1:8:end) = dout_data;
end end
A = [0.025 0.015*1 0.0002*1 0]; A = [0.025 0.015*1 0.0002*1 0];
@ -98,12 +98,12 @@ a_bin = dec2bin(a_fix,32);
fprintf('a_fix is %d\n',a_fix); fprintf('a_fix is %d\n',a_fix);
fprintf('b_fix is %d\n',b_fix); fprintf('b_fix is %d\n',b_fix);
% fprintf('ab_fix is %d\n',ab_fix); fprintf('ab_fix is %d\n',ab_fix);
% fprintf('ab2_fix is %d\n', ab2_fix); fprintf('ab2_fix is %d\n', ab2_fix);
% fprintf('ab3_fix is %d\n', ab3_fix); fprintf('ab3_fix is %d\n', ab3_fix);
% fprintf('ab4_fix is %d\n', ab4_fix); fprintf('ab4_fix is %d\n', ab4_fix);
% fprintf('ab5_fix is %d\n', ab5_fix); fprintf('ab5_fix is %d\n', ab5_fix);
% fprintf('ab6_fix is %d\n', ab6_fix); fprintf('ab6_fix is %d\n', ab6_fix);
% fprintf('ab7_fix is %d\n', ab7_fix); fprintf('ab7_fix is %d\n', ab7_fix);
% fprintf('b8_fix is %d\n',b8_fix); fprintf('b8_fix is %d\n',b8_fix);

View File

@ -1,17 +1,17 @@
+incdir+./../../rtl/define ../../rtl/z_dsp/z_dsp.v
../../rtl/z_dsp/z_dsp.v ../../rtl/z_dsp/TailCorr_top.v
../../rtl/z_dsp/TailCorr_top.v ../../rtl/z_dsp/rate_adapter.v
../../rtl/z_dsp/IIR_top.v ../../rtl/z_dsp/IIR_top.v
../../rtl/z_dsp/IIR_Filter_p1.v ../../rtl/z_dsp/IIR_Filter_p1.v
../../rtl/z_dsp/IIR_Filter_p16.v ../../rtl/z_dsp/IIR_Filter_p8.v
../../rtl/z_dsp/CoefGen.sv ../../rtl/z_dsp/CoefGen.sv
../../rtl/z_dsp/diff_p.v ../../rtl/z_dsp/diff_p.v
../../rtl/z_dsp/Trunc.v ../../rtl/z_dsp/s2p_2.v
../../rtl/z_dsp/mult_x.v ../../rtl/z_dsp/Trunc.v
../../rtl/z_dsp/mult_C.v ../../rtl/z_dsp/mult_C.v
../../rtl/z_dsp/mult_real.v ../../rtl/z_dsp/mult_x.v
../../rtl/z_dsp/syncer.v ../../rtl/z_dsp/syncer.v
../../rtl/z_dsp/sirv_gnrl_dffs.v ../../rtl/z_dsp/sirv_gnrl_dffs.v
../../rtl/model/DW02_mult.v ../../rtl/model/DW02_mult.v
tb_z_dsp.v tb_z_dsp.v

View File

@ -1,329 +1,312 @@
`define SYNTHESIS `timescale 1 ns/1 ns
`timescale 1 ns/1 ns module TB();
module TB #(parameter COMPLEX = 1)();
reg [1 :0] source_mode; reg [1 :0] source_mode;
initial initial
begin begin
$fsdbDumpfile("TB.fsdb"); $fsdbDumpfile("TB.fsdb");
$fsdbDumpvars(0, TB); $fsdbDumpvars(0, TB);
$fsdbDumpMDA(); $fsdbDumpMDA();
// $srandom(417492050); // $srandom(417492050);
source_mode = 2'd3; //1 for rect;2 for random;3 from matlab source_mode = 2'd3; //1 for rect;2 for random;3 from matlab
end end
reg rstn; reg rstn;
reg [15:0] din_rect; reg [15:0] din_rect;
reg [ 3:0] vldi_coef; reg [ 5:0] vldi_coef;
reg vldi_data; reg vldi_data;
parameter CYCLE = 20; parameter CYCLE = 20;
reg clk; reg clk;
initial begin initial begin
clk = 0; clk = 0;
forever forever
#(CYCLE/2) #(CYCLE/2)
clk=~clk; clk=~clk;
end end
reg en;
reg signed [31:0] a_re [3:0]; reg signed [31:0] a_re [5:0];
reg signed [31:0] b_re [3:0]; reg signed [31:0] a_im [5:0];
`ifdef COMPLEX reg signed [31:0] b_re [5:0];
reg signed [31:0] a_im [3:0]; reg signed [31:0] b_im [5:0];
reg signed [31:0] b_im [3:0];
`endif initial begin
rstn = 0;
initial begin vldi_data <= 0;
rstn = 0; vldi_coef <= 0;
vldi_data <= 0; din_rect = 16'd0;
vldi_coef <= 0; a_re[3] <= 0;
din_rect = 16'd0; a_im[3] <= 0;
a_re[0] <= 0; b_re[3] <= 0;
b_re[0] <= 0; b_im[3] <= 0;
a_re[1] <= 0; a_re[4] <= 0;
b_re[1] <= 0; a_im[4] <= 0;
a_re[2] <= 0; b_re[4] <= 0;
b_re[2] <= 0; b_im[4] <= 0;
a_re[3] <= 0; a_re[5] <= 0;
b_re[3] <= 0; a_im[5] <= 0;
`ifdef COMPLEX b_re[5] <= 0;
a_im[0] <= 0; b_im[5] <= 0;
b_im[0] <= 0; repeat(3) @(posedge clk);
a_im[1] <= 0; vldi_coef[0] <= 1;
b_im[1] <= 0; rstn = 1;
a_im[2] <= 0; a_re[0] <= 55007237;
b_im[2] <= 0; a_im[0] <= 0;
a_im[3] <= 0; b_re[0] <= 2143083068;
b_im[3] <= 0; b_im[0] <= 0;
`endif @(posedge clk);
en <= 0; vldi_coef[0] <= 0;
repeat(3) @(posedge clk); a_re[0] <= 0;
vldi_coef[0] <= 1; a_im[0] <= 0;
rstn = 1; b_re[0] <= 0;
en <= 1; b_im[0] <= 0;
a_re[0] <= 55007237; repeat(8) @(posedge clk);
b_re[0] <= 2143083068; vldi_coef[1] <= 1;
@(posedge clk); rstn = 1;
vldi_coef[0] <= 0; a_re[1] <= 32690030;
a_re[0] <= 0; a_im[1] <= 0;
b_re[0] <= 0; b_re[1] <= 2145807236;
repeat(16) @(posedge clk); b_im[1] <= 0;
vldi_coef[1] <= 1; @(posedge clk);
rstn = 1; vldi_coef[1] <= 0;
a_re[1] <= 32690030; a_re[1] <= 0;
b_re[1] <= 2145807236; a_im[1] <= 0;
@(posedge clk); b_re[1] <= 0;
vldi_coef[1] <= 0; b_im[1] <= 0;
a_re[1] <= 0; repeat(8) @(posedge clk);
b_re[1] <= 0; vldi_coef[2] <= 1;
repeat(16) @(posedge clk); rstn = 1;
vldi_coef[2] <= 1; a_re[2] <= 429516;
rstn = 1; a_im[2] <= 0;
a_re[2] <= 429516; b_re[2] <= 2146812530;
b_re[2] <= 2146812530; b_im[2] <= 0;
@(posedge clk); @(posedge clk);
vldi_coef[2] <= 0; vldi_coef[2] <= 0;
a_re[2] <= 0; a_re[2] <= 0;
b_re[2] <= 0; a_im[2] <= 0;
repeat(108) @(posedge clk); b_re[2] <= 0;
vldi_data <= 1; b_im[2] <= 0;
// repeat(10000) @(posedge clk); repeat(108) @(posedge clk);
// vldi_data <= 0; vldi_data <= 1;
// repeat(10000) @(posedge clk);
end // vldi_data <= 0;
reg [21:0] cnt; end
always@(posedge clk or negedge rstn)
if(!rstn)
cnt <= 22'd0; reg [21:0] cnt;
else always@(posedge clk or negedge rstn)
cnt <= cnt + 22'd1; if(!rstn)
cnt <= 22'd0;
initial else
begin cnt <= cnt + 22'd1;
wait(cnt[16]==1'b1)
$finish(0); initial
end begin
wait(cnt[16]==1'b1)
reg vldi_data_r1; $finish(0);
always@(posedge clk or negedge rstn) end
if(!rstn)
vldi_data_r1 <= 1'b0; reg vldi_data_r1;
else always@(posedge clk or negedge rstn)
begin if(!rstn)
vldi_data_r1 <= vldi_data; vldi_data_r1 <= 1'b0;
end else
begin
always@(posedge clk or negedge rstn) vldi_data_r1 <= vldi_data;
if(!rstn) end
din_rect <= 22'd0;
else if(vldi_data) always@(posedge clk or negedge rstn)
begin if(!rstn)
din_rect <= 16'd30000; din_rect <= 22'd0;
end else if(vldi_data)
else begin
begin din_rect <= 16'd30000;
din_rect <= 16'd0; end
end else
begin
reg signed [15:0] random_in [0:15]; din_rect <= 16'd0;
end
always @(posedge clk or negedge rstn) begin
if (!rstn) begin reg signed [15:0] random_in [0:3];
for (int i = 0; i < 16; i = i + 1) begin
random_in[i] <= 16'd0; always @(posedge clk or negedge rstn) begin
end if (!rstn) begin
end for (int i = 0; i < 4; i = i + 1) begin
else if (vldi_data) begin random_in[i] <= 16'd0;
for (int i = 0; i < 16; i = i + 1) begin end
random_in[i] <= $urandom % 30000; end
end else if (vldi_data) begin
end for (int i = 0; i < 4; i = i + 1) begin
else begin random_in[i] <= $urandom % 30000;
for (int i = 0; i < 16; i = i + 1) begin end
random_in[i] <= 16'd0; end
end else begin
end for (int i = 0; i < 4; i = i + 1) begin
end random_in[i] <= 16'd0;
end
integer file[15:0]; end
reg [15:0] data[15:0]; end
integer status[15:0];
reg [15:0] reg_array[15:0]; integer file[3:0];
string filenames[15:0]; reg [15:0] data[3:0];
initial begin integer status[3:0];
if(source_mode == 3) begin reg [15:0] reg_array[3:0];
// string filenames[0:3] = {"in0_matlab.dat", "in1_matlab.dat", "in2_matlab.dat", "in3_matlab.dat"};
for (int i = 0; i < 16; i++) begin initial begin
$sformat(filenames[i], "in%0d_matlab.dat", i); if(source_mode == 3) begin
end string filenames[0:3] = {"in0_matlab.dat", "in1_matlab.dat", "in2_matlab.dat", "in3_matlab.dat"};
for (int i = 0; i < 16; i = i + 1) begin for (int i = 0; i < 4; i = i + 1) begin
file[i] = $fopen(filenames[i], "r"); file[i] = $fopen(filenames[i], "r");
if (file[i] == 0) begin if (file[i] == 0) begin
$display("Failed to open file: %s", filenames[i]); $display("Failed to open file: %s", filenames[i]);
$finish; $finish;
end end
end end
end end
end end
always @(posedge clk or negedge rstn) begin always @(posedge clk or negedge rstn) begin
if (!rstn) begin if (!rstn) begin
for (int i = 0; i < 16; i = i + 1) begin for (int i = 0; i < 4; i = i + 1) begin
reg_array[i] <= 16'd0; reg_array[i] <= 16'd0;
end end
end else if(vldi_data && source_mode == 3) begin end else if(vldi_data && source_mode == 3) begin
for (int i = 0; i < 16; i = i + 1) begin for (int i = 0; i < 4; i = i + 1) begin
status[i] = $fscanf(file[i], "%d\n", data[i]); status[i] = $fscanf(file[i], "%d\n", data[i]);
if (status[i] == 1 ) begin if (status[i] == 1 ) begin
reg_array[i] <= data[i]; reg_array[i] <= data[i];
end end
else begin else begin
reg_array[i] <= 16'd0; reg_array[i] <= 16'd0;
vldi_data <= 0; vldi_data <= 0;
end end
end end
end end
end end
reg signed [15:0] iir_in[15:0]; reg signed [15:0] iir_in[3:0];
always @(*) always @(*)
case(source_mode) case(source_mode)
2'b01 : begin 2'b01 : begin
for (int i = 0; i < 16; i = i + 1) begin for (int i = 0; i < 4; i = i + 1) begin
iir_in[i] = din_rect; iir_in[i] = din_rect;
end end
end end
2'b10 : begin 2'b10 : begin
for (int i = 0; i < 16; i = i + 1) begin for (int i = 0; i < 4; i = i + 1) begin
iir_in[i] = random_in[i]; iir_in[i] = random_in[i];
end end
end end
2'b11 : begin 2'b11 : begin
for (int i = 0; i < 16; i = i + 1) begin for (int i = 0; i < 4; i = i + 1) begin
iir_in[i] = reg_array[i]; iir_in[i] = reg_array[i];
end end
end end
endcase endcase
wire [1:0] intp_mode; wire [1:0] intp_mode;
assign intp_mode = 2'b10; assign intp_mode = 2'b10;
wire [1:0] dac_mode_sel; wire [1:0] dac_mode_sel;
assign dac_mode_sel = 2'b00; assign dac_mode_sel = 2'b00;
wire tc_bypass; wire tc_bypass;
wire vldo; wire vldo;
assign tc_bypass = 1'b0; assign tc_bypass = 1'b0;
//always @(posedge clk or negedge rstn)begin reg en;
// if(rstn==1'b0)begin always @(posedge clk or negedge rstn)begin
// en <= 1; if(rstn==1'b0)begin
// end en <= 1;
// else begin end
// en <= ~en; else begin
// end en <= ~en;
//end end
wire signed [15:0] dout_p[15:0]; end
wire signed [15:0] dout_p[7:0];
z_dsp u_z_dsp(
.rstn ( rstn ), z_dsp inst_z_dsp(
.clk ( clk ), .rstn (rstn ),
.en ( en ), .clk (clk ),
.vldi_coef ( vldi_coef ), .en (en ),
.vldi_data ( vldi_data && vldi_data_r1 ), // .tc_bypass (tc_bypass ),
.din0 ( iir_in[0] ), .vldi_coef (vldi_coef ),
.din1 ( iir_in[1] ), .vldi_data (vldi_data_r1 ),
.din2 ( iir_in[2] ), // .intp_mode (intp_mode ),
.din3 ( iir_in[3] ), // .dac_mode_sel (dac_mode_sel ),
.din4 ( iir_in[4] ), .din0 (iir_in[0] ),
.din5 ( iir_in[5] ), .din1 (iir_in[1] ),
.din6 ( iir_in[6] ), .din2 (iir_in[2] ),
.din7 ( iir_in[7] ), .din3 (iir_in[3] ),
.din8 ( iir_in[8] ), .a0_re (a_re[0] ),
.din9 ( iir_in[9] ), .a0_im (a_im[0] ),
.dina ( iir_in[10] ), .b0_re (b_re[0] ),
.dinb ( iir_in[11] ), .b0_im (b_im[0] ),
.dinc ( iir_in[12] ), .a1_re (a_re[1] ),
.dind ( iir_in[13] ), .a1_im (a_im[1] ),
.dine ( iir_in[14] ), .b1_re (b_re[1] ),
.dinf ( iir_in[15] ), .b1_im (b_im[1] ),
.a0_re ( a_re[0] ), .a2_re (a_re[2] ),
.b0_re ( b_re[0] ), .a2_im (a_im[2] ),
.a1_re ( a_re[1] ), .b2_re (b_re[2] ),
.b1_re ( b_re[1] ), .b2_im (b_im[2] ),
.a2_re ( a_re[2] ), .a3_re (a_re[3] ),
.b2_re ( b_re[2] ), .a3_im (a_im[3] ),
.a3_re ( a_re[3] ), .b3_re (b_re[3] ),
.b3_re ( b_re[3] ), .b3_im (b_im[3] ),
`ifdef COMPLEX .a4_re (a_re[4] ),
.a0_im ( a_im[0] ), .a4_im (a_im[4] ),
.b0_im ( b_im[0] ), .b4_re (b_re[4] ),
.a1_im ( a_im[1] ), .b4_im (b_im[4] ),
.b1_im ( b_im[1] ), .a5_re (a_re[5] ),
.a2_im ( a_im[2] ), .a5_im (a_im[5] ),
.b2_im ( b_im[2] ), .b5_re (b_re[5] ),
.a3_im ( a_im[3] ), .b5_im (b_im[5] ),
.b3_im ( b_im[3] ), .dout0 (dout_p[0] ),
`endif .dout1 (dout_p[1] ),
.dout0 ( dout_p[0] ), .dout2 (dout_p[2] ),
.dout1 ( dout_p[1] ), .dout3 (dout_p[3] ),
.dout2 ( dout_p[2] ), .vldo ( vldo )
.dout3 ( dout_p[3] ), );
.dout4 ( dout_p[4] ),
.dout5 ( dout_p[5] ),
.dout6 ( dout_p[6] ), integer signed In_fid[0:3];
.dout7 ( dout_p[7] ), integer signed dout_fid[0:7];
.dout8 ( dout_p[8] ), string filenames_in[0:3] = {"in0.dat", "in1.dat", "in2.dat", "in3.dat"};
.dout9 ( dout_p[9] ), string filenames_dout[0:7] = {"dout0.dat", "dout1.dat", "dout2.dat", "dout3.dat", "dout4.dat", "dout5.dat", "dout6.dat", "dout7.dat"};
.douta ( dout_p[10] ),
.doutb ( dout_p[11] ), initial begin
.doutc ( dout_p[12] ), #0;
.doutd ( dout_p[13] ), for (int i = 0; i < 4; i = i + 1) begin
.doute ( dout_p[14] ), In_fid[i] = $fopen(filenames_in[i]);
.doutf ( dout_p[15] ), end
.vldo ( vldo ) for (int i = 0; i < 4; i = i + 1) begin
); dout_fid[i] = $fopen(filenames_dout[i]);
end
//integer signed In_fid[0:3]; end
integer signed dout_fid[0:15];
//string filenames_in[0:3] = {"in0.dat", "in1.dat", "in2.dat", "in3.dat"}; always @(posedge clk) begin
string filenames_dout[0:15] = { if (vldi_data_r1) begin
"dout0.dat", "dout1.dat", "dout2.dat", "dout3.dat", for (int i = 0; i < 4; i = i + 1) begin
"dout4.dat", "dout5.dat", "dout6.dat", "dout7.dat", $fwrite(In_fid[i], "%d\n", $signed(iir_in[i]));
"dout8.dat", "dout9.dat", "dout10.dat", "dout11.dat", end
"dout12.dat", "dout13.dat", "dout14.dat", "dout15.dat" end
}; end
initial begin
#0; always @(posedge clk) begin
// for (int i = 0; i < 4; i = i + 1) begin if (vldo) begin
// In_fid[i] = $fopen(filenames_in[i]); for (int i = 0; i < 4; i = i + 1) begin
// end $fwrite(dout_fid[i], "%d\n", $signed(dout_p[i]));
for (int i = 0; i < 16; i = i + 1) begin end
dout_fid[i] = $fopen(filenames_dout[i]); end
end end
end endmodule
//always @(posedge clk) begin
// if (vldi_data_r1) begin
// for (int i = 0; i < 4; i = i + 1) begin
// $fwrite(In_fid[i], "%d\n", $signed(iir_in[i]));
// end
// end
//end
always @(posedge clk) begin
if (vldo) begin
for (int i = 0; i < 16; i = i + 1) begin
$fwrite(dout_fid[i], "%d\n", $signed(dout_p[i]));
end
end
end
endmodule