Line 23... |
Line 23... |
// 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 89... |
Line 89... |
fprintf(fp, "%s", cpyleft);
|
fprintf(fp, "%s", cpyleft);
|
fprintf(fp, "//\n//\n`default_nettype\tnone\n//\n");
|
fprintf(fp, "//\n//\n`default_nettype\tnone\n//\n");
|
fprintf(fp,
|
fprintf(fp,
|
"module truncate(i_clk, i_ce, i_val, o_val);\n"
|
"module truncate(i_clk, i_ce, i_val, o_val);\n"
|
"\tparameter\tIWID=16, OWID=8, SHIFT=0;\n"
|
"\tparameter\tIWID=16, OWID=8, SHIFT=0;\n"
|
"\tinput\t\t\t\t\ti_clk, i_ce;\n"
|
"\tinput\twire\t\t\t\ti_clk, i_ce;\n"
|
"\tinput\t\tsigned\t[(IWID-1):0]\ti_val;\n"
|
"\tinput\twire\tsigned\t[(IWID-1):0]\ti_val;\n"
|
"\toutput\treg\tsigned\t[(OWID-1):0]\to_val;\n"
|
"\toutput\treg\tsigned\t[(OWID-1):0]\to_val;\n"
|
"\n"
|
"\n"
|
"\talways @(posedge i_clk)\n"
|
"\talways @(posedge i_clk)\n"
|
"\t\tif (i_ce)\n"
|
"\t\tif (i_ce)\n"
|
"\t\t\to_val <= i_val[(IWID-1-SHIFT):(IWID-SHIFT-OWID)];\n"
|
"\t\t\to_val <= i_val[(IWID-1-SHIFT):(IWID-SHIFT-OWID)];\n"
|
Line 130... |
Line 130... |
fprintf(fp, "%s", cpyleft);
|
fprintf(fp, "%s", cpyleft);
|
fprintf(fp, "//\n//\n`default_nettype\tnone\n//\n");
|
fprintf(fp, "//\n//\n`default_nettype\tnone\n//\n");
|
fprintf(fp,
|
fprintf(fp,
|
"module roundhalfup(i_clk, i_ce, i_val, o_val);\n"
|
"module roundhalfup(i_clk, i_ce, i_val, o_val);\n"
|
"\tparameter\tIWID=16, OWID=8, SHIFT=0;\n"
|
"\tparameter\tIWID=16, OWID=8, SHIFT=0;\n"
|
"\tinput\t\t\t\t\ti_clk, i_ce;\n"
|
"\tinput\twire\t\t\t\ti_clk, i_ce;\n"
|
"\tinput\t\tsigned\t[(IWID-1):0]\ti_val;\n"
|
"\tinput\twire\tsigned\t[(IWID-1):0]\ti_val;\n"
|
"\toutput\treg\tsigned\t[(OWID-1):0]\to_val;\n"
|
"\toutput\treg\tsigned\t[(OWID-1):0]\to_val;\n"
|
"\n"
|
"\n"
|
"\t// Let's deal with two cases to be as general as we can be here\n"
|
"\t// Let's deal with two cases to be as general as we can be here\n"
|
"\t//\n"
|
"\t//\n"
|
"\t// 1. The desired output would lose no bits at all\n"
|
"\t// 1. The desired output would lose no bits at all\n"
|
Line 209... |
Line 209... |
fprintf(fp, "%s", cpyleft);
|
fprintf(fp, "%s", cpyleft);
|
fprintf(fp, "//\n//\n`default_nettype\tnone\n//\n");
|
fprintf(fp, "//\n//\n`default_nettype\tnone\n//\n");
|
fprintf(fp,
|
fprintf(fp,
|
"module roundfromzero(i_clk, i_ce, i_val, o_val);\n"
|
"module roundfromzero(i_clk, i_ce, i_val, o_val);\n"
|
"\tparameter\tIWID=16, OWID=8, SHIFT=0;\n"
|
"\tparameter\tIWID=16, OWID=8, SHIFT=0;\n"
|
"\tinput\t\t\t\t\ti_clk, i_ce;\n"
|
"\tinput\twire\t\t\t\ti_clk, i_ce;\n"
|
"\tinput\t\tsigned\t[(IWID-1):0]\ti_val;\n"
|
"\tinput\twire\tsigned\t[(IWID-1):0]\ti_val;\n"
|
"\toutput\treg\tsigned\t[(OWID-1):0]\to_val;\n"
|
"\toutput\treg\tsigned\t[(OWID-1):0]\to_val;\n"
|
"\n"
|
"\n"
|
"\t// Let's deal with three cases to be as general as we can be here\n"
|
"\t// Let's deal with three cases to be as general as we can be here\n"
|
"\t//\n"
|
"\t//\n"
|
"\t//\t1. The desired output would lose no bits at all\n"
|
"\t//\t1. The desired output would lose no bits at all\n"
|
Line 319... |
Line 319... |
fprintf(fp, "%s", cpyleft);
|
fprintf(fp, "%s", cpyleft);
|
fprintf(fp, "//\n//\n`default_nettype\tnone\n//\n");
|
fprintf(fp, "//\n//\n`default_nettype\tnone\n//\n");
|
fprintf(fp,
|
fprintf(fp,
|
"module convround(i_clk, i_ce, i_val, o_val);\n"
|
"module convround(i_clk, i_ce, i_val, o_val);\n"
|
"\tparameter\tIWID=16, OWID=8, SHIFT=0;\n"
|
"\tparameter\tIWID=16, OWID=8, SHIFT=0;\n"
|
"\tinput\t\t\t\t\ti_clk, i_ce;\n"
|
"\tinput\twire\t\t\t\ti_clk, i_ce;\n"
|
"\tinput\t\tsigned\t[(IWID-1):0]\ti_val;\n"
|
"\tinput\twire\tsigned\t[(IWID-1):0]\ti_val;\n"
|
"\toutput\treg\tsigned\t[(OWID-1):0]\to_val;\n"
|
"\toutput\treg\tsigned\t[(OWID-1):0]\to_val;\n"
|
"\n"
|
"\n"
|
"\t// Let's deal with three cases to be as general as we can be here\n"
|
"\t// Let's deal with three cases to be as general as we can be here\n"
|
"\t//\n"
|
"\t//\n"
|
"\t//\t1. The desired output would lose no bits at all\n"
|
"\t//\t1. The desired output would lose no bits at all\n"
|