Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prefix #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions sw/bldstage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
// Builds the penultimate FFT stage, using integer operations only.
// This stage is called laststage elsewhere.
//
void build_dblstage(const char *fname, ROUND_T rounding,
void build_dblstage(const char *fname, const char* prefix, ROUND_T rounding,
const bool async_reset, const bool dbg) {
FILE *fp = fopen(fname, "w");
if (NULL == fp) {
Expand Down Expand Up @@ -155,7 +155,7 @@ SLASHLINE
fprintf(fp, "%s", cpyleft);
fprintf(fp, "//\n//\n`default_nettype\tnone\n//\n");
fprintf(fp,
"module\tlaststage%s #(\n"
"module\t%slaststage%s #(\n"
"\t\t// {{{\n"
// (i_clk, %s, i_ce, i_sync, i_left, i_right, o_left, o_right, o_sync%s);\n"
"\t\tparameter\tIWIDTH=%d,OWIDTH=IWIDTH+1, SHIFT=%d\n"
Expand All @@ -166,7 +166,7 @@ SLASHLINE
"\t\tinput\twire\t[(2*IWIDTH-1):0]\ti_left, i_right,\n"
"\t\toutput\treg\t[(2*OWIDTH-1):0]\to_left, o_right,\n"
"\t\toutput\treg\t\t\to_sync%s\n"
"\n", (dbg)?"_dbg":"", // resetw.c_str(), (dbg)?", o_dbg":"",
"\n", prefix, (dbg)?"_dbg":"", // resetw.c_str(), (dbg)?", o_dbg":"",
TST_DBLSTAGE_IWIDTH, TST_DBLSTAGE_SHIFT,
resetw.c_str(), (dbg) ? ",":"");

Expand Down Expand Up @@ -249,17 +249,17 @@ SLASHLINE
"\t// }}}\n"
"\n");
fprintf(fp,
"\t%s #(IWIDTH+1,OWIDTH,SHIFT) do_rnd_0r(i_clk, i_ce,\n"
"\t\t\t\t\t\t\trnd_in_0r, o_out_0r);\n\n", rnd_string);
"\t%s%s #(IWIDTH+1,OWIDTH,SHIFT) do_rnd_0r(i_clk, i_ce,\n"
"\t\t\t\t\t\t\trnd_in_0r, o_out_0r);\n\n", prefix, rnd_string);
fprintf(fp,
"\t%s #(IWIDTH+1,OWIDTH,SHIFT) do_rnd_0i(i_clk, i_ce,\n"
"\t\t\t\t\t\t\trnd_in_0i, o_out_0i);\n\n", rnd_string);
"\t%s%s #(IWIDTH+1,OWIDTH,SHIFT) do_rnd_0i(i_clk, i_ce,\n"
"\t\t\t\t\t\t\trnd_in_0i, o_out_0i);\n\n", prefix, rnd_string);
fprintf(fp,
"\t%s #(IWIDTH+1,OWIDTH,SHIFT) do_rnd_1r(i_clk, i_ce,\n"
"\t\t\t\t\t\t\trnd_in_1r, o_out_1r);\n\n", rnd_string);
"\t%s%s #(IWIDTH+1,OWIDTH,SHIFT) do_rnd_1r(i_clk, i_ce,\n"
"\t\t\t\t\t\t\trnd_in_1r, o_out_1r);\n\n", prefix, rnd_string);
fprintf(fp,
"\t%s #(IWIDTH+1,OWIDTH,SHIFT) do_rnd_1i(i_clk, i_ce,\n"
"\t\t\t\t\t\t\trnd_in_1i, o_out_1i);\n\n", rnd_string);
"\t%s%s #(IWIDTH+1,OWIDTH,SHIFT) do_rnd_1i(i_clk, i_ce,\n"
"\t\t\t\t\t\t\trnd_in_1i, o_out_1i);\n\n", prefix, rnd_string);

fprintf(fp, "\n"
"\t// o_left, o_right\n"
Expand Down Expand Up @@ -297,6 +297,7 @@ SLASHLINE
// build_stage
// {{{
void build_stage(const char *fname,
const char* prefix,
int stage, int nwide, int offset,
int nbits, int xtra, int ckpce,
const bool async_reset, const bool dbg) {
Expand Down Expand Up @@ -349,7 +350,7 @@ SLASHLINE
(dbg)?"_dbg":"", prjname, creator);
fprintf(fstage, "%s", cpyleft);
fprintf(fstage, "//\n//\n`default_nettype\tnone\n//\n");
fprintf(fstage, "module\tfftstage%s #(\n", (dbg)?"_dbg":"");
fprintf(fstage, "module\t%sfftstage%s #(\n", prefix, (dbg)?"_dbg":"");
fprintf(fstage, "\t\t// {{{\n");
// These parameter values are useless at this point--they are to be
// replaced by the parameter values in the calling program. Only
Expand Down Expand Up @@ -591,7 +592,8 @@ SLASHLINE
"\tgenerate if (OPT_HWMPY)\n"
"\tbegin : HWBFLY\n"
"\n"
"\t\thwbfly #(\n"
"\t\t%shwbfly #(\n", prefix);
fprintf(fstage,
"\t\t\t// {{{\n"
"\t\t\t.IWIDTH(IWIDTH),\n"
"\t\t\t.CWIDTH(CWIDTH),\n"
Expand Down Expand Up @@ -619,7 +621,8 @@ SLASHLINE
"\n"
"\tend else begin : FWBFLY\n"
"\n"
"\t\tbutterfly #(\n"
"\t\t%sbutterfly #(\n", prefix);
fprintf(fstage,
"\t\t\t// {{{\n"
"\t\t\t.IWIDTH(IWIDTH),\n"
"\t\t\t.CWIDTH(CWIDTH),\n"
Expand Down
5 changes: 3 additions & 2 deletions sw/bldstage.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@

#include "rounding.h"

extern void build_dblstage(const char *fname, ROUND_T rounding,
const bool async_reset = false, const bool dbg = false);
extern void build_dblstage(const char *fname, const char* prefix,
ROUND_T rounding, const bool async_reset = false, const bool dbg = false);

extern void build_stage(const char *fname,
const char* prefix,
int stage, int nwide, int offset,
int nbits, int xtra, int ckpce,
const bool async_reset = false,
Expand Down
45 changes: 23 additions & 22 deletions sw/butterfly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ int lstat(const char *filename, struct stat *buf) { return 1; };

// build_butterfly
// {{{
void build_butterfly(const char *fname, int xtracbits, ROUND_T rounding,
void build_butterfly(const char *fname, const char *prefix, int xtracbits, ROUND_T rounding,
int ckpce, const bool async_reset) {
FILE *fp = fopen(fname, "w");
if (NULL == fp) {
Expand Down Expand Up @@ -200,9 +200,10 @@ SLASHLINE
fprintf(fp, "//\n//\n`default_nettype\tnone\n//\n");

fprintf(fp,
"module\tbutterfly #(\n"
"module\t%sbutterfly #(\n"
"\t\t// {{{\n"
"\t\t// Public changeable parameters ...\n");
"\t\t// Public changeable parameters ...\n",
prefix);

fprintf(fp,
"\t\t// IWIDTH\n"
Expand Down Expand Up @@ -1129,17 +1130,17 @@ SLASHLINE
"\tassign left_si = { {(2){fifo_i[(IWIDTH+CWIDTH)]}}, fifo_i };\n\n");

fprintf(fp,
"\t%s #(CWIDTH+IWIDTH+3,OWIDTH,SHIFT+4)\n"
"\tdo_rnd_left_r(i_clk, i_ce, left_sr, rnd_left_r);\n\n", rnd_string);
"\t%s%s #(CWIDTH+IWIDTH+3,OWIDTH,SHIFT+4)\n"
"\tdo_rnd_left_r(i_clk, i_ce, left_sr, rnd_left_r);\n\n", prefix, rnd_string);
fprintf(fp,
"\t%s #(CWIDTH+IWIDTH+3,OWIDTH,SHIFT+4)\n"
"\tdo_rnd_left_i(i_clk, i_ce, left_si, rnd_left_i);\n\n", rnd_string);
"\t%s%s #(CWIDTH+IWIDTH+3,OWIDTH,SHIFT+4)\n"
"\tdo_rnd_left_i(i_clk, i_ce, left_si, rnd_left_i);\n\n", prefix, rnd_string);
fprintf(fp,
"\t%s #(CWIDTH+IWIDTH+3,OWIDTH,SHIFT+4)\n"
"\tdo_rnd_right_r(i_clk, i_ce, mpy_r, rnd_right_r);\n\n", rnd_string);
"\t%s%s #(CWIDTH+IWIDTH+3,OWIDTH,SHIFT+4)\n"
"\tdo_rnd_right_r(i_clk, i_ce, mpy_r, rnd_right_r);\n\n", prefix, rnd_string);
fprintf(fp,
"\t%s #(CWIDTH+IWIDTH+3,OWIDTH,SHIFT+4)\n"
"\tdo_rnd_right_i(i_clk, i_ce, mpy_i, rnd_right_i);\n", rnd_string);
"\t%s%s #(CWIDTH+IWIDTH+3,OWIDTH,SHIFT+4)\n"
"\tdo_rnd_right_i(i_clk, i_ce, mpy_i, rnd_right_i);\n", prefix, rnd_string);
fprintf(fp, "\t// }}}\n\n");
fprintf(fp,
"\t// fifo_read, mpy_r, mpy_i\n"
Expand Down Expand Up @@ -1546,7 +1547,7 @@ SLASHLINE

// build_hwbfly
// {{{
void build_hwbfly(const char *fname, int xtracbits, ROUND_T rounding,
void build_hwbfly(const char *fname, const char* prefix, int xtracbits, ROUND_T rounding,
int ckpce, const bool async_reset) {
FILE *fp = fopen(fname, "w");
if (NULL == fp) {
Expand Down Expand Up @@ -1609,7 +1610,7 @@ SLASHLINE
fprintf(fp, "%s", cpyleft);
fprintf(fp, "//\n//\n`default_nettype\tnone\n//\n");
fprintf(fp,
"module hwbfly #(\n"
"module %shwbfly #(\n"
// (i_clk, %s, i_ce, i_coef, i_left, i_right, i_aux,\n"
// "\t\to_left, o_right, o_aux);\n"
"\t\t// {{{\n"
Expand All @@ -1629,7 +1630,7 @@ SLASHLINE
"\t\t// {{{\n"
"\t\t// The number of clocks per clock enable, 1, 2, or 3.\n"
"\t\tparameter\t[1:0]\tCKPCE=%d\n\t\t// }}}\n\t\t// }}}\n",
xtracbits, ckpce);
prefix, xtracbits, ckpce);

fprintf(fp,
"\t) (\n"
Expand Down Expand Up @@ -2213,17 +2214,17 @@ SLASHLINE
fprintf(fp,
"\t// Round the results\n"
"\t// {{{\n"
"\t%s #(CWIDTH+IWIDTH+1,OWIDTH,SHIFT+2)\n"
"\tdo_rnd_left_r(i_clk, i_ce, left_sr, rnd_left_r);\n\n", rnd_string);
"\t%s%s #(CWIDTH+IWIDTH+1,OWIDTH,SHIFT+2)\n"
"\tdo_rnd_left_r(i_clk, i_ce, left_sr, rnd_left_r);\n\n", prefix, rnd_string);
fprintf(fp,
"\t%s #(CWIDTH+IWIDTH+1,OWIDTH,SHIFT+2)\n"
"\tdo_rnd_left_i(i_clk, i_ce, left_si, rnd_left_i);\n\n", rnd_string);
"\t%s%s #(CWIDTH+IWIDTH+1,OWIDTH,SHIFT+2)\n"
"\tdo_rnd_left_i(i_clk, i_ce, left_si, rnd_left_i);\n\n", prefix, rnd_string);
fprintf(fp,
"\t%s #(CWIDTH+IWIDTH+3,OWIDTH,SHIFT+4)\n"
"\tdo_rnd_right_r(i_clk, i_ce, mpy_r, rnd_right_r);\n\n", rnd_string);
"\t%s%s #(CWIDTH+IWIDTH+3,OWIDTH,SHIFT+4)\n"
"\tdo_rnd_right_r(i_clk, i_ce, mpy_r, rnd_right_r);\n\n", prefix, rnd_string);
fprintf(fp,
"\t%s #(CWIDTH+IWIDTH+3,OWIDTH,SHIFT+4)\n"
"\tdo_rnd_right_i(i_clk, i_ce, mpy_i, rnd_right_i);\n\t// }}}\n\n", rnd_string);
"\t%s%s #(CWIDTH+IWIDTH+3,OWIDTH,SHIFT+4)\n"
"\tdo_rnd_right_i(i_clk, i_ce, mpy_i, rnd_right_i);\n\t// }}}\n\n", prefix, rnd_string);


fprintf(fp,
Expand Down
5 changes: 3 additions & 2 deletions sw/butterfly.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@
#ifndef BUTTERFLY_H
#define BUTTERFLY_H

extern void build_butterfly(const char *fname, int xtracbits,
extern void build_butterfly(const char *fname, const char* prefix, int xtracbits,
ROUND_T rounding, int ckpce = 1,
const bool async_reset = false);

extern void build_hwbfly(const char *fname, int xtracbits, ROUND_T rounding,
extern void build_hwbfly(const char *fname, const char* prefix,
int xtracbits, ROUND_T rounding,
int ckpce = 3, const bool async_reset= false);

#endif
Loading