Skip to content

Add prefix #16

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
@@ -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) {
@@ -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"
@@ -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) ? ",":"");

@@ -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"
@@ -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) {
@@ -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
@@ -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"
@@ -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"
5 changes: 3 additions & 2 deletions sw/bldstage.h
Original file line number Diff line number Diff line change
@@ -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,
45 changes: 23 additions & 22 deletions sw/butterfly.cpp
Original file line number Diff line number Diff line change
@@ -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) {
@@ -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"
@@ -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"
@@ -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) {
@@ -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"
@@ -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"
@@ -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,
5 changes: 3 additions & 2 deletions sw/butterfly.h
Original file line number Diff line number Diff line change
@@ -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
189 changes: 107 additions & 82 deletions sw/fftgen.cpp

Large diffs are not rendered by default.

20 changes: 12 additions & 8 deletions sw/rounding.cpp
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@

// build_truncator
// {{{
void build_truncator(const char *fname) {
void build_truncator(const char *fname, const char* prefix) {
printf("TRUNCATING!\n");
FILE *fp = fopen(fname, "w");
if (NULL == fp) {
@@ -91,7 +91,8 @@ SLASHLINE
fprintf(fp, "%s", cpyleft);
fprintf(fp, "//\n//\n`default_nettype\tnone\n//\n");
fprintf(fp,
"module truncate(i_clk, i_ce, i_val, o_val);\n"
"module %struncate(i_clk, i_ce, i_val, o_val);\n", prefix);
fprintf(fp,
"\tparameter\tIWID=16, OWID=8, SHIFT=0;\n"
"\tinput\twire\t\t\t\ti_clk, i_ce;\n"
"\tinput\twire\tsigned\t[(IWID-1):0]\ti_val;\n"
@@ -107,7 +108,7 @@ SLASHLINE

// build_roundhalfup
// {{{
void build_roundhalfup(const char *fname) {
void build_roundhalfup(const char *fname, const char* prefix) {
FILE *fp = fopen(fname, "w");
if (NULL == fp) {
fprintf(stderr, "Could not open \'%s\' for writing\n", fname);
@@ -135,7 +136,8 @@ SLASHLINE
fprintf(fp, "%s", cpyleft);
fprintf(fp, "//\n//\n`default_nettype\tnone\n//\n");
fprintf(fp,
"module roundhalfup(i_clk, i_ce, i_val, o_val);\n"
"module %sroundhalfup(i_clk, i_ce, i_val, o_val);\n", prefix);
fprintf(fp,
"\tparameter\tIWID=16, OWID=8, SHIFT=0;\n"
"\tinput\twire\t\t\t\ti_clk, i_ce;\n"
"\tinput\twire\tsigned\t[(IWID-1):0]\ti_val;\n"
@@ -181,7 +183,7 @@ SLASHLINE

// build_roundfromzero
// {{{
void build_roundfromzero(const char *fname) {
void build_roundfromzero(const char *fname, const char* prefix) {
FILE *fp = fopen(fname, "w");
if (NULL == fp) {
fprintf(stderr, "Could not open \'%s\' for writing\n", fname);
@@ -217,7 +219,8 @@ SLASHLINE
fprintf(fp, "%s", cpyleft);
fprintf(fp, "//\n//\n`default_nettype\tnone\n//\n");
fprintf(fp,
"module roundfromzero(i_clk, i_ce, i_val, o_val);\n"
"module %sroundfromzero(i_clk, i_ce, i_val, o_val);\n", prefix);
fprintf(fp,
"\tparameter\tIWID=16, OWID=8, SHIFT=0;\n"
"\tinput\twire\t\t\t\ti_clk, i_ce;\n"
"\tinput\twire\tsigned\t[(IWID-1):0]\ti_val;\n"
@@ -305,7 +308,7 @@ SLASHLINE

// build_convround
// {{{
void build_convround(const char *fname) {
void build_convround(const char *fname, const char* prefix) {
FILE *fp = fopen(fname, "w");
if (NULL == fp) {
fprintf(stderr, "Could not open \'%s\' for writing\n", fname);
@@ -334,7 +337,8 @@ SLASHLINE
fprintf(fp, "%s", cpyleft);
fprintf(fp, "//\n//\n`default_nettype\tnone\n//\n");
fprintf(fp,
"module convround(i_clk, i_ce, i_val, o_val);\n"
"module %sconvround(i_clk, i_ce, i_val, o_val);\n", prefix);
fprintf(fp,
"\tparameter\tIWID=16, OWID=8, SHIFT=0;\n"
"\tinput\twire\t\t\t\ti_clk, i_ce;\n"
"\tinput\twire\tsigned\t[(IWID-1):0]\ti_val;\n"
8 changes: 4 additions & 4 deletions sw/rounding.h
Original file line number Diff line number Diff line change
@@ -45,9 +45,9 @@ typedef enum {
} ROUND_T;


extern void build_truncator(const char *fname);
extern void build_roundhalfup(const char *fname);
extern void build_roundfromzero(const char *fname);
extern void build_convround(const char *fname);
extern void build_truncator(const char *fname, const char* prefix);
extern void build_roundhalfup(const char *fname, const char* prefix);
extern void build_roundfromzero(const char *fname, const char* prefix);
extern void build_convround(const char *fname, const char* prefix);

#endif
15 changes: 8 additions & 7 deletions sw/softmpy.cpp
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@

// build_multiply
// {{{
void build_multiply(const char *fname) {
void build_multiply(const char *fname, const char* prefix) {
FILE *fp = fopen(fname, "w");
if (NULL == fp) {
fprintf(stderr, "Could not open \'%s\' for writing\n", fname);
@@ -100,8 +100,8 @@ SLASHLINE
fprintf(fp, "%s", cpyleft);
fprintf(fp, "//\n//\n`default_nettype\tnone\n//\n");
fprintf(fp,
"module shiftaddmpy(i_clk, i_ce, i_a, i_b, o_r);\n"
"\tparameter\tAWIDTH=%d,BWIDTH=", TST_SHIFTADDMPY_AW);
"module %sshiftaddmpy(i_clk, i_ce, i_a, i_b, o_r);\n"
"\tparameter\tAWIDTH=%d,BWIDTH=", prefix, TST_SHIFTADDMPY_AW);
#ifdef TST_SHIFTADDMPY_BW
fprintf(fp, "%d;\n", TST_SHIFTADDMPY_BW);
#else
@@ -171,7 +171,7 @@ SLASHLINE

// build_bimpy -- the binary sub-multiply (everything else is addition)
// {{{
void build_bimpy(const char *fname) {
void build_bimpy(const char *fname, const char* prefix) {
FILE *fp = fopen(fname, "w");
if (NULL == fp) {
fprintf(stderr, "Could not open \'%s\' for writing\n", fname);
@@ -205,7 +205,8 @@ SLASHLINE
fprintf(fp, "%s", cpyleft);
fprintf(fp, "//\n//\n`default_nettype\tnone\n//\n");
fprintf(fp,
"module bimpy #(\n" // (i_clk, i_reset, i_ce, i_a, i_b, o_r);\n"
"module %sbimpy #(\n", prefix); // (i_clk, i_reset, i_ce, i_a, i_b, o_r);\n"
fprintf(fp,
"\t\t// {{{\n"
"\t\tparameter\tBW=18, // Number of bits in i_b\n"
"\t\tlocalparam\tLUTB=2 // Number of bits in i_a for our LUT multiply\n"
@@ -308,7 +309,7 @@ SLASHLINE

// build_longbimpy
// {{{
void build_longbimpy(const char *fname) {
void build_longbimpy(const char *fname, const char* prefix) {
FILE *fp = fopen(fname, "w");
if (NULL == fp) {
fprintf(stderr, "Could not open \'%s\' for writing\n", fname);
@@ -339,7 +340,7 @@ SLASHLINE
fprintf(fp, "%s", cpyleft);
fprintf(fp, "//\n//\n`default_nettype\tnone\n//\n");
fprintf(fp,
"module longbimpy #(\n");
"module %slongbimpy #(\n", prefix);

fprintf(fp, "\t\t// {{{\n"
"\t\tparameter IAW=%d, // The width of i_a, min width is 5\n"
6 changes: 3 additions & 3 deletions sw/softmpy.h
Original file line number Diff line number Diff line change
@@ -41,8 +41,8 @@
#ifndef SOFTMPY_H
#define SOFTMPY_H

extern void build_multiply(const char *fname);
extern void build_bimpy(const char *fname);
extern void build_longbimpy(const char *fname);
extern void build_multiply(const char *fname, const char* prefix);
extern void build_bimpy(const char *fname, const char* prefix);
extern void build_longbimpy(const char *fname, const char* prefix);

#endif // SOFTMPY_H