Line 103... |
Line 103... |
"module\tqtrstage(i_clk, i_rst, i_ce, i_sync, i_data, o_data, o_sync);\n"
|
"module\tqtrstage(i_clk, i_rst, i_ce, i_sync, i_data, o_data, o_sync);\n"
|
"\tparameter IWIDTH=16, OWIDTH=IWIDTH+1;\n"
|
"\tparameter IWIDTH=16, OWIDTH=IWIDTH+1;\n"
|
"\t// Parameters specific to the core that should be changed when this\n"
|
"\t// Parameters specific to the core that should be changed when this\n"
|
"\t// core is built ... Note that the minimum LGSPAN is 2. Smaller \n"
|
"\t// core is built ... Note that the minimum LGSPAN is 2. Smaller \n"
|
"\t// spans must use the fftdoubles stage.\n"
|
"\t// spans must use the fftdoubles stage.\n"
|
"\tparameter\tLGWIDTH=8, ODD=0, INVERSE=0,SHIFT=0,ROUND=0;\n"
|
"\tparameter\tLGWIDTH=8, ODD=0, INVERSE=0,SHIFT=0,ROUND=1;\n"
|
"\tinput\t i_clk, i_rst, i_ce, i_sync;\n"
|
"\tinput\t i_clk, i_rst, i_ce, i_sync;\n"
|
"\tinput\t [(2*IWIDTH-1):0] i_data;\n"
|
"\tinput\t [(2*IWIDTH-1):0] i_data;\n"
|
"\toutput\treg [(2*OWIDTH-1):0] o_data;\n"
|
"\toutput\treg [(2*OWIDTH-1):0] o_data;\n"
|
"\toutput\treg o_sync;\n"
|
"\toutput\treg o_sync;\n"
|
"\t\n");
|
"\t\n");
|
Line 260... |
Line 260... |
"//\n", prjname, creator);
|
"//\n", prjname, creator);
|
|
|
fprintf(fp, "%s", cpyleft);
|
fprintf(fp, "%s", cpyleft);
|
fprintf(fp,
|
fprintf(fp,
|
"module\tdblstage(i_clk, i_rst, i_ce, i_sync, i_left, i_right, o_left, o_right, o_sync);\n"
|
"module\tdblstage(i_clk, i_rst, i_ce, i_sync, i_left, i_right, o_left, o_right, o_sync);\n"
|
"\tparameter\tIWIDTH=16,OWIDTH=IWIDTH+1, SHIFT=0;\n"
|
"\tparameter\tIWIDTH=16,OWIDTH=IWIDTH+1, SHIFT=0;\n" // ROUND=1
|
"\tinput\t\ti_clk, i_rst, i_ce, i_sync;\n"
|
"\tinput\t\ti_clk, i_rst, i_ce, i_sync;\n"
|
"\tinput\t\t[(2*IWIDTH-1):0]\ti_left, i_right;\n"
|
"\tinput\t\t[(2*IWIDTH-1):0]\ti_left, i_right;\n"
|
"\toutput\twire\t[(2*OWIDTH-1):0]\to_left, o_right;\n"
|
"\toutput\twire\t[(2*OWIDTH-1):0]\to_left, o_right;\n"
|
"\toutput\treg\t\t\to_sync;\n"
|
"\toutput\treg\t\t\to_sync;\n"
|
"\n"
|
"\n"
|
Line 274... |
Line 274... |
"\tassign\ti_in_1r = i_right[(2*IWIDTH-1):(IWIDTH)]; \n"
|
"\tassign\ti_in_1r = i_right[(2*IWIDTH-1):(IWIDTH)]; \n"
|
"\tassign\ti_in_1i = i_right[(IWIDTH-1):0]; \n"
|
"\tassign\ti_in_1i = i_right[(IWIDTH-1):0]; \n"
|
"\twire\t[(OWIDTH-1):0]\t\to_out_0r, o_out_0i,\n"
|
"\twire\t[(OWIDTH-1):0]\t\to_out_0r, o_out_0i,\n"
|
"\t\t\t\t\to_out_1r, o_out_1i;\n"
|
"\t\t\t\t\to_out_1r, o_out_1i;\n"
|
"\n"
|
"\n"
|
|
"\n"
|
|
// "\t// Handle a potential rounding situation, when IWIDTH=OWIDTH.\n"
|
|
//"\n"
|
|
// "\twire\tsigned\t[(IWIDTH-1):0]\trnd;\n"
|
|
//"\n"
|
|
// "\tgenerate\n"
|
|
// "\tif ((ROUND==1)&&(IWIDTH==OWIDTH))\n"
|
|
// "\t\tassign rnd = { {(IWIDTH-1){1'b0}}, 1'b1 };\n"
|
|
// "\telse\n"
|
|
// "\t\tassign rnd = { {(IWIDTH){1'b0}} };\n"
|
|
// "\tendgenerate\n"
|
|
"\n"
|
"\t// Don't forget that we accumulate a bit by adding two values\n"
|
"\t// Don't forget that we accumulate a bit by adding two values\n"
|
"\t// together. Therefore our intermediate value must have one more\n"
|
"\t// together. Therefore our intermediate value must have one more\n"
|
"\t// bit than the two originals.\n"
|
"\t// bit than the two originals.\n"
|
"\treg\t[IWIDTH:0]\tout_0r, out_0i, out_1r, out_1i;\n"
|
"\treg\t[IWIDTH:0]\tout_0r, out_0i, out_1r, out_1i;\n"
|
"\n"
|
"\n"
|
Line 288... |
Line 300... |
"\t\t\twait_for_sync <= 1'b1;\n"
|
"\t\t\twait_for_sync <= 1'b1;\n"
|
"\t\telse if ((i_ce)&&((~wait_for_sync)||(i_sync)))\n"
|
"\t\telse if ((i_ce)&&((~wait_for_sync)||(i_sync)))\n"
|
"\t\tbegin\n"
|
"\t\tbegin\n"
|
"\t\t\twait_for_sync <= 1'b0;\n"
|
"\t\t\twait_for_sync <= 1'b0;\n"
|
"\t\t\t//\n"
|
"\t\t\t//\n"
|
"\t\t\tout_0r <= i_in_0r + i_in_1r;\n"
|
"\t\t\tout_0r <= i_in_0r + i_in_1r;\n" // + rnd
|
"\t\t\tout_0i <= i_in_0i + i_in_1i;\n"
|
"\t\t\tout_0i <= i_in_0i + i_in_1i;\n" // + rnd
|
"\t\t\t//\n"
|
"\t\t\t//\n"
|
"\t\t\tout_1r <= i_in_0r - i_in_1r;\n"
|
"\t\t\tout_1r <= i_in_0r - i_in_1r;\n" // + rnd
|
"\t\t\tout_1i <= i_in_0i - i_in_1i;\n"
|
"\t\t\tout_1i <= i_in_0i - i_in_1i;\n" // + rnd
|
"\t\t\t//\n"
|
"\t\t\t//\n"
|
"\t\t\to_sync <= i_sync;\n"
|
"\t\t\to_sync <= i_sync;\n"
|
"\t\tend\n"
|
"\t\tend\n"
|
"\n"
|
"\n"
|
"\t// Now, if the master control program doesn't want to keep all of\n"
|
"\t// Now, if the master control program doesn't want to keep all of\n"
|
Line 632... |
Line 644... |
"\t\to_left, o_right, o_aux);\n"
|
"\t\to_left, o_right, o_aux);\n"
|
"\t// Public changeable parameters ...\n"
|
"\t// Public changeable parameters ...\n"
|
"\tparameter IWIDTH=%d,CWIDTH=IWIDTH+%d,OWIDTH=IWIDTH+1;\n"
|
"\tparameter IWIDTH=%d,CWIDTH=IWIDTH+%d,OWIDTH=IWIDTH+1;\n"
|
"\t// Parameters specific to the core that should not be changed.\n"
|
"\t// Parameters specific to the core that should not be changed.\n"
|
"\tparameter MPYDELAY=%d'd%d, // (IWIDTH+1 < CWIDTH)?(IWIDTH+4):(CWIDTH+3),\n"
|
"\tparameter MPYDELAY=%d'd%d, // (IWIDTH+1 < CWIDTH)?(IWIDTH+4):(CWIDTH+3),\n"
|
"\t\t\tSHIFT=0, ROUND=0;\n"
|
"\t\t\tSHIFT=0, ROUND=1;\n"
|
"\t// The LGDELAY should be the base two log of the MPYDELAY. If\n"
|
"\t// The LGDELAY should be the base two log of the MPYDELAY. If\n"
|
"\t// this value is fractional, then round up to the nearest\n"
|
"\t// this value is fractional, then round up to the nearest\n"
|
"\t// integer: LGDELAY=ceil(log(MPYDELAY)/log(2));\n"
|
"\t// integer: LGDELAY=ceil(log(MPYDELAY)/log(2));\n"
|
"\tparameter\tLGDELAY=%d;\n"
|
"\tparameter\tLGDELAY=%d;\n"
|
"\tinput\t\ti_clk, i_rst, i_ce;\n"
|
"\tinput\t\ti_clk, i_rst, i_ce;\n"
|
Line 798... |
Line 810... |
"\treg\tsigned\t[(CWIDTH+IWIDTH+3-1):0] b_left_r, b_left_i,\n"
|
"\treg\tsigned\t[(CWIDTH+IWIDTH+3-1):0] b_left_r, b_left_i,\n"
|
"\t\t\t\t\t\tb_right_r, b_right_i;\n"
|
"\t\t\t\t\t\tb_right_r, b_right_i;\n"
|
"\treg\tsigned\t[(CWIDTH+IWIDTH+3-1):0] mpy_r, mpy_i;\n"
|
"\treg\tsigned\t[(CWIDTH+IWIDTH+3-1):0] mpy_r, mpy_i;\n"
|
"\treg\tsigned\t[(CWIDTH+IWIDTH+3-1):0] rnd;\n"
|
"\treg\tsigned\t[(CWIDTH+IWIDTH+3-1):0] rnd;\n"
|
"\tgenerate\n"
|
"\tgenerate\n"
|
"\tif ((~ROUND)||(CWIDTH+IWIDTH-OWIDTH-SHIFT<1))\n"
|
"\tif ((ROUND==0)||(CWIDTH+IWIDTH-OWIDTH-SHIFT<1))\n"
|
"\t\tassign rnd = ({(CWIDTH+IWIDTH+3){1'b0}});\n"
|
"\t\tassign rnd = ({(CWIDTH+IWIDTH+3){1'b0}});\n"
|
"\telse\n"
|
"\telse\n"
|
"\t\tassign rnd = ({ {(OWIDTH+3+SHIFT){1'b0}},1'b1,\n"
|
"\t\tassign rnd = ({ {(OWIDTH+4+SHIFT){1'b0}},1'b1,\n"
|
"\t\t\t\t{(CWIDTH+IWIDTH-OWIDTH-SHIFT-1){1'b0}} });\n"
|
"\t\t\t\t{((IWIDTH+CWIDTH+3)-(OWIDTH+SHIFT+5)){1'b0}} });\n"
|
"\tendgenerate\n"
|
"\tendgenerate\n"
|
"\n");
|
"\n");
|
fprintf(fp,
|
fprintf(fp,
|
"\talways @(posedge i_clk)\n"
|
"\talways @(posedge i_clk)\n"
|
"\t\tif (i_ce)\n"
|
"\t\tif (i_ce)\n"
|