OpenCores
URL https://opencores.org/ocsvn/dblclockfft/dblclockfft/trunk

Subversion Repositories dblclockfft

[/] [dblclockfft/] [trunk/] [sw/] [fftgen.cpp] - Diff between revs 36 and 37

Show entire file | Details | Blame | View Log

Rev 36 Rev 37
Line 38... Line 38...
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
// for more details.
//
//
// You should have received a copy of the GNU General Public License along
// You should have received a copy of the GNU General Public License along
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
// with this program.  (It's in the $(ROOT)/doc directory.  Run make with no
// target there if the PDF file isn't present.)  If not, see
// target there if the PDF file isn't present.)  If not, see
// <http://www.gnu.org/licenses/> for a copy.
// <http://www.gnu.org/licenses/> for a copy.
//
//
// License:     GPL, v3, as defined and found on www.gnu.org,
// License:     GPL, v3, as defined and found on www.gnu.org,
//              http://www.gnu.org/licenses/gpl.html
//              http://www.gnu.org/licenses/gpl.html
Line 148... Line 148...
        "\tparameter    IWIDTH=%d, OWIDTH=IWIDTH+1;\n"
        "\tparameter    IWIDTH=%d, 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=%d, ODD=0, INVERSE=0,SHIFT=0;\n"
        "\tparameter\tLGWIDTH=%d, ODD=0, INVERSE=0,SHIFT=0;\n"
        "\tinput\t                              i_clk, %s, i_ce, i_sync;\n"
        "\tinput\twire                          i_clk, %s, i_ce, i_sync;\n"
        "\tinput\t      [(2*IWIDTH-1):0]        i_data;\n"
        "\tinput\twire  [(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", (dbg)?"_dbg":"",
        "\t\n", (dbg)?"_dbg":"",
        resetw.c_str(),
        resetw.c_str(),
        (dbg)?", o_dbg":"", TST_QTRSTAGE_IWIDTH,
        (dbg)?", o_dbg":"", TST_QTRSTAGE_IWIDTH,
Line 400... Line 400...
 
 
        fprintf(fp,
        fprintf(fp,
"module\tqtrstage%s(i_clk, %s, i_ce, i_sync, i_data, o_data, o_sync%s);\n"
"module\tqtrstage%s(i_clk, %s, i_ce, i_sync, i_data, o_data, o_sync%s);\n"
        "\tparameter    IWIDTH=%d, OWIDTH=IWIDTH+1;\n"
        "\tparameter    IWIDTH=%d, OWIDTH=IWIDTH+1;\n"
        "\tparameter\tLGWIDTH=%d, INVERSE=0,SHIFT=0;\n"
        "\tparameter\tLGWIDTH=%d, INVERSE=0,SHIFT=0;\n"
        "\tinput\t                              i_clk, %s, i_ce, i_sync;\n"
        "\tinput\twire                          i_clk, %s, i_ce, i_sync;\n"
        "\tinput\t      [(2*IWIDTH-1):0]        i_data;\n"
        "\tinput\twire  [(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", (dbg)?"_dbg":"", resetw.c_str(),
                "\t\n", (dbg)?"_dbg":"", resetw.c_str(),
                (dbg)?", o_dbg":"", TST_QTRSTAGE_IWIDTH,
                (dbg)?", o_dbg":"", TST_QTRSTAGE_IWIDTH,
                TST_QTRSTAGE_LGWIDTH, resetw.c_str());
                TST_QTRSTAGE_LGWIDTH, resetw.c_str());
Line 761... Line 761...
        fprintf(fp, "//\n//\n`default_nettype\tnone\n//\n");
        fprintf(fp, "//\n//\n`default_nettype\tnone\n//\n");
 
 
        fprintf(fp,
        fprintf(fp,
"module laststage(i_clk, %s, i_ce, i_sync, i_val, o_val, o_sync);\n"
"module laststage(i_clk, %s, i_ce, i_sync, i_val, o_val, o_sync);\n"
"       parameter       IWIDTH=16,OWIDTH=IWIDTH+1, SHIFT=0;\n"
"       parameter       IWIDTH=16,OWIDTH=IWIDTH+1, SHIFT=0;\n"
"       input                                   i_clk, %s, i_ce, i_sync;\n"
"       input   wire                            i_clk, %s, i_ce, i_sync;\n"
"       input           [(2*IWIDTH-1):0]        i_val;\n"
"       input   wire    [(2*IWIDTH-1):0]        i_val;\n"
"       output  wire    [(2*OWIDTH-1):0]        o_val;\n"
"       output  wire    [(2*OWIDTH-1):0]        o_val;\n"
"       output  reg                             o_sync;\n\n",
"       output  reg                             o_sync;\n\n",
                resetw.c_str(), resetw.c_str());
                resetw.c_str(), resetw.c_str());
 
 
        fprintf(fp,
        fprintf(fp,
Line 990... Line 990...
"\t-p <nmpy>  Sets the number of hardware multiplies (DSPs) to use, versus\n"
"\t-p <nmpy>  Sets the number of hardware multiplies (DSPs) to use, versus\n"
"\t\tshift-add emulation.  The default is not to use any hardware\n"
"\t\tshift-add emulation.  The default is not to use any hardware\n"
"\t\tmultipliers.\n"
"\t\tmultipliers.\n"
"\t-r\tBuild a real-FFT at four input points per sample, rather than a\n"
"\t-r\tBuild a real-FFT at four input points per sample, rather than a\n"
"\t\tcomplex FFT.  (Default is a Complex FFT.)\n"
"\t\tcomplex FFT.  (Default is a Complex FFT.)\n"
 
"\t\tThis option is a place-holder.  The real-FFT has not (yet) been\n"
 
"\t\timplemented.\n"
"\t-s\tSkip the final bit reversal stage.  This is useful in\n"
"\t-s\tSkip the final bit reversal stage.  This is useful in\n"
"\t\talgorithms that need to apply a filter without needing to do\n"
"\t\talgorithms that need to apply a filter without needing to do\n"
"\t\tbin shifting, as these algorithms can, with this option, just\n"
"\t\tbin shifting, as these algorithms can, with this option, just\n"
"\t\tmultiply by a bit reversed correlation sequence and then\n"
"\t\tmultiply by a bit reversed correlation sequence and then\n"
"\t\tinverse FFT the (still bit reversed) result.  (You would need\n"
"\t\tinverse FFT the (still bit reversed) result.  (You would need\n"
Line 1020... Line 1022...
                        nummpy=DEF_NMPY, nmpypstage=6, mpy_stages;
                        nummpy=DEF_NMPY, nmpypstage=6, mpy_stages;
        int     nbitsout, maxbitsout = -1, xtrapbits=DEF_XTRAPBITS, ckpce = 0;
        int     nbitsout, maxbitsout = -1, xtrapbits=DEF_XTRAPBITS, ckpce = 0;
        const char *EMPTYSTR = "";
        const char *EMPTYSTR = "";
        bool    bitreverse = true, inverse=false,
        bool    bitreverse = true, inverse=false,
                verbose_flag = false,
                verbose_flag = false,
                single_clock = false,
                single_clock = true,
                real_fft = false,
                real_fft = false,
                async_reset = false;
                async_reset = false;
        FILE    *vmain;
        FILE    *vmain;
        std::string     coredir = DEF_COREDIR, cmdline = "", hdrname = "";
        std::string     coredir = DEF_COREDIR, cmdline = "", hdrname = "";
        ROUND_T rounding = RND_CONVERGENT;
        ROUND_T rounding = RND_CONVERGENT;
Line 1417... Line 1419...
"// Arguments:\tThis file was computer generated using the following command\n"
"// Arguments:\tThis file was computer generated using the following command\n"
"//\t\tline:\n"
"//\t\tline:\n"
"//\n");
"//\n");
        fprintf(vmain, "//\t\t%% %s\n", cmdline.c_str());
        fprintf(vmain, "//\t\t%% %s\n", cmdline.c_str());
        fprintf(vmain, "//\n");
        fprintf(vmain, "//\n");
 
        fprintf(vmain, "//\tThis core will use hardware accelerated multiplies (DSPs)\n"
 
                "//\tfor %d of the %d stages\n", mpy_stages, lgval(fftsize));
 
        fprintf(vmain, "//\n");
        fprintf(vmain, "%s", creator);
        fprintf(vmain, "%s", creator);
        fprintf(vmain, "//\n");
        fprintf(vmain, "//\n");
        fprintf(vmain, "%s", cpyleft);
        fprintf(vmain, "%s", cpyleft);
        fprintf(vmain, "//\n//\n`default_nettype\tnone\n//\n");
        fprintf(vmain, "//\n//\n`default_nettype\tnone\n//\n");
 
 
Line 1439... Line 1444...
        } else {
        } else {
                fprintf(vmain, "\t\ti_left, i_right,\n");
                fprintf(vmain, "\t\ti_left, i_right,\n");
                fprintf(vmain, "\t\to_left, o_right, o_sync%s);\n",
                fprintf(vmain, "\t\to_left, o_right, o_sync%s);\n",
                        (dbg)?", o_dbg":"");
                        (dbg)?", o_dbg":"");
        }
        }
        fprintf(vmain, "\tparameter\tIWIDTH=%d, OWIDTH=%d, LGWIDTH=%d;\n\t//\n", nbitsin, nbitsout, lgsize);
        fprintf(vmain,
 
        "\t// The bit-width of the input, IWIDTH, output, OWIDTH, and the log\n"
 
        "\t// of the FFT size.  These are localparams, rather than parameters,\n"
 
        "\t// because once the core has been generated, they can no longer be\n"
 
        "\t// changed.  (These values can be adjusted by running the core\n"
 
        "\t// generator again.)  The reason is simply that these values have\n"
 
        "\t// been hardwired into the core at several places.\n");
 
        fprintf(vmain, "\tlocalparam\tIWIDTH=%d, OWIDTH=%d, LGWIDTH=%d;\n\t//\n", nbitsin, nbitsout, lgsize);
        assert(lgsize > 0);
        assert(lgsize > 0);
        fprintf(vmain, "\tinput\t\t\t\t\ti_clk, %s, i_ce;\n\t//\n",
        fprintf(vmain, "\tinput\twire\t\t\t\ti_clk, %s, i_ce;\n\t//\n",
                resetw.c_str());
                resetw.c_str());
        if (single_clock) {
        if (single_clock) {
        fprintf(vmain, "\tinput\t\t[(2*IWIDTH-1):0]\ti_sample;\n");
        fprintf(vmain, "\tinput\twire\t[(2*IWIDTH-1):0]\ti_sample;\n");
        fprintf(vmain, "\toutput\treg\t[(2*OWIDTH-1):0]\to_result;\n");
        fprintf(vmain, "\toutput\treg\t[(2*OWIDTH-1):0]\to_result;\n");
        } else {
        } else {
        fprintf(vmain, "\tinput\t\t[(2*IWIDTH-1):0]\ti_left, i_right;\n");
        fprintf(vmain, "\tinput\twire\t[(2*IWIDTH-1):0]\ti_left, i_right;\n");
        fprintf(vmain, "\toutput\treg\t[(2*OWIDTH-1):0]\to_left, o_right;\n");
        fprintf(vmain, "\toutput\treg\t[(2*OWIDTH-1):0]\to_left, o_right;\n");
        }
        }
        fprintf(vmain, "\toutput\treg\t\t\t\to_sync;\n");
        fprintf(vmain, "\toutput\treg\t\t\t\to_sync;\n");
        if (dbg)
        if (dbg)
                fprintf(vmain, "\toutput\twire\t[33:0]\t\to_dbg;\n");
                fprintf(vmain, "\toutput\twire\t[33:0]\t\to_dbg;\n");
Line 1498... Line 1510...
 
 
                        // Last two stages are always non-multiply stages
                        // Last two stages are always non-multiply stages
                        // since the multiplies can be done by adds
                        // since the multiplies can be done by adds
                        mpystage = ((lgtmp-2) <= mpy_stages);
                        mpystage = ((lgtmp-2) <= mpy_stages);
 
 
 
                        fprintf(vmain, "\n\n");
                        if (mpystage)
                        if (mpystage)
                                fprintf(vmain, "\t// A hardware optimized FFT stage\n");
                                fprintf(vmain, "\t// A hardware optimized FFT stage\n");
                        fprintf(vmain, "\n\n");
 
                        fprintf(vmain, "\twire\t\tw_s%d;\n", fftsize);
                        fprintf(vmain, "\twire\t\tw_s%d;\n", fftsize);
                        if (single_clock) {
                        if (single_clock) {
                                fprintf(vmain, "\twire\t[%d:0]\tw_d%d;\n", 2*(obits+xtrapbits)-1, fftsize);
                                fprintf(vmain, "\twire\t[%d:0]\tw_d%d;\n", 2*(obits+xtrapbits)-1, fftsize);
                                cmem = gen_coeff_fname(EMPTYSTR, fftsize, 1, 0, inverse);
                                cmem = gen_coeff_fname(coredir.c_str(), fftsize, 1, 0, inverse);
                                cmemfp = gen_coeff_open(cmem.c_str());
                                cmemfp = gen_coeff_open(cmem.c_str());
                                gen_coeffs(cmemfp, fftsize,  nbitsin+xtracbits, 1, 0, inverse);
                                gen_coeffs(cmemfp, fftsize,  nbitsin+xtracbits, 1, 0, inverse);
                                fprintf(vmain, "\tfftstage%s\t#(IWIDTH,IWIDTH+%d,%d,%d,%d,0,\n\t\t\t%d, %d, \"%s\")\n\t\tstage_%d(i_clk, %s, i_ce,\n",
                                cmem = gen_coeff_fname(EMPTYSTR, fftsize, 1, 0, inverse);
 
                                fprintf(vmain, "\tfftstage%s\t#(IWIDTH,IWIDTH+%d,%d,%d,0,\n\t\t\t%d, %d, \"%s\")\n\t\tstage_%d(i_clk, %s, i_ce,\n",
                                        ((dbg)&&(dbgstage == fftsize))?"_dbg":"",
                                        ((dbg)&&(dbgstage == fftsize))?"_dbg":"",
                                        xtracbits, obits+xtrapbits,
                                        xtracbits, obits+xtrapbits,
                                        lgsize, lgtmp-1,
                                        lgtmp-1, (mpystage)?1:0,
                                        (mpystage)?1:0,
 
                                        ckpce, cmem.c_str(),
                                        ckpce, cmem.c_str(),
                                        fftsize, resetw.c_str());
                                        fftsize, resetw.c_str());
                                fprintf(vmain, "\t\t\t(%s%s), i_sample, w_d%d, w_s%d%s);\n",
                                fprintf(vmain, "\t\t\t(%s%s), i_sample, w_d%d, w_s%d%s);\n",
                                        (async_reset)?"":"!", resetw.c_str(),
                                        (async_reset)?"":"!", resetw.c_str(),
                                        fftsize, fftsize,
                                        fftsize, fftsize,
                                        ((dbg)&&(dbgstage == fftsize))
                                        ((dbg)&&(dbgstage == fftsize))
                                                ? ", o_dbg":"");
                                                ? ", o_dbg":"");
                        } else {
                        } else {
                                fprintf(vmain, "\t// verilator lint_off UNUSED\n\twire\t\tw_os%d;\n\t// verilator lint_on  UNUSED\n", fftsize);
                                fprintf(vmain, "\t// verilator lint_off UNUSED\n\twire\t\tw_os%d;\n\t// verilator lint_on  UNUSED\n", fftsize);
                                fprintf(vmain, "\twire\t[%d:0]\tw_e%d, w_o%d;\n", 2*(obits+xtrapbits)-1, fftsize, fftsize);
                                fprintf(vmain, "\twire\t[%d:0]\tw_e%d, w_o%d;\n", 2*(obits+xtrapbits)-1, fftsize, fftsize);
                                cmem = gen_coeff_fname(EMPTYSTR, fftsize, 2, 0, inverse);
                                cmem = gen_coeff_fname(coredir.c_str(), fftsize, 2, 0, inverse);
                                cmemfp = gen_coeff_open(cmem.c_str());
                                cmemfp = gen_coeff_open(cmem.c_str());
                                gen_coeffs(cmemfp, fftsize,  nbitsin+xtracbits, 2, 0, inverse);
                                gen_coeffs(cmemfp, fftsize,  nbitsin+xtracbits, 2, 0, inverse);
                                fprintf(vmain, "\tfftstage%s\t#(IWIDTH,IWIDTH+%d,%d,%d,%d,0,\n\t\t\t%d, %d, \"%s\")\n\t\tstage_e%d(i_clk, %s, i_ce,\n",
                                cmem = gen_coeff_fname(EMPTYSTR, fftsize, 2, 0, inverse);
 
                                fprintf(vmain, "\tfftstage%s\t#(IWIDTH,IWIDTH+%d,%d,%d,0,\n\t\t\t%d, %d, \"%s\")\n\t\tstage_e%d(i_clk, %s, i_ce,\n",
                                        ((dbg)&&(dbgstage == fftsize))?"_dbg":"",
                                        ((dbg)&&(dbgstage == fftsize))?"_dbg":"",
                                        xtracbits, obits+xtrapbits,
                                        xtracbits, obits+xtrapbits,
                                        lgsize, lgtmp-2,
                                        lgtmp-2, (mpystage)?1:0,
                                        (mpystage)?1:0,
 
                                        ckpce, cmem.c_str(),
                                        ckpce, cmem.c_str(),
                                        fftsize, resetw.c_str());
                                        fftsize, resetw.c_str());
                                fprintf(vmain, "\t\t\t(%s%s), i_left, w_e%d, w_s%d%s);\n",
                                fprintf(vmain, "\t\t\t(%s%s), i_left, w_e%d, w_s%d%s);\n",
                                        (async_reset)?"":"!", resetw.c_str(),
                                        (async_reset)?"":"!", resetw.c_str(),
                                        fftsize, fftsize,
                                        fftsize, fftsize,
                                        ((dbg)&&(dbgstage == fftsize))?", o_dbg":"");
                                        ((dbg)&&(dbgstage == fftsize))?", o_dbg":"");
                                cmem = gen_coeff_fname(EMPTYSTR, fftsize, 2, 1, inverse);
                                cmem = gen_coeff_fname(coredir.c_str(), fftsize, 2, 1, inverse);
                                cmemfp = gen_coeff_open(cmem.c_str());
                                cmemfp = gen_coeff_open(cmem.c_str());
                                gen_coeffs(cmemfp, fftsize,  nbitsin+xtracbits, 2, 1, inverse);
                                gen_coeffs(cmemfp, fftsize,  nbitsin+xtracbits, 2, 1, inverse);
                                fprintf(vmain, "\tfftstage\t#(IWIDTH,IWIDTH+%d,%d,%d,%d,0,\n\t\t\t%d, %d, \"%s\")\n\t\tstage_o%d(i_clk, %s, i_ce,\n",
                                cmem = gen_coeff_fname(EMPTYSTR, fftsize, 2, 1, inverse);
 
                                fprintf(vmain, "\tfftstage\t#(IWIDTH,IWIDTH+%d,%d,%d,0,\n\t\t\t%d, %d, \"%s\")\n\t\tstage_o%d(i_clk, %s, i_ce,\n",
                                        xtracbits, obits+xtrapbits,
                                        xtracbits, obits+xtrapbits,
                                        lgsize, lgtmp-2,
                                        lgtmp-2, (mpystage)?1:0,
                                        (mpystage)?1:0,
 
                                        ckpce, cmem.c_str(),
                                        ckpce, cmem.c_str(),
                                        fftsize, resetw.c_str());
                                        fftsize, resetw.c_str());
                                fprintf(vmain, "\t\t\t(%s%s), i_right, w_o%d, w_os%d);\n",
                                fprintf(vmain, "\t\t\t(%s%s), i_right, w_o%d, w_os%d);\n",
                                        (async_reset)?"":"!",resetw.c_str(),
                                        (async_reset)?"":"!",resetw.c_str(),
                                        fftsize, fftsize);
                                        fftsize, fftsize);
Line 1563... Line 1575...
                                dbgname += "_dbg";
                                dbgname += "_dbg";
                                dbgname += ".v";
                                dbgname += ".v";
                                if (single_clock)
                                if (single_clock)
                                        build_stage(fname.c_str(), fftsize, 1, 0, nbits, xtracbits, ckpce, async_reset, true);
                                        build_stage(fname.c_str(), fftsize, 1, 0, nbits, xtracbits, ckpce, async_reset, true);
                                else
                                else
                                        build_stage(fname.c_str(), fftsize/2, 2, 1, nbits, xtracbits, ckpce, async_reset, true);
                                        build_stage(fname.c_str(), fftsize, 2, 1, nbits, xtracbits, ckpce, async_reset, true);
                        }
                        }
 
 
                        fname += ".v";
                        fname += ".v";
                        if (single_clock) {
                        if (single_clock) {
                                build_stage(fname.c_str(), fftsize, 1, 0,
                                build_stage(fname.c_str(), fftsize, 1, 0,
                                        nbits, xtracbits, ckpce, async_reset,
                                        nbits, xtracbits, ckpce, async_reset,
                                        false);
                                        false);
                        } else {
                        } else {
                                // All stages use the same Verilog, so we only
                                // All stages use the same Verilog, so we only
                                // need to build one
                                // need to build one
                                build_stage(fname.c_str(), fftsize/2, 2, 1,
                                build_stage(fname.c_str(), fftsize, 2, 1,
                                        nbits, xtracbits, ckpce, async_reset, false);
                                        nbits, xtracbits, ckpce, async_reset, false);
                        }
                        }
                }
                }
 
 
                nbits = obits;  // New number of input bits
                nbits = obits;  // New number of input bits
Line 1602... Line 1614...
                                        tmp_size);
                                        tmp_size);
                                if (single_clock) {
                                if (single_clock) {
                                        fprintf(vmain,"\twire\t[%d:0]\tw_d%d;\n",
                                        fprintf(vmain,"\twire\t[%d:0]\tw_d%d;\n",
                                                2*(obits+xtrapbits)-1,
                                                2*(obits+xtrapbits)-1,
                                                tmp_size);
                                                tmp_size);
                                        cmem = gen_coeff_fname(EMPTYSTR, tmp_size, 1, 0, inverse);
                                        cmem = gen_coeff_fname(coredir.c_str(), tmp_size, 1, 0, inverse);
                                        cmemfp = gen_coeff_open(cmem.c_str());
                                        cmemfp = gen_coeff_open(cmem.c_str());
                                        gen_coeffs(cmemfp, tmp_size,
                                        gen_coeffs(cmemfp, tmp_size,
                                                nbits+xtracbits+xtrapbits, 1, 0, inverse);
                                                nbits+xtracbits+xtrapbits, 1, 0, inverse);
                                        fprintf(vmain, "\tfftstage%s\t#(%d,%d,%d,%d,%d,%d,\n\t\t\t%d, %d, \"%s\")\n\t\tstage_%d(i_clk, %s, i_ce,\n",
                                        cmem = gen_coeff_fname(EMPTYSTR, tmp_size, 1, 0, inverse);
 
                                        fprintf(vmain, "\tfftstage%s\t#(%d,%d,%d,%d,%d,\n\t\t\t%d, %d, \"%s\")\n\t\tstage_%d(i_clk, %s, i_ce,\n",
                                                ((dbg)&&(dbgstage==tmp_size))?"_dbg":"",
                                                ((dbg)&&(dbgstage==tmp_size))?"_dbg":"",
                                                nbits+xtrapbits,
                                                nbits+xtrapbits,
                                                nbits+xtracbits+xtrapbits,
                                                nbits+xtracbits+xtrapbits,
                                                obits+xtrapbits,
                                                obits+xtrapbits,
                                                lgsize, lgtmp-1,
                                                lgtmp-1, (dropbit)?0:0, (mpystage)?1:0,
                                                (dropbit)?0:0, (mpystage)?1:0,
 
                                                ckpce,
                                                ckpce,
                                                cmem.c_str(), tmp_size,
                                                cmem.c_str(), tmp_size,
                                                resetw.c_str());
                                                resetw.c_str());
                                        fprintf(vmain, "\t\t\tw_s%d, w_d%d, w_d%d, w_s%d%s);\n",
                                        fprintf(vmain, "\t\t\tw_s%d, w_d%d, w_d%d, w_s%d%s);\n",
                                                tmp_size<<1, tmp_size<<1,
                                                tmp_size<<1, tmp_size<<1,
Line 1627... Line 1639...
                                        fprintf(vmain, "\t// verilator lint_off UNUSED\n\twire\t\tw_os%d;\n\t// verilator lint_on  UNUSED\n",
                                        fprintf(vmain, "\t// verilator lint_off UNUSED\n\twire\t\tw_os%d;\n\t// verilator lint_on  UNUSED\n",
                                                tmp_size);
                                                tmp_size);
                                        fprintf(vmain,"\twire\t[%d:0]\tw_e%d, w_o%d;\n",
                                        fprintf(vmain,"\twire\t[%d:0]\tw_e%d, w_o%d;\n",
                                                2*(obits+xtrapbits)-1,
                                                2*(obits+xtrapbits)-1,
                                                tmp_size, tmp_size);
                                                tmp_size, tmp_size);
                                        cmem = gen_coeff_fname(EMPTYSTR, tmp_size, 2, 0, inverse);
                                        cmem = gen_coeff_fname(coredir.c_str(), tmp_size, 2, 0, inverse);
                                        cmemfp = gen_coeff_open(cmem.c_str());
                                        cmemfp = gen_coeff_open(cmem.c_str());
                                        gen_coeffs(cmemfp, tmp_size,
                                        gen_coeffs(cmemfp, tmp_size,
                                                nbits+xtracbits+xtrapbits, 2, 0, inverse);
                                                nbits+xtracbits+xtrapbits, 2, 0, inverse);
                                        fprintf(vmain, "\tfftstage%s\t#(%d,%d,%d,%d,%d,%d,\n\t\t\t%d, %d, \"%s\")\n\t\tstage_e%d(i_clk, %s, i_ce,\n",
                                        cmem = gen_coeff_fname(EMPTYSTR, tmp_size, 2, 0, inverse);
 
                                        fprintf(vmain, "\tfftstage%s\t#(%d,%d,%d,%d,%d,\n\t\t\t%d, %d, \"%s\")\n\t\tstage_e%d(i_clk, %s, i_ce,\n",
                                                ((dbg)&&(dbgstage==tmp_size))?"_dbg":"",
                                                ((dbg)&&(dbgstage==tmp_size))?"_dbg":"",
                                                nbits+xtrapbits,
                                                nbits+xtrapbits,
                                                nbits+xtracbits+xtrapbits,
                                                nbits+xtracbits+xtrapbits,
                                                obits+xtrapbits,
                                                obits+xtrapbits,
                                                lgsize, lgtmp-2,
                                                lgtmp-2, (dropbit)?0:0, (mpystage)?1:0,
                                                (dropbit)?0:0, (mpystage)?1:0,
 
                                                ckpce,
                                                ckpce,
                                                cmem.c_str(), tmp_size,
                                                cmem.c_str(), tmp_size,
                                                resetw.c_str());
                                                resetw.c_str());
                                        fprintf(vmain, "\t\t\tw_s%d, w_e%d, w_e%d, w_s%d%s);\n",
                                        fprintf(vmain, "\t\t\tw_s%d, w_e%d, w_e%d, w_s%d%s);\n",
                                                tmp_size<<1, tmp_size<<1,
                                                tmp_size<<1, tmp_size<<1,
                                                tmp_size, tmp_size,
                                                tmp_size, tmp_size,
                                                ((dbg)&&(dbgstage == tmp_size))
                                                ((dbg)&&(dbgstage == tmp_size))
                                                        ?", o_dbg":"");
                                                        ?", o_dbg":"");
                                        cmem = gen_coeff_fname(EMPTYSTR,
                                        cmem = gen_coeff_fname(coredir.c_str(),
                                                tmp_size, 2, 1, inverse);
                                                tmp_size, 2, 1, inverse);
                                        cmemfp = gen_coeff_open(cmem.c_str());
                                        cmemfp = gen_coeff_open(cmem.c_str());
                                        gen_coeffs(cmemfp, tmp_size,
                                        gen_coeffs(cmemfp, tmp_size,
                                                nbits+xtracbits+xtrapbits,
                                                nbits+xtracbits+xtrapbits,
                                                2, 1, inverse);
                                                2, 1, inverse);
                                        fprintf(vmain, "\tfftstage\t#(%d,%d,%d,%d,%d,%d,\n\t\t\t%d, %d, \"%s\")\n\t\tstage_o%d(i_clk, %s, i_ce,\n",
                                        cmem = gen_coeff_fname(EMPTYSTR,
 
                                                tmp_size, 2, 1, inverse);
 
                                        fprintf(vmain, "\tfftstage\t#(%d,%d,%d,%d,%d,\n\t\t\t%d, %d, \"%s\")\n\t\tstage_o%d(i_clk, %s, i_ce,\n",
                                                nbits+xtrapbits,
                                                nbits+xtrapbits,
                                                nbits+xtracbits+xtrapbits,
                                                nbits+xtracbits+xtrapbits,
                                                obits+xtrapbits,
                                                obits+xtrapbits,
                                                lgsize, lgtmp-2,
                                                lgtmp-2, (dropbit)?0:0, (mpystage)?1:0,
                                                (dropbit)?0:0, (mpystage)?1:0,
 
                                                ckpce, cmem.c_str(), tmp_size,
                                                ckpce, cmem.c_str(), tmp_size,
                                                resetw.c_str());
                                                resetw.c_str());
                                        fprintf(vmain, "\t\t\tw_s%d, w_o%d, w_o%d, w_os%d);\n",
                                        fprintf(vmain, "\t\t\tw_s%d, w_o%d, w_o%d, w_os%d);\n",
                                                tmp_size<<1, tmp_size<<1,
                                                tmp_size<<1, tmp_size<<1,
                                                tmp_size, tmp_size);
                                                tmp_size, tmp_size);
Line 1724... Line 1737...
                                        2*obits-1);
                                        2*obits-1);
                        } else {
                        } else {
                                fprintf(vmain, "\twire\t[%d:0]\tw_e2, w_o2;\n",
                                fprintf(vmain, "\twire\t[%d:0]\tw_e2, w_o2;\n",
                                        2*obits-1);
                                        2*obits-1);
                        }
                        }
                        if ((nbits+xtrapbits+1 == obits)&&(!dropbit))
                        /*
                                printf("WARNING: SCALING OFF BY A FACTOR OF TWO--should\'ve dropped a bit in the last stage.\n");
                        if ((nbits+xtrapbits+1 == obits)&&(!dropbit))
 
                                printf("Warning: Less than optimal scaling\n");
 
                        */
 
 
                        if (single_clock) {
                        if (single_clock) {
                                fprintf(vmain, "\tlaststage\t#(%d,%d,%d)\tstage_2(i_clk, %s, i_ce,\n",
                                fprintf(vmain, "\tlaststage\t#(%d,%d,%d)\tstage_2(i_clk, %s, i_ce,\n",
                                        nbits+xtrapbits, obits,(dropbit)?0:1,
                                        nbits+xtrapbits, obits,(dropbit)?0:1,
                                        resetw.c_str());
                                        resetw.c_str());

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.