add chips/yosys (part 5)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- chips/yosys/techlibs/ice40/synth_ice40.cc +467 -0
- chips/yosys/techlibs/ice40/tests/.gitignore +11 -0
- chips/yosys/techlibs/ice40/tests/test_arith.v +3 -0
- chips/yosys/techlibs/ice40/tests/test_arith.ys +17 -0
- chips/yosys/techlibs/ice40/tests/test_bram.sh +18 -0
- chips/yosys/techlibs/ice40/tests/test_bram.v +24 -0
- chips/yosys/techlibs/ice40/tests/test_bram_tb.v +110 -0
- chips/yosys/techlibs/ice40/tests/test_dsp_map.sh +107 -0
- chips/yosys/techlibs/ice40/tests/test_dsp_model.sh +16 -0
- chips/yosys/techlibs/ice40/tests/test_dsp_model.v +567 -0
- chips/yosys/techlibs/ice40/tests/test_ffs.sh +20 -0
- chips/yosys/techlibs/ice40/tests/test_ffs.v +42 -0
- chips/yosys/techlibs/intel/CMakeLists.txt +54 -0
- chips/yosys/techlibs/intel/common/altpll_bb.v +366 -0
- chips/yosys/techlibs/intel/common/brams_m9k.txt +33 -0
- chips/yosys/techlibs/intel/common/brams_map_m9k.v +92 -0
- chips/yosys/techlibs/intel/common/ff_map.v +11 -0
- chips/yosys/techlibs/intel/common/m9k_bb.v +70 -0
- chips/yosys/techlibs/intel/cyclone10lp/cells_arith.v +71 -0
- chips/yosys/techlibs/intel/cyclone10lp/cells_map.v +73 -0
- chips/yosys/techlibs/intel/cyclone10lp/cells_sim.v +137 -0
- chips/yosys/techlibs/intel/cycloneiv/cells_arith.v +103 -0
- chips/yosys/techlibs/intel/cycloneiv/cells_map.v +57 -0
- chips/yosys/techlibs/intel/cycloneiv/cells_sim.v +297 -0
- chips/yosys/techlibs/intel/cycloneive/arith_map.v +105 -0
- chips/yosys/techlibs/intel/cycloneive/cells_map.v +73 -0
- chips/yosys/techlibs/intel/cycloneive/cells_sim.v +292 -0
- chips/yosys/techlibs/intel/max10/cells_arith.v +71 -0
- chips/yosys/techlibs/intel/max10/cells_map.v +57 -0
- chips/yosys/techlibs/intel/max10/cells_sim.v +345 -0
- chips/yosys/techlibs/intel/max10/dsp_map.v +72 -0
- chips/yosys/techlibs/intel/synth_intel.cc +327 -0
- chips/yosys/techlibs/intel_alm/CMakeLists.txt +58 -0
- chips/yosys/techlibs/intel_alm/common/abc9_map.v +18 -0
- chips/yosys/techlibs/intel_alm/common/abc9_model.v +10 -0
- chips/yosys/techlibs/intel_alm/common/abc9_unmap.v +11 -0
- chips/yosys/techlibs/intel_alm/common/alm_map.v +57 -0
- chips/yosys/techlibs/intel_alm/common/alm_sim.v +219 -0
- chips/yosys/techlibs/intel_alm/common/arith_alm_map.v +71 -0
- chips/yosys/techlibs/intel_alm/common/bram_m10k.txt +29 -0
- chips/yosys/techlibs/intel_alm/common/bram_m10k_map.v +26 -0
- chips/yosys/techlibs/intel_alm/common/dff_map.v +13 -0
- chips/yosys/techlibs/intel_alm/common/dff_sim.v +99 -0
- chips/yosys/techlibs/intel_alm/common/dsp_map.v +51 -0
- chips/yosys/techlibs/intel_alm/common/dsp_sim.v +130 -0
- chips/yosys/techlibs/intel_alm/common/lutram_mlab.txt +18 -0
- chips/yosys/techlibs/intel_alm/common/megafunction_bb.v +717 -0
- chips/yosys/techlibs/intel_alm/common/mem_sim.v +111 -0
- chips/yosys/techlibs/intel_alm/common/misc_sim.v +21 -0
- chips/yosys/techlibs/intel_alm/cyclonev/cells_sim.v +168 -0
chips/yosys/techlibs/ice40/synth_ice40.cc
ADDED
|
@@ -0,0 +1,467 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* yosys -- Yosys Open SYnthesis Suite
|
| 3 |
+
*
|
| 4 |
+
* Copyright (C) 2012 Claire Xenia Wolf <claire@yosyshq.com>
|
| 5 |
+
*
|
| 6 |
+
* Permission to use, copy, modify, and/or distribute this software for any
|
| 7 |
+
* purpose with or without fee is hereby granted, provided that the above
|
| 8 |
+
* copyright notice and this permission notice appear in all copies.
|
| 9 |
+
*
|
| 10 |
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
| 11 |
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
| 12 |
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
| 13 |
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 14 |
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 15 |
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
| 16 |
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
| 17 |
+
*
|
| 18 |
+
*/
|
| 19 |
+
|
| 20 |
+
#include "kernel/register.h"
|
| 21 |
+
#include "kernel/celltypes.h"
|
| 22 |
+
#include "kernel/rtlil.h"
|
| 23 |
+
#include "kernel/log.h"
|
| 24 |
+
#include "passes/proc/proc_dlatch.h"
|
| 25 |
+
|
| 26 |
+
USING_YOSYS_NAMESPACE
|
| 27 |
+
PRIVATE_NAMESPACE_BEGIN
|
| 28 |
+
|
| 29 |
+
struct SynthIce40Pass : public ScriptPass
|
| 30 |
+
{
|
| 31 |
+
SynthIce40Pass() : ScriptPass("synth_ice40", "synthesis for iCE40 FPGAs") { }
|
| 32 |
+
|
| 33 |
+
void on_register() override
|
| 34 |
+
{
|
| 35 |
+
RTLIL::constpad["synth_ice40.abc9.hx.W"] = "250";
|
| 36 |
+
RTLIL::constpad["synth_ice40.abc9.lp.W"] = "400";
|
| 37 |
+
RTLIL::constpad["synth_ice40.abc9.u.W"] = "750";
|
| 38 |
+
target_register.emplace("ice40", Target{
|
| 39 |
+
"Lattice iCE40",
|
| 40 |
+
{
|
| 41 |
+
{"", { // default
|
| 42 |
+
"",
|
| 43 |
+
{"+/ice40/cells_sim.v"}
|
| 44 |
+
}}
|
| 45 |
+
}
|
| 46 |
+
});
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
void help() override
|
| 50 |
+
{
|
| 51 |
+
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
| 52 |
+
log("\n");
|
| 53 |
+
log(" synth_ice40 [options]\n");
|
| 54 |
+
log("\n");
|
| 55 |
+
log("This command runs synthesis for iCE40 FPGAs.\n");
|
| 56 |
+
log("\n");
|
| 57 |
+
log(" -device < hx | lp | u >\n");
|
| 58 |
+
log(" optimise timing for the specified device. default: hx\n");
|
| 59 |
+
log(" (irrelevant if -noabc)\n");
|
| 60 |
+
log("\n");
|
| 61 |
+
log(" -top <module>\n");
|
| 62 |
+
log(" use the specified module as top module\n");
|
| 63 |
+
log("\n");
|
| 64 |
+
log(" -blif <file>\n");
|
| 65 |
+
log(" write the design to the specified BLIF file. writing of an output file\n");
|
| 66 |
+
log(" is omitted if this parameter is not specified.\n");
|
| 67 |
+
log("\n");
|
| 68 |
+
log(" -edif <file>\n");
|
| 69 |
+
log(" write the design to the specified EDIF file. writing of an output file\n");
|
| 70 |
+
log(" is omitted if this parameter is not specified.\n");
|
| 71 |
+
log("\n");
|
| 72 |
+
log(" -json <file>\n");
|
| 73 |
+
log(" write the design to the specified JSON file. writing of an output file\n");
|
| 74 |
+
log(" is omitted if this parameter is not specified.\n");
|
| 75 |
+
log("\n");
|
| 76 |
+
log(" -run <from_label>:<to_label>\n");
|
| 77 |
+
log(" only run the commands between the labels (see below). an empty\n");
|
| 78 |
+
log(" from label is synonymous to 'begin', and empty to label is\n");
|
| 79 |
+
log(" synonymous to the end of the command list.\n");
|
| 80 |
+
log("\n");
|
| 81 |
+
log(" -noflatten\n");
|
| 82 |
+
log(" do not flatten design before synthesis\n");
|
| 83 |
+
log("\n");
|
| 84 |
+
log(" -dff\n");
|
| 85 |
+
log(" run 'abc9' with -dff option\n");
|
| 86 |
+
log("\n");
|
| 87 |
+
log(" -nocarry\n");
|
| 88 |
+
log(" do not use SB_CARRY cells in output netlist\n");
|
| 89 |
+
log("\n");
|
| 90 |
+
log(" -nodffe\n");
|
| 91 |
+
log(" do not use SB_DFFE* cells in output netlist\n");
|
| 92 |
+
log("\n");
|
| 93 |
+
log(" -dffe_min_ce_use <min_ce_use>\n");
|
| 94 |
+
log(" do not use SB_DFFE* cells if the resulting CE line would go to less\n");
|
| 95 |
+
log(" than min_ce_use SB_DFFE* in output netlist\n");
|
| 96 |
+
log("\n");
|
| 97 |
+
log(" -nobram\n");
|
| 98 |
+
log(" do not use SB_RAM40_4K* cells in output netlist\n");
|
| 99 |
+
log("\n");
|
| 100 |
+
log(" -spram\n");
|
| 101 |
+
log(" enable automatic inference of SB_SPRAM256KA\n");
|
| 102 |
+
log("\n");
|
| 103 |
+
log(" -dsp\n");
|
| 104 |
+
log(" use iCE40 UltraPlus DSP cells for large arithmetic\n");
|
| 105 |
+
log("\n");
|
| 106 |
+
log(" -noabc\n");
|
| 107 |
+
log(" use built-in Yosys LUT techmapping instead of abc9\n");
|
| 108 |
+
log("\n");
|
| 109 |
+
log(" -vpr\n");
|
| 110 |
+
log(" generate an output netlist (and BLIF file) suitable for VPR\n");
|
| 111 |
+
log(" (this feature is experimental and incomplete)\n");
|
| 112 |
+
log("\n");
|
| 113 |
+
log(" -no-rw-check\n");
|
| 114 |
+
log(" marks all recognized read ports as \"return don't-care value on\n");
|
| 115 |
+
log(" read/write collision\" (same result as setting the no_rw_check\n");
|
| 116 |
+
log(" attribute on all memories).\n");
|
| 117 |
+
log("\n");
|
| 118 |
+
SynthLatchesConfig::help();
|
| 119 |
+
log("\n");
|
| 120 |
+
log("\n");
|
| 121 |
+
log("The following commands are executed by this synthesis command:\n");
|
| 122 |
+
help_script();
|
| 123 |
+
log("\n");
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
string top_opt, blif_file, edif_file, json_file, device_opt;
|
| 127 |
+
SynthLatchesConfig latches;
|
| 128 |
+
bool nocarry, nodffe, nobram, spram, dsp, flatten, noabc, vpr, dff, no_rw_check;
|
| 129 |
+
int min_ce_use;
|
| 130 |
+
|
| 131 |
+
void clear_flags() override
|
| 132 |
+
{
|
| 133 |
+
top_opt = "-auto-top";
|
| 134 |
+
blif_file = "";
|
| 135 |
+
edif_file = "";
|
| 136 |
+
json_file = "";
|
| 137 |
+
nocarry = false;
|
| 138 |
+
nodffe = false;
|
| 139 |
+
min_ce_use = -1;
|
| 140 |
+
nobram = false;
|
| 141 |
+
spram = false;
|
| 142 |
+
dsp = false;
|
| 143 |
+
flatten = true;
|
| 144 |
+
noabc = false;
|
| 145 |
+
vpr = false;
|
| 146 |
+
device_opt = "hx";
|
| 147 |
+
no_rw_check = false;
|
| 148 |
+
latches = SynthLatchesConfig();
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
void execute(std::vector<std::string> args, RTLIL::Design *design) override
|
| 152 |
+
{
|
| 153 |
+
string run_from, run_to;
|
| 154 |
+
clear_flags();
|
| 155 |
+
|
| 156 |
+
size_t argidx;
|
| 157 |
+
for (argidx = 1; argidx < args.size(); argidx++)
|
| 158 |
+
{
|
| 159 |
+
if (args[argidx] == "-top" && argidx+1 < args.size()) {
|
| 160 |
+
top_opt = "-top " + args[++argidx];
|
| 161 |
+
continue;
|
| 162 |
+
}
|
| 163 |
+
if (args[argidx] == "-blif" && argidx+1 < args.size()) {
|
| 164 |
+
blif_file = args[++argidx];
|
| 165 |
+
continue;
|
| 166 |
+
}
|
| 167 |
+
if (args[argidx] == "-edif" && argidx+1 < args.size()) {
|
| 168 |
+
edif_file = args[++argidx];
|
| 169 |
+
continue;
|
| 170 |
+
}
|
| 171 |
+
if (args[argidx] == "-json" && argidx+1 < args.size()) {
|
| 172 |
+
json_file = args[++argidx];
|
| 173 |
+
continue;
|
| 174 |
+
}
|
| 175 |
+
if (args[argidx] == "-run" && argidx+1 < args.size()) {
|
| 176 |
+
size_t pos = args[argidx+1].find(':');
|
| 177 |
+
if (pos == std::string::npos)
|
| 178 |
+
break;
|
| 179 |
+
run_from = args[++argidx].substr(0, pos);
|
| 180 |
+
run_to = args[argidx].substr(pos+1);
|
| 181 |
+
continue;
|
| 182 |
+
}
|
| 183 |
+
if (args[argidx] == "-flatten") {
|
| 184 |
+
flatten = true;
|
| 185 |
+
continue;
|
| 186 |
+
}
|
| 187 |
+
if (args[argidx] == "-noflatten") {
|
| 188 |
+
flatten = false;
|
| 189 |
+
continue;
|
| 190 |
+
}
|
| 191 |
+
if (args[argidx] == "-retime") {
|
| 192 |
+
// removed, retiming is not supported with ABC9
|
| 193 |
+
continue;
|
| 194 |
+
}
|
| 195 |
+
if (args[argidx] == "-relut") {
|
| 196 |
+
// removed, opt_lut is always run
|
| 197 |
+
continue;
|
| 198 |
+
}
|
| 199 |
+
if (args[argidx] == "-nocarry") {
|
| 200 |
+
nocarry = true;
|
| 201 |
+
continue;
|
| 202 |
+
}
|
| 203 |
+
if (args[argidx] == "-nodffe") {
|
| 204 |
+
nodffe = true;
|
| 205 |
+
continue;
|
| 206 |
+
}
|
| 207 |
+
if (args[argidx] == "-dffe_min_ce_use" && argidx+1 < args.size()) {
|
| 208 |
+
min_ce_use = atoi(args[++argidx].c_str());
|
| 209 |
+
continue;
|
| 210 |
+
}
|
| 211 |
+
if (args[argidx] == "-nobram") {
|
| 212 |
+
nobram = true;
|
| 213 |
+
continue;
|
| 214 |
+
}
|
| 215 |
+
if (args[argidx] == "-spram") {
|
| 216 |
+
spram = true;
|
| 217 |
+
continue;
|
| 218 |
+
}
|
| 219 |
+
if (args[argidx] == "-dsp") {
|
| 220 |
+
dsp = true;
|
| 221 |
+
continue;
|
| 222 |
+
}
|
| 223 |
+
if (args[argidx] == "-noabc") {
|
| 224 |
+
noabc = true;
|
| 225 |
+
continue;
|
| 226 |
+
}
|
| 227 |
+
if (args[argidx] == "-vpr") {
|
| 228 |
+
vpr = true;
|
| 229 |
+
continue;
|
| 230 |
+
}
|
| 231 |
+
if (args[argidx] == "-abc9") {
|
| 232 |
+
// removed, ABC9 is used if not -noabc
|
| 233 |
+
continue;
|
| 234 |
+
}
|
| 235 |
+
if (args[argidx] == "-noabc9") {
|
| 236 |
+
// removed, ABC9 is used if not -noabc
|
| 237 |
+
continue;
|
| 238 |
+
}
|
| 239 |
+
if (args[argidx] == "-dff") {
|
| 240 |
+
dff = true;
|
| 241 |
+
continue;
|
| 242 |
+
}
|
| 243 |
+
if (args[argidx] == "-device" && argidx+1 < args.size()) {
|
| 244 |
+
device_opt = args[++argidx];
|
| 245 |
+
continue;
|
| 246 |
+
}
|
| 247 |
+
if (args[argidx] == "-no-rw-check") {
|
| 248 |
+
no_rw_check = true;
|
| 249 |
+
continue;
|
| 250 |
+
}
|
| 251 |
+
if (latches.parse(args, argidx))
|
| 252 |
+
continue;
|
| 253 |
+
break;
|
| 254 |
+
}
|
| 255 |
+
extra_args(args, argidx, design);
|
| 256 |
+
|
| 257 |
+
if (!design->full_selection())
|
| 258 |
+
log_cmd_error("This command only operates on fully selected designs!\n");
|
| 259 |
+
if (device_opt != "hx" && device_opt != "lp" && device_opt !="u")
|
| 260 |
+
log_cmd_error("Invalid or no device specified: '%s'\n", device_opt);
|
| 261 |
+
|
| 262 |
+
log_header(design, "Executing SYNTH_ICE40 pass.\n");
|
| 263 |
+
log_push();
|
| 264 |
+
|
| 265 |
+
run_script(design, run_from, run_to);
|
| 266 |
+
|
| 267 |
+
log_pop();
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
void script() override
|
| 271 |
+
{
|
| 272 |
+
std::string define;
|
| 273 |
+
if (device_opt == "lp")
|
| 274 |
+
define = "-D ICE40_LP";
|
| 275 |
+
else if (device_opt == "u")
|
| 276 |
+
define = "-D ICE40_U";
|
| 277 |
+
else
|
| 278 |
+
define = "-D ICE40_HX";
|
| 279 |
+
std::string no_rw_check_opt = "";
|
| 280 |
+
if (no_rw_check)
|
| 281 |
+
no_rw_check_opt = " -no-rw-check";
|
| 282 |
+
if (help_mode)
|
| 283 |
+
no_rw_check_opt = " [-no-rw-check]";
|
| 284 |
+
|
| 285 |
+
if (check_label("begin"))
|
| 286 |
+
{
|
| 287 |
+
run("read_verilog " + define + " -lib -specify +/ice40/cells_sim.v");
|
| 288 |
+
run(stringf("hierarchy -check %s", help_mode ? "-top <top>" : top_opt));
|
| 289 |
+
run(stringf("proc -latches %s", latches.str()));
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
if (check_label("flatten", "(unless -noflatten)"))
|
| 293 |
+
{
|
| 294 |
+
if (flatten) {
|
| 295 |
+
run("check");
|
| 296 |
+
run("flatten");
|
| 297 |
+
run("tribuf -logic");
|
| 298 |
+
run("deminout");
|
| 299 |
+
}
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
+
if (check_label("coarse"))
|
| 303 |
+
{
|
| 304 |
+
run("opt_expr");
|
| 305 |
+
run("check");
|
| 306 |
+
run("opt_clean");
|
| 307 |
+
run("opt -nodffe -nosdff");
|
| 308 |
+
run("fsm");
|
| 309 |
+
run("opt");
|
| 310 |
+
run("wreduce");
|
| 311 |
+
run("peepopt");
|
| 312 |
+
run("opt_clean");
|
| 313 |
+
run("share");
|
| 314 |
+
run("techmap -map +/cmp2lut.v -D LUT_WIDTH=4");
|
| 315 |
+
run("opt_expr");
|
| 316 |
+
run("opt_clean");
|
| 317 |
+
if (help_mode || dsp) {
|
| 318 |
+
run("memory_dff" + no_rw_check_opt); // ice40_dsp will merge registers, reserve memory port registers first
|
| 319 |
+
// give every product its own adder for the DSP post-adder
|
| 320 |
+
run("alumacc -macc-only", " (if -dsp)");
|
| 321 |
+
run("maccmap -unmap", " (if -dsp)");
|
| 322 |
+
run("opt_clean", " (if -dsp)");
|
| 323 |
+
run("wreduce t:$mul");
|
| 324 |
+
run("techmap -map +/mul2dsp.v -map +/ice40/dsp_map.v -D DSP_A_MAXWIDTH=16 -D DSP_B_MAXWIDTH=16 "
|
| 325 |
+
"-D DSP_A_MINWIDTH=2 -D DSP_B_MINWIDTH=2 -D DSP_Y_MINWIDTH=11 "
|
| 326 |
+
"-D DSP_NAME=$__MUL16X16", "(if -dsp)");
|
| 327 |
+
run("select a:mul2dsp", " (if -dsp)");
|
| 328 |
+
run("setattr -unset mul2dsp", " (if -dsp)");
|
| 329 |
+
run("opt_expr -fine", " (if -dsp)");
|
| 330 |
+
run("wreduce", " (if -dsp)");
|
| 331 |
+
run("select -clear", " (if -dsp)");
|
| 332 |
+
run("ice40_dsp", " (if -dsp)");
|
| 333 |
+
run("chtype -set $mul t:$__soft_mul", "(if -dsp)");
|
| 334 |
+
}
|
| 335 |
+
run("alumacc");
|
| 336 |
+
run("opt");
|
| 337 |
+
run("memory -nomap" + no_rw_check_opt);
|
| 338 |
+
run("opt_clean");
|
| 339 |
+
}
|
| 340 |
+
|
| 341 |
+
if (check_label("map_ram"))
|
| 342 |
+
{
|
| 343 |
+
std::string args = "";
|
| 344 |
+
if (help_mode)
|
| 345 |
+
args += " [-no-auto-huge] [-no-auto-block]";
|
| 346 |
+
else {
|
| 347 |
+
if (!spram)
|
| 348 |
+
args += " -no-auto-huge";
|
| 349 |
+
if (nobram)
|
| 350 |
+
args += " -no-auto-block";
|
| 351 |
+
}
|
| 352 |
+
run("memory_libmap -lib +/ice40/brams.txt -lib +/ice40/spram.txt" + args, "(-no-auto-huge unless -spram, -no-auto-block if -nobram)");
|
| 353 |
+
run("techmap -map +/ice40/brams_map.v -map +/ice40/spram_map.v");
|
| 354 |
+
run("ice40_braminit");
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
if (check_label("map_ffram"))
|
| 358 |
+
{
|
| 359 |
+
run("opt -fast -mux_undef -undriven -fine");
|
| 360 |
+
run("memory_map");
|
| 361 |
+
run("opt -undriven -fine");
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
if (check_label("map_gates"))
|
| 365 |
+
{
|
| 366 |
+
if (nocarry)
|
| 367 |
+
run("techmap");
|
| 368 |
+
else {
|
| 369 |
+
run("ice40_wrapcarry");
|
| 370 |
+
run("techmap -map +/techmap.v -map +/ice40/arith_map.v");
|
| 371 |
+
}
|
| 372 |
+
run("opt -fast");
|
| 373 |
+
run("ice40_opt");
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
if (check_label("map_ffs"))
|
| 377 |
+
{
|
| 378 |
+
if (nodffe)
|
| 379 |
+
run(stringf("dfflegalize -cell $_DFF_?_ 0 -cell $_DFF_?P?_ 0 -cell $_SDFF_?P?_ 0 -cell $_DLATCH_?_ x"));
|
| 380 |
+
else
|
| 381 |
+
run(stringf("dfflegalize -cell $_DFF_?_ 0 -cell $_DFFE_?P_ 0 -cell $_DFF_?P?_ 0 -cell $_DFFE_?P?P_ 0 -cell $_SDFF_?P?_ 0 -cell $_SDFFCE_?P?P_ 0 -cell $_DLATCH_?_ x -mince %d", min_ce_use));
|
| 382 |
+
run("techmap -map +/ice40/ff_map.v");
|
| 383 |
+
run("opt_expr -mux_undef");
|
| 384 |
+
run("simplemap");
|
| 385 |
+
run("ice40_opt -full");
|
| 386 |
+
}
|
| 387 |
+
|
| 388 |
+
if (check_label("map_luts"))
|
| 389 |
+
{
|
| 390 |
+
if (latches.policy == LatchPolicy::Error || help_mode)
|
| 391 |
+
run("check -latchonly -assert", "(only if -latches error, the default)");
|
| 392 |
+
run("techmap -map +/ice40/latches_map.v");
|
| 393 |
+
if (noabc || help_mode) {
|
| 394 |
+
run("simplemap", " (if -noabc)");
|
| 395 |
+
if (noabc || help_mode)
|
| 396 |
+
run("techmap -map +/gate2lut.v -D LUT_WIDTH=4", "(only if -noabc)");
|
| 397 |
+
}
|
| 398 |
+
if (!noabc) {
|
| 399 |
+
run("read_verilog " + define + " -icells -lib -specify +/ice40/abc9_model.v");
|
| 400 |
+
std::string abc9_opts;
|
| 401 |
+
std::string k = "synth_ice40.abc9.W";
|
| 402 |
+
if (active_design && active_design->scratchpad.count(k))
|
| 403 |
+
abc9_opts += stringf(" -W %s", active_design->scratchpad_get_string(k));
|
| 404 |
+
else {
|
| 405 |
+
k = stringf("synth_ice40.abc9.%s.W", device_opt);
|
| 406 |
+
abc9_opts += stringf(" -W %s", RTLIL::constpad.at(k));
|
| 407 |
+
}
|
| 408 |
+
if (dff)
|
| 409 |
+
abc9_opts += " -dff";
|
| 410 |
+
run("abc9 " + abc9_opts);
|
| 411 |
+
}
|
| 412 |
+
run("ice40_wrapcarry -unwrap");
|
| 413 |
+
run("techmap -map +/ice40/ff_map.v");
|
| 414 |
+
run("clean");
|
| 415 |
+
run("opt_lut -tech ice40");
|
| 416 |
+
}
|
| 417 |
+
|
| 418 |
+
if (check_label("map_cells"))
|
| 419 |
+
{
|
| 420 |
+
if (help_mode)
|
| 421 |
+
run("techmap -map +/ice40/cells_map.v", "(skip if -vpr)");
|
| 422 |
+
else if (!vpr)
|
| 423 |
+
run("techmap -map +/ice40/cells_map.v");
|
| 424 |
+
run("clean");
|
| 425 |
+
}
|
| 426 |
+
|
| 427 |
+
if (check_label("check"))
|
| 428 |
+
{
|
| 429 |
+
run("autoname");
|
| 430 |
+
run("hierarchy -check");
|
| 431 |
+
run("stat");
|
| 432 |
+
run("check -noinit");
|
| 433 |
+
run("blackbox =A:whitebox");
|
| 434 |
+
}
|
| 435 |
+
|
| 436 |
+
if (check_label("blif"))
|
| 437 |
+
{
|
| 438 |
+
if (!blif_file.empty() || help_mode) {
|
| 439 |
+
if (vpr || help_mode) {
|
| 440 |
+
run(stringf("opt_clean -purge"),
|
| 441 |
+
" (vpr mode)");
|
| 442 |
+
run(stringf("write_blif -attr -cname -conn -param %s",
|
| 443 |
+
help_mode ? "<file-name>" : blif_file),
|
| 444 |
+
" (vpr mode)");
|
| 445 |
+
}
|
| 446 |
+
if (!vpr)
|
| 447 |
+
run(stringf("write_blif -gates -attr -param %s",
|
| 448 |
+
help_mode ? "<file-name>" : blif_file),
|
| 449 |
+
" (non-vpr mode)");
|
| 450 |
+
}
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
+
if (check_label("edif"))
|
| 454 |
+
{
|
| 455 |
+
if (!edif_file.empty() || help_mode)
|
| 456 |
+
run(stringf("write_edif %s", help_mode ? "<file-name>" : edif_file));
|
| 457 |
+
}
|
| 458 |
+
|
| 459 |
+
if (check_label("json"))
|
| 460 |
+
{
|
| 461 |
+
if (!json_file.empty() || help_mode)
|
| 462 |
+
run(stringf("write_json %s", help_mode ? "<file-name>" : json_file));
|
| 463 |
+
}
|
| 464 |
+
}
|
| 465 |
+
} SynthIce40Pass;
|
| 466 |
+
|
| 467 |
+
PRIVATE_NAMESPACE_END
|
chips/yosys/techlibs/ice40/tests/.gitignore
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/test_ffs_[01][01][01][01][01]_*
|
| 2 |
+
/test_bram_[0-9]*
|
| 3 |
+
/test_dsp_model
|
| 4 |
+
/test_dsp_model.vcd
|
| 5 |
+
/test_dsp_model_ref.v
|
| 6 |
+
/test_dsp_model_uut.v
|
| 7 |
+
/test_dsp_map
|
| 8 |
+
/test_dsp_map.vcd
|
| 9 |
+
/test_dsp_map_tb.v
|
| 10 |
+
/test_dsp_map_top.v
|
| 11 |
+
/test_dsp_map_syn.v
|
chips/yosys/techlibs/ice40/tests/test_arith.v
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module test(input [4:0] a, b, c, output [4:0] y);
|
| 2 |
+
assign y = ((a+b) ^ (a-c)) - ((a*b) + (a*c) - (b*c));
|
| 3 |
+
endmodule
|
chips/yosys/techlibs/ice40/tests/test_arith.ys
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
read_verilog test_arith.v
|
| 2 |
+
synth_ice40
|
| 3 |
+
rename test gate
|
| 4 |
+
|
| 5 |
+
read_verilog test_arith.v
|
| 6 |
+
rename test gold
|
| 7 |
+
|
| 8 |
+
miter -equiv -flatten -make_outputs gold gate miter
|
| 9 |
+
sat -verify -prove trigger 0 -show-ports miter
|
| 10 |
+
|
| 11 |
+
synth_ice40 -top gate
|
| 12 |
+
|
| 13 |
+
read_verilog test_arith.v
|
| 14 |
+
rename test gold
|
| 15 |
+
|
| 16 |
+
miter -equiv -flatten -make_outputs gold gate miter
|
| 17 |
+
sat -verify -prove trigger 0 -show-ports miter
|
chips/yosys/techlibs/ice40/tests/test_bram.sh
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
|
| 3 |
+
set -ex
|
| 4 |
+
|
| 5 |
+
for abits in 7 8 9 10 11 12; do
|
| 6 |
+
for dbits in 2 4 8 16 24 32; do
|
| 7 |
+
id="test_bram_${abits}_${dbits}"
|
| 8 |
+
iadr=$((RANDOM % (1 << abits)))
|
| 9 |
+
idat=$((RANDOM % ((1 << dbits) - 1) + 1))
|
| 10 |
+
sed -re "s/(ABITS = )0/\1$abits/g; s/(DBITS = )0/\1$dbits/g; s/(INIT_ADDR = )0/\1$iadr/g; s/(INIT_DATA = )0/\1$idat/g;" < test_bram.v > ${id}.v
|
| 11 |
+
sed -re "s/(ABITS = )0/\1$abits/g; s/(DBITS = )0/\1$dbits/g; s/(INIT_ADDR = )0/\1$iadr/g; s/(INIT_DATA = )0/\1$idat/g;" < test_bram_tb.v > ${id}_tb.v
|
| 12 |
+
../../../yosys -ql ${id}_syn.log -p "synth_ice40" -o ${id}_syn.v ${id}.v
|
| 13 |
+
# iverilog -s bram_tb -o ${id}_tb ${id}_syn.v ${id}_tb.v /opt/lscc/iCEcube2.2014.08/verilog/sb_ice_syn.v
|
| 14 |
+
iverilog -s bram_tb -o ${id}_tb ${id}_syn.v ${id}_tb.v ../cells_sim.v
|
| 15 |
+
./${id}_tb > ${id}_tb.txt
|
| 16 |
+
if grep -H ERROR ${id}_tb.txt; then false; fi
|
| 17 |
+
done; done
|
| 18 |
+
echo OK
|
chips/yosys/techlibs/ice40/tests/test_bram.v
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module bram #(
|
| 2 |
+
parameter ABITS = 8, DBITS = 8,
|
| 3 |
+
parameter INIT_ADDR = 0, INIT_DATA = 0
|
| 4 |
+
) (
|
| 5 |
+
input clk,
|
| 6 |
+
|
| 7 |
+
input [ABITS-1:0] WR_ADDR,
|
| 8 |
+
input [DBITS-1:0] WR_DATA,
|
| 9 |
+
input WR_EN,
|
| 10 |
+
|
| 11 |
+
input [ABITS-1:0] RD_ADDR,
|
| 12 |
+
output reg [DBITS-1:0] RD_DATA
|
| 13 |
+
);
|
| 14 |
+
reg [DBITS-1:0] memory [0:2**ABITS-1];
|
| 15 |
+
|
| 16 |
+
initial begin
|
| 17 |
+
memory[INIT_ADDR] <= INIT_DATA;
|
| 18 |
+
end
|
| 19 |
+
|
| 20 |
+
always @(posedge clk) begin
|
| 21 |
+
if (WR_EN) memory[WR_ADDR] <= WR_DATA;
|
| 22 |
+
RD_DATA <= memory[RD_ADDR];
|
| 23 |
+
end
|
| 24 |
+
endmodule
|
chips/yosys/techlibs/ice40/tests/test_bram_tb.v
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module bram_tb #(
|
| 2 |
+
parameter ABITS = 8, DBITS = 8,
|
| 3 |
+
parameter INIT_ADDR = 0, INIT_DATA = 0
|
| 4 |
+
);
|
| 5 |
+
reg clk;
|
| 6 |
+
reg [ABITS-1:0] WR_ADDR;
|
| 7 |
+
reg [DBITS-1:0] WR_DATA;
|
| 8 |
+
reg WR_EN;
|
| 9 |
+
reg [ABITS-1:0] RD_ADDR;
|
| 10 |
+
wire [DBITS-1:0] RD_DATA;
|
| 11 |
+
|
| 12 |
+
bram uut (
|
| 13 |
+
.clk (clk ),
|
| 14 |
+
.WR_ADDR(WR_ADDR),
|
| 15 |
+
.WR_DATA(WR_DATA),
|
| 16 |
+
.WR_EN (WR_EN ),
|
| 17 |
+
.RD_ADDR(RD_ADDR),
|
| 18 |
+
.RD_DATA(RD_DATA)
|
| 19 |
+
);
|
| 20 |
+
|
| 21 |
+
reg [63:0] xorshift64_state = 64'd88172645463325252 ^ (ABITS << 24) ^ (DBITS << 16);
|
| 22 |
+
|
| 23 |
+
task xorshift64_next;
|
| 24 |
+
begin
|
| 25 |
+
// see page 4 of Marsaglia, George (July 2003). "Xorshift RNGs". Journal of Statistical Software 8 (14).
|
| 26 |
+
xorshift64_state = xorshift64_state ^ (xorshift64_state << 13);
|
| 27 |
+
xorshift64_state = xorshift64_state ^ (xorshift64_state >> 7);
|
| 28 |
+
xorshift64_state = xorshift64_state ^ (xorshift64_state << 17);
|
| 29 |
+
end
|
| 30 |
+
endtask
|
| 31 |
+
|
| 32 |
+
reg [ABITS-1:0] randaddr1;
|
| 33 |
+
reg [ABITS-1:0] randaddr2;
|
| 34 |
+
reg [ABITS-1:0] randaddr3;
|
| 35 |
+
|
| 36 |
+
function [31:0] getaddr(input [3:0] n);
|
| 37 |
+
begin
|
| 38 |
+
case (n)
|
| 39 |
+
0: getaddr = 0;
|
| 40 |
+
1: getaddr = 2**ABITS-1;
|
| 41 |
+
2: getaddr = 'b101 << (ABITS / 3);
|
| 42 |
+
3: getaddr = 'b101 << (2*ABITS / 3);
|
| 43 |
+
4: getaddr = 'b11011 << (ABITS / 4);
|
| 44 |
+
5: getaddr = 'b11011 << (2*ABITS / 4);
|
| 45 |
+
6: getaddr = 'b11011 << (3*ABITS / 4);
|
| 46 |
+
7: getaddr = randaddr1;
|
| 47 |
+
8: getaddr = randaddr2;
|
| 48 |
+
9: getaddr = randaddr3;
|
| 49 |
+
default: begin
|
| 50 |
+
getaddr = 1 << (2*n-16);
|
| 51 |
+
if (!getaddr) getaddr = xorshift64_state;
|
| 52 |
+
end
|
| 53 |
+
endcase
|
| 54 |
+
end
|
| 55 |
+
endfunction
|
| 56 |
+
|
| 57 |
+
reg [DBITS-1:0] memory [0:2**ABITS-1];
|
| 58 |
+
reg [DBITS-1:0] expected_rd, expected_rd_masked;
|
| 59 |
+
|
| 60 |
+
event error;
|
| 61 |
+
integer i, j;
|
| 62 |
+
|
| 63 |
+
initial begin
|
| 64 |
+
// $dumpfile("testbench.vcd");
|
| 65 |
+
// $dumpvars(0, bram_tb);
|
| 66 |
+
|
| 67 |
+
memory[INIT_ADDR] <= INIT_DATA;
|
| 68 |
+
|
| 69 |
+
xorshift64_next;
|
| 70 |
+
xorshift64_next;
|
| 71 |
+
xorshift64_next;
|
| 72 |
+
xorshift64_next;
|
| 73 |
+
|
| 74 |
+
randaddr1 = xorshift64_state;
|
| 75 |
+
xorshift64_next;
|
| 76 |
+
|
| 77 |
+
randaddr2 = xorshift64_state;
|
| 78 |
+
xorshift64_next;
|
| 79 |
+
|
| 80 |
+
randaddr3 = xorshift64_state;
|
| 81 |
+
xorshift64_next;
|
| 82 |
+
|
| 83 |
+
clk <= 0;
|
| 84 |
+
for (i = 0; i < 512; i = i+1) begin
|
| 85 |
+
WR_DATA = xorshift64_state;
|
| 86 |
+
xorshift64_next;
|
| 87 |
+
|
| 88 |
+
WR_ADDR = getaddr(i < 256 ? i[7:4] : xorshift64_state[63:60]);
|
| 89 |
+
xorshift64_next;
|
| 90 |
+
|
| 91 |
+
RD_ADDR = i == 0 ? INIT_ADDR : getaddr(i < 256 ? i[3:0] : xorshift64_state[59:56]);
|
| 92 |
+
WR_EN = xorshift64_state[55] && ((WR_ADDR & 'hff) != (RD_ADDR & 'hff));
|
| 93 |
+
xorshift64_next;
|
| 94 |
+
|
| 95 |
+
#1; clk <= 1;
|
| 96 |
+
#1; clk <= 0;
|
| 97 |
+
|
| 98 |
+
expected_rd = memory[RD_ADDR];
|
| 99 |
+
if (WR_EN) memory[WR_ADDR] = WR_DATA;
|
| 100 |
+
|
| 101 |
+
for (j = 0; j < DBITS; j = j+1)
|
| 102 |
+
expected_rd_masked[j] = expected_rd[j] !== 1'bx ? expected_rd[j] : RD_DATA[j];
|
| 103 |
+
|
| 104 |
+
$display("#OUT# %3d | WA=%x WD=%x WE=%x | RA=%x RD=%x (%x) | %s",
|
| 105 |
+
i, WR_ADDR, WR_DATA, WR_EN, RD_ADDR, RD_DATA, expected_rd,
|
| 106 |
+
expected_rd_masked === RD_DATA ? "ok" : "ERROR");
|
| 107 |
+
if (expected_rd_masked !== RD_DATA) begin -> error; end
|
| 108 |
+
end
|
| 109 |
+
end
|
| 110 |
+
endmodule
|
chips/yosys/techlibs/ice40/tests/test_dsp_map.sh
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -ex
|
| 3 |
+
|
| 4 |
+
for iter in {1..100}
|
| 5 |
+
do
|
| 6 |
+
SZA=$(( 3 + $RANDOM % 13 ))
|
| 7 |
+
SZB=$(( 3 + $RANDOM % 13 ))
|
| 8 |
+
SZO=$(( 3 + $RANDOM % 29 ))
|
| 9 |
+
|
| 10 |
+
C0=clk$(( $RANDOM & 1))
|
| 11 |
+
C1=clk$(( $RANDOM & 1))
|
| 12 |
+
C2=clk$(( $RANDOM & 1))
|
| 13 |
+
C3=clk$(( $RANDOM & 1))
|
| 14 |
+
|
| 15 |
+
E0=$( test $(( $RANDOM & 1 )) -eq 0 && echo posedge || echo negedge )
|
| 16 |
+
E1=$( test $(( $RANDOM & 1 )) -eq 0 && echo posedge || echo negedge )
|
| 17 |
+
E2=$( test $(( $RANDOM & 1 )) -eq 0 && echo posedge || echo negedge )
|
| 18 |
+
E3=$( test $(( $RANDOM & 1 )) -eq 0 && echo posedge || echo negedge )
|
| 19 |
+
|
| 20 |
+
SP=$( test $(( $RANDOM & 1 )) -eq 0 && echo S || echo P )
|
| 21 |
+
|
| 22 |
+
RC=$( test $(( $RANDOM & 1 )) -eq 0 && echo "reset" || echo "!reset" )
|
| 23 |
+
RV="32'h$( echo $RANDOM | md5sum | cut -c1-8 )"
|
| 24 |
+
|
| 25 |
+
cat > test_dsp_map_top.v << EOT
|
| 26 |
+
module top (
|
| 27 |
+
input clk0, clk1, reset,
|
| 28 |
+
input [$SZA:0] A,
|
| 29 |
+
input [$SZB:0] B,
|
| 30 |
+
output [$SZO:0] O
|
| 31 |
+
);
|
| 32 |
+
reg [15:0] AA, BB;
|
| 33 |
+
reg [31:0] P, S;
|
| 34 |
+
|
| 35 |
+
always @($E0 $C0) AA <= A;
|
| 36 |
+
always @($E1 $C1) BB <= B;
|
| 37 |
+
always @($E2 $C2) P <= AA * BB;
|
| 38 |
+
always @($E3 $C3) S <= $RC ? $RV : S + P;
|
| 39 |
+
assign O = $SP;
|
| 40 |
+
endmodule
|
| 41 |
+
EOT
|
| 42 |
+
|
| 43 |
+
cat > test_dsp_map_tb.v << EOT
|
| 44 |
+
\`timescale 1ns / 1ps
|
| 45 |
+
module testbench;
|
| 46 |
+
reg clk1, clk0, reset;
|
| 47 |
+
reg [$SZA:0] A;
|
| 48 |
+
reg [$SZB:0] B;
|
| 49 |
+
|
| 50 |
+
wire [$SZO:0] O_top, O_syn;
|
| 51 |
+
|
| 52 |
+
top top_inst (.clk0(clk0), .clk1(clk1), .reset(reset), .A(A), .B(B), .O(O_top));
|
| 53 |
+
syn syn_inst (.clk0(clk0), .clk1(clk1), .reset(reset), .A(A), .B(B), .O(O_syn));
|
| 54 |
+
|
| 55 |
+
initial begin
|
| 56 |
+
// \$dumpfile("test_dsp_map.vcd");
|
| 57 |
+
// \$dumpvars(0, testbench);
|
| 58 |
+
|
| 59 |
+
#2;
|
| 60 |
+
clk0 = 0;
|
| 61 |
+
clk1 = 0;
|
| 62 |
+
reset = 1;
|
| 63 |
+
reset = $RC;
|
| 64 |
+
A = 0;
|
| 65 |
+
B = 0;
|
| 66 |
+
|
| 67 |
+
repeat (3) begin
|
| 68 |
+
#2; clk0 = ~clk0;
|
| 69 |
+
#2; clk0 = ~clk0;
|
| 70 |
+
#2; clk1 = ~clk1;
|
| 71 |
+
#2; clk1 = ~clk1;
|
| 72 |
+
end
|
| 73 |
+
|
| 74 |
+
repeat (100) begin
|
| 75 |
+
#2;
|
| 76 |
+
A = \$urandom;
|
| 77 |
+
B = \$urandom;
|
| 78 |
+
reset = \$urandom & \$urandom & \$urandom & \$urandom;
|
| 79 |
+
if (\$urandom & 1) begin
|
| 80 |
+
#2; clk0 = ~clk0;
|
| 81 |
+
#2; clk0 = ~clk0;
|
| 82 |
+
end else begin
|
| 83 |
+
#2; clk1 = ~clk1;
|
| 84 |
+
#2; clk1 = ~clk1;
|
| 85 |
+
end
|
| 86 |
+
#2;
|
| 87 |
+
if (O_top !== O_syn) begin
|
| 88 |
+
\$display("ERROR: O_top=%b O_syn=%b", O_top, O_syn);
|
| 89 |
+
\$stop;
|
| 90 |
+
end
|
| 91 |
+
// \$display("OK O_top=O_syn=%b", O_top);
|
| 92 |
+
end
|
| 93 |
+
|
| 94 |
+
\$display("Test passed.");
|
| 95 |
+
\$finish;
|
| 96 |
+
end
|
| 97 |
+
endmodule
|
| 98 |
+
EOT
|
| 99 |
+
|
| 100 |
+
../../../yosys -p 'read_verilog test_dsp_map_top.v; synth_ice40 -dsp; rename top syn; write_verilog test_dsp_map_syn.v'
|
| 101 |
+
iverilog -o test_dsp_map -s testbench test_dsp_map_tb.v test_dsp_map_top.v test_dsp_map_syn.v ../cells_sim.v
|
| 102 |
+
vvp -N test_dsp_map
|
| 103 |
+
done
|
| 104 |
+
|
| 105 |
+
: ""
|
| 106 |
+
: "#### All tests passed. ####"
|
| 107 |
+
: ""
|
chips/yosys/techlibs/ice40/tests/test_dsp_model.sh
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -ex
|
| 3 |
+
sed 's/SB_MAC16/SB_MAC16_UUT/; /SB_MAC16_UUT/,/endmodule/ p; d;' < ../cells_sim.v > test_dsp_model_uut.v
|
| 4 |
+
if [ ! -f "test_dsp_model_ref.v" ]; then
|
| 5 |
+
cat /opt/lscc/iCEcube2.2017.01/verilog/sb_ice_syn.v > test_dsp_model_ref.v
|
| 6 |
+
fi
|
| 7 |
+
for tb in testbench \
|
| 8 |
+
testbench_comb_8x8_A testbench_comb_8x8_B testbench_comb_16x16 \
|
| 9 |
+
testbench_seq_16x16_A testbench_seq_16x16_B \
|
| 10 |
+
testbench_comb_8x8_A_signedA testbench_comb_8x8_A_signedB testbench_comb_8x8_A_signedAB \
|
| 11 |
+
testbench_comb_8x8_B_signedA testbench_comb_8x8_B_signedB testbench_comb_8x8_B_signedAB \
|
| 12 |
+
testbench_comb_16x16_signedA testbench_comb_16x16_signedB testbench_comb_16x16_signedAB
|
| 13 |
+
do
|
| 14 |
+
iverilog -s $tb -o test_dsp_model test_dsp_model.v test_dsp_model_uut.v test_dsp_model_ref.v
|
| 15 |
+
vvp -N ./test_dsp_model
|
| 16 |
+
done
|
chips/yosys/techlibs/ice40/tests/test_dsp_model.v
ADDED
|
@@ -0,0 +1,567 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
`timescale 1ns / 1ps
|
| 2 |
+
|
| 3 |
+
module testbench;
|
| 4 |
+
parameter [0:0] NEG_TRIGGER = 0;
|
| 5 |
+
parameter [0:0] C_REG = 0;
|
| 6 |
+
parameter [0:0] A_REG = 0;
|
| 7 |
+
parameter [0:0] B_REG = 0;
|
| 8 |
+
parameter [0:0] D_REG = 0;
|
| 9 |
+
parameter [0:0] TOP_8x8_MULT_REG = 0;
|
| 10 |
+
parameter [0:0] BOT_8x8_MULT_REG = 0;
|
| 11 |
+
parameter [0:0] PIPELINE_16x16_MULT_REG1 = 0;
|
| 12 |
+
parameter [0:0] PIPELINE_16x16_MULT_REG2 = 0;
|
| 13 |
+
parameter [1:0] TOPOUTPUT_SELECT = 0;
|
| 14 |
+
parameter [1:0] TOPADDSUB_LOWERINPUT = 0;
|
| 15 |
+
parameter [0:0] TOPADDSUB_UPPERINPUT = 1;
|
| 16 |
+
parameter [1:0] TOPADDSUB_CARRYSELECT = 0;
|
| 17 |
+
parameter [1:0] BOTOUTPUT_SELECT = 0;
|
| 18 |
+
parameter [1:0] BOTADDSUB_LOWERINPUT = 0;
|
| 19 |
+
parameter [0:0] BOTADDSUB_UPPERINPUT = 1;
|
| 20 |
+
parameter [1:0] BOTADDSUB_CARRYSELECT = 0;
|
| 21 |
+
parameter [0:0] MODE_8x8 = 0;
|
| 22 |
+
parameter [0:0] A_SIGNED = 0;
|
| 23 |
+
parameter [0:0] B_SIGNED = 0;
|
| 24 |
+
|
| 25 |
+
reg CLK, CE;
|
| 26 |
+
reg [15:0] C, A, B, D;
|
| 27 |
+
reg AHOLD, BHOLD, CHOLD, DHOLD;
|
| 28 |
+
reg IRSTTOP, IRSTBOT;
|
| 29 |
+
reg ORSTTOP, ORSTBOT;
|
| 30 |
+
reg OLOADTOP, OLOADBOT;
|
| 31 |
+
reg ADDSUBTOP, ADDSUBBOT;
|
| 32 |
+
reg OHOLDTOP, OHOLDBOT;
|
| 33 |
+
reg CI, ACCUMCI, SIGNEXTIN;
|
| 34 |
+
|
| 35 |
+
output [31:0] REF_O, UUT_O;
|
| 36 |
+
output REF_CO, REF_ACCUMCO, REF_SIGNEXTOUT;
|
| 37 |
+
output UUT_CO, UUT_ACCUMCO, UUT_SIGNEXTOUT;
|
| 38 |
+
|
| 39 |
+
integer errcount = 0;
|
| 40 |
+
|
| 41 |
+
task clkcycle;
|
| 42 |
+
begin
|
| 43 |
+
#5;
|
| 44 |
+
CLK = ~CLK;
|
| 45 |
+
#10;
|
| 46 |
+
CLK = ~CLK;
|
| 47 |
+
#2;
|
| 48 |
+
if (REF_O !== UUT_O) begin
|
| 49 |
+
$display("ERROR at %1t: REF_O=%b UUT_O=%b DIFF=%b", $time, REF_O, UUT_O, REF_O ^ UUT_O);
|
| 50 |
+
errcount = errcount + 1;
|
| 51 |
+
end
|
| 52 |
+
if (REF_CO !== UUT_CO) begin
|
| 53 |
+
$display("ERROR at %1t: REF_CO=%b UUT_CO=%b", $time, REF_CO, UUT_CO);
|
| 54 |
+
errcount = errcount + 1;
|
| 55 |
+
end
|
| 56 |
+
if (REF_ACCUMCO !== UUT_ACCUMCO) begin
|
| 57 |
+
$display("ERROR at %1t: REF_ACCUMCO=%b UUT_ACCUMCO=%b", $time, REF_ACCUMCO, UUT_ACCUMCO);
|
| 58 |
+
errcount = errcount + 1;
|
| 59 |
+
end
|
| 60 |
+
if (REF_SIGNEXTOUT !== UUT_SIGNEXTOUT) begin
|
| 61 |
+
$display("ERROR at %1t: REF_SIGNEXTOUT=%b UUT_SIGNEXTOUT=%b", $time, REF_SIGNEXTOUT, UUT_SIGNEXTOUT);
|
| 62 |
+
errcount = errcount + 1;
|
| 63 |
+
end
|
| 64 |
+
#3;
|
| 65 |
+
end
|
| 66 |
+
endtask
|
| 67 |
+
|
| 68 |
+
initial begin
|
| 69 |
+
$dumpfile("test_dsp_model.vcd");
|
| 70 |
+
$dumpvars(0, testbench);
|
| 71 |
+
|
| 72 |
+
#2;
|
| 73 |
+
CLK = NEG_TRIGGER;
|
| 74 |
+
CE = 1;
|
| 75 |
+
{C, A, B, D} = 0;
|
| 76 |
+
{AHOLD, BHOLD, CHOLD, DHOLD} = 0;
|
| 77 |
+
{OLOADTOP, OLOADBOT} = 0;
|
| 78 |
+
{ADDSUBTOP, ADDSUBBOT} = 0;
|
| 79 |
+
{OHOLDTOP, OHOLDBOT} = 0;
|
| 80 |
+
{CI, ACCUMCI, SIGNEXTIN} = 0;
|
| 81 |
+
|
| 82 |
+
{IRSTTOP, IRSTBOT} = ~0;
|
| 83 |
+
{ORSTTOP, ORSTBOT} = ~0;
|
| 84 |
+
|
| 85 |
+
#3;
|
| 86 |
+
{IRSTTOP, IRSTBOT} = 0;
|
| 87 |
+
{ORSTTOP, ORSTBOT} = 0;
|
| 88 |
+
|
| 89 |
+
repeat (300) begin
|
| 90 |
+
clkcycle;
|
| 91 |
+
|
| 92 |
+
A = $urandom;
|
| 93 |
+
B = $urandom;
|
| 94 |
+
C = $urandom;
|
| 95 |
+
D = $urandom;
|
| 96 |
+
|
| 97 |
+
{AHOLD, BHOLD, CHOLD, DHOLD} = $urandom & $urandom & $urandom;
|
| 98 |
+
{OLOADTOP, OLOADBOT} = $urandom & $urandom & $urandom;
|
| 99 |
+
{ADDSUBTOP, ADDSUBBOT} = $urandom & $urandom & $urandom;
|
| 100 |
+
{OHOLDTOP, OHOLDBOT} = $urandom & $urandom & $urandom;
|
| 101 |
+
{CI, ACCUMCI, SIGNEXTIN} = $urandom & $urandom & $urandom;
|
| 102 |
+
|
| 103 |
+
{IRSTTOP, IRSTBOT} = $urandom & $urandom & $urandom;
|
| 104 |
+
{ORSTTOP, ORSTBOT} = $urandom & $urandom & $urandom;
|
| 105 |
+
end
|
| 106 |
+
|
| 107 |
+
if (errcount == 0) begin
|
| 108 |
+
$display("All tests passed.");
|
| 109 |
+
$finish;
|
| 110 |
+
end else begin
|
| 111 |
+
$display("Caught %1d errors.", errcount);
|
| 112 |
+
$stop;
|
| 113 |
+
end
|
| 114 |
+
end
|
| 115 |
+
|
| 116 |
+
SB_MAC16 #(
|
| 117 |
+
.NEG_TRIGGER (NEG_TRIGGER ),
|
| 118 |
+
.C_REG (C_REG ),
|
| 119 |
+
.A_REG (A_REG ),
|
| 120 |
+
.B_REG (B_REG ),
|
| 121 |
+
.D_REG (D_REG ),
|
| 122 |
+
.TOP_8x8_MULT_REG (TOP_8x8_MULT_REG ),
|
| 123 |
+
.BOT_8x8_MULT_REG (BOT_8x8_MULT_REG ),
|
| 124 |
+
.PIPELINE_16x16_MULT_REG1 (PIPELINE_16x16_MULT_REG1),
|
| 125 |
+
.PIPELINE_16x16_MULT_REG2 (PIPELINE_16x16_MULT_REG2),
|
| 126 |
+
.TOPOUTPUT_SELECT (TOPOUTPUT_SELECT ),
|
| 127 |
+
.TOPADDSUB_LOWERINPUT (TOPADDSUB_LOWERINPUT ),
|
| 128 |
+
.TOPADDSUB_UPPERINPUT (TOPADDSUB_UPPERINPUT ),
|
| 129 |
+
.TOPADDSUB_CARRYSELECT (TOPADDSUB_CARRYSELECT ),
|
| 130 |
+
.BOTOUTPUT_SELECT (BOTOUTPUT_SELECT ),
|
| 131 |
+
.BOTADDSUB_LOWERINPUT (BOTADDSUB_LOWERINPUT ),
|
| 132 |
+
.BOTADDSUB_UPPERINPUT (BOTADDSUB_UPPERINPUT ),
|
| 133 |
+
.BOTADDSUB_CARRYSELECT (BOTADDSUB_CARRYSELECT ),
|
| 134 |
+
.MODE_8x8 (MODE_8x8 ),
|
| 135 |
+
.A_SIGNED (A_SIGNED ),
|
| 136 |
+
.B_SIGNED (B_SIGNED )
|
| 137 |
+
) ref (
|
| 138 |
+
.CLK (CLK ),
|
| 139 |
+
.CE (CE ),
|
| 140 |
+
.C (C ),
|
| 141 |
+
.A (A ),
|
| 142 |
+
.B (B ),
|
| 143 |
+
.D (D ),
|
| 144 |
+
.AHOLD (AHOLD ),
|
| 145 |
+
.BHOLD (BHOLD ),
|
| 146 |
+
.CHOLD (CHOLD ),
|
| 147 |
+
.DHOLD (DHOLD ),
|
| 148 |
+
.IRSTTOP (IRSTTOP ),
|
| 149 |
+
.IRSTBOT (IRSTBOT ),
|
| 150 |
+
.ORSTTOP (ORSTTOP ),
|
| 151 |
+
.ORSTBOT (ORSTBOT ),
|
| 152 |
+
.OLOADTOP (OLOADTOP ),
|
| 153 |
+
.OLOADBOT (OLOADBOT ),
|
| 154 |
+
.ADDSUBTOP (ADDSUBTOP ),
|
| 155 |
+
.ADDSUBBOT (ADDSUBBOT ),
|
| 156 |
+
.OHOLDTOP (OHOLDTOP ),
|
| 157 |
+
.OHOLDBOT (OHOLDBOT ),
|
| 158 |
+
.CI (CI ),
|
| 159 |
+
.ACCUMCI (ACCUMCI ),
|
| 160 |
+
.SIGNEXTIN (SIGNEXTIN ),
|
| 161 |
+
.O (REF_O ),
|
| 162 |
+
.CO (REF_CO ),
|
| 163 |
+
.ACCUMCO (REF_ACCUMCO ),
|
| 164 |
+
.SIGNEXTOUT (REF_SIGNEXTOUT)
|
| 165 |
+
);
|
| 166 |
+
|
| 167 |
+
SB_MAC16_UUT #(
|
| 168 |
+
.NEG_TRIGGER (NEG_TRIGGER ),
|
| 169 |
+
.C_REG (C_REG ),
|
| 170 |
+
.A_REG (A_REG ),
|
| 171 |
+
.B_REG (B_REG ),
|
| 172 |
+
.D_REG (D_REG ),
|
| 173 |
+
.TOP_8x8_MULT_REG (TOP_8x8_MULT_REG ),
|
| 174 |
+
.BOT_8x8_MULT_REG (BOT_8x8_MULT_REG ),
|
| 175 |
+
.PIPELINE_16x16_MULT_REG1 (PIPELINE_16x16_MULT_REG1),
|
| 176 |
+
.PIPELINE_16x16_MULT_REG2 (PIPELINE_16x16_MULT_REG2),
|
| 177 |
+
.TOPOUTPUT_SELECT (TOPOUTPUT_SELECT ),
|
| 178 |
+
.TOPADDSUB_LOWERINPUT (TOPADDSUB_LOWERINPUT ),
|
| 179 |
+
.TOPADDSUB_UPPERINPUT (TOPADDSUB_UPPERINPUT ),
|
| 180 |
+
.TOPADDSUB_CARRYSELECT (TOPADDSUB_CARRYSELECT ),
|
| 181 |
+
.BOTOUTPUT_SELECT (BOTOUTPUT_SELECT ),
|
| 182 |
+
.BOTADDSUB_LOWERINPUT (BOTADDSUB_LOWERINPUT ),
|
| 183 |
+
.BOTADDSUB_UPPERINPUT (BOTADDSUB_UPPERINPUT ),
|
| 184 |
+
.BOTADDSUB_CARRYSELECT (BOTADDSUB_CARRYSELECT ),
|
| 185 |
+
.MODE_8x8 (MODE_8x8 ),
|
| 186 |
+
.A_SIGNED (A_SIGNED ),
|
| 187 |
+
.B_SIGNED (B_SIGNED )
|
| 188 |
+
) uut (
|
| 189 |
+
.CLK (CLK ),
|
| 190 |
+
.CE (CE ),
|
| 191 |
+
.C (C ),
|
| 192 |
+
.A (A ),
|
| 193 |
+
.B (B ),
|
| 194 |
+
.D (D ),
|
| 195 |
+
.AHOLD (AHOLD ),
|
| 196 |
+
.BHOLD (BHOLD ),
|
| 197 |
+
.CHOLD (CHOLD ),
|
| 198 |
+
.DHOLD (DHOLD ),
|
| 199 |
+
.IRSTTOP (IRSTTOP ),
|
| 200 |
+
.IRSTBOT (IRSTBOT ),
|
| 201 |
+
.ORSTTOP (ORSTTOP ),
|
| 202 |
+
.ORSTBOT (ORSTBOT ),
|
| 203 |
+
.OLOADTOP (OLOADTOP ),
|
| 204 |
+
.OLOADBOT (OLOADBOT ),
|
| 205 |
+
.ADDSUBTOP (ADDSUBTOP ),
|
| 206 |
+
.ADDSUBBOT (ADDSUBBOT ),
|
| 207 |
+
.OHOLDTOP (OHOLDTOP ),
|
| 208 |
+
.OHOLDBOT (OHOLDBOT ),
|
| 209 |
+
.CI (CI ),
|
| 210 |
+
.ACCUMCI (ACCUMCI ),
|
| 211 |
+
.SIGNEXTIN (SIGNEXTIN ),
|
| 212 |
+
.O (UUT_O ),
|
| 213 |
+
.CO (UUT_CO ),
|
| 214 |
+
.ACCUMCO (UUT_ACCUMCO ),
|
| 215 |
+
.SIGNEXTOUT (UUT_SIGNEXTOUT)
|
| 216 |
+
);
|
| 217 |
+
endmodule
|
| 218 |
+
|
| 219 |
+
module testbench_comb_8x8_A;
|
| 220 |
+
testbench #(
|
| 221 |
+
.NEG_TRIGGER (0),
|
| 222 |
+
.C_REG (0),
|
| 223 |
+
.A_REG (0),
|
| 224 |
+
.B_REG (0),
|
| 225 |
+
.D_REG (0),
|
| 226 |
+
.TOP_8x8_MULT_REG (0),
|
| 227 |
+
.BOT_8x8_MULT_REG (0),
|
| 228 |
+
.PIPELINE_16x16_MULT_REG1 (0),
|
| 229 |
+
.PIPELINE_16x16_MULT_REG2 (0),
|
| 230 |
+
.TOPOUTPUT_SELECT (2), // 0=P, 1=Q, 2=8x8, 3=16x16
|
| 231 |
+
.TOPADDSUB_LOWERINPUT (0), // 0=A, 1=8x8, 2=16x16, 3=S-EXT
|
| 232 |
+
.TOPADDSUB_UPPERINPUT (0), // 0=Q, 1=C
|
| 233 |
+
.TOPADDSUB_CARRYSELECT (0), // 0=0, 1=1, 2=ACI, 3=CI
|
| 234 |
+
.BOTOUTPUT_SELECT (2), // 0=R, 1=S, 2=8x8, 3=16x16
|
| 235 |
+
.BOTADDSUB_LOWERINPUT (0), // 0=B, 1=8x8, 2=16x16, 3=S-EXT
|
| 236 |
+
.BOTADDSUB_UPPERINPUT (0), // 0=S, 1=D
|
| 237 |
+
.BOTADDSUB_CARRYSELECT (0), // 0=0, 1=1, 2=ACI, 3=CI
|
| 238 |
+
.MODE_8x8 (0),
|
| 239 |
+
.A_SIGNED (0),
|
| 240 |
+
.B_SIGNED (0)
|
| 241 |
+
) testbench ();
|
| 242 |
+
endmodule
|
| 243 |
+
|
| 244 |
+
module testbench_comb_8x8_A_signedA;
|
| 245 |
+
testbench #(
|
| 246 |
+
.NEG_TRIGGER (0),
|
| 247 |
+
.C_REG (0),
|
| 248 |
+
.A_REG (0),
|
| 249 |
+
.B_REG (0),
|
| 250 |
+
.D_REG (0),
|
| 251 |
+
.TOP_8x8_MULT_REG (0),
|
| 252 |
+
.BOT_8x8_MULT_REG (0),
|
| 253 |
+
.PIPELINE_16x16_MULT_REG1 (0),
|
| 254 |
+
.PIPELINE_16x16_MULT_REG2 (0),
|
| 255 |
+
.TOPOUTPUT_SELECT (2), // 0=P, 1=Q, 2=8x8, 3=16x16
|
| 256 |
+
.TOPADDSUB_LOWERINPUT (0), // 0=A, 1=8x8, 2=16x16, 3=S-EXT
|
| 257 |
+
.TOPADDSUB_UPPERINPUT (0), // 0=Q, 1=C
|
| 258 |
+
.TOPADDSUB_CARRYSELECT (0), // 0=0, 1=1, 2=ACI, 3=CI
|
| 259 |
+
.BOTOUTPUT_SELECT (2), // 0=R, 1=S, 2=8x8, 3=16x16
|
| 260 |
+
.BOTADDSUB_LOWERINPUT (0), // 0=B, 1=8x8, 2=16x16, 3=S-EXT
|
| 261 |
+
.BOTADDSUB_UPPERINPUT (0), // 0=S, 1=D
|
| 262 |
+
.BOTADDSUB_CARRYSELECT (0), // 0=0, 1=1, 2=ACI, 3=CI
|
| 263 |
+
.MODE_8x8 (0),
|
| 264 |
+
.A_SIGNED (1),
|
| 265 |
+
.B_SIGNED (0)
|
| 266 |
+
) testbench ();
|
| 267 |
+
endmodule
|
| 268 |
+
|
| 269 |
+
module testbench_comb_8x8_A_signedB;
|
| 270 |
+
testbench #(
|
| 271 |
+
.NEG_TRIGGER (0),
|
| 272 |
+
.C_REG (0),
|
| 273 |
+
.A_REG (0),
|
| 274 |
+
.B_REG (0),
|
| 275 |
+
.D_REG (0),
|
| 276 |
+
.TOP_8x8_MULT_REG (0),
|
| 277 |
+
.BOT_8x8_MULT_REG (0),
|
| 278 |
+
.PIPELINE_16x16_MULT_REG1 (0),
|
| 279 |
+
.PIPELINE_16x16_MULT_REG2 (0),
|
| 280 |
+
.TOPOUTPUT_SELECT (2), // 0=P, 1=Q, 2=8x8, 3=16x16
|
| 281 |
+
.TOPADDSUB_LOWERINPUT (0), // 0=A, 1=8x8, 2=16x16, 3=S-EXT
|
| 282 |
+
.TOPADDSUB_UPPERINPUT (0), // 0=Q, 1=C
|
| 283 |
+
.TOPADDSUB_CARRYSELECT (0), // 0=0, 1=1, 2=ACI, 3=CI
|
| 284 |
+
.BOTOUTPUT_SELECT (2), // 0=R, 1=S, 2=8x8, 3=16x16
|
| 285 |
+
.BOTADDSUB_LOWERINPUT (0), // 0=B, 1=8x8, 2=16x16, 3=S-EXT
|
| 286 |
+
.BOTADDSUB_UPPERINPUT (0), // 0=S, 1=D
|
| 287 |
+
.BOTADDSUB_CARRYSELECT (0), // 0=0, 1=1, 2=ACI, 3=CI
|
| 288 |
+
.MODE_8x8 (0),
|
| 289 |
+
.A_SIGNED (0),
|
| 290 |
+
.B_SIGNED (1)
|
| 291 |
+
) testbench ();
|
| 292 |
+
endmodule
|
| 293 |
+
|
| 294 |
+
module testbench_comb_8x8_A_signedAB;
|
| 295 |
+
testbench #(
|
| 296 |
+
.NEG_TRIGGER (0),
|
| 297 |
+
.C_REG (0),
|
| 298 |
+
.A_REG (0),
|
| 299 |
+
.B_REG (0),
|
| 300 |
+
.D_REG (0),
|
| 301 |
+
.TOP_8x8_MULT_REG (0),
|
| 302 |
+
.BOT_8x8_MULT_REG (0),
|
| 303 |
+
.PIPELINE_16x16_MULT_REG1 (0),
|
| 304 |
+
.PIPELINE_16x16_MULT_REG2 (0),
|
| 305 |
+
.TOPOUTPUT_SELECT (2), // 0=P, 1=Q, 2=8x8, 3=16x16
|
| 306 |
+
.TOPADDSUB_LOWERINPUT (0), // 0=A, 1=8x8, 2=16x16, 3=S-EXT
|
| 307 |
+
.TOPADDSUB_UPPERINPUT (0), // 0=Q, 1=C
|
| 308 |
+
.TOPADDSUB_CARRYSELECT (0), // 0=0, 1=1, 2=ACI, 3=CI
|
| 309 |
+
.BOTOUTPUT_SELECT (2), // 0=R, 1=S, 2=8x8, 3=16x16
|
| 310 |
+
.BOTADDSUB_LOWERINPUT (0), // 0=B, 1=8x8, 2=16x16, 3=S-EXT
|
| 311 |
+
.BOTADDSUB_UPPERINPUT (0), // 0=S, 1=D
|
| 312 |
+
.BOTADDSUB_CARRYSELECT (0), // 0=0, 1=1, 2=ACI, 3=CI
|
| 313 |
+
.MODE_8x8 (0),
|
| 314 |
+
.A_SIGNED (1),
|
| 315 |
+
.B_SIGNED (1)
|
| 316 |
+
) testbench ();
|
| 317 |
+
endmodule
|
| 318 |
+
|
| 319 |
+
module testbench_comb_8x8_B;
|
| 320 |
+
testbench #(
|
| 321 |
+
.NEG_TRIGGER (0),
|
| 322 |
+
.C_REG (0),
|
| 323 |
+
.A_REG (0),
|
| 324 |
+
.B_REG (0),
|
| 325 |
+
.D_REG (0),
|
| 326 |
+
.TOP_8x8_MULT_REG (0),
|
| 327 |
+
.BOT_8x8_MULT_REG (0),
|
| 328 |
+
.PIPELINE_16x16_MULT_REG1 (0),
|
| 329 |
+
.PIPELINE_16x16_MULT_REG2 (0),
|
| 330 |
+
.TOPOUTPUT_SELECT (0), // 0=P, 1=Q, 2=8x8, 3=16x16
|
| 331 |
+
.TOPADDSUB_LOWERINPUT (1), // 0=A, 1=8x8, 2=16x16, 3=S-EXT
|
| 332 |
+
.TOPADDSUB_UPPERINPUT (1), // 0=Q, 1=C
|
| 333 |
+
.TOPADDSUB_CARRYSELECT (0), // 0=0, 1=1, 2=ACI, 3=CI
|
| 334 |
+
.BOTOUTPUT_SELECT (0), // 0=R, 1=S, 2=8x8, 3=16x16
|
| 335 |
+
.BOTADDSUB_LOWERINPUT (1), // 0=B, 1=8x8, 2=16x16, 3=S-EXT
|
| 336 |
+
.BOTADDSUB_UPPERINPUT (1), // 0=S, 1=D
|
| 337 |
+
.BOTADDSUB_CARRYSELECT (0), // 0=0, 1=1, 2=ACI, 3=CI
|
| 338 |
+
.MODE_8x8 (0),
|
| 339 |
+
.A_SIGNED (0),
|
| 340 |
+
.B_SIGNED (0)
|
| 341 |
+
) testbench ();
|
| 342 |
+
endmodule
|
| 343 |
+
|
| 344 |
+
module testbench_comb_8x8_B_signedA;
|
| 345 |
+
testbench #(
|
| 346 |
+
.NEG_TRIGGER (0),
|
| 347 |
+
.C_REG (0),
|
| 348 |
+
.A_REG (0),
|
| 349 |
+
.B_REG (0),
|
| 350 |
+
.D_REG (0),
|
| 351 |
+
.TOP_8x8_MULT_REG (0),
|
| 352 |
+
.BOT_8x8_MULT_REG (0),
|
| 353 |
+
.PIPELINE_16x16_MULT_REG1 (0),
|
| 354 |
+
.PIPELINE_16x16_MULT_REG2 (0),
|
| 355 |
+
.TOPOUTPUT_SELECT (0), // 0=P, 1=Q, 2=8x8, 3=16x16
|
| 356 |
+
.TOPADDSUB_LOWERINPUT (1), // 0=A, 1=8x8, 2=16x16, 3=S-EXT
|
| 357 |
+
.TOPADDSUB_UPPERINPUT (1), // 0=Q, 1=C
|
| 358 |
+
.TOPADDSUB_CARRYSELECT (0), // 0=0, 1=1, 2=ACI, 3=CI
|
| 359 |
+
.BOTOUTPUT_SELECT (0), // 0=R, 1=S, 2=8x8, 3=16x16
|
| 360 |
+
.BOTADDSUB_LOWERINPUT (1), // 0=B, 1=8x8, 2=16x16, 3=S-EXT
|
| 361 |
+
.BOTADDSUB_UPPERINPUT (1), // 0=S, 1=D
|
| 362 |
+
.BOTADDSUB_CARRYSELECT (0), // 0=0, 1=1, 2=ACI, 3=CI
|
| 363 |
+
.MODE_8x8 (0),
|
| 364 |
+
.A_SIGNED (1),
|
| 365 |
+
.B_SIGNED (0)
|
| 366 |
+
) testbench ();
|
| 367 |
+
endmodule
|
| 368 |
+
|
| 369 |
+
module testbench_comb_8x8_B_signedB;
|
| 370 |
+
testbench #(
|
| 371 |
+
.NEG_TRIGGER (0),
|
| 372 |
+
.C_REG (0),
|
| 373 |
+
.A_REG (0),
|
| 374 |
+
.B_REG (0),
|
| 375 |
+
.D_REG (0),
|
| 376 |
+
.TOP_8x8_MULT_REG (0),
|
| 377 |
+
.BOT_8x8_MULT_REG (0),
|
| 378 |
+
.PIPELINE_16x16_MULT_REG1 (0),
|
| 379 |
+
.PIPELINE_16x16_MULT_REG2 (0),
|
| 380 |
+
.TOPOUTPUT_SELECT (0), // 0=P, 1=Q, 2=8x8, 3=16x16
|
| 381 |
+
.TOPADDSUB_LOWERINPUT (1), // 0=A, 1=8x8, 2=16x16, 3=S-EXT
|
| 382 |
+
.TOPADDSUB_UPPERINPUT (1), // 0=Q, 1=C
|
| 383 |
+
.TOPADDSUB_CARRYSELECT (0), // 0=0, 1=1, 2=ACI, 3=CI
|
| 384 |
+
.BOTOUTPUT_SELECT (0), // 0=R, 1=S, 2=8x8, 3=16x16
|
| 385 |
+
.BOTADDSUB_LOWERINPUT (1), // 0=B, 1=8x8, 2=16x16, 3=S-EXT
|
| 386 |
+
.BOTADDSUB_UPPERINPUT (1), // 0=S, 1=D
|
| 387 |
+
.BOTADDSUB_CARRYSELECT (0), // 0=0, 1=1, 2=ACI, 3=CI
|
| 388 |
+
.MODE_8x8 (0),
|
| 389 |
+
.A_SIGNED (0),
|
| 390 |
+
.B_SIGNED (1)
|
| 391 |
+
) testbench ();
|
| 392 |
+
endmodule
|
| 393 |
+
|
| 394 |
+
module testbench_comb_8x8_B_signedAB;
|
| 395 |
+
testbench #(
|
| 396 |
+
.NEG_TRIGGER (0),
|
| 397 |
+
.C_REG (0),
|
| 398 |
+
.A_REG (0),
|
| 399 |
+
.B_REG (0),
|
| 400 |
+
.D_REG (0),
|
| 401 |
+
.TOP_8x8_MULT_REG (0),
|
| 402 |
+
.BOT_8x8_MULT_REG (0),
|
| 403 |
+
.PIPELINE_16x16_MULT_REG1 (0),
|
| 404 |
+
.PIPELINE_16x16_MULT_REG2 (0),
|
| 405 |
+
.TOPOUTPUT_SELECT (0), // 0=P, 1=Q, 2=8x8, 3=16x16
|
| 406 |
+
.TOPADDSUB_LOWERINPUT (1), // 0=A, 1=8x8, 2=16x16, 3=S-EXT
|
| 407 |
+
.TOPADDSUB_UPPERINPUT (1), // 0=Q, 1=C
|
| 408 |
+
.TOPADDSUB_CARRYSELECT (0), // 0=0, 1=1, 2=ACI, 3=CI
|
| 409 |
+
.BOTOUTPUT_SELECT (0), // 0=R, 1=S, 2=8x8, 3=16x16
|
| 410 |
+
.BOTADDSUB_LOWERINPUT (1), // 0=B, 1=8x8, 2=16x16, 3=S-EXT
|
| 411 |
+
.BOTADDSUB_UPPERINPUT (1), // 0=S, 1=D
|
| 412 |
+
.BOTADDSUB_CARRYSELECT (0), // 0=0, 1=1, 2=ACI, 3=CI
|
| 413 |
+
.MODE_8x8 (0),
|
| 414 |
+
.A_SIGNED (1),
|
| 415 |
+
.B_SIGNED (1)
|
| 416 |
+
) testbench ();
|
| 417 |
+
endmodule
|
| 418 |
+
|
| 419 |
+
module testbench_comb_16x16;
|
| 420 |
+
testbench #(
|
| 421 |
+
.NEG_TRIGGER (0),
|
| 422 |
+
.C_REG (0),
|
| 423 |
+
.A_REG (0),
|
| 424 |
+
.B_REG (0),
|
| 425 |
+
.D_REG (0),
|
| 426 |
+
.TOP_8x8_MULT_REG (0),
|
| 427 |
+
.BOT_8x8_MULT_REG (0),
|
| 428 |
+
.PIPELINE_16x16_MULT_REG1 (0),
|
| 429 |
+
.PIPELINE_16x16_MULT_REG2 (0),
|
| 430 |
+
.TOPOUTPUT_SELECT (0), // 0=P, 1=Q, 2=8x8, 3=16x16
|
| 431 |
+
.TOPADDSUB_LOWERINPUT (2), // 0=A, 1=8x8, 2=16x16, 3=S-EXT
|
| 432 |
+
.TOPADDSUB_UPPERINPUT (1), // 0=Q, 1=C
|
| 433 |
+
.TOPADDSUB_CARRYSELECT (2), // 0=0, 1=1, 2=ACI, 3=CI
|
| 434 |
+
.BOTOUTPUT_SELECT (0), // 0=R, 1=S, 2=8x8, 3=16x16
|
| 435 |
+
.BOTADDSUB_LOWERINPUT (2), // 0=B, 1=8x8, 2=16x16, 3=S-EXT
|
| 436 |
+
.BOTADDSUB_UPPERINPUT (1), // 0=S, 1=D
|
| 437 |
+
.BOTADDSUB_CARRYSELECT (2), // 0=0, 1=1, 2=ACI, 3=CI
|
| 438 |
+
.MODE_8x8 (0),
|
| 439 |
+
.A_SIGNED (0),
|
| 440 |
+
.B_SIGNED (0)
|
| 441 |
+
) testbench ();
|
| 442 |
+
endmodule
|
| 443 |
+
|
| 444 |
+
module testbench_comb_16x16_signedA;
|
| 445 |
+
testbench #(
|
| 446 |
+
.NEG_TRIGGER (0),
|
| 447 |
+
.C_REG (0),
|
| 448 |
+
.A_REG (0),
|
| 449 |
+
.B_REG (0),
|
| 450 |
+
.D_REG (0),
|
| 451 |
+
.TOP_8x8_MULT_REG (0),
|
| 452 |
+
.BOT_8x8_MULT_REG (0),
|
| 453 |
+
.PIPELINE_16x16_MULT_REG1 (0),
|
| 454 |
+
.PIPELINE_16x16_MULT_REG2 (0),
|
| 455 |
+
.TOPOUTPUT_SELECT (0), // 0=P, 1=Q, 2=8x8, 3=16x16
|
| 456 |
+
.TOPADDSUB_LOWERINPUT (2), // 0=A, 1=8x8, 2=16x16, 3=S-EXT
|
| 457 |
+
.TOPADDSUB_UPPERINPUT (1), // 0=Q, 1=C
|
| 458 |
+
.TOPADDSUB_CARRYSELECT (2), // 0=0, 1=1, 2=ACI, 3=CI
|
| 459 |
+
.BOTOUTPUT_SELECT (0), // 0=R, 1=S, 2=8x8, 3=16x16
|
| 460 |
+
.BOTADDSUB_LOWERINPUT (2), // 0=B, 1=8x8, 2=16x16, 3=S-EXT
|
| 461 |
+
.BOTADDSUB_UPPERINPUT (1), // 0=S, 1=D
|
| 462 |
+
.BOTADDSUB_CARRYSELECT (2), // 0=0, 1=1, 2=ACI, 3=CI
|
| 463 |
+
.MODE_8x8 (0),
|
| 464 |
+
.A_SIGNED (1),
|
| 465 |
+
.B_SIGNED (0)
|
| 466 |
+
) testbench ();
|
| 467 |
+
endmodule
|
| 468 |
+
|
| 469 |
+
module testbench_comb_16x16_signedB;
|
| 470 |
+
testbench #(
|
| 471 |
+
.NEG_TRIGGER (0),
|
| 472 |
+
.C_REG (0),
|
| 473 |
+
.A_REG (0),
|
| 474 |
+
.B_REG (0),
|
| 475 |
+
.D_REG (0),
|
| 476 |
+
.TOP_8x8_MULT_REG (0),
|
| 477 |
+
.BOT_8x8_MULT_REG (0),
|
| 478 |
+
.PIPELINE_16x16_MULT_REG1 (0),
|
| 479 |
+
.PIPELINE_16x16_MULT_REG2 (0),
|
| 480 |
+
.TOPOUTPUT_SELECT (0), // 0=P, 1=Q, 2=8x8, 3=16x16
|
| 481 |
+
.TOPADDSUB_LOWERINPUT (2), // 0=A, 1=8x8, 2=16x16, 3=S-EXT
|
| 482 |
+
.TOPADDSUB_UPPERINPUT (1), // 0=Q, 1=C
|
| 483 |
+
.TOPADDSUB_CARRYSELECT (2), // 0=0, 1=1, 2=ACI, 3=CI
|
| 484 |
+
.BOTOUTPUT_SELECT (0), // 0=R, 1=S, 2=8x8, 3=16x16
|
| 485 |
+
.BOTADDSUB_LOWERINPUT (2), // 0=B, 1=8x8, 2=16x16, 3=S-EXT
|
| 486 |
+
.BOTADDSUB_UPPERINPUT (1), // 0=S, 1=D
|
| 487 |
+
.BOTADDSUB_CARRYSELECT (2), // 0=0, 1=1, 2=ACI, 3=CI
|
| 488 |
+
.MODE_8x8 (0),
|
| 489 |
+
.A_SIGNED (0),
|
| 490 |
+
.B_SIGNED (1)
|
| 491 |
+
) testbench ();
|
| 492 |
+
endmodule
|
| 493 |
+
|
| 494 |
+
module testbench_comb_16x16_signedAB;
|
| 495 |
+
testbench #(
|
| 496 |
+
.NEG_TRIGGER (0),
|
| 497 |
+
.C_REG (0),
|
| 498 |
+
.A_REG (0),
|
| 499 |
+
.B_REG (0),
|
| 500 |
+
.D_REG (0),
|
| 501 |
+
.TOP_8x8_MULT_REG (0),
|
| 502 |
+
.BOT_8x8_MULT_REG (0),
|
| 503 |
+
.PIPELINE_16x16_MULT_REG1 (0),
|
| 504 |
+
.PIPELINE_16x16_MULT_REG2 (0),
|
| 505 |
+
.TOPOUTPUT_SELECT (0), // 0=P, 1=Q, 2=8x8, 3=16x16
|
| 506 |
+
.TOPADDSUB_LOWERINPUT (2), // 0=A, 1=8x8, 2=16x16, 3=S-EXT
|
| 507 |
+
.TOPADDSUB_UPPERINPUT (1), // 0=Q, 1=C
|
| 508 |
+
.TOPADDSUB_CARRYSELECT (2), // 0=0, 1=1, 2=ACI, 3=CI
|
| 509 |
+
.BOTOUTPUT_SELECT (0), // 0=R, 1=S, 2=8x8, 3=16x16
|
| 510 |
+
.BOTADDSUB_LOWERINPUT (2), // 0=B, 1=8x8, 2=16x16, 3=S-EXT
|
| 511 |
+
.BOTADDSUB_UPPERINPUT (1), // 0=S, 1=D
|
| 512 |
+
.BOTADDSUB_CARRYSELECT (2), // 0=0, 1=1, 2=ACI, 3=CI
|
| 513 |
+
.MODE_8x8 (0),
|
| 514 |
+
.A_SIGNED (1),
|
| 515 |
+
.B_SIGNED (1)
|
| 516 |
+
) testbench ();
|
| 517 |
+
endmodule
|
| 518 |
+
|
| 519 |
+
module testbench_seq_16x16_A;
|
| 520 |
+
testbench #(
|
| 521 |
+
.NEG_TRIGGER (0),
|
| 522 |
+
.C_REG (1),
|
| 523 |
+
.A_REG (1),
|
| 524 |
+
.B_REG (1),
|
| 525 |
+
.D_REG (1),
|
| 526 |
+
.TOP_8x8_MULT_REG (1),
|
| 527 |
+
.BOT_8x8_MULT_REG (1),
|
| 528 |
+
.PIPELINE_16x16_MULT_REG1 (1),
|
| 529 |
+
.PIPELINE_16x16_MULT_REG2 (1),
|
| 530 |
+
.TOPOUTPUT_SELECT (0), // 0=P, 1=Q, 2=8x8, 3=16x16
|
| 531 |
+
.TOPADDSUB_LOWERINPUT (2), // 0=A, 1=8x8, 2=16x16, 3=S-EXT
|
| 532 |
+
.TOPADDSUB_UPPERINPUT (1), // 0=Q, 1=C
|
| 533 |
+
.TOPADDSUB_CARRYSELECT (2), // 0=0, 1=1, 2=ACI, 3=CI
|
| 534 |
+
.BOTOUTPUT_SELECT (0), // 0=R, 1=S, 2=8x8, 3=16x16
|
| 535 |
+
.BOTADDSUB_LOWERINPUT (2), // 0=B, 1=8x8, 2=16x16, 3=S-EXT
|
| 536 |
+
.BOTADDSUB_UPPERINPUT (1), // 0=S, 1=D
|
| 537 |
+
.BOTADDSUB_CARRYSELECT (2), // 0=0, 1=1, 2=ACI, 3=CI
|
| 538 |
+
.MODE_8x8 (0),
|
| 539 |
+
.A_SIGNED (0),
|
| 540 |
+
.B_SIGNED (0)
|
| 541 |
+
) testbench ();
|
| 542 |
+
endmodule
|
| 543 |
+
|
| 544 |
+
module testbench_seq_16x16_B;
|
| 545 |
+
testbench #(
|
| 546 |
+
.NEG_TRIGGER (0),
|
| 547 |
+
.C_REG (1),
|
| 548 |
+
.A_REG (1),
|
| 549 |
+
.B_REG (1),
|
| 550 |
+
.D_REG (1),
|
| 551 |
+
.TOP_8x8_MULT_REG (1),
|
| 552 |
+
.BOT_8x8_MULT_REG (1),
|
| 553 |
+
.PIPELINE_16x16_MULT_REG1 (1),
|
| 554 |
+
.PIPELINE_16x16_MULT_REG2 (0),
|
| 555 |
+
.TOPOUTPUT_SELECT (1), // 0=P, 1=Q, 2=8x8, 3=16x16
|
| 556 |
+
.TOPADDSUB_LOWERINPUT (2), // 0=A, 1=8x8, 2=16x16, 3=S-EXT
|
| 557 |
+
.TOPADDSUB_UPPERINPUT (0), // 0=Q, 1=C
|
| 558 |
+
.TOPADDSUB_CARRYSELECT (2), // 0=0, 1=1, 2=ACI, 3=CI
|
| 559 |
+
.BOTOUTPUT_SELECT (1), // 0=R, 1=S, 2=8x8, 3=16x16
|
| 560 |
+
.BOTADDSUB_LOWERINPUT (2), // 0=B, 1=8x8, 2=16x16, 3=S-EXT
|
| 561 |
+
.BOTADDSUB_UPPERINPUT (0), // 0=S, 1=D
|
| 562 |
+
.BOTADDSUB_CARRYSELECT (2), // 0=0, 1=1, 2=ACI, 3=CI
|
| 563 |
+
.MODE_8x8 (0),
|
| 564 |
+
.A_SIGNED (0),
|
| 565 |
+
.B_SIGNED (0)
|
| 566 |
+
) testbench ();
|
| 567 |
+
endmodule
|
chips/yosys/techlibs/ice40/tests/test_ffs.sh
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -ex
|
| 3 |
+
for CLKPOL in 0 1; do
|
| 4 |
+
for ENABLE_EN in 0 1; do
|
| 5 |
+
for RESET_EN in 0 1; do
|
| 6 |
+
for RESET_VAL in 0 1; do
|
| 7 |
+
for RESET_SYN in 0 1; do
|
| 8 |
+
pf="test_ffs_${CLKPOL}${ENABLE_EN}${RESET_EN}${RESET_VAL}${RESET_SYN}"
|
| 9 |
+
sed -e "s/CLKPOL = 0/CLKPOL = ${CLKPOL}/;" -e "s/ENABLE_EN = 0/ENABLE_EN = ${ENABLE_EN}/;" \
|
| 10 |
+
-e "s/RESET_EN = 0/RESET_EN = ${RESET_EN}/;" -e "s/RESET_VAL = 0/RESET_VAL = ${RESET_VAL}/;" \
|
| 11 |
+
-e "s/RESET_SYN = 0/RESET_SYN = ${RESET_SYN}/;" test_ffs.v > ${pf}_gold.v
|
| 12 |
+
../../../yosys -o ${pf}_gate.v -p "synth_ice40" ${pf}_gold.v
|
| 13 |
+
../../../yosys -p "proc; opt; test_autotb ${pf}_tb.v" ${pf}_gold.v
|
| 14 |
+
iverilog -s testbench -o ${pf}_gold ${pf}_gold.v ${pf}_tb.v
|
| 15 |
+
iverilog -s testbench -o ${pf}_gate ${pf}_gate.v ${pf}_tb.v ../cells_sim.v
|
| 16 |
+
./${pf}_gold > ${pf}_gold.txt
|
| 17 |
+
./${pf}_gate > ${pf}_gate.txt
|
| 18 |
+
cmp ${pf}_gold.txt ${pf}_gate.txt
|
| 19 |
+
done; done; done; done; done
|
| 20 |
+
echo OK.
|
chips/yosys/techlibs/ice40/tests/test_ffs.v
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module test(D, C, E, R, Q);
|
| 2 |
+
parameter [0:0] CLKPOL = 0;
|
| 3 |
+
parameter [0:0] ENABLE_EN = 0;
|
| 4 |
+
parameter [0:0] RESET_EN = 0;
|
| 5 |
+
parameter [0:0] RESET_VAL = 0;
|
| 6 |
+
parameter [0:0] RESET_SYN = 0;
|
| 7 |
+
|
| 8 |
+
(* gentb_clock *)
|
| 9 |
+
input D, C, E, R;
|
| 10 |
+
|
| 11 |
+
output Q;
|
| 12 |
+
|
| 13 |
+
wire gated_reset = R & RESET_EN;
|
| 14 |
+
wire gated_enable = E | ~ENABLE_EN;
|
| 15 |
+
reg posedge_q, negedge_q, posedge_sq, negedge_sq;
|
| 16 |
+
|
| 17 |
+
always @(posedge C, posedge gated_reset)
|
| 18 |
+
if (gated_reset)
|
| 19 |
+
posedge_q <= RESET_VAL;
|
| 20 |
+
else if (gated_enable)
|
| 21 |
+
posedge_q <= D;
|
| 22 |
+
|
| 23 |
+
always @(negedge C, posedge gated_reset)
|
| 24 |
+
if (gated_reset)
|
| 25 |
+
negedge_q <= RESET_VAL;
|
| 26 |
+
else if (gated_enable)
|
| 27 |
+
negedge_q <= D;
|
| 28 |
+
|
| 29 |
+
always @(posedge C)
|
| 30 |
+
if (gated_reset)
|
| 31 |
+
posedge_sq <= RESET_VAL;
|
| 32 |
+
else if (gated_enable)
|
| 33 |
+
posedge_sq <= D;
|
| 34 |
+
|
| 35 |
+
always @(negedge C)
|
| 36 |
+
if (gated_reset)
|
| 37 |
+
negedge_sq <= RESET_VAL;
|
| 38 |
+
else if (gated_enable)
|
| 39 |
+
negedge_sq <= D;
|
| 40 |
+
|
| 41 |
+
assign Q = RESET_SYN ? (CLKPOL ? posedge_sq : negedge_sq) : (CLKPOL ? posedge_q : negedge_q);
|
| 42 |
+
endmodule
|
chips/yosys/techlibs/intel/CMakeLists.txt
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
yosys_pass(synth_intel
|
| 2 |
+
synth_intel.cc
|
| 3 |
+
REQUIRES
|
| 4 |
+
abc
|
| 5 |
+
abc9
|
| 6 |
+
autoname
|
| 7 |
+
blackbox
|
| 8 |
+
check
|
| 9 |
+
clean
|
| 10 |
+
deminout
|
| 11 |
+
dfflegalize
|
| 12 |
+
flatten
|
| 13 |
+
fsm
|
| 14 |
+
hierarchy
|
| 15 |
+
iopadmap
|
| 16 |
+
memory
|
| 17 |
+
memory_bram
|
| 18 |
+
memory_map
|
| 19 |
+
opt
|
| 20 |
+
opt_clean
|
| 21 |
+
opt_expr
|
| 22 |
+
peepopt
|
| 23 |
+
proc
|
| 24 |
+
read_verilog
|
| 25 |
+
setundef
|
| 26 |
+
stat
|
| 27 |
+
synth
|
| 28 |
+
techmap
|
| 29 |
+
tribuf
|
| 30 |
+
wreduce
|
| 31 |
+
write_blif
|
| 32 |
+
write_verilog
|
| 33 |
+
DATA_DIR
|
| 34 |
+
intel
|
| 35 |
+
DATA_FILES
|
| 36 |
+
common/m9k_bb.v
|
| 37 |
+
common/altpll_bb.v
|
| 38 |
+
common/brams_m9k.txt
|
| 39 |
+
common/brams_map_m9k.v
|
| 40 |
+
common/ff_map.v
|
| 41 |
+
|
| 42 |
+
max10/cells_sim.v
|
| 43 |
+
max10/cells_map.v
|
| 44 |
+
max10/dsp_map.v
|
| 45 |
+
|
| 46 |
+
cyclone10lp/cells_sim.v
|
| 47 |
+
cyclone10lp/cells_map.v
|
| 48 |
+
|
| 49 |
+
cycloneiv/cells_sim.v
|
| 50 |
+
cycloneiv/cells_map.v
|
| 51 |
+
|
| 52 |
+
cycloneive/cells_sim.v
|
| 53 |
+
cycloneive/cells_map.v
|
| 54 |
+
)
|
chips/yosys/techlibs/intel/common/altpll_bb.v
ADDED
|
@@ -0,0 +1,366 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* yosys -- Yosys Open SYnthesis Suite
|
| 3 |
+
*
|
| 4 |
+
* Copyright (C) 2012 Claire Xenia Wolf <claire@yosyshq.com>
|
| 5 |
+
*
|
| 6 |
+
* Permission to use, copy, modify, and/or distribute this software for any
|
| 7 |
+
* purpose with or without fee is hereby granted, provided that the above
|
| 8 |
+
* copyright notice and this permission notice appear in all copies.
|
| 9 |
+
*
|
| 10 |
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
| 11 |
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
| 12 |
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
| 13 |
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 14 |
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 15 |
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
| 16 |
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
| 17 |
+
*
|
| 18 |
+
*/
|
| 19 |
+
/* No clearbox model */
|
| 20 |
+
`ifdef NO_CLEARBOX
|
| 21 |
+
(* blackbox *)
|
| 22 |
+
module altpll
|
| 23 |
+
( inclk,
|
| 24 |
+
fbin,
|
| 25 |
+
pllena,
|
| 26 |
+
clkswitch,
|
| 27 |
+
areset,
|
| 28 |
+
pfdena,
|
| 29 |
+
clkena,
|
| 30 |
+
extclkena,
|
| 31 |
+
scanclk,
|
| 32 |
+
scanaclr,
|
| 33 |
+
scanclkena,
|
| 34 |
+
scanread,
|
| 35 |
+
scanwrite,
|
| 36 |
+
scandata,
|
| 37 |
+
phasecounterselect,
|
| 38 |
+
phaseupdown,
|
| 39 |
+
phasestep,
|
| 40 |
+
configupdate,
|
| 41 |
+
fbmimicbidir,
|
| 42 |
+
clk,
|
| 43 |
+
extclk,
|
| 44 |
+
clkbad,
|
| 45 |
+
enable0,
|
| 46 |
+
enable1,
|
| 47 |
+
activeclock,
|
| 48 |
+
clkloss,
|
| 49 |
+
locked,
|
| 50 |
+
scandataout,
|
| 51 |
+
scandone,
|
| 52 |
+
sclkout0,
|
| 53 |
+
sclkout1,
|
| 54 |
+
phasedone,
|
| 55 |
+
vcooverrange,
|
| 56 |
+
vcounderrange,
|
| 57 |
+
fbout,
|
| 58 |
+
fref,
|
| 59 |
+
icdrclk,
|
| 60 |
+
c0,
|
| 61 |
+
c1,
|
| 62 |
+
c2,
|
| 63 |
+
c3,
|
| 64 |
+
c4);
|
| 65 |
+
|
| 66 |
+
parameter intended_device_family = "MAX 10";
|
| 67 |
+
parameter operation_mode = "NORMAL";
|
| 68 |
+
parameter pll_type = "AUTO";
|
| 69 |
+
parameter qualify_conf_done = "OFF";
|
| 70 |
+
parameter compensate_clock = "CLK0";
|
| 71 |
+
parameter scan_chain = "LONG";
|
| 72 |
+
parameter primary_clock = "inclk0";
|
| 73 |
+
parameter inclk0_input_frequency = 1000;
|
| 74 |
+
parameter inclk1_input_frequency = 0;
|
| 75 |
+
parameter gate_lock_signal = "NO";
|
| 76 |
+
parameter gate_lock_counter = 0;
|
| 77 |
+
parameter lock_high = 1;
|
| 78 |
+
parameter lock_low = 0;
|
| 79 |
+
parameter valid_lock_multiplier = 1;
|
| 80 |
+
parameter invalid_lock_multiplier = 5;
|
| 81 |
+
parameter switch_over_type = "AUTO";
|
| 82 |
+
parameter switch_over_on_lossclk = "OFF" ;
|
| 83 |
+
parameter switch_over_on_gated_lock = "OFF" ;
|
| 84 |
+
parameter enable_switch_over_counter = "OFF";
|
| 85 |
+
parameter switch_over_counter = 0;
|
| 86 |
+
parameter feedback_source = "EXTCLK0" ;
|
| 87 |
+
parameter bandwidth = 0;
|
| 88 |
+
parameter bandwidth_type = "UNUSED";
|
| 89 |
+
parameter lpm_hint = "UNUSED";
|
| 90 |
+
parameter spread_frequency = 0;
|
| 91 |
+
parameter down_spread = "0.0";
|
| 92 |
+
parameter self_reset_on_gated_loss_lock = "OFF";
|
| 93 |
+
parameter self_reset_on_loss_lock = "OFF";
|
| 94 |
+
parameter lock_window_ui = "0.05";
|
| 95 |
+
parameter width_clock = 6;
|
| 96 |
+
parameter width_phasecounterselect = 4;
|
| 97 |
+
parameter charge_pump_current_bits = 9999;
|
| 98 |
+
parameter loop_filter_c_bits = 9999;
|
| 99 |
+
parameter loop_filter_r_bits = 9999;
|
| 100 |
+
parameter scan_chain_mif_file = "UNUSED";
|
| 101 |
+
parameter clk9_multiply_by = 1;
|
| 102 |
+
parameter clk8_multiply_by = 1;
|
| 103 |
+
parameter clk7_multiply_by = 1;
|
| 104 |
+
parameter clk6_multiply_by = 1;
|
| 105 |
+
parameter clk5_multiply_by = 1;
|
| 106 |
+
parameter clk4_multiply_by = 1;
|
| 107 |
+
parameter clk3_multiply_by = 1;
|
| 108 |
+
parameter clk2_multiply_by = 1;
|
| 109 |
+
parameter clk1_multiply_by = 1;
|
| 110 |
+
parameter clk0_multiply_by = 1;
|
| 111 |
+
parameter clk9_divide_by = 1;
|
| 112 |
+
parameter clk8_divide_by = 1;
|
| 113 |
+
parameter clk7_divide_by = 1;
|
| 114 |
+
parameter clk6_divide_by = 1;
|
| 115 |
+
parameter clk5_divide_by = 1;
|
| 116 |
+
parameter clk4_divide_by = 1;
|
| 117 |
+
parameter clk3_divide_by = 1;
|
| 118 |
+
parameter clk2_divide_by = 1;
|
| 119 |
+
parameter clk1_divide_by = 1;
|
| 120 |
+
parameter clk0_divide_by = 1;
|
| 121 |
+
parameter clk9_phase_shift = "0";
|
| 122 |
+
parameter clk8_phase_shift = "0";
|
| 123 |
+
parameter clk7_phase_shift = "0";
|
| 124 |
+
parameter clk6_phase_shift = "0";
|
| 125 |
+
parameter clk5_phase_shift = "0";
|
| 126 |
+
parameter clk4_phase_shift = "0";
|
| 127 |
+
parameter clk3_phase_shift = "0";
|
| 128 |
+
parameter clk2_phase_shift = "0";
|
| 129 |
+
parameter clk1_phase_shift = "0";
|
| 130 |
+
parameter clk0_phase_shift = "0";
|
| 131 |
+
|
| 132 |
+
parameter clk9_duty_cycle = 50;
|
| 133 |
+
parameter clk8_duty_cycle = 50;
|
| 134 |
+
parameter clk7_duty_cycle = 50;
|
| 135 |
+
parameter clk6_duty_cycle = 50;
|
| 136 |
+
parameter clk5_duty_cycle = 50;
|
| 137 |
+
parameter clk4_duty_cycle = 50;
|
| 138 |
+
parameter clk3_duty_cycle = 50;
|
| 139 |
+
parameter clk2_duty_cycle = 50;
|
| 140 |
+
parameter clk1_duty_cycle = 50;
|
| 141 |
+
parameter clk0_duty_cycle = 50;
|
| 142 |
+
|
| 143 |
+
parameter clk9_use_even_counter_mode = "OFF";
|
| 144 |
+
parameter clk8_use_even_counter_mode = "OFF";
|
| 145 |
+
parameter clk7_use_even_counter_mode = "OFF";
|
| 146 |
+
parameter clk6_use_even_counter_mode = "OFF";
|
| 147 |
+
parameter clk5_use_even_counter_mode = "OFF";
|
| 148 |
+
parameter clk4_use_even_counter_mode = "OFF";
|
| 149 |
+
parameter clk3_use_even_counter_mode = "OFF";
|
| 150 |
+
parameter clk2_use_even_counter_mode = "OFF";
|
| 151 |
+
parameter clk1_use_even_counter_mode = "OFF";
|
| 152 |
+
parameter clk0_use_even_counter_mode = "OFF";
|
| 153 |
+
parameter clk9_use_even_counter_value = "OFF";
|
| 154 |
+
parameter clk8_use_even_counter_value = "OFF";
|
| 155 |
+
parameter clk7_use_even_counter_value = "OFF";
|
| 156 |
+
parameter clk6_use_even_counter_value = "OFF";
|
| 157 |
+
parameter clk5_use_even_counter_value = "OFF";
|
| 158 |
+
parameter clk4_use_even_counter_value = "OFF";
|
| 159 |
+
parameter clk3_use_even_counter_value = "OFF";
|
| 160 |
+
parameter clk2_use_even_counter_value = "OFF";
|
| 161 |
+
parameter clk1_use_even_counter_value = "OFF";
|
| 162 |
+
parameter clk0_use_even_counter_value = "OFF";
|
| 163 |
+
|
| 164 |
+
parameter clk2_output_frequency = 0;
|
| 165 |
+
parameter clk1_output_frequency = 0;
|
| 166 |
+
parameter clk0_output_frequency = 0;
|
| 167 |
+
|
| 168 |
+
parameter vco_min = 0;
|
| 169 |
+
parameter vco_max = 0;
|
| 170 |
+
parameter vco_center = 0;
|
| 171 |
+
parameter pfd_min = 0;
|
| 172 |
+
parameter pfd_max = 0;
|
| 173 |
+
parameter m_initial = 1;
|
| 174 |
+
parameter m = 0;
|
| 175 |
+
parameter n = 1;
|
| 176 |
+
parameter m2 = 1;
|
| 177 |
+
parameter n2 = 1;
|
| 178 |
+
parameter ss = 0;
|
| 179 |
+
parameter l0_high = 1;
|
| 180 |
+
parameter l1_high = 1;
|
| 181 |
+
parameter g0_high = 1;
|
| 182 |
+
parameter g1_high = 1;
|
| 183 |
+
parameter g2_high = 1;
|
| 184 |
+
parameter g3_high = 1;
|
| 185 |
+
parameter e0_high = 1;
|
| 186 |
+
parameter e1_high = 1;
|
| 187 |
+
parameter e2_high = 1;
|
| 188 |
+
parameter e3_high = 1;
|
| 189 |
+
parameter l0_low = 1;
|
| 190 |
+
parameter l1_low = 1;
|
| 191 |
+
parameter g0_low = 1;
|
| 192 |
+
parameter g1_low = 1;
|
| 193 |
+
parameter g2_low = 1;
|
| 194 |
+
parameter g3_low = 1;
|
| 195 |
+
parameter e0_low = 1;
|
| 196 |
+
parameter e1_low = 1;
|
| 197 |
+
parameter e2_low = 1;
|
| 198 |
+
parameter e3_low = 1;
|
| 199 |
+
parameter l0_initial = 1;
|
| 200 |
+
parameter l1_initial = 1;
|
| 201 |
+
parameter g0_initial = 1;
|
| 202 |
+
parameter g1_initial = 1;
|
| 203 |
+
parameter g2_initial = 1;
|
| 204 |
+
parameter g3_initial = 1;
|
| 205 |
+
parameter e0_initial = 1;
|
| 206 |
+
parameter e1_initial = 1;
|
| 207 |
+
parameter e2_initial = 1;
|
| 208 |
+
parameter e3_initial = 1;
|
| 209 |
+
parameter l0_mode = "bypass";
|
| 210 |
+
parameter l1_mode = "bypass";
|
| 211 |
+
parameter g0_mode = "bypass";
|
| 212 |
+
parameter g1_mode = "bypass";
|
| 213 |
+
parameter g2_mode = "bypass";
|
| 214 |
+
parameter g3_mode = "bypass";
|
| 215 |
+
parameter e0_mode = "bypass";
|
| 216 |
+
parameter e1_mode = "bypass";
|
| 217 |
+
parameter e2_mode = "bypass";
|
| 218 |
+
parameter e3_mode = "bypass";
|
| 219 |
+
parameter l0_ph = 0;
|
| 220 |
+
parameter l1_ph = 0;
|
| 221 |
+
parameter g0_ph = 0;
|
| 222 |
+
parameter g1_ph = 0;
|
| 223 |
+
parameter g2_ph = 0;
|
| 224 |
+
parameter g3_ph = 0;
|
| 225 |
+
parameter e0_ph = 0;
|
| 226 |
+
parameter e1_ph = 0;
|
| 227 |
+
parameter e2_ph = 0;
|
| 228 |
+
parameter e3_ph = 0;
|
| 229 |
+
parameter m_ph = 0;
|
| 230 |
+
parameter l0_time_delay = 0;
|
| 231 |
+
parameter l1_time_delay = 0;
|
| 232 |
+
parameter g0_time_delay = 0;
|
| 233 |
+
parameter g1_time_delay = 0;
|
| 234 |
+
parameter g2_time_delay = 0;
|
| 235 |
+
parameter g3_time_delay = 0;
|
| 236 |
+
parameter e0_time_delay = 0;
|
| 237 |
+
parameter e1_time_delay = 0;
|
| 238 |
+
parameter e2_time_delay = 0;
|
| 239 |
+
parameter e3_time_delay = 0;
|
| 240 |
+
parameter m_time_delay = 0;
|
| 241 |
+
parameter n_time_delay = 0;
|
| 242 |
+
parameter extclk3_counter = "e3" ;
|
| 243 |
+
parameter extclk2_counter = "e2" ;
|
| 244 |
+
parameter extclk1_counter = "e1" ;
|
| 245 |
+
parameter extclk0_counter = "e0" ;
|
| 246 |
+
parameter clk9_counter = "c9" ;
|
| 247 |
+
parameter clk8_counter = "c8" ;
|
| 248 |
+
parameter clk7_counter = "c7" ;
|
| 249 |
+
parameter clk6_counter = "c6" ;
|
| 250 |
+
parameter clk5_counter = "l1" ;
|
| 251 |
+
parameter clk4_counter = "l0" ;
|
| 252 |
+
parameter clk3_counter = "g3" ;
|
| 253 |
+
parameter clk2_counter = "g2" ;
|
| 254 |
+
parameter clk1_counter = "g1" ;
|
| 255 |
+
parameter clk0_counter = "g0" ;
|
| 256 |
+
parameter enable0_counter = "l0";
|
| 257 |
+
parameter enable1_counter = "l0";
|
| 258 |
+
parameter charge_pump_current = 2;
|
| 259 |
+
parameter loop_filter_r = "1.0";
|
| 260 |
+
parameter loop_filter_c = 5;
|
| 261 |
+
parameter vco_post_scale = 0;
|
| 262 |
+
parameter vco_frequency_control = "AUTO";
|
| 263 |
+
parameter vco_phase_shift_step = 0;
|
| 264 |
+
parameter lpm_type = "altpll";
|
| 265 |
+
|
| 266 |
+
parameter port_clkena0 = "PORT_CONNECTIVITY";
|
| 267 |
+
parameter port_clkena1 = "PORT_CONNECTIVITY";
|
| 268 |
+
parameter port_clkena2 = "PORT_CONNECTIVITY";
|
| 269 |
+
parameter port_clkena3 = "PORT_CONNECTIVITY";
|
| 270 |
+
parameter port_clkena4 = "PORT_CONNECTIVITY";
|
| 271 |
+
parameter port_clkena5 = "PORT_CONNECTIVITY";
|
| 272 |
+
parameter port_extclkena0 = "PORT_CONNECTIVITY";
|
| 273 |
+
parameter port_extclkena1 = "PORT_CONNECTIVITY";
|
| 274 |
+
parameter port_extclkena2 = "PORT_CONNECTIVITY";
|
| 275 |
+
parameter port_extclkena3 = "PORT_CONNECTIVITY";
|
| 276 |
+
parameter port_extclk0 = "PORT_CONNECTIVITY";
|
| 277 |
+
parameter port_extclk1 = "PORT_CONNECTIVITY";
|
| 278 |
+
parameter port_extclk2 = "PORT_CONNECTIVITY";
|
| 279 |
+
parameter port_extclk3 = "PORT_CONNECTIVITY";
|
| 280 |
+
parameter port_clk0 = "PORT_CONNECTIVITY";
|
| 281 |
+
parameter port_clk1 = "PORT_CONNECTIVITY";
|
| 282 |
+
parameter port_clk2 = "PORT_CONNECTIVITY";
|
| 283 |
+
parameter port_clk3 = "PORT_CONNECTIVITY";
|
| 284 |
+
parameter port_clk4 = "PORT_CONNECTIVITY";
|
| 285 |
+
parameter port_clk5 = "PORT_CONNECTIVITY";
|
| 286 |
+
parameter port_clk6 = "PORT_CONNECTIVITY";
|
| 287 |
+
parameter port_clk7 = "PORT_CONNECTIVITY";
|
| 288 |
+
parameter port_clk8 = "PORT_CONNECTIVITY";
|
| 289 |
+
parameter port_clk9 = "PORT_CONNECTIVITY";
|
| 290 |
+
parameter port_scandata = "PORT_CONNECTIVITY";
|
| 291 |
+
parameter port_scandataout = "PORT_CONNECTIVITY";
|
| 292 |
+
parameter port_scandone = "PORT_CONNECTIVITY";
|
| 293 |
+
parameter port_sclkout1 = "PORT_CONNECTIVITY";
|
| 294 |
+
parameter port_sclkout0 = "PORT_CONNECTIVITY";
|
| 295 |
+
parameter port_clkbad0 = "PORT_CONNECTIVITY";
|
| 296 |
+
parameter port_clkbad1 = "PORT_CONNECTIVITY";
|
| 297 |
+
parameter port_activeclock = "PORT_CONNECTIVITY";
|
| 298 |
+
parameter port_clkloss = "PORT_CONNECTIVITY";
|
| 299 |
+
parameter port_inclk1 = "PORT_CONNECTIVITY";
|
| 300 |
+
parameter port_inclk0 = "PORT_CONNECTIVITY";
|
| 301 |
+
parameter port_fbin = "PORT_CONNECTIVITY";
|
| 302 |
+
parameter port_fbout = "PORT_CONNECTIVITY";
|
| 303 |
+
parameter port_pllena = "PORT_CONNECTIVITY";
|
| 304 |
+
parameter port_clkswitch = "PORT_CONNECTIVITY";
|
| 305 |
+
parameter port_areset = "PORT_CONNECTIVITY";
|
| 306 |
+
parameter port_pfdena = "PORT_CONNECTIVITY";
|
| 307 |
+
parameter port_scanclk = "PORT_CONNECTIVITY";
|
| 308 |
+
parameter port_scanaclr = "PORT_CONNECTIVITY";
|
| 309 |
+
parameter port_scanread = "PORT_CONNECTIVITY";
|
| 310 |
+
parameter port_scanwrite = "PORT_CONNECTIVITY";
|
| 311 |
+
parameter port_enable0 = "PORT_CONNECTIVITY";
|
| 312 |
+
parameter port_enable1 = "PORT_CONNECTIVITY";
|
| 313 |
+
parameter port_locked = "PORT_CONNECTIVITY";
|
| 314 |
+
parameter port_configupdate = "PORT_CONNECTIVITY";
|
| 315 |
+
parameter port_phasecounterselect = "PORT_CONNECTIVITY";
|
| 316 |
+
parameter port_phasedone = "PORT_CONNECTIVITY";
|
| 317 |
+
parameter port_phasestep = "PORT_CONNECTIVITY";
|
| 318 |
+
parameter port_phaseupdown = "PORT_CONNECTIVITY";
|
| 319 |
+
parameter port_vcooverrange = "PORT_CONNECTIVITY";
|
| 320 |
+
parameter port_vcounderrange = "PORT_CONNECTIVITY";
|
| 321 |
+
parameter port_scanclkena = "PORT_CONNECTIVITY";
|
| 322 |
+
parameter using_fbmimicbidir_port = "ON";
|
| 323 |
+
|
| 324 |
+
input [1:0] inclk;
|
| 325 |
+
input fbin;
|
| 326 |
+
input pllena;
|
| 327 |
+
input clkswitch;
|
| 328 |
+
input areset;
|
| 329 |
+
input pfdena;
|
| 330 |
+
input clkena;
|
| 331 |
+
input extclkena;
|
| 332 |
+
input scanclk;
|
| 333 |
+
input scanaclr;
|
| 334 |
+
input scanclkena;
|
| 335 |
+
input scanread;
|
| 336 |
+
input scanwrite;
|
| 337 |
+
input scandata;
|
| 338 |
+
input phasecounterselect;
|
| 339 |
+
input phaseupdown;
|
| 340 |
+
input phasestep;
|
| 341 |
+
input configupdate;
|
| 342 |
+
inout fbmimicbidir;
|
| 343 |
+
|
| 344 |
+
|
| 345 |
+
output [width_clock-1:0] clk;
|
| 346 |
+
output [3:0] extclk;
|
| 347 |
+
output [1:0] clkbad;
|
| 348 |
+
output enable0;
|
| 349 |
+
output enable1;
|
| 350 |
+
output activeclock;
|
| 351 |
+
output clkloss;
|
| 352 |
+
output locked;
|
| 353 |
+
output scandataout;
|
| 354 |
+
output scandone;
|
| 355 |
+
output sclkout0;
|
| 356 |
+
output sclkout1;
|
| 357 |
+
output phasedone;
|
| 358 |
+
output vcooverrange;
|
| 359 |
+
output vcounderrange;
|
| 360 |
+
output fbout;
|
| 361 |
+
output fref;
|
| 362 |
+
output icdrclk;
|
| 363 |
+
output c0, c1, c2, c3, c4;
|
| 364 |
+
|
| 365 |
+
endmodule // altpll
|
| 366 |
+
`endif
|
chips/yosys/techlibs/intel/common/brams_m9k.txt
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
bram $__M9K_ALTSYNCRAM_SINGLEPORT_FULL
|
| 2 |
+
init 1
|
| 3 |
+
abits 13 @M1
|
| 4 |
+
dbits 1 @M1
|
| 5 |
+
abits 12 @M2
|
| 6 |
+
dbits 2 @M2
|
| 7 |
+
abits 11 @M3
|
| 8 |
+
dbits 4 @M3
|
| 9 |
+
abits 10 @M4
|
| 10 |
+
dbits 8 @M4
|
| 11 |
+
abits 10 @M5
|
| 12 |
+
dbits 9 @M5
|
| 13 |
+
abits 9 @M6
|
| 14 |
+
dbits 16 @M6
|
| 15 |
+
abits 9 @M7
|
| 16 |
+
dbits 18 @M7
|
| 17 |
+
abits 8 @M8
|
| 18 |
+
dbits 32 @M8
|
| 19 |
+
abits 8 @M9
|
| 20 |
+
dbits 36 @M9
|
| 21 |
+
groups 2
|
| 22 |
+
ports 1 1
|
| 23 |
+
wrmode 0 1
|
| 24 |
+
enable 1 1
|
| 25 |
+
transp 0 0
|
| 26 |
+
clocks 2 3
|
| 27 |
+
clkpol 2 3
|
| 28 |
+
endbram
|
| 29 |
+
|
| 30 |
+
match $__M9K_ALTSYNCRAM_SINGLEPORT_FULL
|
| 31 |
+
min efficiency 2
|
| 32 |
+
make_transp
|
| 33 |
+
endmatch
|
chips/yosys/techlibs/intel/common/brams_map_m9k.v
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module \$__M9K_ALTSYNCRAM_SINGLEPORT_FULL (CLK2, CLK3, A1ADDR, A1DATA, A1EN, B1ADDR, B1DATA, B1EN);
|
| 2 |
+
|
| 3 |
+
parameter CFG_ABITS = 8;
|
| 4 |
+
parameter CFG_DBITS = 36;
|
| 5 |
+
parameter ABITS = 1;
|
| 6 |
+
parameter DBITS = 1;
|
| 7 |
+
parameter CLKPOL2 = 1;
|
| 8 |
+
parameter CLKPOL3 = 1;
|
| 9 |
+
|
| 10 |
+
input CLK2;
|
| 11 |
+
input CLK3;
|
| 12 |
+
//Read data
|
| 13 |
+
output [CFG_DBITS-1:0] A1DATA;
|
| 14 |
+
input [CFG_ABITS-1:0] A1ADDR;
|
| 15 |
+
input A1EN;
|
| 16 |
+
//Write data
|
| 17 |
+
output [CFG_DBITS-1:0] B1DATA;
|
| 18 |
+
input [CFG_ABITS-1:0] B1ADDR;
|
| 19 |
+
input B1EN;
|
| 20 |
+
|
| 21 |
+
wire [CFG_DBITS-1:0] B1DATA_t;
|
| 22 |
+
|
| 23 |
+
localparam MODE = CFG_DBITS == 1 ? 1:
|
| 24 |
+
CFG_DBITS == 2 ? 2:
|
| 25 |
+
CFG_DBITS == 4 ? 3:
|
| 26 |
+
CFG_DBITS == 8 ? 4:
|
| 27 |
+
CFG_DBITS == 9 ? 5:
|
| 28 |
+
CFG_DBITS == 16 ? 6:
|
| 29 |
+
CFG_DBITS == 18 ? 7:
|
| 30 |
+
CFG_DBITS == 32 ? 8:
|
| 31 |
+
CFG_DBITS == 36 ? 9:
|
| 32 |
+
'bx;
|
| 33 |
+
|
| 34 |
+
localparam NUMWORDS = CFG_DBITS == 1 ? 8192:
|
| 35 |
+
CFG_DBITS == 2 ? 4096:
|
| 36 |
+
CFG_DBITS == 4 ? 2048:
|
| 37 |
+
CFG_DBITS == 8 ? 1024:
|
| 38 |
+
CFG_DBITS == 9 ? 1024:
|
| 39 |
+
CFG_DBITS == 16 ? 512:
|
| 40 |
+
CFG_DBITS == 18 ? 512:
|
| 41 |
+
CFG_DBITS == 32 ? 256:
|
| 42 |
+
CFG_DBITS == 36 ? 256:
|
| 43 |
+
'bx;
|
| 44 |
+
|
| 45 |
+
altsyncram #(.clock_enable_input_b ("ALTERNATE" ),
|
| 46 |
+
.clock_enable_input_a ("ALTERNATE" ),
|
| 47 |
+
.clock_enable_output_b ("NORMAL" ),
|
| 48 |
+
.clock_enable_output_a ("NORMAL" ),
|
| 49 |
+
.wrcontrol_aclr_a ("NONE" ),
|
| 50 |
+
.indata_aclr_a ("NONE" ),
|
| 51 |
+
.address_aclr_a ("NONE" ),
|
| 52 |
+
.outdata_aclr_a ("NONE" ),
|
| 53 |
+
.outdata_reg_a ("UNREGISTERED"),
|
| 54 |
+
.operation_mode ("SINGLE_PORT" ),
|
| 55 |
+
.intended_device_family ("CYCLONE IVE" ),
|
| 56 |
+
.outdata_reg_a ("UNREGISTERED"),
|
| 57 |
+
.lpm_type ("altsyncram" ),
|
| 58 |
+
.init_type ("unused" ),
|
| 59 |
+
.ram_block_type ("AUTO" ),
|
| 60 |
+
.lpm_hint ("ENABLE_RUNTIME_MOD=NO"), // Forced value
|
| 61 |
+
.power_up_uninitialized ("FALSE"),
|
| 62 |
+
.read_during_write_mode_port_a ("NEW_DATA_NO_NBE_READ"), // Forced value
|
| 63 |
+
.width_byteena_a (1), // Forced value
|
| 64 |
+
.numwords_b ( NUMWORDS ),
|
| 65 |
+
.numwords_a ( NUMWORDS ),
|
| 66 |
+
.widthad_b ( CFG_ABITS ),
|
| 67 |
+
.width_b ( CFG_DBITS ),
|
| 68 |
+
.widthad_a ( CFG_ABITS ),
|
| 69 |
+
.width_a ( CFG_DBITS )
|
| 70 |
+
) _TECHMAP_REPLACE_ (
|
| 71 |
+
.data_a(B1DATA),
|
| 72 |
+
.address_a(B1ADDR),
|
| 73 |
+
.wren_a(B1EN),
|
| 74 |
+
.rden_a(A1EN),
|
| 75 |
+
.q_a(A1DATA),
|
| 76 |
+
.data_b(B1DATA),
|
| 77 |
+
.address_b(0),
|
| 78 |
+
.wren_b(1'b0),
|
| 79 |
+
.rden_b(1'b0),
|
| 80 |
+
.q_b(),
|
| 81 |
+
.clock0(CLK2),
|
| 82 |
+
.clock1(1'b1), // Unused in single port mode
|
| 83 |
+
.clocken0(1'b1),
|
| 84 |
+
.clocken1(1'b1),
|
| 85 |
+
.clocken2(1'b1),
|
| 86 |
+
.clocken3(1'b1),
|
| 87 |
+
.aclr0(1'b0),
|
| 88 |
+
.aclr1(1'b0),
|
| 89 |
+
.addressstall_a(1'b0),
|
| 90 |
+
.addressstall_b(1'b0));
|
| 91 |
+
|
| 92 |
+
endmodule
|
chips/yosys/techlibs/intel/common/ff_map.v
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Async Active Low Reset DFF
|
| 2 |
+
module \$_DFFE_PN0P_ (input D, C, R, E, output Q);
|
| 3 |
+
parameter _TECHMAP_WIREINIT_Q_ = 1'bx;
|
| 4 |
+
generate if (_TECHMAP_WIREINIT_Q_ === 1'b1) begin
|
| 5 |
+
dffeas #(.is_wysiwyg("TRUE"), .power_up("high")) _TECHMAP_REPLACE_ (.d(D), .q(Q), .clk(C), .clrn(R), .prn(1'b1), .ena(E), .asdata(1'b0), .aload(1'b0), .sclr(1'b0), .sload(1'b0));
|
| 6 |
+
end else begin
|
| 7 |
+
dffeas #(.is_wysiwyg("TRUE"), .power_up("low")) _TECHMAP_REPLACE_ (.d(D), .q(Q), .clk(C), .clrn(R), .prn(1'b1), .ena(E), .asdata(1'b0), .aload(1'b0), .sclr(1'b0), .sload(1'b0));
|
| 8 |
+
end
|
| 9 |
+
endgenerate
|
| 10 |
+
wire _TECHMAP_REMOVEINIT_Q_ = 1;
|
| 11 |
+
endmodule
|
chips/yosys/techlibs/intel/common/m9k_bb.v
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* yosys -- Yosys Open SYnthesis Suite
|
| 3 |
+
*
|
| 4 |
+
* Copyright (C) 2012 Claire Xenia Wolf <claire@yosyshq.com>
|
| 5 |
+
*
|
| 6 |
+
* Permission to use, copy, modify, and/or distribute this software for any
|
| 7 |
+
* purpose with or without fee is hereby granted, provided that the above
|
| 8 |
+
* copyright notice and this permission notice appear in all copies.
|
| 9 |
+
*
|
| 10 |
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
| 11 |
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
| 12 |
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
| 13 |
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 14 |
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 15 |
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
| 16 |
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
| 17 |
+
*
|
| 18 |
+
*/
|
| 19 |
+
(* blackbox *)
|
| 20 |
+
module altsyncram(data_a, address_a, wren_a, rden_a, q_a, data_b, address_b, wren_b, rden_b,
|
| 21 |
+
q_b, clock0, clock1, clocken0, clocken1, clocken2, clocken3, aclr0, aclr1,
|
| 22 |
+
addressstall_a, addressstall_b);
|
| 23 |
+
|
| 24 |
+
parameter clock_enable_input_b = "ALTERNATE";
|
| 25 |
+
parameter clock_enable_input_a = "ALTERNATE";
|
| 26 |
+
parameter clock_enable_output_b = "NORMAL";
|
| 27 |
+
parameter clock_enable_output_a = "NORMAL";
|
| 28 |
+
parameter wrcontrol_aclr_a = "NONE";
|
| 29 |
+
parameter indata_aclr_a = "NONE";
|
| 30 |
+
parameter address_aclr_a = "NONE";
|
| 31 |
+
parameter outdata_aclr_a = "NONE";
|
| 32 |
+
parameter outdata_reg_a = "UNREGISTERED";
|
| 33 |
+
parameter operation_mode = "SINGLE_PORT";
|
| 34 |
+
parameter intended_device_family = "MAX 10 FPGA";
|
| 35 |
+
parameter outdata_reg_b = "UNREGISTERED";
|
| 36 |
+
parameter lpm_type = "altsyncram";
|
| 37 |
+
parameter init_type = "unused";
|
| 38 |
+
parameter ram_block_type = "AUTO";
|
| 39 |
+
parameter lpm_hint = "ENABLE_RUNTIME_MOD=NO";
|
| 40 |
+
parameter power_up_uninitialized = "FALSE";
|
| 41 |
+
parameter read_during_write_mode_port_a = "NEW_DATA_NO_NBE_READ";
|
| 42 |
+
parameter width_byteena_a = 1;
|
| 43 |
+
parameter numwords_b = 0;
|
| 44 |
+
parameter numwords_a = 0;
|
| 45 |
+
parameter widthad_b = 1;
|
| 46 |
+
parameter width_b = 1;
|
| 47 |
+
parameter widthad_a = 1;
|
| 48 |
+
parameter width_a = 1;
|
| 49 |
+
|
| 50 |
+
// Port A declarations
|
| 51 |
+
output [35:0] q_a;
|
| 52 |
+
input [35:0] data_a;
|
| 53 |
+
input [7:0] address_a;
|
| 54 |
+
input wren_a;
|
| 55 |
+
input rden_a;
|
| 56 |
+
// Port B declarations
|
| 57 |
+
output [35:0] q_b;
|
| 58 |
+
input [35:0] data_b;
|
| 59 |
+
input [7:0] address_b;
|
| 60 |
+
input wren_b;
|
| 61 |
+
input rden_b;
|
| 62 |
+
// Control signals
|
| 63 |
+
input clock0, clock1;
|
| 64 |
+
input clocken0, clocken1, clocken2, clocken3;
|
| 65 |
+
input aclr0, aclr1;
|
| 66 |
+
input addressstall_a;
|
| 67 |
+
input addressstall_b;
|
| 68 |
+
// TODO: Implement the correct simulation model
|
| 69 |
+
|
| 70 |
+
endmodule // altsyncram
|
chips/yosys/techlibs/intel/cyclone10lp/cells_arith.v
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* yosys -- Yosys Open SYnthesis Suite
|
| 3 |
+
*
|
| 4 |
+
* Copyright (C) 2012 Claire Xenia Wolf <claire@yosyshq.com>
|
| 5 |
+
*
|
| 6 |
+
* Permission to use, copy, modify, and/or distribute this software for any
|
| 7 |
+
* purpose with or without fee is hereby granted, provided that the above
|
| 8 |
+
* copyright notice and this permission notice appear in all copies.
|
| 9 |
+
*
|
| 10 |
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
| 11 |
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
| 12 |
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
| 13 |
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 14 |
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 15 |
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
| 16 |
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
| 17 |
+
*
|
| 18 |
+
*/
|
| 19 |
+
|
| 20 |
+
// NOTE: This is still WIP.
|
| 21 |
+
(* techmap_celltype = "$alu" *)
|
| 22 |
+
module _80_altera_a10gx_alu (A, B, CI, BI, X, Y, CO);
|
| 23 |
+
parameter A_SIGNED = 0;
|
| 24 |
+
parameter B_SIGNED = 0;
|
| 25 |
+
parameter A_WIDTH = 1;
|
| 26 |
+
parameter B_WIDTH = 1;
|
| 27 |
+
parameter Y_WIDTH = 1;
|
| 28 |
+
|
| 29 |
+
(* force_downto *)
|
| 30 |
+
input [A_WIDTH-1:0] A;
|
| 31 |
+
(* force_downto *)
|
| 32 |
+
input [B_WIDTH-1:0] B;
|
| 33 |
+
(* force_downto *)
|
| 34 |
+
output [Y_WIDTH-1:0] X, Y;
|
| 35 |
+
|
| 36 |
+
input CI, BI;
|
| 37 |
+
//output [Y_WIDTH-1:0] CO;
|
| 38 |
+
output CO;
|
| 39 |
+
|
| 40 |
+
wire _TECHMAP_FAIL_ = Y_WIDTH <= 4;
|
| 41 |
+
|
| 42 |
+
(* force_downto *)
|
| 43 |
+
wire [Y_WIDTH-1:0] A_buf, B_buf;
|
| 44 |
+
\$pos #(.A_SIGNED(A_SIGNED), .A_WIDTH(A_WIDTH), .Y_WIDTH(Y_WIDTH)) A_conv (.A(A), .Y(A_buf));
|
| 45 |
+
\$pos #(.A_SIGNED(B_SIGNED), .A_WIDTH(B_WIDTH), .Y_WIDTH(Y_WIDTH)) B_conv (.A(B), .Y(B_buf));
|
| 46 |
+
|
| 47 |
+
(* force_downto *)
|
| 48 |
+
wire [Y_WIDTH-1:0] AA = A_buf;
|
| 49 |
+
(* force_downto *)
|
| 50 |
+
wire [Y_WIDTH-1:0] BB = BI ? ~B_buf : B_buf;
|
| 51 |
+
//wire [Y_WIDTH:0] C = {CO, CI};
|
| 52 |
+
wire [Y_WIDTH+1:0] COx;
|
| 53 |
+
wire [Y_WIDTH+1:0] C = {COx, CI};
|
| 54 |
+
|
| 55 |
+
/* Start implementation */
|
| 56 |
+
(* keep *) cyclone10lp_lcell_comb #(.lut_mask(16'b0000_0000_1010_1010), .sum_lutc_input("cin")) carry_start (.cout(COx[0]), .dataa(C[0]), .datab(1'b1), .datac(1'b1), .datad(1'b1));
|
| 57 |
+
|
| 58 |
+
genvar i;
|
| 59 |
+
generate for (i = 0; i < Y_WIDTH; i = i + 1) begin: slice
|
| 60 |
+
if(i==Y_WIDTH-1) begin
|
| 61 |
+
(* keep *) cyclone10lp_lcell_comb #(.lut_mask(16'b1111_0000_1110_0000), .sum_lutc_input("cin")) carry_end (.combout(COx[Y_WIDTH]), .dataa(1'b1), .datab(1'b1), .datac(1'b1), .datad(1'b1), .cin(C[Y_WIDTH]));
|
| 62 |
+
assign CO = COx[Y_WIDTH];
|
| 63 |
+
end
|
| 64 |
+
else
|
| 65 |
+
cyclone10lp_lcell_comb #(.lut_mask(16'b1001_0110_1110_1000), .sum_lutc_input("cin")) arith_cell (.combout(Y[i]), .cout(COx[i+1]), .dataa(AA[i]), .datab(BB[i]), .datac(1'b1), .datad(1'b1), .cin(C[i+1]));
|
| 66 |
+
end: slice
|
| 67 |
+
endgenerate
|
| 68 |
+
/* End implementation */
|
| 69 |
+
assign X = AA ^ BB;
|
| 70 |
+
|
| 71 |
+
endmodule
|
chips/yosys/techlibs/intel/cyclone10lp/cells_map.v
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* yosys -- Yosys Open SYnthesis Suite
|
| 3 |
+
*
|
| 4 |
+
* Copyright (C) 2012 Claire Xenia Wolf <claire@yosyshq.com>
|
| 5 |
+
*
|
| 6 |
+
* Permission to use, copy, modify, and/or distribute this software for any
|
| 7 |
+
* purpose with or without fee is hereby granted, provided that the above
|
| 8 |
+
* copyright notice and this permission notice appear in all copies.
|
| 9 |
+
*
|
| 10 |
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
| 11 |
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
| 12 |
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
| 13 |
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 14 |
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 15 |
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
| 16 |
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
| 17 |
+
*
|
| 18 |
+
*/
|
| 19 |
+
// > c60k28 (Viacheslav, VT) [at] yandex [dot] com
|
| 20 |
+
// > Intel FPGA technology mapping. User must first simulate the generated \
|
| 21 |
+
// > netlist before going to test it on board.
|
| 22 |
+
|
| 23 |
+
// Input buffer map
|
| 24 |
+
module \$__inpad (input I, output O);
|
| 25 |
+
cyclone10lp_io_ibuf _TECHMAP_REPLACE_ (.o(O), .i(I), .ibar(1'b0));
|
| 26 |
+
endmodule
|
| 27 |
+
|
| 28 |
+
// Output buffer map
|
| 29 |
+
module \$__outpad (input I, output O);
|
| 30 |
+
cyclone10lp_io_obuf _TECHMAP_REPLACE_ (.o(O), .i(I), .oe(1'b1));
|
| 31 |
+
endmodule
|
| 32 |
+
|
| 33 |
+
// LUT Map
|
| 34 |
+
/* 0 -> datac
|
| 35 |
+
1 -> cin */
|
| 36 |
+
module \$lut (A, Y);
|
| 37 |
+
parameter WIDTH = 0;
|
| 38 |
+
parameter LUT = 0;
|
| 39 |
+
(* force_downto *)
|
| 40 |
+
input [WIDTH-1:0] A;
|
| 41 |
+
output Y;
|
| 42 |
+
generate
|
| 43 |
+
if (WIDTH == 1) begin
|
| 44 |
+
assign Y = ~A[0]; // Not need to spend 1 logic cell for such an easy function
|
| 45 |
+
end else
|
| 46 |
+
if (WIDTH == 2) begin
|
| 47 |
+
cyclone10lp_lcell_comb #(.lut_mask({4{LUT}}),
|
| 48 |
+
.sum_lutc_input("datac")) _TECHMAP_REPLACE_ (.combout(Y),
|
| 49 |
+
.dataa(A[0]),
|
| 50 |
+
.datab(A[1]),
|
| 51 |
+
.datac(1'b1),
|
| 52 |
+
.datad(1'b1));
|
| 53 |
+
end else
|
| 54 |
+
if(WIDTH == 3) begin
|
| 55 |
+
cyclone10lp_lcell_comb #(.lut_mask({2{LUT}}),
|
| 56 |
+
.sum_lutc_input("datac")) _TECHMAP_REPLACE_ (.combout(Y),
|
| 57 |
+
.dataa(A[0]),
|
| 58 |
+
.datab(A[1]),
|
| 59 |
+
.datac(A[2]),
|
| 60 |
+
.datad(1'b1));
|
| 61 |
+
end else
|
| 62 |
+
if(WIDTH == 4) begin
|
| 63 |
+
cyclone10lp_lcell_comb #(.lut_mask(LUT),
|
| 64 |
+
.sum_lutc_input("datac")) _TECHMAP_REPLACE_ (.combout(Y),
|
| 65 |
+
.dataa(A[0]),
|
| 66 |
+
.datab(A[1]),
|
| 67 |
+
.datac(A[2]),
|
| 68 |
+
.datad(A[3]));
|
| 69 |
+
end else
|
| 70 |
+
wire _TECHMAP_FAIL_ = 1;
|
| 71 |
+
endgenerate
|
| 72 |
+
|
| 73 |
+
endmodule
|
chips/yosys/techlibs/intel/cyclone10lp/cells_sim.v
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* yosys -- Yosys Open SYnthesis Suite
|
| 3 |
+
*
|
| 4 |
+
* Copyright (C) 2012 Claire Xenia Wolf <claire@yosyshq.com>
|
| 5 |
+
*
|
| 6 |
+
* Permission to use, copy, modify, and/or distribute this software for any
|
| 7 |
+
* purpose with or without fee is hereby granted, provided that the above
|
| 8 |
+
* copyright notice and this permission notice appear in all copies.
|
| 9 |
+
*
|
| 10 |
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
| 11 |
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
| 12 |
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
| 13 |
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 14 |
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 15 |
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
| 16 |
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
| 17 |
+
*
|
| 18 |
+
*/
|
| 19 |
+
module VCC (output V);
|
| 20 |
+
assign V = 1'b1;
|
| 21 |
+
endmodule // VCC
|
| 22 |
+
|
| 23 |
+
module GND (output G);
|
| 24 |
+
assign G = 1'b0;
|
| 25 |
+
endmodule // GND
|
| 26 |
+
|
| 27 |
+
/* Altera Cyclone 10 LP devices Input Buffer Primitive */
|
| 28 |
+
module cyclone10lp_io_ibuf
|
| 29 |
+
(output o, input i, input ibar);
|
| 30 |
+
assign ibar = ibar;
|
| 31 |
+
assign o = i;
|
| 32 |
+
endmodule // cyclone10lp_io_ibuf
|
| 33 |
+
|
| 34 |
+
/* Altera Cyclone 10 LP devices Output Buffer Primitive */
|
| 35 |
+
module cyclone10lp_io_obuf
|
| 36 |
+
(output o, input i, input oe);
|
| 37 |
+
assign o = i;
|
| 38 |
+
assign oe = oe;
|
| 39 |
+
endmodule // cyclone10lp_io_obuf
|
| 40 |
+
|
| 41 |
+
/* Altera Cyclone IV (E) 4-input non-fracturable LUT Primitive */
|
| 42 |
+
module cyclone10lp_lcell_comb
|
| 43 |
+
(output combout, cout,
|
| 44 |
+
input dataa, datab, datac, datad, cin);
|
| 45 |
+
|
| 46 |
+
/* Internal parameters which define the behaviour
|
| 47 |
+
of the LUT primitive.
|
| 48 |
+
lut_mask define the lut function, can be expressed in 16-digit bin or hex.
|
| 49 |
+
sum_lutc_input define the type of LUT (combinational | arithmetic).
|
| 50 |
+
dont_touch for retiming || carry options.
|
| 51 |
+
lpm_type for WYSIWYG */
|
| 52 |
+
|
| 53 |
+
parameter lut_mask = 16'hFFFF;
|
| 54 |
+
parameter dont_touch = "off";
|
| 55 |
+
parameter lpm_type = "cyclone10lp_lcell_comb";
|
| 56 |
+
parameter sum_lutc_input = "datac";
|
| 57 |
+
|
| 58 |
+
reg [1:0] lut_type;
|
| 59 |
+
reg cout_rt;
|
| 60 |
+
reg combout_rt;
|
| 61 |
+
wire dataa_w;
|
| 62 |
+
wire datab_w;
|
| 63 |
+
wire datac_w;
|
| 64 |
+
wire datad_w;
|
| 65 |
+
wire cin_w;
|
| 66 |
+
|
| 67 |
+
assign dataa_w = dataa;
|
| 68 |
+
assign datab_w = datab;
|
| 69 |
+
assign datac_w = datac;
|
| 70 |
+
assign datad_w = datad;
|
| 71 |
+
|
| 72 |
+
function lut_data;
|
| 73 |
+
input [15:0] mask;
|
| 74 |
+
input dataa, datab, datac, datad;
|
| 75 |
+
reg [7:0] s3;
|
| 76 |
+
reg [3:0] s2;
|
| 77 |
+
reg [1:0] s1;
|
| 78 |
+
begin
|
| 79 |
+
s3 = datad ? mask[15:8] : mask[7:0];
|
| 80 |
+
s2 = datac ? s3[7:4] : s3[3:0];
|
| 81 |
+
s1 = datab ? s2[3:2] : s2[1:0];
|
| 82 |
+
lut_data = dataa ? s1[1] : s1[0];
|
| 83 |
+
end
|
| 84 |
+
|
| 85 |
+
endfunction
|
| 86 |
+
|
| 87 |
+
initial begin
|
| 88 |
+
if (sum_lutc_input == "datac") lut_type = 0;
|
| 89 |
+
else
|
| 90 |
+
if (sum_lutc_input == "cin") lut_type = 1;
|
| 91 |
+
else begin
|
| 92 |
+
$error("Error in sum_lutc_input. Parameter %s is not a valid value.\n", sum_lutc_input);
|
| 93 |
+
$finish();
|
| 94 |
+
end
|
| 95 |
+
end
|
| 96 |
+
|
| 97 |
+
always @(dataa_w or datab_w or datac_w or datad_w or cin_w) begin
|
| 98 |
+
if (lut_type == 0) begin // logic function
|
| 99 |
+
combout_rt = lut_data(lut_mask, dataa_w, datab_w,
|
| 100 |
+
datac_w, datad_w);
|
| 101 |
+
end
|
| 102 |
+
else if (lut_type == 1) begin // arithmetic function
|
| 103 |
+
combout_rt = lut_data(lut_mask, dataa_w, datab_w,
|
| 104 |
+
cin_w, datad_w);
|
| 105 |
+
end
|
| 106 |
+
cout_rt = lut_data(lut_mask, dataa_w, datab_w, cin_w, 'b0);
|
| 107 |
+
end
|
| 108 |
+
|
| 109 |
+
assign combout = combout_rt & 1'b1;
|
| 110 |
+
assign cout = cout_rt & 1'b1;
|
| 111 |
+
|
| 112 |
+
endmodule // cyclone10lp_lcell_comb
|
| 113 |
+
|
| 114 |
+
/* Altera D Flip-Flop Primitive */
|
| 115 |
+
module dffeas
|
| 116 |
+
(output q,
|
| 117 |
+
input d, clk, clrn, prn, ena,
|
| 118 |
+
input asdata, aload, sclr, sload);
|
| 119 |
+
|
| 120 |
+
// Timing simulation is not covered
|
| 121 |
+
parameter power_up="dontcare";
|
| 122 |
+
parameter is_wysiwyg="false";
|
| 123 |
+
|
| 124 |
+
reg q_tmp;
|
| 125 |
+
wire reset;
|
| 126 |
+
reg [7:0] debug_net;
|
| 127 |
+
|
| 128 |
+
assign reset = (prn && sclr && ~clrn && ena);
|
| 129 |
+
assign q = q_tmp & 1'b1;
|
| 130 |
+
|
| 131 |
+
always @(posedge clk, posedge aload) begin
|
| 132 |
+
if(reset) q_tmp <= 0;
|
| 133 |
+
else q_tmp <= d;
|
| 134 |
+
end
|
| 135 |
+
assign q = q_tmp;
|
| 136 |
+
|
| 137 |
+
endmodule // dffeas
|
chips/yosys/techlibs/intel/cycloneiv/cells_arith.v
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* yosys -- Yosys Open SYnthesis Suite
|
| 3 |
+
*
|
| 4 |
+
* Copyright (C) 2012 Claire Xenia Wolf <claire@yosyshq.com>
|
| 5 |
+
*
|
| 6 |
+
* Permission to use, copy, modify, and/or distribute this software for any
|
| 7 |
+
* purpose with or without fee is hereby granted, provided that the above
|
| 8 |
+
* copyright notice and this permission notice appear in all copies.
|
| 9 |
+
*
|
| 10 |
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
| 11 |
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
| 12 |
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
| 13 |
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 14 |
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 15 |
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
| 16 |
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
| 17 |
+
*
|
| 18 |
+
*/
|
| 19 |
+
|
| 20 |
+
// NOTE: This is still WIP.
|
| 21 |
+
(* techmap_celltype = "$alu" *)
|
| 22 |
+
/* Uncomment this for LCU????
|
| 23 |
+
module _80_cycloneiv_alu (A, B, CI, BI, X, Y, CO);
|
| 24 |
+
parameter A_SIGNED = 0;
|
| 25 |
+
parameter B_SIGNED = 0;
|
| 26 |
+
parameter A_WIDTH = 1;
|
| 27 |
+
parameter B_WIDTH = 1;
|
| 28 |
+
parameter Y_WIDTH = 1;
|
| 29 |
+
|
| 30 |
+
input [A_WIDTH-1:0] A;
|
| 31 |
+
input [B_WIDTH-1:0] B;
|
| 32 |
+
output [Y_WIDTH-1:0] X, Y;
|
| 33 |
+
|
| 34 |
+
input CI, BI;
|
| 35 |
+
//output [Y_WIDTH-1:0] CO;
|
| 36 |
+
output CO;
|
| 37 |
+
|
| 38 |
+
wire _TECHMAP_FAIL_ = Y_WIDTH <= 2;
|
| 39 |
+
|
| 40 |
+
wire [Y_WIDTH-1:0] A_buf, B_buf;
|
| 41 |
+
\$pos #(.A_SIGNED(A_SIGNED), .A_WIDTH(A_WIDTH), .Y_WIDTH(Y_WIDTH)) A_conv (.A(A), .Y(A_buf));
|
| 42 |
+
\$pos #(.A_SIGNED(B_SIGNED), .A_WIDTH(B_WIDTH), .Y_WIDTH(Y_WIDTH)) B_conv (.A(B), .Y(B_buf));
|
| 43 |
+
|
| 44 |
+
wire [Y_WIDTH-1:0] AA = A_buf;
|
| 45 |
+
wire [Y_WIDTH-1:0] BB = BI ? ~B_buf : B_buf;
|
| 46 |
+
//wire [Y_WIDTH:0] C = {CO, CI};
|
| 47 |
+
wire [Y_WIDTH+1:0] COx;
|
| 48 |
+
wire [Y_WIDTH+1:0] C = {COx, CI};
|
| 49 |
+
|
| 50 |
+
/* Start implementation */
|
| 51 |
+
//cycloneiv_lcell_comb #(.lut_mask(16'b0000_0000_1010_1010), .sum_lutc_input("cin")) carry_start (.cout(COx[0]), .dataa(C[0]), .datab(1'b1), .datac(1'b1), .datad(1'b1));
|
| 52 |
+
/*
|
| 53 |
+
genvar i;
|
| 54 |
+
generate for (i = 0; i < Y_WIDTH; i = i + 1) begin: slice
|
| 55 |
+
if(i==Y_WIDTH-1)
|
| 56 |
+
(* keep *) cycloneiv_lcell_comb #(.lut_mask(16'b1111_0000_1110_0000), .sum_lutc_input("cin")) carry_end (.combout(CO), .dataa(1'b1), .datab(1'b1), .datac(1'b1), .datad(1'b1), .cin(C[Y_WIDTH]));
|
| 57 |
+
//assign CO = COx[Y_WIDTH];
|
| 58 |
+
else
|
| 59 |
+
cycloneiv_lcell_comb #(.lut_mask(16'b1001_0110_1110_1000), .sum_lutc_input("cin")) arith_cell (.combout(Y[i]), .cout(COx[i+1]), .dataa(AA[i]), .datab(BB[i]), .datac(1'b1), .datad(1'b1), .cin(C[i+1]));
|
| 60 |
+
end: slice
|
| 61 |
+
endgenerate
|
| 62 |
+
/* End implementation */
|
| 63 |
+
/*assign X = AA ^ BB;
|
| 64 |
+
|
| 65 |
+
endmodule*/
|
| 66 |
+
module _80_cycloneiv_alu (A, B, CI, BI, X, Y, CO);
|
| 67 |
+
parameter A_SIGNED = 0;
|
| 68 |
+
parameter B_SIGNED = 0;
|
| 69 |
+
parameter A_WIDTH = 1;
|
| 70 |
+
parameter B_WIDTH = 1;
|
| 71 |
+
parameter Y_WIDTH = 1;
|
| 72 |
+
|
| 73 |
+
(* force_downto *)
|
| 74 |
+
input [A_WIDTH-1:0] A;
|
| 75 |
+
(* force_downto *)
|
| 76 |
+
input [B_WIDTH-1:0] B;
|
| 77 |
+
(* force_downto *)
|
| 78 |
+
output [Y_WIDTH-1:0] X, Y;
|
| 79 |
+
|
| 80 |
+
input CI, BI;
|
| 81 |
+
output [Y_WIDTH:0] CO;
|
| 82 |
+
|
| 83 |
+
wire _TECHMAP_FAIL_ = Y_WIDTH < 6;
|
| 84 |
+
|
| 85 |
+
(* force_downto *)
|
| 86 |
+
wire [Y_WIDTH-1:0] A_buf, B_buf;
|
| 87 |
+
\$pos #(.A_SIGNED(A_SIGNED), .A_WIDTH(A_WIDTH), .Y_WIDTH(Y_WIDTH)) A_conv (.A(A), .Y(A_buf));
|
| 88 |
+
\$pos #(.A_SIGNED(B_SIGNED), .A_WIDTH(B_WIDTH), .Y_WIDTH(Y_WIDTH)) B_conv (.A(B), .Y(B_buf));
|
| 89 |
+
|
| 90 |
+
(* force_downto *)
|
| 91 |
+
wire [Y_WIDTH-1:0] AA = A_buf;
|
| 92 |
+
(* force_downto *)
|
| 93 |
+
wire [Y_WIDTH-1:0] BB = BI ? ~B_buf : B_buf;
|
| 94 |
+
wire [Y_WIDTH:0] C = {CO, CI};
|
| 95 |
+
|
| 96 |
+
cycloneiv_lcell_comb #(.lut_mask(16'b0110_0110_1000_1000), .sum_lutc_input("cin")) carry_start (.cout(CO[0]), .dataa(BB[0]), .datab(1'b1), .datac(1'b1), .datad(1'b1));
|
| 97 |
+
genvar i;
|
| 98 |
+
generate for (i = 1; i < Y_WIDTH; i = i + 1) begin:slice
|
| 99 |
+
cycloneiv_lcell_comb #(.lut_mask(16'b0101_1010_0101_0000), .sum_lutc_input("cin")) arith_cell (.combout(Y[i]), .cout(CO[i]), .dataa(BB[i]), .datab(1'b1), .datac(1'b1), .datad(1'b1), .cin(C[i]));
|
| 100 |
+
end endgenerate
|
| 101 |
+
|
| 102 |
+
assign X = AA ^ BB;
|
| 103 |
+
endmodule
|
chips/yosys/techlibs/intel/cycloneiv/cells_map.v
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* yosys -- Yosys Open SYnthesis Suite
|
| 3 |
+
*
|
| 4 |
+
* Copyright (C) 2012 Claire Xenia Wolf <claire@yosyshq.com>
|
| 5 |
+
*
|
| 6 |
+
* Permission to use, copy, modify, and/or distribute this software for any
|
| 7 |
+
* purpose with or without fee is hereby granted, provided that the above
|
| 8 |
+
* copyright notice and this permission notice appear in all copies.
|
| 9 |
+
*
|
| 10 |
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
| 11 |
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
| 12 |
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
| 13 |
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 14 |
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 15 |
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
| 16 |
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
| 17 |
+
*
|
| 18 |
+
*/
|
| 19 |
+
// > c60k28 (Viacheslav, VT) [at] yandex [dot] com
|
| 20 |
+
// > Intel FPGA technology mapping. User must first simulate the generated \
|
| 21 |
+
// > netlist before going to test it on board.
|
| 22 |
+
|
| 23 |
+
// Input buffer map
|
| 24 |
+
module \$__inpad (input I, output O);
|
| 25 |
+
cycloneiv_io_ibuf _TECHMAP_REPLACE_ (.o(O), .i(I), .ibar(1'b0));
|
| 26 |
+
endmodule
|
| 27 |
+
|
| 28 |
+
// Output buffer map
|
| 29 |
+
module \$__outpad (input I, output O);
|
| 30 |
+
cycloneiv_io_obuf _TECHMAP_REPLACE_ (.o(O), .i(I), .oe(1'b1));
|
| 31 |
+
endmodule
|
| 32 |
+
|
| 33 |
+
// LUT Map
|
| 34 |
+
/* 0 -> datac
|
| 35 |
+
1 -> cin */
|
| 36 |
+
module \$lut (A, Y);
|
| 37 |
+
parameter WIDTH = 0;
|
| 38 |
+
parameter LUT = 0;
|
| 39 |
+
(* force_downto *)
|
| 40 |
+
input [WIDTH-1:0] A;
|
| 41 |
+
output Y;
|
| 42 |
+
generate
|
| 43 |
+
if (WIDTH == 1) begin
|
| 44 |
+
assign Y = ~A[0]; // Not need to spend 1 logic cell for such an easy function
|
| 45 |
+
end else
|
| 46 |
+
if (WIDTH == 2) begin
|
| 47 |
+
cycloneiv_lcell_comb #(.lut_mask({4{LUT}}), .sum_lutc_input("datac")) _TECHMAP_REPLACE_ (.combout(Y), .dataa(A[0]), .datab(A[1]), .datac(1'b1),.datad(1'b1));
|
| 48 |
+
end else
|
| 49 |
+
if(WIDTH == 3) begin
|
| 50 |
+
cycloneiv_lcell_comb #(.lut_mask({2{LUT}}), .sum_lutc_input("datac")) _TECHMAP_REPLACE_ (.combout(Y), .dataa(A[0]), .datab(A[1]), .datac(A[2]),.datad(1'b1));
|
| 51 |
+
end else
|
| 52 |
+
if(WIDTH == 4) begin
|
| 53 |
+
cycloneiv_lcell_comb #(.lut_mask(LUT), .sum_lutc_input("datac")) _TECHMAP_REPLACE_ (.combout(Y), .dataa(A[0]), .datab(A[1]), .datac(A[2]),.datad(A[3]));
|
| 54 |
+
end else
|
| 55 |
+
wire _TECHMAP_FAIL_ = 1;
|
| 56 |
+
endgenerate
|
| 57 |
+
endmodule //
|
chips/yosys/techlibs/intel/cycloneiv/cells_sim.v
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* yosys -- Yosys Open SYnthesis Suite
|
| 3 |
+
*
|
| 4 |
+
* Copyright (C) 2012 Claire Xenia Wolf <claire@yosyshq.com>
|
| 5 |
+
*
|
| 6 |
+
* Permission to use, copy, modify, and/or distribute this software for any
|
| 7 |
+
* purpose with or without fee is hereby granted, provided that the above
|
| 8 |
+
* copyright notice and this permission notice appear in all copies.
|
| 9 |
+
*
|
| 10 |
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
| 11 |
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
| 12 |
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
| 13 |
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 14 |
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 15 |
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
| 16 |
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
| 17 |
+
*
|
| 18 |
+
*/
|
| 19 |
+
|
| 20 |
+
module VCC (output V);
|
| 21 |
+
assign V = 1'b1;
|
| 22 |
+
endmodule // VCC
|
| 23 |
+
|
| 24 |
+
module GND (output G);
|
| 25 |
+
assign G = 1'b0;
|
| 26 |
+
endmodule // GND
|
| 27 |
+
|
| 28 |
+
/* Altera Cyclone IV (GX) devices Input Buffer Primitive */
|
| 29 |
+
module cycloneiv_io_ibuf
|
| 30 |
+
(output o, input i, input ibar);
|
| 31 |
+
assign ibar = ibar;
|
| 32 |
+
assign o = i;
|
| 33 |
+
endmodule // fiftyfivenm_io_ibuf
|
| 34 |
+
|
| 35 |
+
/* Altera Cyclone IV (GX) devices Output Buffer Primitive */
|
| 36 |
+
module cycloneiv_io_obuf
|
| 37 |
+
(output o, input i, input oe);
|
| 38 |
+
assign o = i;
|
| 39 |
+
assign oe = oe;
|
| 40 |
+
endmodule // fiftyfivenm_io_obuf
|
| 41 |
+
|
| 42 |
+
/* Altera Cyclone IV (GX) 4-input non-fracturable LUT Primitive */
|
| 43 |
+
module cycloneiv_lcell_comb
|
| 44 |
+
(output combout, cout,
|
| 45 |
+
input dataa, datab, datac, datad, cin);
|
| 46 |
+
|
| 47 |
+
/* Internal parameters which define the behaviour
|
| 48 |
+
of the LUT primitive.
|
| 49 |
+
lut_mask define the lut function, can be expressed in 16-digit bin or hex.
|
| 50 |
+
sum_lutc_input define the type of LUT (combinational | arithmetic).
|
| 51 |
+
dont_touch for retiming || carry options.
|
| 52 |
+
lpm_type for WYSIWYG */
|
| 53 |
+
|
| 54 |
+
parameter lut_mask = 16'hFFFF;
|
| 55 |
+
parameter dont_touch = "off";
|
| 56 |
+
parameter lpm_type = "cycloneiv_lcell_comb";
|
| 57 |
+
parameter sum_lutc_input = "datac";
|
| 58 |
+
|
| 59 |
+
reg [1:0] lut_type;
|
| 60 |
+
reg cout_rt;
|
| 61 |
+
reg combout_rt;
|
| 62 |
+
wire dataa_w;
|
| 63 |
+
wire datab_w;
|
| 64 |
+
wire datac_w;
|
| 65 |
+
wire datad_w;
|
| 66 |
+
wire cin_w;
|
| 67 |
+
|
| 68 |
+
assign dataa_w = dataa;
|
| 69 |
+
assign datab_w = datab;
|
| 70 |
+
assign datac_w = datac;
|
| 71 |
+
assign datad_w = datad;
|
| 72 |
+
|
| 73 |
+
function lut_data;
|
| 74 |
+
input [15:0] mask;
|
| 75 |
+
input dataa, datab, datac, datad;
|
| 76 |
+
reg [7:0] s3;
|
| 77 |
+
reg [3:0] s2;
|
| 78 |
+
reg [1:0] s1;
|
| 79 |
+
begin
|
| 80 |
+
s3 = datad ? mask[15:8] : mask[7:0];
|
| 81 |
+
s2 = datac ? s3[7:4] : s3[3:0];
|
| 82 |
+
s1 = datab ? s2[3:2] : s2[1:0];
|
| 83 |
+
lut_data = dataa ? s1[1] : s1[0];
|
| 84 |
+
end
|
| 85 |
+
|
| 86 |
+
endfunction
|
| 87 |
+
|
| 88 |
+
initial begin
|
| 89 |
+
if (sum_lutc_input == "datac") lut_type = 0;
|
| 90 |
+
else
|
| 91 |
+
if (sum_lutc_input == "cin") lut_type = 1;
|
| 92 |
+
else begin
|
| 93 |
+
$error("Error in sum_lutc_input. Parameter %s is not a valid value.\n", sum_lutc_input);
|
| 94 |
+
$finish();
|
| 95 |
+
end
|
| 96 |
+
end
|
| 97 |
+
|
| 98 |
+
always @(dataa_w or datab_w or datac_w or datad_w or cin_w) begin
|
| 99 |
+
if (lut_type == 0) begin // logic function
|
| 100 |
+
combout_rt = lut_data(lut_mask, dataa_w, datab_w,
|
| 101 |
+
datac_w, datad_w);
|
| 102 |
+
end
|
| 103 |
+
else if (lut_type == 1) begin // arithmetic function
|
| 104 |
+
combout_rt = lut_data(lut_mask, dataa_w, datab_w,
|
| 105 |
+
cin_w, datad_w);
|
| 106 |
+
end
|
| 107 |
+
cout_rt = lut_data(lut_mask, dataa_w, datab_w, cin_w, 'b0);
|
| 108 |
+
end
|
| 109 |
+
|
| 110 |
+
assign combout = combout_rt & 1'b1;
|
| 111 |
+
assign cout = cout_rt & 1'b1;
|
| 112 |
+
|
| 113 |
+
endmodule // cycloneiv_lcell_comb
|
| 114 |
+
|
| 115 |
+
/* Altera D Flip-Flop Primitive */
|
| 116 |
+
module dffeas
|
| 117 |
+
(output q,
|
| 118 |
+
input d, clk, clrn, prn, ena,
|
| 119 |
+
input asdata, aload, sclr, sload);
|
| 120 |
+
|
| 121 |
+
// Timing simulation is not covered
|
| 122 |
+
parameter power_up="dontcare";
|
| 123 |
+
parameter is_wysiwyg="false";
|
| 124 |
+
|
| 125 |
+
reg q_tmp;
|
| 126 |
+
wire reset;
|
| 127 |
+
reg [7:0] debug_net;
|
| 128 |
+
|
| 129 |
+
assign reset = (prn && sclr && ~clrn && ena);
|
| 130 |
+
assign q = q_tmp & 1'b1;
|
| 131 |
+
|
| 132 |
+
always @(posedge clk, posedge aload) begin
|
| 133 |
+
if(reset) q_tmp <= 0;
|
| 134 |
+
else q_tmp <= d;
|
| 135 |
+
end
|
| 136 |
+
assign q = q_tmp;
|
| 137 |
+
|
| 138 |
+
endmodule // dffeas
|
| 139 |
+
|
| 140 |
+
/* Cyclone IV GX altpll clearbox model */
|
| 141 |
+
(* blackbox *)
|
| 142 |
+
module cycloneiv_pll
|
| 143 |
+
(inclk,
|
| 144 |
+
fbin,
|
| 145 |
+
fbout,
|
| 146 |
+
clkswitch,
|
| 147 |
+
areset,
|
| 148 |
+
pfdena,
|
| 149 |
+
scanclk,
|
| 150 |
+
scandata,
|
| 151 |
+
scanclkena,
|
| 152 |
+
configupdate,
|
| 153 |
+
clk,
|
| 154 |
+
phasecounterselect,
|
| 155 |
+
phaseupdown,
|
| 156 |
+
phasestep,
|
| 157 |
+
clkbad,
|
| 158 |
+
activeclock,
|
| 159 |
+
locked,
|
| 160 |
+
scandataout,
|
| 161 |
+
scandone,
|
| 162 |
+
phasedone,
|
| 163 |
+
vcooverrange,
|
| 164 |
+
vcounderrange,
|
| 165 |
+
fref,
|
| 166 |
+
icdrclk);
|
| 167 |
+
|
| 168 |
+
parameter operation_mode = "normal";
|
| 169 |
+
parameter pll_type = "auto";
|
| 170 |
+
parameter compensate_clock = "clock0";
|
| 171 |
+
parameter inclk0_input_frequency = 0;
|
| 172 |
+
parameter inclk1_input_frequency = 0;
|
| 173 |
+
parameter self_reset_on_loss_lock = "off";
|
| 174 |
+
parameter switch_over_type = "auto";
|
| 175 |
+
parameter switch_over_counter = 1;
|
| 176 |
+
parameter enable_switch_over_counter = "off";
|
| 177 |
+
parameter bandwidth = 0;
|
| 178 |
+
parameter bandwidth_type = "auto";
|
| 179 |
+
parameter use_dc_coupling = "false";
|
| 180 |
+
parameter lock_high = 0;
|
| 181 |
+
parameter lock_low = 0;
|
| 182 |
+
parameter lock_window_ui = "0.05";
|
| 183 |
+
parameter test_bypass_lock_detect = "off";
|
| 184 |
+
parameter clk0_output_frequency = 0;
|
| 185 |
+
parameter clk0_multiply_by = 0;
|
| 186 |
+
parameter clk0_divide_by = 0;
|
| 187 |
+
parameter clk0_phase_shift = "0";
|
| 188 |
+
parameter clk0_duty_cycle = 50;
|
| 189 |
+
parameter clk1_output_frequency = 0;
|
| 190 |
+
parameter clk1_multiply_by = 0;
|
| 191 |
+
parameter clk1_divide_by = 0;
|
| 192 |
+
parameter clk1_phase_shift = "0";
|
| 193 |
+
parameter clk1_duty_cycle = 50;
|
| 194 |
+
parameter clk2_output_frequency = 0;
|
| 195 |
+
parameter clk2_multiply_by = 0;
|
| 196 |
+
parameter clk2_divide_by = 0;
|
| 197 |
+
parameter clk2_phase_shift = "0";
|
| 198 |
+
parameter clk2_duty_cycle = 50;
|
| 199 |
+
parameter clk3_output_frequency = 0;
|
| 200 |
+
parameter clk3_multiply_by = 0;
|
| 201 |
+
parameter clk3_divide_by = 0;
|
| 202 |
+
parameter clk3_phase_shift = "0";
|
| 203 |
+
parameter clk3_duty_cycle = 50;
|
| 204 |
+
parameter clk4_output_frequency = 0;
|
| 205 |
+
parameter clk4_multiply_by = 0;
|
| 206 |
+
parameter clk4_divide_by = 0;
|
| 207 |
+
parameter clk4_phase_shift = "0";
|
| 208 |
+
parameter clk4_duty_cycle = 50;
|
| 209 |
+
parameter pfd_min = 0;
|
| 210 |
+
parameter pfd_max = 0;
|
| 211 |
+
parameter vco_min = 0;
|
| 212 |
+
parameter vco_max = 0;
|
| 213 |
+
parameter vco_center = 0;
|
| 214 |
+
// Advanced user parameters
|
| 215 |
+
parameter m_initial = 1;
|
| 216 |
+
parameter m = 0;
|
| 217 |
+
parameter n = 1;
|
| 218 |
+
parameter c0_high = 1;
|
| 219 |
+
parameter c0_low = 1;
|
| 220 |
+
parameter c0_initial = 1;
|
| 221 |
+
parameter c0_mode = "bypass";
|
| 222 |
+
parameter c0_ph = 0;
|
| 223 |
+
parameter c1_high = 1;
|
| 224 |
+
parameter c1_low = 1;
|
| 225 |
+
parameter c1_initial = 1;
|
| 226 |
+
parameter c1_mode = "bypass";
|
| 227 |
+
parameter c1_ph = 0;
|
| 228 |
+
parameter c2_high = 1;
|
| 229 |
+
parameter c2_low = 1;
|
| 230 |
+
parameter c2_initial = 1;
|
| 231 |
+
parameter c2_mode = "bypass";
|
| 232 |
+
parameter c2_ph = 0;
|
| 233 |
+
parameter c3_high = 1;
|
| 234 |
+
parameter c3_low = 1;
|
| 235 |
+
parameter c3_initial = 1;
|
| 236 |
+
parameter c3_mode = "bypass";
|
| 237 |
+
parameter c3_ph = 0;
|
| 238 |
+
parameter c4_high = 1;
|
| 239 |
+
parameter c4_low = 1;
|
| 240 |
+
parameter c4_initial = 1;
|
| 241 |
+
parameter c4_mode = "bypass";
|
| 242 |
+
parameter c4_ph = 0;
|
| 243 |
+
parameter m_ph = 0;
|
| 244 |
+
parameter clk0_counter = "unused";
|
| 245 |
+
parameter clk1_counter = "unused";
|
| 246 |
+
parameter clk2_counter = "unused";
|
| 247 |
+
parameter clk3_counter = "unused";
|
| 248 |
+
parameter clk4_counter = "unused";
|
| 249 |
+
parameter c1_use_casc_in = "off";
|
| 250 |
+
parameter c2_use_casc_in = "off";
|
| 251 |
+
parameter c3_use_casc_in = "off";
|
| 252 |
+
parameter c4_use_casc_in = "off";
|
| 253 |
+
parameter m_test_source = -1;
|
| 254 |
+
parameter c0_test_source = -1;
|
| 255 |
+
parameter c1_test_source = -1;
|
| 256 |
+
parameter c2_test_source = -1;
|
| 257 |
+
parameter c3_test_source = -1;
|
| 258 |
+
parameter c4_test_source = -1;
|
| 259 |
+
parameter vco_multiply_by = 0;
|
| 260 |
+
parameter vco_divide_by = 0;
|
| 261 |
+
parameter vco_post_scale = 1;
|
| 262 |
+
parameter vco_frequency_control = "auto";
|
| 263 |
+
parameter vco_phase_shift_step = 0;
|
| 264 |
+
parameter charge_pump_current = 10;
|
| 265 |
+
parameter loop_filter_r = "1.0";
|
| 266 |
+
parameter loop_filter_c = 0;
|
| 267 |
+
parameter pll_compensation_delay = 0;
|
| 268 |
+
parameter lpm_type = "cycloneiv_pll";
|
| 269 |
+
parameter phase_counter_select_width = 3;
|
| 270 |
+
|
| 271 |
+
input [1:0] inclk;
|
| 272 |
+
input fbin;
|
| 273 |
+
input clkswitch;
|
| 274 |
+
input areset;
|
| 275 |
+
input pfdena;
|
| 276 |
+
input [phase_counter_select_width - 1:0] phasecounterselect;
|
| 277 |
+
input phaseupdown;
|
| 278 |
+
input phasestep;
|
| 279 |
+
input scanclk;
|
| 280 |
+
input scanclkena;
|
| 281 |
+
input scandata;
|
| 282 |
+
input configupdate;
|
| 283 |
+
|
| 284 |
+
output [4:0] clk;
|
| 285 |
+
output [1:0] clkbad;
|
| 286 |
+
output activeclock;
|
| 287 |
+
output locked;
|
| 288 |
+
output scandataout;
|
| 289 |
+
output scandone;
|
| 290 |
+
output fbout;
|
| 291 |
+
output phasedone;
|
| 292 |
+
output vcooverrange;
|
| 293 |
+
output vcounderrange;
|
| 294 |
+
output fref;
|
| 295 |
+
output icdrclk;
|
| 296 |
+
|
| 297 |
+
endmodule // cycloneive_pll
|
chips/yosys/techlibs/intel/cycloneive/arith_map.v
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* yosys -- Yosys Open SYnthesis Suite
|
| 3 |
+
*
|
| 4 |
+
* Copyright (C) 2012 Claire Xenia Wolf <claire@yosyshq.com>
|
| 5 |
+
*
|
| 6 |
+
* Permission to use, copy, modify, and/or distribute this software for any
|
| 7 |
+
* purpose with or without fee is hereby granted, provided that the above
|
| 8 |
+
* copyright notice and this permission notice appear in all copies.
|
| 9 |
+
*
|
| 10 |
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
| 11 |
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
| 12 |
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
| 13 |
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 14 |
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 15 |
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
| 16 |
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
| 17 |
+
*
|
| 18 |
+
*/
|
| 19 |
+
/* TODO: Describe the following mode */
|
| 20 |
+
module fa
|
| 21 |
+
(input a_c,
|
| 22 |
+
input b_c,
|
| 23 |
+
input cin_c,
|
| 24 |
+
output cout_t,
|
| 25 |
+
output sum_x);
|
| 26 |
+
|
| 27 |
+
wire a_c;
|
| 28 |
+
wire b_c;
|
| 29 |
+
wire cout_t;
|
| 30 |
+
wire cin_c;
|
| 31 |
+
wire sum_x;
|
| 32 |
+
wire VCC;
|
| 33 |
+
|
| 34 |
+
assign VCC = 1'b1;
|
| 35 |
+
|
| 36 |
+
cycloneiv_lcell_comb gen_sum_0 (.combout(sum_x),
|
| 37 |
+
.dataa(a_c),
|
| 38 |
+
.datab(b_c),
|
| 39 |
+
.datac(cin_c),
|
| 40 |
+
.datad(VCC));
|
| 41 |
+
defparam syn__05_.lut_mask = 16'b1001011010010110;
|
| 42 |
+
defparam syn__05_.sum_lutc_input = "datac";
|
| 43 |
+
|
| 44 |
+
cycloneiv_lcell_comb gen_cout_0 (.combout(cout_t),
|
| 45 |
+
.dataa(cin_c),
|
| 46 |
+
.datab(b_c),
|
| 47 |
+
.datac(a_c),
|
| 48 |
+
.datad(VCC));
|
| 49 |
+
defparam syn__06_.lut_mask = 16'b1110000011100000;
|
| 50 |
+
defparam syn__06_.sum_lutc_input = "datac";
|
| 51 |
+
|
| 52 |
+
endmodule // fa
|
| 53 |
+
|
| 54 |
+
module f_stage();
|
| 55 |
+
|
| 56 |
+
endmodule // f_stage
|
| 57 |
+
|
| 58 |
+
module f_end();
|
| 59 |
+
|
| 60 |
+
endmodule // f_end
|
| 61 |
+
|
| 62 |
+
module _80_cycloneive_alu (A, B, CI, BI, X, Y, CO);
|
| 63 |
+
parameter A_SIGNED = 0;
|
| 64 |
+
parameter B_SIGNED = 0;
|
| 65 |
+
parameter A_WIDTH = 1;
|
| 66 |
+
parameter B_WIDTH = 1;
|
| 67 |
+
parameter Y_WIDTH = 1;
|
| 68 |
+
|
| 69 |
+
(* force_downto *)
|
| 70 |
+
input [A_WIDTH-1:0] A;
|
| 71 |
+
(* force_downto *)
|
| 72 |
+
input [B_WIDTH-1:0] B;
|
| 73 |
+
(* force_downto *)
|
| 74 |
+
output [Y_WIDTH-1:0] X, Y;
|
| 75 |
+
|
| 76 |
+
input CI, BI;
|
| 77 |
+
output [Y_WIDTH:0] CO;
|
| 78 |
+
|
| 79 |
+
wire _TECHMAP_FAIL_ = Y_WIDTH < 5;
|
| 80 |
+
|
| 81 |
+
(* force_downto *)
|
| 82 |
+
wire [Y_WIDTH-1:0] A_buf, B_buf;
|
| 83 |
+
\$pos #(.A_SIGNED(A_SIGNED), .A_WIDTH(A_WIDTH), .Y_WIDTH(Y_WIDTH)) A_conv (.A(A), .Y(A_buf));
|
| 84 |
+
\$pos #(.A_SIGNED(B_SIGNED), .A_WIDTH(B_WIDTH), .Y_WIDTH(Y_WIDTH)) B_conv (.A(B), .Y(B_buf));
|
| 85 |
+
|
| 86 |
+
(* force_downto *)
|
| 87 |
+
wire [Y_WIDTH-1:0] AA = A_buf;
|
| 88 |
+
(* force_downto *)
|
| 89 |
+
wire [Y_WIDTH-1:0] BB = BI ? ~B_buf : B_buf;
|
| 90 |
+
wire [Y_WIDTH:0] C = {CO, CI};
|
| 91 |
+
|
| 92 |
+
fa f0 (.a_c(AA[0]),
|
| 93 |
+
.b_c(BB[0]),
|
| 94 |
+
.cin_c(C[0]),
|
| 95 |
+
.cout_t(C0[1]),
|
| 96 |
+
.sum_x(Y[0]));
|
| 97 |
+
|
| 98 |
+
genvar i;
|
| 99 |
+
generate for (i = 1; i < Y_WIDTH; i = i + 1) begin:slice
|
| 100 |
+
cycloneive_lcell_comb #(.lut_mask(16'b0101_1010_0101_0000), .sum_lutc_input("cin")) arith_cell (.combout(Y[i]), .cout(CO[i]), .dataa(BB[i]), .datab(1'b1), .datac(1'b1), .datad(1'b1), .cin(C[i]));
|
| 101 |
+
end endgenerate
|
| 102 |
+
|
| 103 |
+
assign X = AA ^ BB;
|
| 104 |
+
|
| 105 |
+
endmodule
|
chips/yosys/techlibs/intel/cycloneive/cells_map.v
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* yosys -- Yosys Open SYnthesis Suite
|
| 3 |
+
*
|
| 4 |
+
* Copyright (C) 2012 Claire Xenia Wolf <claire@yosyshq.com>
|
| 5 |
+
*
|
| 6 |
+
* Permission to use, copy, modify, and/or distribute this software for any
|
| 7 |
+
* purpose with or without fee is hereby granted, provided that the above
|
| 8 |
+
* copyright notice and this permission notice appear in all copies.
|
| 9 |
+
*
|
| 10 |
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
| 11 |
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
| 12 |
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
| 13 |
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 14 |
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 15 |
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
| 16 |
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
| 17 |
+
*
|
| 18 |
+
*/
|
| 19 |
+
// > c60k28 (Viacheslav, VT) [at] yandex [dot] com
|
| 20 |
+
// > Intel FPGA technology mapping. User must first simulate the generated \
|
| 21 |
+
// > netlist before going to test it on board.
|
| 22 |
+
|
| 23 |
+
// Input buffer map
|
| 24 |
+
module \$__inpad (input I, output O);
|
| 25 |
+
cycloneive_io_ibuf _TECHMAP_REPLACE_ (.o(O), .i(I), .ibar(1'b0));
|
| 26 |
+
endmodule
|
| 27 |
+
|
| 28 |
+
// Output buffer map
|
| 29 |
+
module \$__outpad (input I, output O);
|
| 30 |
+
cycloneive_io_obuf _TECHMAP_REPLACE_ (.o(O), .i(I), .oe(1'b1));
|
| 31 |
+
endmodule
|
| 32 |
+
|
| 33 |
+
// LUT Map
|
| 34 |
+
/* 0 -> datac
|
| 35 |
+
1 -> cin */
|
| 36 |
+
module \$lut (A, Y);
|
| 37 |
+
parameter WIDTH = 0;
|
| 38 |
+
parameter LUT = 0;
|
| 39 |
+
(* force_downto *)
|
| 40 |
+
input [WIDTH-1:0] A;
|
| 41 |
+
output Y;
|
| 42 |
+
generate
|
| 43 |
+
if (WIDTH == 1) begin
|
| 44 |
+
assign Y = ~A[0]; // Not need to spend 1 logic cell for such an easy function
|
| 45 |
+
end else
|
| 46 |
+
if (WIDTH == 2) begin
|
| 47 |
+
cycloneive_lcell_comb #(.lut_mask({4{LUT}}),
|
| 48 |
+
.sum_lutc_input("datac")) _TECHMAP_REPLACE_ (.combout(Y),
|
| 49 |
+
.dataa(A[0]),
|
| 50 |
+
.datab(A[1]),
|
| 51 |
+
.datac(1'b1),
|
| 52 |
+
.datad(1'b1));
|
| 53 |
+
end else
|
| 54 |
+
if(WIDTH == 3) begin
|
| 55 |
+
cycloneive_lcell_comb #(.lut_mask({2{LUT}}),
|
| 56 |
+
.sum_lutc_input("datac")) _TECHMAP_REPLACE_ (.combout(Y),
|
| 57 |
+
.dataa(A[0]),
|
| 58 |
+
.datab(A[1]),
|
| 59 |
+
.datac(A[2]),
|
| 60 |
+
.datad(1'b1));
|
| 61 |
+
end else
|
| 62 |
+
if(WIDTH == 4) begin
|
| 63 |
+
cycloneive_lcell_comb #(.lut_mask(LUT),
|
| 64 |
+
.sum_lutc_input("datac")) _TECHMAP_REPLACE_ (.combout(Y),
|
| 65 |
+
.dataa(A[0]),
|
| 66 |
+
.datab(A[1]),
|
| 67 |
+
.datac(A[2]),
|
| 68 |
+
.datad(A[3]));
|
| 69 |
+
end else
|
| 70 |
+
wire _TECHMAP_FAIL_ = 1;
|
| 71 |
+
endgenerate
|
| 72 |
+
|
| 73 |
+
endmodule
|
chips/yosys/techlibs/intel/cycloneive/cells_sim.v
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* yosys -- Yosys Open SYnthesis Suite
|
| 3 |
+
*
|
| 4 |
+
* Copyright (C) 2012 Claire Xenia Wolf <claire@yosyshq.com>
|
| 5 |
+
*
|
| 6 |
+
* Permission to use, copy, modify, and/or distribute this software for any
|
| 7 |
+
* purpose with or without fee is hereby granted, provided that the above
|
| 8 |
+
* copyright notice and this permission notice appear in all copies.
|
| 9 |
+
*
|
| 10 |
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
| 11 |
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
| 12 |
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
| 13 |
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 14 |
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 15 |
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
| 16 |
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
| 17 |
+
*
|
| 18 |
+
*/
|
| 19 |
+
module VCC (output V);
|
| 20 |
+
assign V = 1'b1;
|
| 21 |
+
endmodule // VCC
|
| 22 |
+
|
| 23 |
+
module GND (output G);
|
| 24 |
+
assign G = 1'b0;
|
| 25 |
+
endmodule // GND
|
| 26 |
+
|
| 27 |
+
/* Altera Cyclone IV (E) devices Input Buffer Primitive */
|
| 28 |
+
module cycloneive_io_ibuf
|
| 29 |
+
(output o, input i, input ibar);
|
| 30 |
+
assign ibar = ibar;
|
| 31 |
+
assign o = i;
|
| 32 |
+
endmodule // fiftyfivenm_io_ibuf
|
| 33 |
+
|
| 34 |
+
/* Altera Cyclone IV (E) devices Output Buffer Primitive */
|
| 35 |
+
module cycloneive_io_obuf
|
| 36 |
+
(output o, input i, input oe);
|
| 37 |
+
assign o = i;
|
| 38 |
+
assign oe = oe;
|
| 39 |
+
endmodule // fiftyfivenm_io_obuf
|
| 40 |
+
|
| 41 |
+
/* Altera Cyclone IV (E) 4-input non-fracturable LUT Primitive */
|
| 42 |
+
module cycloneive_lcell_comb
|
| 43 |
+
(output combout, cout,
|
| 44 |
+
input dataa, datab, datac, datad, cin);
|
| 45 |
+
|
| 46 |
+
/* Internal parameters which define the behaviour
|
| 47 |
+
of the LUT primitive.
|
| 48 |
+
lut_mask define the lut function, can be expressed in 16-digit bin or hex.
|
| 49 |
+
sum_lutc_input define the type of LUT (combinational | arithmetic).
|
| 50 |
+
dont_touch for retiming || carry options.
|
| 51 |
+
lpm_type for WYSIWYG */
|
| 52 |
+
|
| 53 |
+
parameter lut_mask = 16'hFFFF;
|
| 54 |
+
parameter dont_touch = "off";
|
| 55 |
+
parameter lpm_type = "cycloneive_lcell_comb";
|
| 56 |
+
parameter sum_lutc_input = "datac";
|
| 57 |
+
|
| 58 |
+
reg [1:0] lut_type;
|
| 59 |
+
reg cout_rt;
|
| 60 |
+
reg combout_rt;
|
| 61 |
+
wire dataa_w;
|
| 62 |
+
wire datab_w;
|
| 63 |
+
wire datac_w;
|
| 64 |
+
wire datad_w;
|
| 65 |
+
wire cin_w;
|
| 66 |
+
|
| 67 |
+
assign dataa_w = dataa;
|
| 68 |
+
assign datab_w = datab;
|
| 69 |
+
assign datac_w = datac;
|
| 70 |
+
assign datad_w = datad;
|
| 71 |
+
|
| 72 |
+
function lut_data;
|
| 73 |
+
input [15:0] mask;
|
| 74 |
+
input dataa, datab, datac, datad;
|
| 75 |
+
reg [7:0] s3;
|
| 76 |
+
reg [3:0] s2;
|
| 77 |
+
reg [1:0] s1;
|
| 78 |
+
begin
|
| 79 |
+
s3 = datad ? mask[15:8] : mask[7:0];
|
| 80 |
+
s2 = datac ? s3[7:4] : s3[3:0];
|
| 81 |
+
s1 = datab ? s2[3:2] : s2[1:0];
|
| 82 |
+
lut_data = dataa ? s1[1] : s1[0];
|
| 83 |
+
end
|
| 84 |
+
|
| 85 |
+
endfunction
|
| 86 |
+
|
| 87 |
+
initial begin
|
| 88 |
+
if (sum_lutc_input == "datac") lut_type = 0;
|
| 89 |
+
else
|
| 90 |
+
if (sum_lutc_input == "cin") lut_type = 1;
|
| 91 |
+
else begin
|
| 92 |
+
$error("Error in sum_lutc_input. Parameter %s is not a valid value.\n", sum_lutc_input);
|
| 93 |
+
$finish();
|
| 94 |
+
end
|
| 95 |
+
end
|
| 96 |
+
|
| 97 |
+
always @(dataa_w or datab_w or datac_w or datad_w or cin_w) begin
|
| 98 |
+
if (lut_type == 0) begin // logic function
|
| 99 |
+
combout_rt = lut_data(lut_mask, dataa_w, datab_w,
|
| 100 |
+
datac_w, datad_w);
|
| 101 |
+
end
|
| 102 |
+
else if (lut_type == 1) begin // arithmetic function
|
| 103 |
+
combout_rt = lut_data(lut_mask, dataa_w, datab_w,
|
| 104 |
+
cin_w, datad_w);
|
| 105 |
+
end
|
| 106 |
+
cout_rt = lut_data(lut_mask, dataa_w, datab_w, cin_w, 'b0);
|
| 107 |
+
end
|
| 108 |
+
|
| 109 |
+
assign combout = combout_rt & 1'b1;
|
| 110 |
+
assign cout = cout_rt & 1'b1;
|
| 111 |
+
|
| 112 |
+
endmodule // cycloneive_lcell_comb
|
| 113 |
+
|
| 114 |
+
/* Altera D Flip-Flop Primitive */
|
| 115 |
+
module dffeas
|
| 116 |
+
(output q,
|
| 117 |
+
input d, clk, clrn, prn, ena,
|
| 118 |
+
input asdata, aload, sclr, sload);
|
| 119 |
+
|
| 120 |
+
// Timing simulation is not covered
|
| 121 |
+
parameter power_up="dontcare";
|
| 122 |
+
parameter is_wysiwyg="false";
|
| 123 |
+
|
| 124 |
+
reg q_tmp;
|
| 125 |
+
wire reset;
|
| 126 |
+
reg [7:0] debug_net;
|
| 127 |
+
|
| 128 |
+
assign reset = (prn && sclr && ~clrn && ena);
|
| 129 |
+
assign q = q_tmp & 1'b1;
|
| 130 |
+
|
| 131 |
+
always @(posedge clk, posedge aload) begin
|
| 132 |
+
if(reset) q_tmp <= 0;
|
| 133 |
+
else q_tmp <= d;
|
| 134 |
+
end
|
| 135 |
+
assign q = q_tmp;
|
| 136 |
+
|
| 137 |
+
endmodule // dffeas
|
| 138 |
+
|
| 139 |
+
/* Cyclone IV E altpll clearbox model */
|
| 140 |
+
(* blackbox *)
|
| 141 |
+
module cycloneive_pll
|
| 142 |
+
(inclk,
|
| 143 |
+
fbin,
|
| 144 |
+
fbout,
|
| 145 |
+
clkswitch,
|
| 146 |
+
areset,
|
| 147 |
+
pfdena,
|
| 148 |
+
scanclk,
|
| 149 |
+
scandata,
|
| 150 |
+
scanclkena,
|
| 151 |
+
configupdate,
|
| 152 |
+
clk,
|
| 153 |
+
phasecounterselect,
|
| 154 |
+
phaseupdown,
|
| 155 |
+
phasestep,
|
| 156 |
+
clkbad,
|
| 157 |
+
activeclock,
|
| 158 |
+
locked,
|
| 159 |
+
scandataout,
|
| 160 |
+
scandone,
|
| 161 |
+
phasedone,
|
| 162 |
+
vcooverrange,
|
| 163 |
+
vcounderrange);
|
| 164 |
+
|
| 165 |
+
parameter operation_mode = "normal";
|
| 166 |
+
parameter pll_type = "auto";
|
| 167 |
+
parameter compensate_clock = "clock0";
|
| 168 |
+
parameter inclk0_input_frequency = 0;
|
| 169 |
+
parameter inclk1_input_frequency = 0;
|
| 170 |
+
parameter self_reset_on_loss_lock = "off";
|
| 171 |
+
parameter switch_over_type = "auto";
|
| 172 |
+
parameter switch_over_counter = 1;
|
| 173 |
+
parameter enable_switch_over_counter = "off";
|
| 174 |
+
parameter bandwidth = 0;
|
| 175 |
+
parameter bandwidth_type = "auto";
|
| 176 |
+
parameter use_dc_coupling = "false";
|
| 177 |
+
parameter lock_high = 0;
|
| 178 |
+
parameter lock_low = 0;
|
| 179 |
+
parameter lock_window_ui = "0.05";
|
| 180 |
+
parameter test_bypass_lock_detect = "off";
|
| 181 |
+
parameter clk0_output_frequency = 0;
|
| 182 |
+
parameter clk0_multiply_by = 0;
|
| 183 |
+
parameter clk0_divide_by = 0;
|
| 184 |
+
parameter clk0_phase_shift = "0";
|
| 185 |
+
parameter clk0_duty_cycle = 50;
|
| 186 |
+
parameter clk1_output_frequency = 0;
|
| 187 |
+
parameter clk1_multiply_by = 0;
|
| 188 |
+
parameter clk1_divide_by = 0;
|
| 189 |
+
parameter clk1_phase_shift = "0";
|
| 190 |
+
parameter clk1_duty_cycle = 50;
|
| 191 |
+
parameter clk2_output_frequency = 0;
|
| 192 |
+
parameter clk2_multiply_by = 0;
|
| 193 |
+
parameter clk2_divide_by = 0;
|
| 194 |
+
parameter clk2_phase_shift = "0";
|
| 195 |
+
parameter clk2_duty_cycle = 50;
|
| 196 |
+
parameter clk3_output_frequency = 0;
|
| 197 |
+
parameter clk3_multiply_by = 0;
|
| 198 |
+
parameter clk3_divide_by = 0;
|
| 199 |
+
parameter clk3_phase_shift = "0";
|
| 200 |
+
parameter clk3_duty_cycle = 50;
|
| 201 |
+
parameter clk4_output_frequency = 0;
|
| 202 |
+
parameter clk4_multiply_by = 0;
|
| 203 |
+
parameter clk4_divide_by = 0;
|
| 204 |
+
parameter clk4_phase_shift = "0";
|
| 205 |
+
parameter clk4_duty_cycle = 50;
|
| 206 |
+
parameter pfd_min = 0;
|
| 207 |
+
parameter pfd_max = 0;
|
| 208 |
+
parameter vco_min = 0;
|
| 209 |
+
parameter vco_max = 0;
|
| 210 |
+
parameter vco_center = 0;
|
| 211 |
+
// Advanced user parameters
|
| 212 |
+
parameter m_initial = 1;
|
| 213 |
+
parameter m = 0;
|
| 214 |
+
parameter n = 1;
|
| 215 |
+
parameter c0_high = 1;
|
| 216 |
+
parameter c0_low = 1;
|
| 217 |
+
parameter c0_initial = 1;
|
| 218 |
+
parameter c0_mode = "bypass";
|
| 219 |
+
parameter c0_ph = 0;
|
| 220 |
+
parameter c1_high = 1;
|
| 221 |
+
parameter c1_low = 1;
|
| 222 |
+
parameter c1_initial = 1;
|
| 223 |
+
parameter c1_mode = "bypass";
|
| 224 |
+
parameter c1_ph = 0;
|
| 225 |
+
parameter c2_high = 1;
|
| 226 |
+
parameter c2_low = 1;
|
| 227 |
+
parameter c2_initial = 1;
|
| 228 |
+
parameter c2_mode = "bypass";
|
| 229 |
+
parameter c2_ph = 0;
|
| 230 |
+
parameter c3_high = 1;
|
| 231 |
+
parameter c3_low = 1;
|
| 232 |
+
parameter c3_initial = 1;
|
| 233 |
+
parameter c3_mode = "bypass";
|
| 234 |
+
parameter c3_ph = 0;
|
| 235 |
+
parameter c4_high = 1;
|
| 236 |
+
parameter c4_low = 1;
|
| 237 |
+
parameter c4_initial = 1;
|
| 238 |
+
parameter c4_mode = "bypass";
|
| 239 |
+
parameter c4_ph = 0;
|
| 240 |
+
parameter m_ph = 0;
|
| 241 |
+
parameter clk0_counter = "unused";
|
| 242 |
+
parameter clk1_counter = "unused";
|
| 243 |
+
parameter clk2_counter = "unused";
|
| 244 |
+
parameter clk3_counter = "unused";
|
| 245 |
+
parameter clk4_counter = "unused";
|
| 246 |
+
parameter c1_use_casc_in = "off";
|
| 247 |
+
parameter c2_use_casc_in = "off";
|
| 248 |
+
parameter c3_use_casc_in = "off";
|
| 249 |
+
parameter c4_use_casc_in = "off";
|
| 250 |
+
parameter m_test_source = -1;
|
| 251 |
+
parameter c0_test_source = -1;
|
| 252 |
+
parameter c1_test_source = -1;
|
| 253 |
+
parameter c2_test_source = -1;
|
| 254 |
+
parameter c3_test_source = -1;
|
| 255 |
+
parameter c4_test_source = -1;
|
| 256 |
+
parameter vco_multiply_by = 0;
|
| 257 |
+
parameter vco_divide_by = 0;
|
| 258 |
+
parameter vco_post_scale = 1;
|
| 259 |
+
parameter vco_frequency_control = "auto";
|
| 260 |
+
parameter vco_phase_shift_step = 0;
|
| 261 |
+
parameter charge_pump_current = 10;
|
| 262 |
+
parameter loop_filter_r = "1.0";
|
| 263 |
+
parameter loop_filter_c = 0;
|
| 264 |
+
parameter pll_compensation_delay = 0;
|
| 265 |
+
parameter lpm_type = "cycloneive_pll";
|
| 266 |
+
parameter phase_counter_select_width = 3;
|
| 267 |
+
|
| 268 |
+
input [1:0] inclk;
|
| 269 |
+
input fbin;
|
| 270 |
+
input clkswitch;
|
| 271 |
+
input areset;
|
| 272 |
+
input pfdena;
|
| 273 |
+
input [phase_counter_select_width - 1:0] phasecounterselect;
|
| 274 |
+
input phaseupdown;
|
| 275 |
+
input phasestep;
|
| 276 |
+
input scanclk;
|
| 277 |
+
input scanclkena;
|
| 278 |
+
input scandata;
|
| 279 |
+
input configupdate;
|
| 280 |
+
|
| 281 |
+
output [4:0] clk;
|
| 282 |
+
output [1:0] clkbad;
|
| 283 |
+
output activeclock;
|
| 284 |
+
output locked;
|
| 285 |
+
output scandataout;
|
| 286 |
+
output scandone;
|
| 287 |
+
output fbout;
|
| 288 |
+
output phasedone;
|
| 289 |
+
output vcooverrange;
|
| 290 |
+
output vcounderrange;
|
| 291 |
+
|
| 292 |
+
endmodule // cycloneive_pll
|
chips/yosys/techlibs/intel/max10/cells_arith.v
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* yosys -- Yosys Open SYnthesis Suite
|
| 3 |
+
*
|
| 4 |
+
* Copyright (C) 2012 Claire Xenia Wolf <claire@yosyshq.com>
|
| 5 |
+
*
|
| 6 |
+
* Permission to use, copy, modify, and/or distribute this software for any
|
| 7 |
+
* purpose with or without fee is hereby granted, provided that the above
|
| 8 |
+
* copyright notice and this permission notice appear in all copies.
|
| 9 |
+
*
|
| 10 |
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
| 11 |
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
| 12 |
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
| 13 |
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 14 |
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 15 |
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
| 16 |
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
| 17 |
+
*
|
| 18 |
+
*/
|
| 19 |
+
|
| 20 |
+
// NOTE: This is still WIP.
|
| 21 |
+
(* techmap_celltype = "$alu" *)
|
| 22 |
+
module _80_altera_max10_alu (A, B, CI, BI, X, Y, CO);
|
| 23 |
+
parameter A_SIGNED = 0;
|
| 24 |
+
parameter B_SIGNED = 0;
|
| 25 |
+
parameter A_WIDTH = 1;
|
| 26 |
+
parameter B_WIDTH = 1;
|
| 27 |
+
parameter Y_WIDTH = 1;
|
| 28 |
+
|
| 29 |
+
(* force_downto *)
|
| 30 |
+
input [A_WIDTH-1:0] A;
|
| 31 |
+
(* force_downto *)
|
| 32 |
+
input [B_WIDTH-1:0] B;
|
| 33 |
+
(* force_downto *)
|
| 34 |
+
output [Y_WIDTH-1:0] X, Y;
|
| 35 |
+
|
| 36 |
+
input CI, BI;
|
| 37 |
+
//output [Y_WIDTH-1:0] CO;
|
| 38 |
+
output CO;
|
| 39 |
+
|
| 40 |
+
wire _TECHMAP_FAIL_ = Y_WIDTH <= 4;
|
| 41 |
+
|
| 42 |
+
(* force_downto *)
|
| 43 |
+
wire [Y_WIDTH-1:0] A_buf, B_buf;
|
| 44 |
+
\$pos #(.A_SIGNED(A_SIGNED), .A_WIDTH(A_WIDTH), .Y_WIDTH(Y_WIDTH)) A_conv (.A(A), .Y(A_buf));
|
| 45 |
+
\$pos #(.A_SIGNED(B_SIGNED), .A_WIDTH(B_WIDTH), .Y_WIDTH(Y_WIDTH)) B_conv (.A(B), .Y(B_buf));
|
| 46 |
+
|
| 47 |
+
(* force_downto *)
|
| 48 |
+
wire [Y_WIDTH-1:0] AA = A_buf;
|
| 49 |
+
(* force_downto *)
|
| 50 |
+
wire [Y_WIDTH-1:0] BB = BI ? ~B_buf : B_buf;
|
| 51 |
+
//wire [Y_WIDTH:0] C = {CO, CI};
|
| 52 |
+
wire [Y_WIDTH+1:0] COx;
|
| 53 |
+
wire [Y_WIDTH+1:0] C = {COx, CI};
|
| 54 |
+
|
| 55 |
+
/* Start implementation */
|
| 56 |
+
(* keep *) fiftyfivenm_lcell_comb #(.lut_mask(16'b0000_0000_1010_1010), .sum_lutc_input("cin")) carry_start (.cout(COx[0]), .dataa(C[0]), .datab(1'b1), .datac(1'b1), .datad(1'b1));
|
| 57 |
+
|
| 58 |
+
genvar i;
|
| 59 |
+
generate for (i = 0; i < Y_WIDTH; i = i + 1) begin: slice
|
| 60 |
+
if(i==Y_WIDTH-1) begin
|
| 61 |
+
(* keep *) fiftyfivenm_lcell_comb #(.lut_mask(16'b1111_0000_1110_0000), .sum_lutc_input("cin")) carry_end (.combout(COx[Y_WIDTH]), .dataa(1'b1), .datab(1'b1), .datac(1'b1), .datad(1'b1), .cin(C[Y_WIDTH]));
|
| 62 |
+
assign CO = COx[Y_WIDTH];
|
| 63 |
+
end
|
| 64 |
+
else
|
| 65 |
+
fiftyfivenm_lcell_comb #(.lut_mask(16'b1001_0110_1110_1000), .sum_lutc_input("cin")) arith_cell (.combout(Y[i]), .cout(COx[i+1]), .dataa(AA[i]), .datab(BB[i]), .datac(1'b1), .datad(1'b1), .cin(C[i+1]));
|
| 66 |
+
end: slice
|
| 67 |
+
endgenerate
|
| 68 |
+
/* End implementation */
|
| 69 |
+
assign X = AA ^ BB;
|
| 70 |
+
|
| 71 |
+
endmodule
|
chips/yosys/techlibs/intel/max10/cells_map.v
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* yosys -- Yosys Open SYnthesis Suite
|
| 3 |
+
*
|
| 4 |
+
* Copyright (C) 2012 Claire Xenia Wolf <claire@yosyshq.com>
|
| 5 |
+
*
|
| 6 |
+
* Permission to use, copy, modify, and/or distribute this software for any
|
| 7 |
+
* purpose with or without fee is hereby granted, provided that the above
|
| 8 |
+
* copyright notice and this permission notice appear in all copies.
|
| 9 |
+
*
|
| 10 |
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
| 11 |
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
| 12 |
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
| 13 |
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 14 |
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 15 |
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
| 16 |
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
| 17 |
+
*
|
| 18 |
+
*/
|
| 19 |
+
// > c60k28 (Viacheslav, VT) [at] yandex [dot] com
|
| 20 |
+
// > Intel FPGA technology mapping. User must first simulate the generated \
|
| 21 |
+
// > netlist before going to test it on board.
|
| 22 |
+
|
| 23 |
+
// Input buffer map
|
| 24 |
+
module \$__inpad (input I, output O);
|
| 25 |
+
fiftyfivenm_io_ibuf _TECHMAP_REPLACE_ (.o(O), .i(I), .ibar(1'b0));
|
| 26 |
+
endmodule
|
| 27 |
+
|
| 28 |
+
// Output buffer map
|
| 29 |
+
module \$__outpad (input I, output O);
|
| 30 |
+
fiftyfivenm_io_obuf _TECHMAP_REPLACE_ (.o(O), .i(I), .oe(1'b1));
|
| 31 |
+
endmodule
|
| 32 |
+
|
| 33 |
+
// LUT Map
|
| 34 |
+
/* 0 -> datac
|
| 35 |
+
1 -> cin */
|
| 36 |
+
module \$lut (A, Y);
|
| 37 |
+
parameter WIDTH = 0;
|
| 38 |
+
parameter LUT = 0;
|
| 39 |
+
(* force_downto *)
|
| 40 |
+
input [WIDTH-1:0] A;
|
| 41 |
+
output Y;
|
| 42 |
+
generate
|
| 43 |
+
if (WIDTH == 1) begin
|
| 44 |
+
assign Y = ~A[0]; // Not need to spend 1 logic cell for such an easy function
|
| 45 |
+
end else
|
| 46 |
+
if (WIDTH == 2) begin
|
| 47 |
+
fiftyfivenm_lcell_comb #(.lut_mask({4{LUT}}), .sum_lutc_input("datac")) _TECHMAP_REPLACE_ (.combout(Y), .dataa(A[0]), .datab(A[1]), .datac(1'b1),.datad(1'b1));
|
| 48 |
+
end else
|
| 49 |
+
if(WIDTH == 3) begin
|
| 50 |
+
fiftyfivenm_lcell_comb #(.lut_mask({2{LUT}}), .sum_lutc_input("datac")) _TECHMAP_REPLACE_ (.combout(Y), .dataa(A[0]), .datab(A[1]), .datac(A[2]),.datad(1'b1));
|
| 51 |
+
end else
|
| 52 |
+
if(WIDTH == 4) begin
|
| 53 |
+
fiftyfivenm_lcell_comb #(.lut_mask(LUT), .sum_lutc_input("datac")) _TECHMAP_REPLACE_ (.combout(Y), .dataa(A[0]), .datab(A[1]), .datac(A[2]),.datad(A[3]));
|
| 54 |
+
end else
|
| 55 |
+
wire _TECHMAP_FAIL_ = 1;
|
| 56 |
+
endgenerate
|
| 57 |
+
endmodule //
|
chips/yosys/techlibs/intel/max10/cells_sim.v
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* yosys -- Yosys Open SYnthesis Suite
|
| 3 |
+
*
|
| 4 |
+
* Copyright (C) 2012 Claire Xenia Wolf <claire@yosyshq.com>
|
| 5 |
+
* Copyright (C) 2024 Richard Herveille <richard.herveille@roalogic.com>
|
| 6 |
+
*
|
| 7 |
+
* Permission to use, copy, modify, and/or distribute this software for any
|
| 8 |
+
* purpose with or without fee is hereby granted, provided that the above
|
| 9 |
+
* copyright notice and this permission notice appear in all copies.
|
| 10 |
+
*
|
| 11 |
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
| 12 |
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
| 13 |
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
| 14 |
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 15 |
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 16 |
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
| 17 |
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
| 18 |
+
*
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
module VCC (output V);
|
| 22 |
+
assign V = 1'b1;
|
| 23 |
+
endmodule // VCC
|
| 24 |
+
|
| 25 |
+
module GND (output G);
|
| 26 |
+
assign G = 1'b0;
|
| 27 |
+
endmodule // GND
|
| 28 |
+
|
| 29 |
+
/* Altera MAX10 devices Input Buffer Primitive */
|
| 30 |
+
module fiftyfivenm_io_ibuf
|
| 31 |
+
(output o, input i, input ibar);
|
| 32 |
+
assign ibar = ibar;
|
| 33 |
+
assign o = i;
|
| 34 |
+
endmodule // fiftyfivenm_io_ibuf
|
| 35 |
+
|
| 36 |
+
/* Altera MAX10 devices Output Buffer Primitive */
|
| 37 |
+
module fiftyfivenm_io_obuf
|
| 38 |
+
(output o, input i, input oe);
|
| 39 |
+
assign o = i;
|
| 40 |
+
assign oe = oe;
|
| 41 |
+
endmodule // fiftyfivenm_io_obuf
|
| 42 |
+
|
| 43 |
+
/* Altera MAX10 4-input non-fracturable LUT Primitive */
|
| 44 |
+
module fiftyfivenm_lcell_comb
|
| 45 |
+
(output combout, cout,
|
| 46 |
+
input dataa, datab, datac, datad, cin);
|
| 47 |
+
|
| 48 |
+
/* Internal parameters which define the behaviour
|
| 49 |
+
of the LUT primitive.
|
| 50 |
+
lut_mask define the lut function, can be expressed in 16-digit bin or hex.
|
| 51 |
+
sum_lutc_input define the type of LUT (combinational | arithmetic).
|
| 52 |
+
dont_touch for retiming || carry options.
|
| 53 |
+
lpm_type for WYSIWYG */
|
| 54 |
+
|
| 55 |
+
parameter lut_mask = 16'hFFFF;
|
| 56 |
+
parameter dont_touch = "off";
|
| 57 |
+
parameter lpm_type = "fiftyfivenm_lcell_comb";
|
| 58 |
+
parameter sum_lutc_input = "datac";
|
| 59 |
+
|
| 60 |
+
reg [1:0] lut_type;
|
| 61 |
+
reg cout_rt;
|
| 62 |
+
reg combout_rt;
|
| 63 |
+
wire dataa_w;
|
| 64 |
+
wire datab_w;
|
| 65 |
+
wire datac_w;
|
| 66 |
+
wire datad_w;
|
| 67 |
+
wire cin_w;
|
| 68 |
+
|
| 69 |
+
assign dataa_w = dataa;
|
| 70 |
+
assign datab_w = datab;
|
| 71 |
+
assign datac_w = datac;
|
| 72 |
+
assign datad_w = datad;
|
| 73 |
+
|
| 74 |
+
function lut_data;
|
| 75 |
+
input [15:0] mask;
|
| 76 |
+
input dataa, datab, datac, datad;
|
| 77 |
+
reg [7:0] s3;
|
| 78 |
+
reg [3:0] s2;
|
| 79 |
+
reg [1:0] s1;
|
| 80 |
+
begin
|
| 81 |
+
s3 = datad ? mask[15:8] : mask[7:0];
|
| 82 |
+
s2 = datac ? s3[7:4] : s3[3:0];
|
| 83 |
+
s1 = datab ? s2[3:2] : s2[1:0];
|
| 84 |
+
lut_data = dataa ? s1[1] : s1[0];
|
| 85 |
+
end
|
| 86 |
+
|
| 87 |
+
endfunction
|
| 88 |
+
|
| 89 |
+
initial begin
|
| 90 |
+
if (sum_lutc_input == "datac") lut_type = 0;
|
| 91 |
+
else
|
| 92 |
+
if (sum_lutc_input == "cin") lut_type = 1;
|
| 93 |
+
else begin
|
| 94 |
+
$error("Error in sum_lutc_input. Parameter %s is not a valid value.\n", sum_lutc_input);
|
| 95 |
+
$finish();
|
| 96 |
+
end
|
| 97 |
+
end
|
| 98 |
+
|
| 99 |
+
always @(dataa_w or datab_w or datac_w or datad_w or cin_w) begin
|
| 100 |
+
if (lut_type == 0) begin // logic function
|
| 101 |
+
combout_rt = lut_data(lut_mask, dataa_w, datab_w,
|
| 102 |
+
datac_w, datad_w);
|
| 103 |
+
end
|
| 104 |
+
else if (lut_type == 1) begin // arithmetic function
|
| 105 |
+
combout_rt = lut_data(lut_mask, dataa_w, datab_w,
|
| 106 |
+
cin_w, datad_w);
|
| 107 |
+
end
|
| 108 |
+
cout_rt = lut_data(lut_mask, dataa_w, datab_w, cin_w, 'b0);
|
| 109 |
+
end
|
| 110 |
+
|
| 111 |
+
assign combout = combout_rt & 1'b1;
|
| 112 |
+
assign cout = cout_rt & 1'b1;
|
| 113 |
+
|
| 114 |
+
endmodule // fiftyfivenm_lcell_comb
|
| 115 |
+
|
| 116 |
+
/* Altera D Flip-Flop Primitive */
|
| 117 |
+
module dffeas
|
| 118 |
+
(output q,
|
| 119 |
+
input d, clk, clrn, prn, ena,
|
| 120 |
+
input asdata, aload, sclr, sload);
|
| 121 |
+
|
| 122 |
+
// Timing simulation is not covered
|
| 123 |
+
parameter power_up="dontcare";
|
| 124 |
+
parameter is_wysiwyg="false";
|
| 125 |
+
|
| 126 |
+
reg q_tmp;
|
| 127 |
+
wire reset;
|
| 128 |
+
reg [7:0] debug_net;
|
| 129 |
+
|
| 130 |
+
assign reset = (prn && sclr && ~clrn && ena);
|
| 131 |
+
assign q = q_tmp & 1'b1;
|
| 132 |
+
|
| 133 |
+
always @(posedge clk, posedge aload) begin
|
| 134 |
+
if(reset) q_tmp <= 0;
|
| 135 |
+
else q_tmp <= d;
|
| 136 |
+
end
|
| 137 |
+
assign q = q_tmp;
|
| 138 |
+
|
| 139 |
+
endmodule // dffeas
|
| 140 |
+
|
| 141 |
+
/* MAX10 altpll clearbox model */
|
| 142 |
+
(* blackbox *)
|
| 143 |
+
module fiftyfivenm_pll
|
| 144 |
+
(inclk,
|
| 145 |
+
fbin,
|
| 146 |
+
fbout,
|
| 147 |
+
clkswitch,
|
| 148 |
+
areset,
|
| 149 |
+
pfdena,
|
| 150 |
+
scanclk,
|
| 151 |
+
scandata,
|
| 152 |
+
scanclkena,
|
| 153 |
+
configupdate,
|
| 154 |
+
clk,
|
| 155 |
+
phasecounterselect,
|
| 156 |
+
phaseupdown,
|
| 157 |
+
phasestep,
|
| 158 |
+
clkbad,
|
| 159 |
+
activeclock,
|
| 160 |
+
locked,
|
| 161 |
+
scandataout,
|
| 162 |
+
scandone,
|
| 163 |
+
phasedone,
|
| 164 |
+
vcooverrange,
|
| 165 |
+
vcounderrange);
|
| 166 |
+
|
| 167 |
+
parameter operation_mode = "normal";
|
| 168 |
+
parameter pll_type = "auto";
|
| 169 |
+
parameter compensate_clock = "clock0";
|
| 170 |
+
parameter inclk0_input_frequency = 0;
|
| 171 |
+
parameter inclk1_input_frequency = 0;
|
| 172 |
+
parameter self_reset_on_loss_lock = "off";
|
| 173 |
+
parameter switch_over_type = "auto";
|
| 174 |
+
parameter switch_over_counter = 1;
|
| 175 |
+
parameter enable_switch_over_counter = "off";
|
| 176 |
+
parameter bandwidth = 0;
|
| 177 |
+
parameter bandwidth_type = "auto";
|
| 178 |
+
parameter use_dc_coupling = "false";
|
| 179 |
+
parameter lock_high = 0;
|
| 180 |
+
parameter lock_low = 0;
|
| 181 |
+
parameter lock_window_ui = "0.05";
|
| 182 |
+
parameter test_bypass_lock_detect = "off";
|
| 183 |
+
parameter clk0_output_frequency = 0;
|
| 184 |
+
parameter clk0_multiply_by = 0;
|
| 185 |
+
parameter clk0_divide_by = 0;
|
| 186 |
+
parameter clk0_phase_shift = "0";
|
| 187 |
+
parameter clk0_duty_cycle = 50;
|
| 188 |
+
parameter clk1_output_frequency = 0;
|
| 189 |
+
parameter clk1_multiply_by = 0;
|
| 190 |
+
parameter clk1_divide_by = 0;
|
| 191 |
+
parameter clk1_phase_shift = "0";
|
| 192 |
+
parameter clk1_duty_cycle = 50;
|
| 193 |
+
parameter clk2_output_frequency = 0;
|
| 194 |
+
parameter clk2_multiply_by = 0;
|
| 195 |
+
parameter clk2_divide_by = 0;
|
| 196 |
+
parameter clk2_phase_shift = "0";
|
| 197 |
+
parameter clk2_duty_cycle = 50;
|
| 198 |
+
parameter clk3_output_frequency = 0;
|
| 199 |
+
parameter clk3_multiply_by = 0;
|
| 200 |
+
parameter clk3_divide_by = 0;
|
| 201 |
+
parameter clk3_phase_shift = "0";
|
| 202 |
+
parameter clk3_duty_cycle = 50;
|
| 203 |
+
parameter clk4_output_frequency = 0;
|
| 204 |
+
parameter clk4_multiply_by = 0;
|
| 205 |
+
parameter clk4_divide_by = 0;
|
| 206 |
+
parameter clk4_phase_shift = "0";
|
| 207 |
+
parameter clk4_duty_cycle = 50;
|
| 208 |
+
parameter pfd_min = 0;
|
| 209 |
+
parameter pfd_max = 0;
|
| 210 |
+
parameter vco_min = 0;
|
| 211 |
+
parameter vco_max = 0;
|
| 212 |
+
parameter vco_center = 0;
|
| 213 |
+
// Advanced user parameters
|
| 214 |
+
parameter m_initial = 1;
|
| 215 |
+
parameter m = 0;
|
| 216 |
+
parameter n = 1;
|
| 217 |
+
parameter c0_high = 1;
|
| 218 |
+
parameter c0_low = 1;
|
| 219 |
+
parameter c0_initial = 1;
|
| 220 |
+
parameter c0_mode = "bypass";
|
| 221 |
+
parameter c0_ph = 0;
|
| 222 |
+
parameter c1_high = 1;
|
| 223 |
+
parameter c1_low = 1;
|
| 224 |
+
parameter c1_initial = 1;
|
| 225 |
+
parameter c1_mode = "bypass";
|
| 226 |
+
parameter c1_ph = 0;
|
| 227 |
+
parameter c2_high = 1;
|
| 228 |
+
parameter c2_low = 1;
|
| 229 |
+
parameter c2_initial = 1;
|
| 230 |
+
parameter c2_mode = "bypass";
|
| 231 |
+
parameter c2_ph = 0;
|
| 232 |
+
parameter c3_high = 1;
|
| 233 |
+
parameter c3_low = 1;
|
| 234 |
+
parameter c3_initial = 1;
|
| 235 |
+
parameter c3_mode = "bypass";
|
| 236 |
+
parameter c3_ph = 0;
|
| 237 |
+
parameter c4_high = 1;
|
| 238 |
+
parameter c4_low = 1;
|
| 239 |
+
parameter c4_initial = 1;
|
| 240 |
+
parameter c4_mode = "bypass";
|
| 241 |
+
parameter c4_ph = 0;
|
| 242 |
+
parameter m_ph = 0;
|
| 243 |
+
parameter clk0_counter = "unused";
|
| 244 |
+
parameter clk1_counter = "unused";
|
| 245 |
+
parameter clk2_counter = "unused";
|
| 246 |
+
parameter clk3_counter = "unused";
|
| 247 |
+
parameter clk4_counter = "unused";
|
| 248 |
+
parameter c1_use_casc_in = "off";
|
| 249 |
+
parameter c2_use_casc_in = "off";
|
| 250 |
+
parameter c3_use_casc_in = "off";
|
| 251 |
+
parameter c4_use_casc_in = "off";
|
| 252 |
+
parameter m_test_source = -1;
|
| 253 |
+
parameter c0_test_source = -1;
|
| 254 |
+
parameter c1_test_source = -1;
|
| 255 |
+
parameter c2_test_source = -1;
|
| 256 |
+
parameter c3_test_source = -1;
|
| 257 |
+
parameter c4_test_source = -1;
|
| 258 |
+
parameter vco_multiply_by = 0;
|
| 259 |
+
parameter vco_divide_by = 0;
|
| 260 |
+
parameter vco_post_scale = 1;
|
| 261 |
+
parameter vco_frequency_control = "auto";
|
| 262 |
+
parameter vco_phase_shift_step = 0;
|
| 263 |
+
parameter charge_pump_current = 10;
|
| 264 |
+
parameter loop_filter_r = "1.0";
|
| 265 |
+
parameter loop_filter_c = 0;
|
| 266 |
+
parameter pll_compensation_delay = 0;
|
| 267 |
+
parameter lpm_type = "fiftyfivenm_pll";
|
| 268 |
+
parameter phase_counter_select_width = 3;
|
| 269 |
+
|
| 270 |
+
input [1:0] inclk;
|
| 271 |
+
input fbin;
|
| 272 |
+
input clkswitch;
|
| 273 |
+
input areset;
|
| 274 |
+
input pfdena;
|
| 275 |
+
input [phase_counter_select_width - 1:0] phasecounterselect;
|
| 276 |
+
input phaseupdown;
|
| 277 |
+
input phasestep;
|
| 278 |
+
input scanclk;
|
| 279 |
+
input scanclkena;
|
| 280 |
+
input scandata;
|
| 281 |
+
input configupdate;
|
| 282 |
+
output [4:0] clk;
|
| 283 |
+
output [1:0] clkbad;
|
| 284 |
+
output activeclock;
|
| 285 |
+
output locked;
|
| 286 |
+
output scandataout;
|
| 287 |
+
output scandone;
|
| 288 |
+
output fbout;
|
| 289 |
+
output phasedone;
|
| 290 |
+
output vcooverrange;
|
| 291 |
+
output vcounderrange;
|
| 292 |
+
|
| 293 |
+
endmodule // max10_pll
|
| 294 |
+
|
| 295 |
+
|
| 296 |
+
/* MAX10 MULT clearbox model */
|
| 297 |
+
(* blackbox *)
|
| 298 |
+
module fiftyfivenm_mac_mult (
|
| 299 |
+
dataa,
|
| 300 |
+
datab,
|
| 301 |
+
dataout,
|
| 302 |
+
signa,
|
| 303 |
+
signb,
|
| 304 |
+
|
| 305 |
+
aclr,
|
| 306 |
+
clk,
|
| 307 |
+
ena
|
| 308 |
+
);
|
| 309 |
+
parameter dataa_clock = "none";
|
| 310 |
+
parameter dataa_width = 18;
|
| 311 |
+
parameter datab_clock = "none";
|
| 312 |
+
parameter datab_width = 18;
|
| 313 |
+
parameter signa_clock = "none";
|
| 314 |
+
parameter signb_clock = "none";
|
| 315 |
+
parameter lpm_type = "fiftyfivenm_mac_mult";
|
| 316 |
+
|
| 317 |
+
input [dataa_width -1:0] dataa;
|
| 318 |
+
input [datab_width -1:0] datab;
|
| 319 |
+
output [(dataa_width+datab_width)-1:0] dataout;
|
| 320 |
+
input signa;
|
| 321 |
+
input signb;
|
| 322 |
+
input aclr;
|
| 323 |
+
input clk;
|
| 324 |
+
input ena;
|
| 325 |
+
endmodule //fiftyfivenm_mac_mult
|
| 326 |
+
|
| 327 |
+
module fiftyfivenm_mac_out (
|
| 328 |
+
dataa,
|
| 329 |
+
dataout,
|
| 330 |
+
|
| 331 |
+
aclr,
|
| 332 |
+
clk,
|
| 333 |
+
ena
|
| 334 |
+
);
|
| 335 |
+
|
| 336 |
+
parameter dataa_width = 38;
|
| 337 |
+
parameter output_clock = "none";
|
| 338 |
+
parameter lpm_type = "fiftyfivenm_mac_out";
|
| 339 |
+
|
| 340 |
+
input [dataa_width-1:0] dataa;
|
| 341 |
+
output [dataa_width-1:0] dataout;
|
| 342 |
+
input aclr;
|
| 343 |
+
input clk;
|
| 344 |
+
input ena;
|
| 345 |
+
endmodule //fiftyfivenm_mac_out
|
chips/yosys/techlibs/intel/max10/dsp_map.v
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module \$__MUL18X18 (input [17:0] A, input [17:0] B, output [35:0] Y);
|
| 2 |
+
parameter A_SIGNED = 0;
|
| 3 |
+
parameter B_SIGNED = 0;
|
| 4 |
+
parameter A_WIDTH = 0;
|
| 5 |
+
parameter B_WIDTH = 0;
|
| 6 |
+
parameter Y_WIDTH = 0;
|
| 7 |
+
|
| 8 |
+
wire [A_WIDTH+B_WIDTH-1:0] mult_result;
|
| 9 |
+
|
| 10 |
+
fiftyfivenm_mac_mult #(
|
| 11 |
+
.dataa_clock ("none"),
|
| 12 |
+
.datab_clock ("none"),
|
| 13 |
+
.signa_clock ("none"),
|
| 14 |
+
.signb_clock ("none"),
|
| 15 |
+
.dataa_width (A_WIDTH),
|
| 16 |
+
.datab_width (B_WIDTH),
|
| 17 |
+
.lpm_type ("fiftyfivenm_mac_mult")
|
| 18 |
+
) _TECHMAP_REPLACE_mac_mult (
|
| 19 |
+
//Data path
|
| 20 |
+
.dataa ( A ),
|
| 21 |
+
.datab ( B ),
|
| 22 |
+
.dataout( mult_result ),
|
| 23 |
+
.signa ( A_SIGNED != 0 ? 1'b1 : 1'b0),
|
| 24 |
+
.signb ( B_SIGNED != 0 ? 1'b1 : 1'b0)
|
| 25 |
+
);
|
| 26 |
+
|
| 27 |
+
fiftyfivenm_mac_out #(
|
| 28 |
+
.dataa_width (A_WIDTH + B_WIDTH),
|
| 29 |
+
.output_clock ("none"),
|
| 30 |
+
.lpm_type ("fiftyfivenm_mac_out")
|
| 31 |
+
) _TECHMAP_REPLACE_mac_out (
|
| 32 |
+
.dataa (mult_result),
|
| 33 |
+
.dataout (Y)
|
| 34 |
+
);
|
| 35 |
+
endmodule
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
module \$__MUL9X9 (input [8:0] A, input [8:0] B, output [17:0] Y);
|
| 39 |
+
parameter A_SIGNED = 0;
|
| 40 |
+
parameter B_SIGNED = 0;
|
| 41 |
+
parameter A_WIDTH = 0;
|
| 42 |
+
parameter B_WIDTH = 0;
|
| 43 |
+
parameter Y_WIDTH = 0;
|
| 44 |
+
|
| 45 |
+
wire [A_WIDTH+B_WIDTH-1:0] mult_result;
|
| 46 |
+
|
| 47 |
+
fiftyfivenm_mac_mult #(
|
| 48 |
+
.dataa_clock ("none"),
|
| 49 |
+
.datab_clock ("none"),
|
| 50 |
+
.signa_clock ("none"),
|
| 51 |
+
.signb_clock ("none"),
|
| 52 |
+
.dataa_width (A_WIDTH),
|
| 53 |
+
.datab_width (B_WIDTH),
|
| 54 |
+
.lpm_type ("fiftyfivenm_mac_mult")
|
| 55 |
+
) _TECHMAP_REPLACE_mac_mult (
|
| 56 |
+
//Data path
|
| 57 |
+
.dataa ( A ),
|
| 58 |
+
.datab ( B ),
|
| 59 |
+
.dataout( mult_result ),
|
| 60 |
+
.signa ( A_SIGNED != 0 ? 1'b1 : 1'b0),
|
| 61 |
+
.signb ( B_SIGNED != 0 ? 1'b1 : 1'b0)
|
| 62 |
+
);
|
| 63 |
+
|
| 64 |
+
fiftyfivenm_mac_out #(
|
| 65 |
+
.dataa_width (A_WIDTH + B_WIDTH),
|
| 66 |
+
.output_clock ("none"),
|
| 67 |
+
.lpm_type ("fiftyfivenm_mac_out")
|
| 68 |
+
) _TECHMAP_REPLACE_mac_out (
|
| 69 |
+
.dataa (mult_result),
|
| 70 |
+
.dataout (Y)
|
| 71 |
+
);
|
| 72 |
+
endmodule
|
chips/yosys/techlibs/intel/synth_intel.cc
ADDED
|
@@ -0,0 +1,327 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* yosys -- Yosys Open SYnthesis Suite
|
| 3 |
+
*
|
| 4 |
+
* Copyright (C) 2012 Claire Xenia Wolf <claire@yosyshq.com>
|
| 5 |
+
* Copyright (C) 2024 Richard Herveille <richard.herveille@roalogic.com>
|
| 6 |
+
*
|
| 7 |
+
* Permission to use, copy, modify, and/or distribute this software for any
|
| 8 |
+
* purpose with or without fee is hereby granted, provided that the above
|
| 9 |
+
* copyright notice and this permission notice appear in all copies.
|
| 10 |
+
*
|
| 11 |
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
| 12 |
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
| 13 |
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
| 14 |
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 15 |
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 16 |
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
| 17 |
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
| 18 |
+
*
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#include "kernel/celltypes.h"
|
| 22 |
+
#include "kernel/log.h"
|
| 23 |
+
#include "kernel/register.h"
|
| 24 |
+
#include "kernel/rtlil.h"
|
| 25 |
+
|
| 26 |
+
USING_YOSYS_NAMESPACE
|
| 27 |
+
PRIVATE_NAMESPACE_BEGIN
|
| 28 |
+
|
| 29 |
+
struct SynthIntelPass : public ScriptPass {
|
| 30 |
+
SynthIntelPass() : ScriptPass("synth_intel", "synthesis for Intel (Altera) FPGAs.") { experimental(); }
|
| 31 |
+
|
| 32 |
+
void on_register() override
|
| 33 |
+
{
|
| 34 |
+
target_register.emplace("intel", Target{
|
| 35 |
+
"Intel (Altera)",
|
| 36 |
+
{
|
| 37 |
+
{"max10", {
|
| 38 |
+
"MAX 10",
|
| 39 |
+
{"+/intel/max10/cells_sim.v", "+/intel/common/m9k_bb.v", "+/intel/common/altpll_bb.v"}
|
| 40 |
+
}},
|
| 41 |
+
{"cycloneiv", {
|
| 42 |
+
"Cyclone IV",
|
| 43 |
+
{"+/intel/cycloneiv/cells_sim.v", "+/intel/common/m9k_bb.v", "+/intel/common/altpll_bb.v"}
|
| 44 |
+
}},
|
| 45 |
+
{"cycloneive", {
|
| 46 |
+
"Cyclone IVe",
|
| 47 |
+
{"+/intel/cycloneive/cells_sim.v", "+/intel/common/m9k_bb.v", "+/intel/common/altpll_bb.v"}
|
| 48 |
+
}},
|
| 49 |
+
{"cyclone10lp", {
|
| 50 |
+
"Cyclone 10LP",
|
| 51 |
+
{"+/intel/cyclone10lp/cells_sim.v", "+/intel/common/m9k_bb.v", "+/intel/common/altpll_bb.v"}
|
| 52 |
+
}}
|
| 53 |
+
}
|
| 54 |
+
});
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
void help() override
|
| 58 |
+
{
|
| 59 |
+
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
| 60 |
+
log("\n");
|
| 61 |
+
log(" synth_intel [options]\n");
|
| 62 |
+
log("\n");
|
| 63 |
+
log("This command runs synthesis for Intel FPGAs.\n");
|
| 64 |
+
log("\n");
|
| 65 |
+
log(" -family <max10 | cyclone10lp | cycloneiv | cycloneive>\n");
|
| 66 |
+
log(" generate the synthesis netlist for the specified family.\n");
|
| 67 |
+
log(" MAX10 is the default target if no family argument specified.\n");
|
| 68 |
+
log(" For Cyclone IV GX devices, use cycloneiv argument; for Cyclone IV E, use\n");
|
| 69 |
+
log(" cycloneive. For Cyclone V and Cyclone 10 GX, use the synth_intel_alm\n");
|
| 70 |
+
log(" backend instead.\n");
|
| 71 |
+
log("\n");
|
| 72 |
+
log(" -top <module>\n");
|
| 73 |
+
log(" use the specified module as top module (default='top')\n");
|
| 74 |
+
log("\n");
|
| 75 |
+
log(" -vqm <file>\n");
|
| 76 |
+
log(" write the design to the specified Verilog Quartus Mapping File. Writing\n");
|
| 77 |
+
log(" of an output file is omitted if this parameter is not specified.\n");
|
| 78 |
+
log(" Note that this backend has not been tested and is likely incompatible\n");
|
| 79 |
+
log(" with recent versions of Quartus.\n");
|
| 80 |
+
log("\n");
|
| 81 |
+
log(" -vpr <file>\n");
|
| 82 |
+
log(" write BLIF files for VPR flow experiments. The synthesized BLIF output\n");
|
| 83 |
+
log(" file is not compatible with the Quartus flow. Writing of an\n");
|
| 84 |
+
log(" output file is omitted if this parameter is not specified.\n");
|
| 85 |
+
log("\n");
|
| 86 |
+
log(" -run <from_label>:<to_label>\n");
|
| 87 |
+
log(" only run the commands between the labels (see below). an empty\n");
|
| 88 |
+
log(" from label is synonymous to 'begin', and empty to label is\n");
|
| 89 |
+
log(" synonymous to the end of the command list.\n");
|
| 90 |
+
log("\n");
|
| 91 |
+
log(" -dff\n");
|
| 92 |
+
log(" pass DFFs to ABC to perform sequential logic optimisations\n");
|
| 93 |
+
log(" (EXPERIMENTAL)\n");
|
| 94 |
+
log("\n");
|
| 95 |
+
log(" -iopads\n");
|
| 96 |
+
log(" use IO pad cells in output netlist\n");
|
| 97 |
+
log("\n");
|
| 98 |
+
log(" -nobram\n");
|
| 99 |
+
log(" do not use block RAM cells in output netlist\n");
|
| 100 |
+
log("\n");
|
| 101 |
+
log(" -nodsp\n");
|
| 102 |
+
log(" do not map multipliers to MUL18/MUL9 cells\n");
|
| 103 |
+
log("\n");
|
| 104 |
+
log(" -noflatten\n");
|
| 105 |
+
log(" do not flatten design before synthesis\n");
|
| 106 |
+
log("\n");
|
| 107 |
+
log("The following commands are executed by this synthesis command:\n");
|
| 108 |
+
help_script();
|
| 109 |
+
log("\n");
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
string top_opt, family_opt, vout_file, blif_file;
|
| 113 |
+
bool flatten, nobram, dff, nodsp, iopads;
|
| 114 |
+
|
| 115 |
+
void clear_flags() override
|
| 116 |
+
{
|
| 117 |
+
top_opt = "-auto-top";
|
| 118 |
+
family_opt = "max10";
|
| 119 |
+
vout_file = "";
|
| 120 |
+
blif_file = "";
|
| 121 |
+
flatten = true;
|
| 122 |
+
nobram = false;
|
| 123 |
+
dff = false;
|
| 124 |
+
nodsp = false;
|
| 125 |
+
iopads = false;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
void execute(std::vector<std::string> args, RTLIL::Design *design) override
|
| 129 |
+
{
|
| 130 |
+
string run_from, run_to;
|
| 131 |
+
clear_flags();
|
| 132 |
+
|
| 133 |
+
size_t argidx;
|
| 134 |
+
for (argidx = 1; argidx < args.size(); argidx++) {
|
| 135 |
+
if (args[argidx] == "-family" && argidx + 1 < args.size()) {
|
| 136 |
+
family_opt = args[++argidx];
|
| 137 |
+
continue;
|
| 138 |
+
}
|
| 139 |
+
if (args[argidx] == "-top" && argidx + 1 < args.size()) {
|
| 140 |
+
top_opt = "-top " + args[++argidx];
|
| 141 |
+
continue;
|
| 142 |
+
}
|
| 143 |
+
if (args[argidx] == "-vqm" && argidx + 1 < args.size()) {
|
| 144 |
+
vout_file = args[++argidx];
|
| 145 |
+
log_warning("The Quartus backend has not been tested recently and is likely incompatible with modern versions of Quartus.\n");
|
| 146 |
+
continue;
|
| 147 |
+
}
|
| 148 |
+
if (args[argidx] == "-vpr" && argidx + 1 < args.size()) {
|
| 149 |
+
blif_file = args[++argidx];
|
| 150 |
+
continue;
|
| 151 |
+
}
|
| 152 |
+
if (args[argidx] == "-run" && argidx + 1 < args.size()) {
|
| 153 |
+
size_t pos = args[argidx + 1].find(':');
|
| 154 |
+
if (pos == std::string::npos)
|
| 155 |
+
break;
|
| 156 |
+
run_from = args[++argidx].substr(0, pos);
|
| 157 |
+
run_to = args[argidx].substr(pos + 1);
|
| 158 |
+
continue;
|
| 159 |
+
}
|
| 160 |
+
if (args[argidx] == "-iopads") {
|
| 161 |
+
iopads = true;
|
| 162 |
+
continue;
|
| 163 |
+
}
|
| 164 |
+
if (args[argidx] == "-dff") {
|
| 165 |
+
dff = true;
|
| 166 |
+
continue;
|
| 167 |
+
}
|
| 168 |
+
if (args[argidx] == "-nodsp") {
|
| 169 |
+
nodsp = true;
|
| 170 |
+
continue;
|
| 171 |
+
}
|
| 172 |
+
if (args[argidx] == "-nobram") {
|
| 173 |
+
nobram = true;
|
| 174 |
+
continue;
|
| 175 |
+
}
|
| 176 |
+
if (args[argidx] == "-noflatten") {
|
| 177 |
+
flatten = false;
|
| 178 |
+
continue;
|
| 179 |
+
}
|
| 180 |
+
if (args[argidx] == "-retime") {
|
| 181 |
+
// Removed: ABC9 does not support retiming.
|
| 182 |
+
continue;
|
| 183 |
+
}
|
| 184 |
+
break;
|
| 185 |
+
}
|
| 186 |
+
extra_args(args, argidx, design);
|
| 187 |
+
|
| 188 |
+
if (!design->full_selection())
|
| 189 |
+
log_cmd_error("This command only operates on fully selected designs!\n");
|
| 190 |
+
|
| 191 |
+
if (family_opt == "cyclonev")
|
| 192 |
+
log_cmd_error("Cyclone V synthesis has been moved to synth_intel_alm.\n");
|
| 193 |
+
|
| 194 |
+
if (family_opt != "max10" &&
|
| 195 |
+
family_opt != "cycloneiv" &&
|
| 196 |
+
family_opt != "cycloneive" &&
|
| 197 |
+
family_opt != "cyclone10lp")
|
| 198 |
+
log_cmd_error("Invalid or no family specified: '%s'\n", family_opt);
|
| 199 |
+
|
| 200 |
+
if (family_opt != "max10")
|
| 201 |
+
nodsp = true;
|
| 202 |
+
|
| 203 |
+
log_header(design, "Executing SYNTH_INTEL pass.\n");
|
| 204 |
+
log_push();
|
| 205 |
+
|
| 206 |
+
run_script(design, run_from, run_to);
|
| 207 |
+
|
| 208 |
+
log_pop();
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
void script() override
|
| 212 |
+
{
|
| 213 |
+
if (check_label("begin")) {
|
| 214 |
+
if (check_label("family"))
|
| 215 |
+
run(stringf("read_verilog -sv -lib +/intel/%s/cells_sim.v", family_opt));
|
| 216 |
+
|
| 217 |
+
// Misc and common cells
|
| 218 |
+
run("read_verilog -sv -lib +/intel/common/m9k_bb.v");
|
| 219 |
+
run("read_verilog -sv -lib +/intel/common/altpll_bb.v");
|
| 220 |
+
run(stringf("hierarchy -check %s", help_mode ? "-top <top>" : top_opt));
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
if (check_label("coarse")) {
|
| 224 |
+
run("proc");
|
| 225 |
+
if (flatten || help_mode) {
|
| 226 |
+
run("check");
|
| 227 |
+
run("flatten", "(skip if -noflatten)");
|
| 228 |
+
}
|
| 229 |
+
run("tribuf -logic");
|
| 230 |
+
run("deminout");
|
| 231 |
+
run("opt_expr");
|
| 232 |
+
run("check");
|
| 233 |
+
run("opt_clean");
|
| 234 |
+
run("opt -nodffe -nosdff");
|
| 235 |
+
run("fsm");
|
| 236 |
+
run("opt");
|
| 237 |
+
run("wreduce");
|
| 238 |
+
run("peepopt");
|
| 239 |
+
run("opt_clean");
|
| 240 |
+
run("techmap -map +/cmp2lut.v -D LUT_WIDTH=4");
|
| 241 |
+
run("opt_expr");
|
| 242 |
+
run("opt_clean");
|
| 243 |
+
|
| 244 |
+
if (help_mode) {
|
| 245 |
+
run("techmap -map +mul2dsp.v [...]", "(unless -nodsp)");
|
| 246 |
+
} else if (!nodsp) {
|
| 247 |
+
run("techmap -map +/mul2dsp.v -D DSP_A_MAXWIDTH=18 -D DSP_B_MAXWIDTH=18 -D DSP_A_MINWIDTH=10 -D DSP_B_MINWIDTH=4 -D DSP_NAME=$__MUL18X18");
|
| 248 |
+
run("chtype -set $mul t:$__soft_mul");
|
| 249 |
+
run("techmap -map +/mul2dsp.v -D DSP_A_MAXWIDTH=18 -D DSP_B_MAXWIDTH=18 -D DSP_A_MINWIDTH=4 -D DSP_B_MINWIDTH=10 -D DSP_NAME=$__MUL18X18");
|
| 250 |
+
run("chtype -set $mul t:$__soft_mul");
|
| 251 |
+
run("techmap -map +/mul2dsp.v -D DSP_A_MAXWIDTH=9 -D DSP_B_MAXWIDTH=9 -D DSP_A_MINWIDTH=4 -D DSP_B_MINWIDTH=4 -D DSP_NAME=$__MUL9X9");
|
| 252 |
+
run("chtype -set $mul t:$__soft_mul");
|
| 253 |
+
run("alumacc");
|
| 254 |
+
run(stringf("techmap -map +/intel/%s/dsp_map.v", family_opt));
|
| 255 |
+
} else {
|
| 256 |
+
run("alumacc");
|
| 257 |
+
}
|
| 258 |
+
run("opt");
|
| 259 |
+
run("memory -nomap");
|
| 260 |
+
run("opt_clean");
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
if (!nobram && check_label("map_bram", "(skip if -nobram)")) {
|
| 264 |
+
if (family_opt == "cycloneiv" ||
|
| 265 |
+
family_opt == "cycloneive" ||
|
| 266 |
+
family_opt == "max10" ||
|
| 267 |
+
help_mode) {
|
| 268 |
+
run("memory_bram -rules +/intel/common/brams_m9k.txt", "(if applicable for family)");
|
| 269 |
+
run("techmap -map +/intel/common/brams_map_m9k.v", "(if applicable for family)");
|
| 270 |
+
} else {
|
| 271 |
+
log_warning("BRAM mapping is not currently supported for %s.\n", family_opt);
|
| 272 |
+
}
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
if (check_label("map_ffram")) {
|
| 276 |
+
run("opt -fast -mux_undef -undriven -fine -full");
|
| 277 |
+
run("memory_map");
|
| 278 |
+
run("opt -undriven -fine");
|
| 279 |
+
run("techmap -map +/techmap.v");
|
| 280 |
+
run("opt -full");
|
| 281 |
+
run("clean -purge");
|
| 282 |
+
run("setundef -undriven -zero");
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
if (check_label("map_ffs")) {
|
| 286 |
+
run("dfflegalize -cell $_DFFE_PN0P_ 01");
|
| 287 |
+
run("techmap -map +/intel/common/ff_map.v");
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
if (check_label("map_luts")) {
|
| 291 |
+
run("abc9 -lut 4 -W 300" + string(dff ? " -dff" : ""));
|
| 292 |
+
run("clean");
|
| 293 |
+
run("opt -fast");
|
| 294 |
+
run("autoname");
|
| 295 |
+
run("clean");
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
if (check_label("map_cells")) {
|
| 299 |
+
if (iopads || help_mode)
|
| 300 |
+
run("iopadmap -bits -outpad $__outpad I:O -inpad $__inpad O:I A:top", "(if -iopads)");
|
| 301 |
+
run(stringf("techmap -map +/intel/%s/cells_map.v", family_opt));
|
| 302 |
+
run("clean -purge");
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
if (check_label("check")) {
|
| 306 |
+
run("hierarchy -check");
|
| 307 |
+
run("stat");
|
| 308 |
+
run("check -noinit");
|
| 309 |
+
run("blackbox =A:whitebox");
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
if (check_label("vqm")) {
|
| 313 |
+
if (!vout_file.empty() || help_mode)
|
| 314 |
+
run(stringf("write_verilog -attr2comment -defparam -nohex -decimal -renameprefix syn_ %s",
|
| 315 |
+
help_mode ? "<file-name>" : vout_file));
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
if (check_label("vpr")) {
|
| 319 |
+
if (!blif_file.empty() || help_mode) {
|
| 320 |
+
run(stringf("opt_clean -purge"));
|
| 321 |
+
run(stringf("write_blif %s", help_mode ? "<file-name>" : blif_file));
|
| 322 |
+
}
|
| 323 |
+
}
|
| 324 |
+
}
|
| 325 |
+
} SynthIntelPass;
|
| 326 |
+
|
| 327 |
+
PRIVATE_NAMESPACE_END
|
chips/yosys/techlibs/intel_alm/CMakeLists.txt
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
yosys_pass(synth_intel_alm
|
| 2 |
+
synth_intel_alm.cc
|
| 3 |
+
REQUIRES
|
| 4 |
+
abc9
|
| 5 |
+
alumacc
|
| 6 |
+
autoname
|
| 7 |
+
blackbox
|
| 8 |
+
check
|
| 9 |
+
clean
|
| 10 |
+
clkbufmap
|
| 11 |
+
deminout
|
| 12 |
+
dfflegalize
|
| 13 |
+
flatten
|
| 14 |
+
fsm
|
| 15 |
+
hierarchy
|
| 16 |
+
iopadmap
|
| 17 |
+
memory
|
| 18 |
+
memory_bram
|
| 19 |
+
memory_map
|
| 20 |
+
opt
|
| 21 |
+
opt_clean
|
| 22 |
+
opt_expr
|
| 23 |
+
peepopt
|
| 24 |
+
proc
|
| 25 |
+
read_verilog
|
| 26 |
+
share
|
| 27 |
+
stat
|
| 28 |
+
synth
|
| 29 |
+
techmap
|
| 30 |
+
tribuf
|
| 31 |
+
wreduce
|
| 32 |
+
DATA_DIR
|
| 33 |
+
intel_alm
|
| 34 |
+
DATA_FILES
|
| 35 |
+
# Techmap
|
| 36 |
+
common/abc9_map.v
|
| 37 |
+
common/abc9_unmap.v
|
| 38 |
+
common/abc9_model.v
|
| 39 |
+
common/alm_map.v
|
| 40 |
+
common/alm_sim.v
|
| 41 |
+
common/arith_alm_map.v
|
| 42 |
+
common/dff_map.v
|
| 43 |
+
common/dff_sim.v
|
| 44 |
+
common/dsp_sim.v
|
| 45 |
+
common/dsp_map.v
|
| 46 |
+
common/mem_sim.v
|
| 47 |
+
common/misc_sim.v
|
| 48 |
+
|
| 49 |
+
cyclonev/cells_sim.v
|
| 50 |
+
|
| 51 |
+
# RAM
|
| 52 |
+
common/bram_m10k.txt
|
| 53 |
+
common/bram_m10k_map.v
|
| 54 |
+
common/lutram_mlab.txt
|
| 55 |
+
|
| 56 |
+
# Miscellaneous
|
| 57 |
+
common/megafunction_bb.v
|
| 58 |
+
)
|
chips/yosys/techlibs/intel_alm/common/abc9_map.v
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// This file exists to map purely-synchronous flops to ABC9 flops, while
|
| 2 |
+
// mapping flops with asynchronous-clear as boxes, this is because ABC9
|
| 3 |
+
// doesn't support asynchronous-clear flops in sequential synthesis.
|
| 4 |
+
|
| 5 |
+
module MISTRAL_FF(
|
| 6 |
+
input DATAIN, CLK, ACLR, ENA, SCLR, SLOAD, SDATA,
|
| 7 |
+
output reg Q
|
| 8 |
+
);
|
| 9 |
+
|
| 10 |
+
parameter _TECHMAP_CONSTMSK_ACLR_ = 1'b0;
|
| 11 |
+
|
| 12 |
+
// If the async-clear is constant, we assume it's disabled.
|
| 13 |
+
if (_TECHMAP_CONSTMSK_ACLR_ != 1'b0)
|
| 14 |
+
$__MISTRAL_FF_SYNCONLY _TECHMAP_REPLACE_ (.DATAIN(DATAIN), .CLK(CLK), .ENA(ENA), .SCLR(SCLR), .SLOAD(SLOAD), .SDATA(SDATA), .Q(Q));
|
| 15 |
+
else
|
| 16 |
+
wire _TECHMAP_FAIL_ = 1;
|
| 17 |
+
|
| 18 |
+
endmodule
|
chips/yosys/techlibs/intel_alm/common/abc9_model.v
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// This is a purely-synchronous flop, that ABC9 can use for sequential synthesis.
|
| 2 |
+
(* abc9_flop, lib_whitebox *)
|
| 3 |
+
module $__MISTRAL_FF_SYNCONLY (
|
| 4 |
+
input DATAIN, CLK, ENA, SCLR, SLOAD, SDATA,
|
| 5 |
+
output reg Q
|
| 6 |
+
);
|
| 7 |
+
|
| 8 |
+
MISTRAL_FF ff (.DATAIN(DATAIN), .CLK(CLK), .ENA(ENA), .ACLR(1'b1), .SCLR(SCLR), .SLOAD(SLOAD), .SDATA(SDATA), .Q(Q));
|
| 9 |
+
|
| 10 |
+
endmodule
|
chips/yosys/techlibs/intel_alm/common/abc9_unmap.v
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// After performing sequential synthesis, map the synchronous flops back to
|
| 2 |
+
// standard MISTRAL_FF flops.
|
| 3 |
+
|
| 4 |
+
module $__MISTRAL_FF_SYNCONLY (
|
| 5 |
+
input DATAIN, CLK, ENA, SCLR, SLOAD, SDATA,
|
| 6 |
+
output reg Q
|
| 7 |
+
);
|
| 8 |
+
|
| 9 |
+
MISTRAL_FF _TECHMAP_REPLACE_ (.DATAIN(DATAIN), .CLK(CLK), .ACLR(1'b1), .ENA(ENA), .SCLR(SCLR), .SLOAD(SLOAD), .SDATA(SDATA), .Q(Q));
|
| 10 |
+
|
| 11 |
+
endmodule
|
chips/yosys/techlibs/intel_alm/common/alm_map.v
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module \$lut (A, Y);
|
| 2 |
+
|
| 3 |
+
parameter WIDTH = 1;
|
| 4 |
+
parameter LUT = 0;
|
| 5 |
+
|
| 6 |
+
(* force_downto *)
|
| 7 |
+
input [WIDTH-1:0] A;
|
| 8 |
+
output Y;
|
| 9 |
+
|
| 10 |
+
generate
|
| 11 |
+
if (WIDTH == 1) begin
|
| 12 |
+
generate
|
| 13 |
+
if (LUT == 2'b00) begin
|
| 14 |
+
assign Y = 1'b0;
|
| 15 |
+
end
|
| 16 |
+
else if (LUT == 2'b01) begin
|
| 17 |
+
MISTRAL_NOT _TECHMAP_REPLACE_(
|
| 18 |
+
.A(A[0]), .Q(Y)
|
| 19 |
+
);
|
| 20 |
+
end
|
| 21 |
+
else if (LUT == 2'b10) begin
|
| 22 |
+
assign Y = A;
|
| 23 |
+
end
|
| 24 |
+
else if (LUT == 2'b11) begin
|
| 25 |
+
assign Y = 1'b1;
|
| 26 |
+
end
|
| 27 |
+
endgenerate
|
| 28 |
+
end else
|
| 29 |
+
if (WIDTH == 2) begin
|
| 30 |
+
MISTRAL_ALUT2 #(.LUT(LUT)) _TECHMAP_REPLACE_(
|
| 31 |
+
.A(A[0]), .B(A[1]), .Q(Y)
|
| 32 |
+
);
|
| 33 |
+
end else
|
| 34 |
+
if (WIDTH == 3) begin
|
| 35 |
+
MISTRAL_ALUT3 #(.LUT(LUT)) _TECHMAP_REPLACE_(
|
| 36 |
+
.A(A[0]), .B(A[1]), .C(A[2]), .Q(Y)
|
| 37 |
+
);
|
| 38 |
+
end else
|
| 39 |
+
if (WIDTH == 4) begin
|
| 40 |
+
MISTRAL_ALUT4 #(.LUT(LUT)) _TECHMAP_REPLACE_(
|
| 41 |
+
.A(A[0]), .B(A[1]), .C(A[2]), .D(A[3]), .Q(Y)
|
| 42 |
+
);
|
| 43 |
+
end else
|
| 44 |
+
if (WIDTH == 5) begin
|
| 45 |
+
MISTRAL_ALUT5 #(.LUT(LUT)) _TECHMAP_REPLACE_ (
|
| 46 |
+
.A(A[0]), .B(A[1]), .C(A[2]), .D(A[3]), .E(A[4]), .Q(Y)
|
| 47 |
+
);
|
| 48 |
+
end else
|
| 49 |
+
if (WIDTH == 6) begin
|
| 50 |
+
MISTRAL_ALUT6 #(.LUT(LUT)) _TECHMAP_REPLACE_ (
|
| 51 |
+
.A(A[0]), .B(A[1]), .C(A[2]), .D(A[3]), .E(A[4]), .F(A[5]), .Q(Y)
|
| 52 |
+
);
|
| 53 |
+
end else begin
|
| 54 |
+
wire _TECHMAP_FAIL_ = 1'b1;
|
| 55 |
+
end
|
| 56 |
+
endgenerate
|
| 57 |
+
endmodule
|
chips/yosys/techlibs/intel_alm/common/alm_sim.v
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// The core logic primitive of the Cyclone V is the Adaptive Logic Module
|
| 2 |
+
// (ALM). Each ALM is made up of an 8-input, 2-output look-up table, covered
|
| 3 |
+
// in this file, connected to combinational outputs, a carry chain, and four
|
| 4 |
+
// D flip-flops (which are covered as MISTRAL_FF in dff_sim.v).
|
| 5 |
+
//
|
| 6 |
+
// The ALM is vertically symmetric, so I find it helps to think in terms of
|
| 7 |
+
// half-ALMs, as that's predominantly the unit that synth_intel_alm uses.
|
| 8 |
+
//
|
| 9 |
+
// ALMs are quite flexible, having multiple modes.
|
| 10 |
+
//
|
| 11 |
+
// Normal (combinational) mode
|
| 12 |
+
// ---------------------------
|
| 13 |
+
// The ALM can implement:
|
| 14 |
+
// - a single 6-input function (with the other inputs usable for flip-flop access)
|
| 15 |
+
// - two 5-input functions that share two inputs
|
| 16 |
+
// - a 5-input and a 4-input function that share one input
|
| 17 |
+
// - a 5-input and a 3-or-less-input function that share no inputs
|
| 18 |
+
// - two 4-or-less-input functions that share no inputs
|
| 19 |
+
//
|
| 20 |
+
// Normal-mode functions are represented as MISTRAL_ALUTN cells with N inputs.
|
| 21 |
+
// It would be possible to represent a normal mode function as a single cell -
|
| 22 |
+
// the vendor cyclone{v,10gx}_lcell_comb cell does exactly that - but I felt
|
| 23 |
+
// it was more user-friendly to print out the specific function sizes
|
| 24 |
+
// separately.
|
| 25 |
+
//
|
| 26 |
+
// With the exception of MISTRAL_ALUT6, you can think of two normal-mode cells
|
| 27 |
+
// fitting inside a single ALM.
|
| 28 |
+
//
|
| 29 |
+
// Extended (7-input) mode
|
| 30 |
+
// -----------------------
|
| 31 |
+
// The ALM can also fit a 7-input function made of two 5-input functions that
|
| 32 |
+
// share four inputs, multiplexed by another input.
|
| 33 |
+
//
|
| 34 |
+
// Because this can't accept arbitrary 7-input functions, Yosys can't handle
|
| 35 |
+
// it, so it doesn't have a cell, but I would likely call it MISTRAL_ALUT7(E?)
|
| 36 |
+
// if it did, and it would take up a full ALM.
|
| 37 |
+
//
|
| 38 |
+
// It might be possible to add an extraction pass to examine all ALUT5 cells
|
| 39 |
+
// that feed into ALUT3 cells to see if they can be combined into an extended
|
| 40 |
+
// ALM, but I don't think it will be worth it.
|
| 41 |
+
//
|
| 42 |
+
// Arithmetic mode
|
| 43 |
+
// ---------------
|
| 44 |
+
// In arithmetic mode, each half-ALM uses its carry chain to perform fast addition
|
| 45 |
+
// of two four-input functions that share three inputs. Oddly, the result of
|
| 46 |
+
// one of the functions is inverted before being added (you can see this as
|
| 47 |
+
// the dot on a full-adder input of Figure 1-8 in the Handbook).
|
| 48 |
+
//
|
| 49 |
+
// The cell for an arithmetic-mode half-ALM is MISTRAL_ALM_ARITH. One idea
|
| 50 |
+
// I've had (or rather was suggested by mwk) is that functions that feed into
|
| 51 |
+
// arithmetic-mode cells could be packed directly into the arithmetic-mode
|
| 52 |
+
// cell as a function, which reduces the number of ALMs needed.
|
| 53 |
+
//
|
| 54 |
+
// Shared arithmetic mode
|
| 55 |
+
// ----------------------
|
| 56 |
+
// Shared arithmetic mode looks a lot like arithmetic mode, but here the
|
| 57 |
+
// output of every other four-input function goes to the input of the adder
|
| 58 |
+
// the next bit along. What this means is that adding three bits together can
|
| 59 |
+
// be done in an ALM, because functions can be used to implement addition that
|
| 60 |
+
// then feeds into the carry chain. This means that three bits can be added per
|
| 61 |
+
// ALM, as opposed to two in the arithmetic mode.
|
| 62 |
+
//
|
| 63 |
+
// Shared arithmetic mode doesn't currently have a cell, but I intend to add
|
| 64 |
+
// it as MISTRAL_ALM_SHARED, and have it occupy a full ALM. Because it adds
|
| 65 |
+
// three bits per cell, it makes addition shorter and use less ALMs, but
|
| 66 |
+
// I don't know enough to tell whether it's more efficient to use shared
|
| 67 |
+
// arithmetic mode to shorten the carry chain, or plain arithmetic mode with
|
| 68 |
+
// the functions packed in.
|
| 69 |
+
|
| 70 |
+
`default_nettype none
|
| 71 |
+
|
| 72 |
+
// Cyclone V LUT output timings (picoseconds):
|
| 73 |
+
//
|
| 74 |
+
// CARRY A B C D E F G
|
| 75 |
+
// COMBOUT - 605 583 510 512 - 97 400 (LUT6)
|
| 76 |
+
// COMBOUT - 602 583 457 510 302 93 483 (LUT7)
|
| 77 |
+
// SUMOUT 368 1342 1323 887 927 - 785 -
|
| 78 |
+
// CARRYOUT 71 1082 1062 866 813 - 1198 -
|
| 79 |
+
|
| 80 |
+
(* abc9_lut=2, lib_whitebox *)
|
| 81 |
+
module MISTRAL_ALUT6(input A, B, C, D, E, F, output Q);
|
| 82 |
+
|
| 83 |
+
parameter [63:0] LUT = 64'h0000_0000_0000_0000;
|
| 84 |
+
|
| 85 |
+
`ifdef cyclonev
|
| 86 |
+
specify
|
| 87 |
+
(A => Q) = 605;
|
| 88 |
+
(B => Q) = 583;
|
| 89 |
+
(C => Q) = 510;
|
| 90 |
+
(D => Q) = 512;
|
| 91 |
+
(E => Q) = 400;
|
| 92 |
+
(F => Q) = 97;
|
| 93 |
+
endspecify
|
| 94 |
+
`endif
|
| 95 |
+
|
| 96 |
+
assign Q = LUT >> {F, E, D, C, B, A};
|
| 97 |
+
|
| 98 |
+
endmodule
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
(* abc9_lut=1, lib_whitebox *)
|
| 102 |
+
module MISTRAL_ALUT5(input A, B, C, D, E, output Q);
|
| 103 |
+
|
| 104 |
+
parameter [31:0] LUT = 32'h0000_0000;
|
| 105 |
+
|
| 106 |
+
`ifdef cyclonev
|
| 107 |
+
specify
|
| 108 |
+
(A => Q) = 583;
|
| 109 |
+
(B => Q) = 510;
|
| 110 |
+
(C => Q) = 512;
|
| 111 |
+
(D => Q) = 400;
|
| 112 |
+
(E => Q) = 97;
|
| 113 |
+
endspecify
|
| 114 |
+
`endif
|
| 115 |
+
|
| 116 |
+
assign Q = LUT >> {E, D, C, B, A};
|
| 117 |
+
|
| 118 |
+
endmodule
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
(* abc9_lut=1, lib_whitebox *)
|
| 122 |
+
module MISTRAL_ALUT4(input A, B, C, D, output Q);
|
| 123 |
+
|
| 124 |
+
parameter [15:0] LUT = 16'h0000;
|
| 125 |
+
|
| 126 |
+
`ifdef cyclonev
|
| 127 |
+
specify
|
| 128 |
+
(A => Q) = 510;
|
| 129 |
+
(B => Q) = 512;
|
| 130 |
+
(C => Q) = 400;
|
| 131 |
+
(D => Q) = 97;
|
| 132 |
+
endspecify
|
| 133 |
+
`endif
|
| 134 |
+
|
| 135 |
+
assign Q = LUT >> {D, C, B, A};
|
| 136 |
+
|
| 137 |
+
endmodule
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
(* abc9_lut=1, lib_whitebox *)
|
| 141 |
+
module MISTRAL_ALUT3(input A, B, C, output Q);
|
| 142 |
+
|
| 143 |
+
parameter [7:0] LUT = 8'h00;
|
| 144 |
+
|
| 145 |
+
`ifdef cyclonev
|
| 146 |
+
specify
|
| 147 |
+
(A => Q) = 510;
|
| 148 |
+
(B => Q) = 400;
|
| 149 |
+
(C => Q) = 97;
|
| 150 |
+
endspecify
|
| 151 |
+
`endif
|
| 152 |
+
|
| 153 |
+
assign Q = LUT >> {C, B, A};
|
| 154 |
+
|
| 155 |
+
endmodule
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
(* abc9_lut=1, lib_whitebox *)
|
| 159 |
+
module MISTRAL_ALUT2(input A, B, output Q);
|
| 160 |
+
|
| 161 |
+
parameter [3:0] LUT = 4'h0;
|
| 162 |
+
|
| 163 |
+
`ifdef cyclonev
|
| 164 |
+
specify
|
| 165 |
+
(A => Q) = 400;
|
| 166 |
+
(B => Q) = 97;
|
| 167 |
+
endspecify
|
| 168 |
+
`endif
|
| 169 |
+
|
| 170 |
+
assign Q = LUT >> {B, A};
|
| 171 |
+
|
| 172 |
+
endmodule
|
| 173 |
+
|
| 174 |
+
|
| 175 |
+
(* abc9_lut=1, lib_whitebox *)
|
| 176 |
+
module MISTRAL_NOT(input A, output Q);
|
| 177 |
+
|
| 178 |
+
`ifdef cyclonev
|
| 179 |
+
specify
|
| 180 |
+
(A => Q) = 97;
|
| 181 |
+
endspecify
|
| 182 |
+
`endif
|
| 183 |
+
|
| 184 |
+
assign Q = ~A;
|
| 185 |
+
|
| 186 |
+
endmodule
|
| 187 |
+
|
| 188 |
+
(* abc9_box, lib_whitebox *)
|
| 189 |
+
module MISTRAL_ALUT_ARITH(input A, B, C, D0, D1, (* abc9_carry *) input CI, output SO, (* abc9_carry *) output CO);
|
| 190 |
+
|
| 191 |
+
parameter LUT0 = 16'h0000;
|
| 192 |
+
parameter LUT1 = 16'h0000;
|
| 193 |
+
|
| 194 |
+
`ifdef cyclonev
|
| 195 |
+
specify
|
| 196 |
+
(A => SO) = 1342;
|
| 197 |
+
(B => SO) = 1323;
|
| 198 |
+
(C => SO) = 927;
|
| 199 |
+
(D0 => SO) = 887;
|
| 200 |
+
(D1 => SO) = 785;
|
| 201 |
+
(CI => SO) = 368;
|
| 202 |
+
|
| 203 |
+
(A => CO) = 1082;
|
| 204 |
+
(B => CO) = 1062;
|
| 205 |
+
(C => CO) = 813;
|
| 206 |
+
(D0 => CO) = 866;
|
| 207 |
+
(D1 => CO) = 1198;
|
| 208 |
+
(CI => CO) = 36; // Divided by 2 to account for there being two ALUT_ARITHs in an ALM)
|
| 209 |
+
endspecify
|
| 210 |
+
`endif
|
| 211 |
+
|
| 212 |
+
wire q0, q1;
|
| 213 |
+
|
| 214 |
+
assign q0 = LUT0 >> {D0, C, B, A};
|
| 215 |
+
assign q1 = LUT1 >> {D1, C, B, A};
|
| 216 |
+
|
| 217 |
+
assign {CO, SO} = q0 + !q1 + CI;
|
| 218 |
+
|
| 219 |
+
endmodule
|
chips/yosys/techlibs/intel_alm/common/arith_alm_map.v
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
`default_nettype none
|
| 2 |
+
|
| 3 |
+
module \$alu (A, B, CI, BI, X, Y, CO);
|
| 4 |
+
|
| 5 |
+
parameter A_SIGNED = 0;
|
| 6 |
+
parameter B_SIGNED = 0;
|
| 7 |
+
parameter A_WIDTH = 1;
|
| 8 |
+
parameter B_WIDTH = 1;
|
| 9 |
+
parameter Y_WIDTH = 1;
|
| 10 |
+
|
| 11 |
+
parameter _TECHMAP_CONSTMSK_CI_ = 0;
|
| 12 |
+
parameter _TECHMAP_CONSTVAL_CI_ = 0;
|
| 13 |
+
|
| 14 |
+
(* force_downto *)
|
| 15 |
+
input [A_WIDTH-1:0] A;
|
| 16 |
+
(* force_downto *)
|
| 17 |
+
input [B_WIDTH-1:0] B;
|
| 18 |
+
input CI, BI;
|
| 19 |
+
(* force_downto *)
|
| 20 |
+
output [Y_WIDTH-1:0] X, Y, CO;
|
| 21 |
+
|
| 22 |
+
(* force_downto *)
|
| 23 |
+
wire [Y_WIDTH-1:0] A_buf, B_buf;
|
| 24 |
+
\$pos #(.A_SIGNED(A_SIGNED), .A_WIDTH(A_WIDTH), .Y_WIDTH(Y_WIDTH)) A_conv (.A(A), .Y(A_buf));
|
| 25 |
+
\$pos #(.A_SIGNED(B_SIGNED), .A_WIDTH(B_WIDTH), .Y_WIDTH(Y_WIDTH)) B_conv (.A(B), .Y(B_buf));
|
| 26 |
+
|
| 27 |
+
(* force_downto *)
|
| 28 |
+
wire [Y_WIDTH-1:0] AA = A_buf;
|
| 29 |
+
(* force_downto *)
|
| 30 |
+
wire [Y_WIDTH-1:0] BB = BI ? ~B_buf : B_buf;
|
| 31 |
+
(* force_downto *)
|
| 32 |
+
wire [Y_WIDTH-1:0] BX = B_buf;
|
| 33 |
+
wire [Y_WIDTH:0] ALM_CARRY;
|
| 34 |
+
|
| 35 |
+
// Start of carry chain
|
| 36 |
+
generate
|
| 37 |
+
if (_TECHMAP_CONSTMSK_CI_ == 1 && _TECHMAP_CONSTVAL_CI_ == 1'b0) begin
|
| 38 |
+
assign ALM_CARRY[0] = _TECHMAP_CONSTVAL_CI_;
|
| 39 |
+
end else begin
|
| 40 |
+
MISTRAL_ALUT_ARITH #(
|
| 41 |
+
.LUT0(16'b1010_1010_1010_1010), // Q = A
|
| 42 |
+
.LUT1(16'b0000_0000_0000_0000), // Q = 0 (LUT1's input to the adder is inverted)
|
| 43 |
+
) alm_start (
|
| 44 |
+
.A(CI), .B(1'b1), .C(1'b1), .D0(1'b1), .D1(1'b1),
|
| 45 |
+
.CI(1'b0),
|
| 46 |
+
.CO(ALM_CARRY[0])
|
| 47 |
+
);
|
| 48 |
+
end
|
| 49 |
+
endgenerate
|
| 50 |
+
|
| 51 |
+
// Carry chain
|
| 52 |
+
genvar i;
|
| 53 |
+
generate for (i = 0; i < Y_WIDTH; i = i + 1) begin:slice
|
| 54 |
+
// TODO: mwk suggests that a pass could merge pre-adder logic into this.
|
| 55 |
+
MISTRAL_ALUT_ARITH #(
|
| 56 |
+
.LUT0(16'b1010_1010_1010_1010), // Q = A
|
| 57 |
+
.LUT1(16'b1100_0011_1100_0011), // Q = C ? B : ~B (LUT1's input to the adder is inverted)
|
| 58 |
+
) alm_i (
|
| 59 |
+
.A(AA[i]), .B(BX[i]), .C(BI), .D0(1'b1), .D1(1'b1),
|
| 60 |
+
.CI(ALM_CARRY[i]),
|
| 61 |
+
.SO(Y[i]),
|
| 62 |
+
.CO(ALM_CARRY[i+1])
|
| 63 |
+
);
|
| 64 |
+
|
| 65 |
+
// ALM carry chain is not directly accessible, so calculate the carry through soft logic if really needed.
|
| 66 |
+
assign CO[i] = (AA[i] && BB[i]) || ((Y[i] ^ AA[i] ^ BB[i]) && (AA[i] || BB[i]));
|
| 67 |
+
end endgenerate
|
| 68 |
+
|
| 69 |
+
assign X = AA ^ BB;
|
| 70 |
+
|
| 71 |
+
endmodule
|
chips/yosys/techlibs/intel_alm/common/bram_m10k.txt
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
bram $__MISTRAL_M10K
|
| 2 |
+
init 1
|
| 3 |
+
abits 13 @D8192x1
|
| 4 |
+
dbits 1 @D8192x1
|
| 5 |
+
abits 12 @D4096x2
|
| 6 |
+
dbits 2 @D4096x2
|
| 7 |
+
abits 11 @D2048x5
|
| 8 |
+
dbits 5 @D2048x5
|
| 9 |
+
abits 10 @D1024x10
|
| 10 |
+
dbits 10 @D1024x10
|
| 11 |
+
abits 9 @D512x20
|
| 12 |
+
dbits 20 @D512x20
|
| 13 |
+
abits 8 @D256x40
|
| 14 |
+
dbits 40 @D256x40
|
| 15 |
+
groups 2
|
| 16 |
+
ports 1 1
|
| 17 |
+
wrmode 1 0
|
| 18 |
+
# read enable; write enable + byte enables (only for multiples of 8)
|
| 19 |
+
enable 1 1
|
| 20 |
+
transp 0 0
|
| 21 |
+
clocks 1 1
|
| 22 |
+
clkpol 1 1
|
| 23 |
+
endbram
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
match $__MISTRAL_M10K
|
| 27 |
+
min efficiency 5
|
| 28 |
+
make_transp
|
| 29 |
+
endmatch
|
chips/yosys/techlibs/intel_alm/common/bram_m10k_map.v
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Stub to invert M10K write-enable.
|
| 2 |
+
|
| 3 |
+
module \$__MISTRAL_M10K (CLK1, A1ADDR, A1DATA, A1EN, B1ADDR, B1DATA, B1EN);
|
| 4 |
+
|
| 5 |
+
parameter INIT = 0;
|
| 6 |
+
|
| 7 |
+
parameter CFG_ABITS = 10;
|
| 8 |
+
parameter CFG_DBITS = 10;
|
| 9 |
+
|
| 10 |
+
input CLK1;
|
| 11 |
+
input [CFG_ABITS-1:0] A1ADDR, B1ADDR;
|
| 12 |
+
input [CFG_DBITS-1:0] A1DATA;
|
| 13 |
+
input A1EN, B1EN;
|
| 14 |
+
output reg [CFG_DBITS-1:0] B1DATA;
|
| 15 |
+
|
| 16 |
+
// Normal M10K configs use WREN[1], which is negative-true.
|
| 17 |
+
// However, 8x40-bit mode uses WREN[0], which is positive-true.
|
| 18 |
+
wire a1en;
|
| 19 |
+
if (CFG_DBITS == 40)
|
| 20 |
+
assign a1en = A1EN;
|
| 21 |
+
else
|
| 22 |
+
assign a1en = !A1EN;
|
| 23 |
+
|
| 24 |
+
MISTRAL_M10K #(.INIT(INIT), .CFG_ABITS(CFG_ABITS), .CFG_DBITS(CFG_DBITS)) _TECHMAP_REPLACE_ (.CLK1(CLK1), .A1ADDR(A1ADDR), .A1DATA(A1DATA), .A1EN(a1en), .B1ADDR(B1ADDR), .B1DATA(B1DATA), .B1EN(B1EN));
|
| 25 |
+
|
| 26 |
+
endmodule
|
chips/yosys/techlibs/intel_alm/common/dff_map.v
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
`default_nettype none
|
| 2 |
+
|
| 3 |
+
// D flip-flop with async reset and enable
|
| 4 |
+
module \$_DFFE_PN0P_ (input D, C, R, E, output Q);
|
| 5 |
+
wire _TECHMAP_REMOVEINIT_Q_ = 1'b1;
|
| 6 |
+
MISTRAL_FF _TECHMAP_REPLACE_(.DATAIN(D), .CLK(C), .ACLR(R), .ENA(E), .SCLR(1'b0), .SLOAD(1'b0), .SDATA(1'b0), .Q(Q));
|
| 7 |
+
endmodule
|
| 8 |
+
|
| 9 |
+
// D flip-flop with sync reset and enable (enable has priority)
|
| 10 |
+
module \$_SDFFCE_PP0P_ (input D, C, R, E, output Q);
|
| 11 |
+
wire _TECHMAP_REMOVEINIT_Q_ = 1'b1;
|
| 12 |
+
MISTRAL_FF _TECHMAP_REPLACE_(.DATAIN(D), .CLK(C), .ACLR(1'b1), .ENA(E), .SCLR(R), .SLOAD(1'b0), .SDATA(1'b0), .Q(Q));
|
| 13 |
+
endmodule
|
chips/yosys/techlibs/intel_alm/common/dff_sim.v
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// The four D flip-flops (DFFs) in a Cyclone V/10GX Adaptive Logic Module (ALM)
|
| 2 |
+
// act as one-bit memory cells that can be placed very flexibly (wherever there's
|
| 3 |
+
// an ALM); each flop is represented by a MISTRAL_FF cell.
|
| 4 |
+
//
|
| 5 |
+
// The flops in these chips are rather flexible in some ways, but in practice
|
| 6 |
+
// quite crippled by FPGA standards.
|
| 7 |
+
//
|
| 8 |
+
// What the flops can do
|
| 9 |
+
// ---------------------
|
| 10 |
+
// The core flop acts as a single-bit memory that initialises to zero at chip
|
| 11 |
+
// reset. It takes in data on the rising edge of CLK if ENA is high,
|
| 12 |
+
// and outputs it to Q. The ENA (clock enable) pin can therefore be used to
|
| 13 |
+
// capture the input only if a condition is true.
|
| 14 |
+
//
|
| 15 |
+
// The data itself is zero if SCLR (synchronous clear) is high, else it comes
|
| 16 |
+
// from SDATA (synchronous data) if SLOAD (synchronous load) is high, or DATAIN
|
| 17 |
+
// if SLOAD is low.
|
| 18 |
+
//
|
| 19 |
+
// If ACLR (asynchronous clear) is low then Q is forced to zero, regardless of
|
| 20 |
+
// the synchronous inputs or CLK edge. This is most often used for an FPGA-wide
|
| 21 |
+
// power-on reset.
|
| 22 |
+
//
|
| 23 |
+
// An asynchronous set that sets Q to one can be emulated by inverting the input
|
| 24 |
+
// and output of the flop, resulting in ACLR forcing Q to zero, which then gets
|
| 25 |
+
// inverted to produce one. Likewise, logic can operate on the falling edge of
|
| 26 |
+
// CLK if CLK is inverted before being passed as an input.
|
| 27 |
+
//
|
| 28 |
+
// What the flops *can't* do
|
| 29 |
+
// -------------------------
|
| 30 |
+
// The trickiest part of the above capabilities is the lack of configurable
|
| 31 |
+
// initialisation state. For example, it isn't possible to implement a flop with
|
| 32 |
+
// asynchronous clear that initialises to one, because the hardware initialises
|
| 33 |
+
// to zero. Likewise, you can't emulate a flop with asynchronous set that
|
| 34 |
+
// initialises to zero, because the inverters mean the flop initialises to one.
|
| 35 |
+
//
|
| 36 |
+
// If the input design requires one of these cells (which appears to be rare
|
| 37 |
+
// in practice) then synth_intel_alm will fail to synthesize the design where
|
| 38 |
+
// other Yosys synthesis scripts might succeed.
|
| 39 |
+
//
|
| 40 |
+
// This stands in notable contrast to e.g. Xilinx flip-flops, which have
|
| 41 |
+
// configurable initialisation state and native synchronous/asynchronous
|
| 42 |
+
// set/clear (although not at the same time), which means they can generally
|
| 43 |
+
// implement a much wider variety of logic.
|
| 44 |
+
|
| 45 |
+
// DATAIN: synchronous data input
|
| 46 |
+
// CLK: clock input (positive edge)
|
| 47 |
+
// ACLR: asynchronous clear (negative-true)
|
| 48 |
+
// ENA: clock-enable
|
| 49 |
+
// SCLR: synchronous clear
|
| 50 |
+
// SLOAD: synchronous load
|
| 51 |
+
// SDATA: synchronous load data
|
| 52 |
+
//
|
| 53 |
+
// Q: data output
|
| 54 |
+
//
|
| 55 |
+
// Note: the DFFEAS primitive is mostly emulated; it does not reflect what the hardware implements.
|
| 56 |
+
|
| 57 |
+
(* abc9_box, lib_whitebox *)
|
| 58 |
+
module MISTRAL_FF(
|
| 59 |
+
input DATAIN,
|
| 60 |
+
(* clkbuf_sink *) input CLK,
|
| 61 |
+
input ACLR, ENA, SCLR, SLOAD, SDATA,
|
| 62 |
+
output reg Q
|
| 63 |
+
);
|
| 64 |
+
|
| 65 |
+
`ifdef cyclonev
|
| 66 |
+
specify
|
| 67 |
+
if (ENA && ACLR !== 1'b0 && !SCLR && !SLOAD) (posedge CLK => (Q : DATAIN)) = 731;
|
| 68 |
+
if (ENA && SCLR) (posedge CLK => (Q : 1'b0)) = 890;
|
| 69 |
+
if (ENA && !SCLR && SLOAD) (posedge CLK => (Q : SDATA)) = 618;
|
| 70 |
+
|
| 71 |
+
$setup(DATAIN, posedge CLK, /* -196 */ 0);
|
| 72 |
+
$setup(ENA, posedge CLK, /* -196 */ 0);
|
| 73 |
+
$setup(SCLR, posedge CLK, /* -196 */ 0);
|
| 74 |
+
$setup(SLOAD, posedge CLK, /* -196 */ 0);
|
| 75 |
+
$setup(SDATA, posedge CLK, /* -196 */ 0);
|
| 76 |
+
|
| 77 |
+
if (ACLR === 1'b0) (ACLR => Q) = 282;
|
| 78 |
+
endspecify
|
| 79 |
+
`endif
|
| 80 |
+
|
| 81 |
+
initial begin
|
| 82 |
+
// Altera flops initialise to zero.
|
| 83 |
+
Q = 0;
|
| 84 |
+
end
|
| 85 |
+
|
| 86 |
+
always @(posedge CLK, negedge ACLR) begin
|
| 87 |
+
// Asynchronous clear
|
| 88 |
+
if (!ACLR) Q <= 0;
|
| 89 |
+
// Clock-enable
|
| 90 |
+
else if (ENA) begin
|
| 91 |
+
// Synchronous clear
|
| 92 |
+
if (SCLR) Q <= 0;
|
| 93 |
+
// Synchronous load
|
| 94 |
+
else if (SLOAD) Q <= SDATA;
|
| 95 |
+
else Q <= DATAIN;
|
| 96 |
+
end
|
| 97 |
+
end
|
| 98 |
+
|
| 99 |
+
endmodule
|
chips/yosys/techlibs/intel_alm/common/dsp_map.v
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
`default_nettype none
|
| 2 |
+
|
| 3 |
+
module __MUL27X27(A, B, Y);
|
| 4 |
+
|
| 5 |
+
parameter A_SIGNED = 1;
|
| 6 |
+
parameter B_SIGNED = 1;
|
| 7 |
+
parameter A_WIDTH = 27;
|
| 8 |
+
parameter B_WIDTH = 27;
|
| 9 |
+
parameter Y_WIDTH = 54;
|
| 10 |
+
|
| 11 |
+
input [A_WIDTH-1:0] A;
|
| 12 |
+
input [B_WIDTH-1:0] B;
|
| 13 |
+
output [Y_WIDTH-1:0] Y;
|
| 14 |
+
|
| 15 |
+
MISTRAL_MUL27X27 _TECHMAP_REPLACE_ (.A(A), .B(B), .Y(Y));
|
| 16 |
+
|
| 17 |
+
endmodule
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
module __MUL18X18(A, B, Y);
|
| 21 |
+
|
| 22 |
+
parameter A_SIGNED = 1;
|
| 23 |
+
parameter B_SIGNED = 1;
|
| 24 |
+
parameter A_WIDTH = 18;
|
| 25 |
+
parameter B_WIDTH = 18;
|
| 26 |
+
parameter Y_WIDTH = 36;
|
| 27 |
+
|
| 28 |
+
input [A_WIDTH-1:0] A;
|
| 29 |
+
input [B_WIDTH-1:0] B;
|
| 30 |
+
output [Y_WIDTH-1:0] Y;
|
| 31 |
+
|
| 32 |
+
MISTRAL_MUL18X18 _TECHMAP_REPLACE_ (.A(A), .B(B), .Y(Y));
|
| 33 |
+
|
| 34 |
+
endmodule
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
module __MUL9X9(A, B, Y);
|
| 38 |
+
|
| 39 |
+
parameter A_SIGNED = 1;
|
| 40 |
+
parameter B_SIGNED = 1;
|
| 41 |
+
parameter A_WIDTH = 9;
|
| 42 |
+
parameter B_WIDTH = 9;
|
| 43 |
+
parameter Y_WIDTH = 18;
|
| 44 |
+
|
| 45 |
+
input [A_WIDTH-1:0] A;
|
| 46 |
+
input [B_WIDTH-1:0] B;
|
| 47 |
+
output [Y_WIDTH-1:0] Y;
|
| 48 |
+
|
| 49 |
+
MISTRAL_MUL9X9 _TECHMAP_REPLACE_ (.A(A), .B(B), .Y(Y));
|
| 50 |
+
|
| 51 |
+
endmodule
|
chips/yosys/techlibs/intel_alm/common/dsp_sim.v
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
`default_nettype none
|
| 2 |
+
|
| 3 |
+
(* abc9_box *)
|
| 4 |
+
module MISTRAL_MUL27X27(input [26:0] A, input [26:0] B, output [53:0] Y);
|
| 5 |
+
|
| 6 |
+
parameter A_SIGNED = 1;
|
| 7 |
+
parameter B_SIGNED = 1;
|
| 8 |
+
|
| 9 |
+
`ifdef cyclonev
|
| 10 |
+
specify
|
| 11 |
+
(A *> Y) = 3732;
|
| 12 |
+
(B *> Y) = 3928;
|
| 13 |
+
endspecify
|
| 14 |
+
`endif
|
| 15 |
+
`ifdef arriav
|
| 16 |
+
// NOTE: Arria V appears to have only one set of timings for all DSP modes...
|
| 17 |
+
specify
|
| 18 |
+
(A *> Y) = 1895;
|
| 19 |
+
(B *> Y) = 2053;
|
| 20 |
+
endspecify
|
| 21 |
+
`endif
|
| 22 |
+
`ifdef cyclone10gx
|
| 23 |
+
// TODO: Cyclone 10 GX timings; the below are for Cyclone V
|
| 24 |
+
specify
|
| 25 |
+
(A *> Y) = 3732;
|
| 26 |
+
(B *> Y) = 3928;
|
| 27 |
+
endspecify
|
| 28 |
+
`endif
|
| 29 |
+
|
| 30 |
+
wire [53:0] A_, B_;
|
| 31 |
+
|
| 32 |
+
if (A_SIGNED)
|
| 33 |
+
assign A_ = $signed(A);
|
| 34 |
+
else
|
| 35 |
+
assign A_ = $unsigned(A);
|
| 36 |
+
|
| 37 |
+
if (B_SIGNED)
|
| 38 |
+
assign B_ = $signed(B);
|
| 39 |
+
else
|
| 40 |
+
assign B_ = $unsigned(B);
|
| 41 |
+
|
| 42 |
+
assign Y = A_ * B_;
|
| 43 |
+
|
| 44 |
+
endmodule
|
| 45 |
+
|
| 46 |
+
(* abc9_box *)
|
| 47 |
+
module MISTRAL_MUL18X18(input [17:0] A, input [17:0] B, output [35:0] Y);
|
| 48 |
+
|
| 49 |
+
parameter A_SIGNED = 1;
|
| 50 |
+
parameter B_SIGNED = 1;
|
| 51 |
+
|
| 52 |
+
`ifdef cyclonev
|
| 53 |
+
specify
|
| 54 |
+
(A *> Y) = 3180;
|
| 55 |
+
(B *> Y) = 3982;
|
| 56 |
+
endspecify
|
| 57 |
+
`endif
|
| 58 |
+
`ifdef arriav
|
| 59 |
+
// NOTE: Arria V appears to have only one set of timings for all DSP modes...
|
| 60 |
+
specify
|
| 61 |
+
(A *> Y) = 1895;
|
| 62 |
+
(B *> Y) = 2053;
|
| 63 |
+
endspecify
|
| 64 |
+
`endif
|
| 65 |
+
`ifdef cyclone10gx
|
| 66 |
+
// TODO: Cyclone 10 GX timings; the below are for Cyclone V
|
| 67 |
+
specify
|
| 68 |
+
(A *> Y) = 3180;
|
| 69 |
+
(B *> Y) = 3982;
|
| 70 |
+
endspecify
|
| 71 |
+
`endif
|
| 72 |
+
|
| 73 |
+
wire [35:0] A_, B_;
|
| 74 |
+
|
| 75 |
+
if (A_SIGNED)
|
| 76 |
+
assign A_ = $signed(A);
|
| 77 |
+
else
|
| 78 |
+
assign A_ = $unsigned(A);
|
| 79 |
+
|
| 80 |
+
if (B_SIGNED)
|
| 81 |
+
assign B_ = $signed(B);
|
| 82 |
+
else
|
| 83 |
+
assign B_ = $unsigned(B);
|
| 84 |
+
|
| 85 |
+
assign Y = A_ * B_;
|
| 86 |
+
|
| 87 |
+
endmodule
|
| 88 |
+
|
| 89 |
+
(* abc9_box *)
|
| 90 |
+
module MISTRAL_MUL9X9(input [8:0] A, input [8:0] B, output [17:0] Y);
|
| 91 |
+
|
| 92 |
+
parameter A_SIGNED = 1;
|
| 93 |
+
parameter B_SIGNED = 1;
|
| 94 |
+
|
| 95 |
+
`ifdef cyclonev
|
| 96 |
+
specify
|
| 97 |
+
(A *> Y) = 2818;
|
| 98 |
+
(B *> Y) = 3051;
|
| 99 |
+
endspecify
|
| 100 |
+
`endif
|
| 101 |
+
`ifdef arriav
|
| 102 |
+
// NOTE: Arria V appears to have only one set of timings for all DSP modes...
|
| 103 |
+
specify
|
| 104 |
+
(A *> Y) = 1895;
|
| 105 |
+
(B *> Y) = 2053;
|
| 106 |
+
endspecify
|
| 107 |
+
`endif
|
| 108 |
+
`ifdef cyclone10gx
|
| 109 |
+
// TODO: Cyclone 10 GX timings; the below are for Cyclone V
|
| 110 |
+
specify
|
| 111 |
+
(A *> Y) = 2818;
|
| 112 |
+
(B *> Y) = 3051;
|
| 113 |
+
endspecify
|
| 114 |
+
`endif
|
| 115 |
+
|
| 116 |
+
wire [17:0] A_, B_;
|
| 117 |
+
|
| 118 |
+
if (A_SIGNED)
|
| 119 |
+
assign A_ = $signed(A);
|
| 120 |
+
else
|
| 121 |
+
assign A_ = $unsigned(A);
|
| 122 |
+
|
| 123 |
+
if (B_SIGNED)
|
| 124 |
+
assign B_ = $signed(B);
|
| 125 |
+
else
|
| 126 |
+
assign B_ = $unsigned(B);
|
| 127 |
+
|
| 128 |
+
assign Y = A_ * B_;
|
| 129 |
+
|
| 130 |
+
endmodule
|
chips/yosys/techlibs/intel_alm/common/lutram_mlab.txt
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
bram MISTRAL_MLAB
|
| 2 |
+
init 0 # TODO: Re-enable when Yosys remembers the original filename.
|
| 3 |
+
abits 5
|
| 4 |
+
dbits 1
|
| 5 |
+
groups 2
|
| 6 |
+
ports 1 1
|
| 7 |
+
wrmode 1 0
|
| 8 |
+
# write enable
|
| 9 |
+
enable 1 0
|
| 10 |
+
transp 0 0
|
| 11 |
+
clocks 1 0
|
| 12 |
+
clkpol 1 1
|
| 13 |
+
endbram
|
| 14 |
+
|
| 15 |
+
match MISTRAL_MLAB
|
| 16 |
+
min efficiency 5
|
| 17 |
+
make_outreg
|
| 18 |
+
endmatch
|
chips/yosys/techlibs/intel_alm/common/megafunction_bb.v
ADDED
|
@@ -0,0 +1,717 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Intel megafunction declarations, to avoid Yosys complaining.
|
| 2 |
+
`default_nettype none
|
| 3 |
+
|
| 4 |
+
(* blackbox *)
|
| 5 |
+
module altera_pll
|
| 6 |
+
#(
|
| 7 |
+
parameter reference_clock_frequency = "0 ps",
|
| 8 |
+
parameter fractional_vco_multiplier = "false",
|
| 9 |
+
parameter pll_type = "General",
|
| 10 |
+
parameter pll_subtype = "General",
|
| 11 |
+
parameter number_of_clocks = 1,
|
| 12 |
+
parameter operation_mode = "internal feedback",
|
| 13 |
+
parameter deserialization_factor = 4,
|
| 14 |
+
parameter data_rate = 0,
|
| 15 |
+
|
| 16 |
+
parameter sim_additional_refclk_cycles_to_lock = 0,
|
| 17 |
+
parameter output_clock_frequency0 = "0 ps",
|
| 18 |
+
parameter phase_shift0 = "0 ps",
|
| 19 |
+
parameter duty_cycle0 = 50,
|
| 20 |
+
|
| 21 |
+
parameter output_clock_frequency1 = "0 ps",
|
| 22 |
+
parameter phase_shift1 = "0 ps",
|
| 23 |
+
parameter duty_cycle1 = 50,
|
| 24 |
+
|
| 25 |
+
parameter output_clock_frequency2 = "0 ps",
|
| 26 |
+
parameter phase_shift2 = "0 ps",
|
| 27 |
+
parameter duty_cycle2 = 50,
|
| 28 |
+
|
| 29 |
+
parameter output_clock_frequency3 = "0 ps",
|
| 30 |
+
parameter phase_shift3 = "0 ps",
|
| 31 |
+
parameter duty_cycle3 = 50,
|
| 32 |
+
|
| 33 |
+
parameter output_clock_frequency4 = "0 ps",
|
| 34 |
+
parameter phase_shift4 = "0 ps",
|
| 35 |
+
parameter duty_cycle4 = 50,
|
| 36 |
+
|
| 37 |
+
parameter output_clock_frequency5 = "0 ps",
|
| 38 |
+
parameter phase_shift5 = "0 ps",
|
| 39 |
+
parameter duty_cycle5 = 50,
|
| 40 |
+
|
| 41 |
+
parameter output_clock_frequency6 = "0 ps",
|
| 42 |
+
parameter phase_shift6 = "0 ps",
|
| 43 |
+
parameter duty_cycle6 = 50,
|
| 44 |
+
|
| 45 |
+
parameter output_clock_frequency7 = "0 ps",
|
| 46 |
+
parameter phase_shift7 = "0 ps",
|
| 47 |
+
parameter duty_cycle7 = 50,
|
| 48 |
+
|
| 49 |
+
parameter output_clock_frequency8 = "0 ps",
|
| 50 |
+
parameter phase_shift8 = "0 ps",
|
| 51 |
+
parameter duty_cycle8 = 50,
|
| 52 |
+
|
| 53 |
+
parameter output_clock_frequency9 = "0 ps",
|
| 54 |
+
parameter phase_shift9 = "0 ps",
|
| 55 |
+
parameter duty_cycle9 = 50,
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
parameter output_clock_frequency10 = "0 ps",
|
| 59 |
+
parameter phase_shift10 = "0 ps",
|
| 60 |
+
parameter duty_cycle10 = 50,
|
| 61 |
+
|
| 62 |
+
parameter output_clock_frequency11 = "0 ps",
|
| 63 |
+
parameter phase_shift11 = "0 ps",
|
| 64 |
+
parameter duty_cycle11 = 50,
|
| 65 |
+
|
| 66 |
+
parameter output_clock_frequency12 = "0 ps",
|
| 67 |
+
parameter phase_shift12 = "0 ps",
|
| 68 |
+
parameter duty_cycle12 = 50,
|
| 69 |
+
|
| 70 |
+
parameter output_clock_frequency13 = "0 ps",
|
| 71 |
+
parameter phase_shift13 = "0 ps",
|
| 72 |
+
parameter duty_cycle13 = 50,
|
| 73 |
+
|
| 74 |
+
parameter output_clock_frequency14 = "0 ps",
|
| 75 |
+
parameter phase_shift14 = "0 ps",
|
| 76 |
+
parameter duty_cycle14 = 50,
|
| 77 |
+
|
| 78 |
+
parameter output_clock_frequency15 = "0 ps",
|
| 79 |
+
parameter phase_shift15 = "0 ps",
|
| 80 |
+
parameter duty_cycle15 = 50,
|
| 81 |
+
|
| 82 |
+
parameter output_clock_frequency16 = "0 ps",
|
| 83 |
+
parameter phase_shift16 = "0 ps",
|
| 84 |
+
parameter duty_cycle16 = 50,
|
| 85 |
+
|
| 86 |
+
parameter output_clock_frequency17 = "0 ps",
|
| 87 |
+
parameter phase_shift17 = "0 ps",
|
| 88 |
+
parameter duty_cycle17 = 50,
|
| 89 |
+
|
| 90 |
+
parameter clock_name_0 = "",
|
| 91 |
+
parameter clock_name_1 = "",
|
| 92 |
+
parameter clock_name_2 = "",
|
| 93 |
+
parameter clock_name_3 = "",
|
| 94 |
+
parameter clock_name_4 = "",
|
| 95 |
+
parameter clock_name_5 = "",
|
| 96 |
+
parameter clock_name_6 = "",
|
| 97 |
+
parameter clock_name_7 = "",
|
| 98 |
+
parameter clock_name_8 = "",
|
| 99 |
+
|
| 100 |
+
parameter clock_name_global_0 = "false",
|
| 101 |
+
parameter clock_name_global_1 = "false",
|
| 102 |
+
parameter clock_name_global_2 = "false",
|
| 103 |
+
parameter clock_name_global_3 = "false",
|
| 104 |
+
parameter clock_name_global_4 = "false",
|
| 105 |
+
parameter clock_name_global_5 = "false",
|
| 106 |
+
parameter clock_name_global_6 = "false",
|
| 107 |
+
parameter clock_name_global_7 = "false",
|
| 108 |
+
parameter clock_name_global_8 = "false",
|
| 109 |
+
|
| 110 |
+
parameter m_cnt_hi_div = 1,
|
| 111 |
+
parameter m_cnt_lo_div = 1,
|
| 112 |
+
parameter m_cnt_bypass_en = "false",
|
| 113 |
+
parameter m_cnt_odd_div_duty_en = "false",
|
| 114 |
+
parameter n_cnt_hi_div = 1,
|
| 115 |
+
parameter n_cnt_lo_div = 1,
|
| 116 |
+
parameter n_cnt_bypass_en = "false",
|
| 117 |
+
parameter n_cnt_odd_div_duty_en = "false",
|
| 118 |
+
parameter c_cnt_hi_div0 = 1,
|
| 119 |
+
parameter c_cnt_lo_div0 = 1,
|
| 120 |
+
parameter c_cnt_bypass_en0 = "false",
|
| 121 |
+
parameter c_cnt_in_src0 = "ph_mux_clk",
|
| 122 |
+
parameter c_cnt_odd_div_duty_en0 = "false",
|
| 123 |
+
parameter c_cnt_prst0 = 1,
|
| 124 |
+
parameter c_cnt_ph_mux_prst0 = 0,
|
| 125 |
+
parameter c_cnt_hi_div1 = 1,
|
| 126 |
+
parameter c_cnt_lo_div1 = 1,
|
| 127 |
+
parameter c_cnt_bypass_en1 = "false",
|
| 128 |
+
parameter c_cnt_in_src1 = "ph_mux_clk",
|
| 129 |
+
parameter c_cnt_odd_div_duty_en1 = "false",
|
| 130 |
+
parameter c_cnt_prst1 = 1,
|
| 131 |
+
parameter c_cnt_ph_mux_prst1 = 0,
|
| 132 |
+
parameter c_cnt_hi_div2 = 1,
|
| 133 |
+
parameter c_cnt_lo_div2 = 1,
|
| 134 |
+
parameter c_cnt_bypass_en2 = "false",
|
| 135 |
+
parameter c_cnt_in_src2 = "ph_mux_clk",
|
| 136 |
+
parameter c_cnt_odd_div_duty_en2 = "false",
|
| 137 |
+
parameter c_cnt_prst2 = 1,
|
| 138 |
+
parameter c_cnt_ph_mux_prst2 = 0,
|
| 139 |
+
parameter c_cnt_hi_div3 = 1,
|
| 140 |
+
parameter c_cnt_lo_div3 = 1,
|
| 141 |
+
parameter c_cnt_bypass_en3 = "false",
|
| 142 |
+
parameter c_cnt_in_src3 = "ph_mux_clk",
|
| 143 |
+
parameter c_cnt_odd_div_duty_en3 = "false",
|
| 144 |
+
parameter c_cnt_prst3 = 1,
|
| 145 |
+
parameter c_cnt_ph_mux_prst3 = 0,
|
| 146 |
+
parameter c_cnt_hi_div4 = 1,
|
| 147 |
+
parameter c_cnt_lo_div4 = 1,
|
| 148 |
+
parameter c_cnt_bypass_en4 = "false",
|
| 149 |
+
parameter c_cnt_in_src4 = "ph_mux_clk",
|
| 150 |
+
parameter c_cnt_odd_div_duty_en4 = "false",
|
| 151 |
+
parameter c_cnt_prst4 = 1,
|
| 152 |
+
parameter c_cnt_ph_mux_prst4 = 0,
|
| 153 |
+
parameter c_cnt_hi_div5 = 1,
|
| 154 |
+
parameter c_cnt_lo_div5 = 1,
|
| 155 |
+
parameter c_cnt_bypass_en5 = "false",
|
| 156 |
+
parameter c_cnt_in_src5 = "ph_mux_clk",
|
| 157 |
+
parameter c_cnt_odd_div_duty_en5 = "false",
|
| 158 |
+
parameter c_cnt_prst5 = 1,
|
| 159 |
+
parameter c_cnt_ph_mux_prst5 = 0,
|
| 160 |
+
parameter c_cnt_hi_div6 = 1,
|
| 161 |
+
parameter c_cnt_lo_div6 = 1,
|
| 162 |
+
parameter c_cnt_bypass_en6 = "false",
|
| 163 |
+
parameter c_cnt_in_src6 = "ph_mux_clk",
|
| 164 |
+
parameter c_cnt_odd_div_duty_en6 = "false",
|
| 165 |
+
parameter c_cnt_prst6 = 1,
|
| 166 |
+
parameter c_cnt_ph_mux_prst6 = 0,
|
| 167 |
+
parameter c_cnt_hi_div7 = 1,
|
| 168 |
+
parameter c_cnt_lo_div7 = 1,
|
| 169 |
+
parameter c_cnt_bypass_en7 = "false",
|
| 170 |
+
parameter c_cnt_in_src7 = "ph_mux_clk",
|
| 171 |
+
parameter c_cnt_odd_div_duty_en7 = "false",
|
| 172 |
+
parameter c_cnt_prst7 = 1,
|
| 173 |
+
parameter c_cnt_ph_mux_prst7 = 0,
|
| 174 |
+
parameter c_cnt_hi_div8 = 1,
|
| 175 |
+
parameter c_cnt_lo_div8 = 1,
|
| 176 |
+
parameter c_cnt_bypass_en8 = "false",
|
| 177 |
+
parameter c_cnt_in_src8 = "ph_mux_clk",
|
| 178 |
+
parameter c_cnt_odd_div_duty_en8 = "false",
|
| 179 |
+
parameter c_cnt_prst8 = 1,
|
| 180 |
+
parameter c_cnt_ph_mux_prst8 = 0,
|
| 181 |
+
parameter c_cnt_hi_div9 = 1,
|
| 182 |
+
parameter c_cnt_lo_div9 = 1,
|
| 183 |
+
parameter c_cnt_bypass_en9 = "false",
|
| 184 |
+
parameter c_cnt_in_src9 = "ph_mux_clk",
|
| 185 |
+
parameter c_cnt_odd_div_duty_en9 = "false",
|
| 186 |
+
parameter c_cnt_prst9 = 1,
|
| 187 |
+
parameter c_cnt_ph_mux_prst9 = 0,
|
| 188 |
+
parameter c_cnt_hi_div10 = 1,
|
| 189 |
+
parameter c_cnt_lo_div10 = 1,
|
| 190 |
+
parameter c_cnt_bypass_en10 = "false",
|
| 191 |
+
parameter c_cnt_in_src10 = "ph_mux_clk",
|
| 192 |
+
parameter c_cnt_odd_div_duty_en10 = "false",
|
| 193 |
+
parameter c_cnt_prst10 = 1,
|
| 194 |
+
parameter c_cnt_ph_mux_prst10 = 0,
|
| 195 |
+
parameter c_cnt_hi_div11 = 1,
|
| 196 |
+
parameter c_cnt_lo_div11 = 1,
|
| 197 |
+
parameter c_cnt_bypass_en11 = "false",
|
| 198 |
+
parameter c_cnt_in_src11 = "ph_mux_clk",
|
| 199 |
+
parameter c_cnt_odd_div_duty_en11 = "false",
|
| 200 |
+
parameter c_cnt_prst11 = 1,
|
| 201 |
+
parameter c_cnt_ph_mux_prst11 = 0,
|
| 202 |
+
parameter c_cnt_hi_div12 = 1,
|
| 203 |
+
parameter c_cnt_lo_div12 = 1,
|
| 204 |
+
parameter c_cnt_bypass_en12 = "false",
|
| 205 |
+
parameter c_cnt_in_src12 = "ph_mux_clk",
|
| 206 |
+
parameter c_cnt_odd_div_duty_en12 = "false",
|
| 207 |
+
parameter c_cnt_prst12 = 1,
|
| 208 |
+
parameter c_cnt_ph_mux_prst12 = 0,
|
| 209 |
+
parameter c_cnt_hi_div13 = 1,
|
| 210 |
+
parameter c_cnt_lo_div13 = 1,
|
| 211 |
+
parameter c_cnt_bypass_en13 = "false",
|
| 212 |
+
parameter c_cnt_in_src13 = "ph_mux_clk",
|
| 213 |
+
parameter c_cnt_odd_div_duty_en13 = "false",
|
| 214 |
+
parameter c_cnt_prst13 = 1,
|
| 215 |
+
parameter c_cnt_ph_mux_prst13 = 0,
|
| 216 |
+
parameter c_cnt_hi_div14 = 1,
|
| 217 |
+
parameter c_cnt_lo_div14 = 1,
|
| 218 |
+
parameter c_cnt_bypass_en14 = "false",
|
| 219 |
+
parameter c_cnt_in_src14 = "ph_mux_clk",
|
| 220 |
+
parameter c_cnt_odd_div_duty_en14 = "false",
|
| 221 |
+
parameter c_cnt_prst14 = 1,
|
| 222 |
+
parameter c_cnt_ph_mux_prst14 = 0,
|
| 223 |
+
parameter c_cnt_hi_div15 = 1,
|
| 224 |
+
parameter c_cnt_lo_div15 = 1,
|
| 225 |
+
parameter c_cnt_bypass_en15 = "false",
|
| 226 |
+
parameter c_cnt_in_src15 = "ph_mux_clk",
|
| 227 |
+
parameter c_cnt_odd_div_duty_en15 = "false",
|
| 228 |
+
parameter c_cnt_prst15 = 1,
|
| 229 |
+
parameter c_cnt_ph_mux_prst15 = 0,
|
| 230 |
+
parameter c_cnt_hi_div16 = 1,
|
| 231 |
+
parameter c_cnt_lo_div16 = 1,
|
| 232 |
+
parameter c_cnt_bypass_en16 = "false",
|
| 233 |
+
parameter c_cnt_in_src16 = "ph_mux_clk",
|
| 234 |
+
parameter c_cnt_odd_div_duty_en16 = "false",
|
| 235 |
+
parameter c_cnt_prst16 = 1,
|
| 236 |
+
parameter c_cnt_ph_mux_prst16 = 0,
|
| 237 |
+
parameter c_cnt_hi_div17 = 1,
|
| 238 |
+
parameter c_cnt_lo_div17 = 1,
|
| 239 |
+
parameter c_cnt_bypass_en17 = "false",
|
| 240 |
+
parameter c_cnt_in_src17 = "ph_mux_clk",
|
| 241 |
+
parameter c_cnt_odd_div_duty_en17 = "false",
|
| 242 |
+
parameter c_cnt_prst17 = 1,
|
| 243 |
+
parameter c_cnt_ph_mux_prst17 = 0,
|
| 244 |
+
parameter pll_vco_div = 1,
|
| 245 |
+
parameter pll_slf_rst = "false",
|
| 246 |
+
parameter pll_bw_sel = "low",
|
| 247 |
+
parameter pll_output_clk_frequency = "0 MHz",
|
| 248 |
+
parameter pll_cp_current = 0,
|
| 249 |
+
parameter pll_bwctrl = 0,
|
| 250 |
+
parameter pll_fractional_division = 1,
|
| 251 |
+
parameter pll_fractional_cout = 24,
|
| 252 |
+
parameter pll_dsm_out_sel = "1st_order",
|
| 253 |
+
parameter mimic_fbclk_type = "gclk",
|
| 254 |
+
parameter pll_fbclk_mux_1 = "glb",
|
| 255 |
+
parameter pll_fbclk_mux_2 = "fb_1",
|
| 256 |
+
parameter pll_m_cnt_in_src = "ph_mux_clk",
|
| 257 |
+
parameter pll_vcoph_div = 1,
|
| 258 |
+
parameter refclk1_frequency = "0 MHz",
|
| 259 |
+
parameter pll_clkin_0_src = "clk_0",
|
| 260 |
+
parameter pll_clkin_1_src = "clk_0",
|
| 261 |
+
parameter pll_clk_loss_sw_en = "false",
|
| 262 |
+
parameter pll_auto_clk_sw_en = "false",
|
| 263 |
+
parameter pll_manu_clk_sw_en = "false",
|
| 264 |
+
parameter pll_clk_sw_dly = 0,
|
| 265 |
+
parameter pll_extclk_0_cnt_src = "pll_extclk_cnt_src_vss",
|
| 266 |
+
parameter pll_extclk_1_cnt_src = "pll_extclk_cnt_src_vss"
|
| 267 |
+
) (
|
| 268 |
+
//input
|
| 269 |
+
input refclk,
|
| 270 |
+
input refclk1,
|
| 271 |
+
input fbclk,
|
| 272 |
+
input rst,
|
| 273 |
+
input phase_en,
|
| 274 |
+
input updn,
|
| 275 |
+
input [2:0] num_phase_shifts,
|
| 276 |
+
input scanclk,
|
| 277 |
+
input [4:0] cntsel,
|
| 278 |
+
input [63:0] reconfig_to_pll,
|
| 279 |
+
input extswitch,
|
| 280 |
+
input adjpllin,
|
| 281 |
+
input cclk,
|
| 282 |
+
|
| 283 |
+
//output
|
| 284 |
+
output [ number_of_clocks -1 : 0] outclk,
|
| 285 |
+
output fboutclk,
|
| 286 |
+
output locked,
|
| 287 |
+
output phase_done,
|
| 288 |
+
output [63:0] reconfig_from_pll,
|
| 289 |
+
output activeclk,
|
| 290 |
+
output [1:0] clkbad,
|
| 291 |
+
output [7:0] phout,
|
| 292 |
+
output [1:0] lvds_clk,
|
| 293 |
+
output [1:0] loaden,
|
| 294 |
+
output [1:0] extclk_out,
|
| 295 |
+
output [ number_of_clocks -1 : 0] cascade_out,
|
| 296 |
+
|
| 297 |
+
//inout
|
| 298 |
+
inout zdbfbclk
|
| 299 |
+
);
|
| 300 |
+
|
| 301 |
+
endmodule
|
| 302 |
+
|
| 303 |
+
|
| 304 |
+
(* blackbox *)
|
| 305 |
+
module altera_std_synchronizer(clk, din, dout, reset_n);
|
| 306 |
+
|
| 307 |
+
parameter depth = 2;
|
| 308 |
+
|
| 309 |
+
input clk;
|
| 310 |
+
input reset_n;
|
| 311 |
+
input din;
|
| 312 |
+
output dout;
|
| 313 |
+
|
| 314 |
+
endmodule
|
| 315 |
+
|
| 316 |
+
(* blackbox *)
|
| 317 |
+
module altddio_in (
|
| 318 |
+
datain, // required port, DDR input data
|
| 319 |
+
inclock, // required port, input reference clock to sample data by
|
| 320 |
+
inclocken, // enable data clock
|
| 321 |
+
aset, // asynchronous set
|
| 322 |
+
aclr, // asynchronous clear
|
| 323 |
+
sset, // synchronous set
|
| 324 |
+
sclr, // synchronous clear
|
| 325 |
+
dataout_h, // data sampled at the rising edge of inclock
|
| 326 |
+
dataout_l // data sampled at the falling edge of inclock
|
| 327 |
+
);
|
| 328 |
+
|
| 329 |
+
parameter width = 1;
|
| 330 |
+
parameter power_up_high = "OFF";
|
| 331 |
+
parameter invert_input_clocks = "OFF";
|
| 332 |
+
parameter intended_device_family = "Stratix";
|
| 333 |
+
parameter lpm_type = "altddio_in";
|
| 334 |
+
parameter lpm_hint = "UNUSED";
|
| 335 |
+
|
| 336 |
+
input [width-1:0] datain;
|
| 337 |
+
input inclock;
|
| 338 |
+
input inclocken;
|
| 339 |
+
input aset;
|
| 340 |
+
input aclr;
|
| 341 |
+
input sset;
|
| 342 |
+
input sclr;
|
| 343 |
+
|
| 344 |
+
output [width-1:0] dataout_h;
|
| 345 |
+
output [width-1:0] dataout_l;
|
| 346 |
+
|
| 347 |
+
endmodule
|
| 348 |
+
|
| 349 |
+
|
| 350 |
+
(* blackbox *)
|
| 351 |
+
module altddio_out (
|
| 352 |
+
datain_h,
|
| 353 |
+
datain_l,
|
| 354 |
+
outclock,
|
| 355 |
+
outclocken,
|
| 356 |
+
aset,
|
| 357 |
+
aclr,
|
| 358 |
+
sset,
|
| 359 |
+
sclr,
|
| 360 |
+
oe,
|
| 361 |
+
dataout,
|
| 362 |
+
oe_out
|
| 363 |
+
);
|
| 364 |
+
|
| 365 |
+
parameter width = 1;
|
| 366 |
+
parameter power_up_high = "OFF";
|
| 367 |
+
parameter oe_reg = "UNUSED";
|
| 368 |
+
parameter extend_oe_disable = "UNUSED";
|
| 369 |
+
parameter intended_device_family = "Stratix";
|
| 370 |
+
parameter invert_output = "OFF";
|
| 371 |
+
parameter lpm_type = "altddio_out";
|
| 372 |
+
parameter lpm_hint = "UNUSED";
|
| 373 |
+
|
| 374 |
+
input [width-1:0] datain_h;
|
| 375 |
+
input [width-1:0] datain_l;
|
| 376 |
+
input outclock;
|
| 377 |
+
input outclocken;
|
| 378 |
+
input aset;
|
| 379 |
+
input aclr;
|
| 380 |
+
input sset;
|
| 381 |
+
input sclr;
|
| 382 |
+
input oe;
|
| 383 |
+
|
| 384 |
+
output [width-1:0] dataout;
|
| 385 |
+
output [width-1:0] oe_out;
|
| 386 |
+
|
| 387 |
+
endmodule
|
| 388 |
+
|
| 389 |
+
|
| 390 |
+
(* blackbox *)
|
| 391 |
+
module altddio_bidir (
|
| 392 |
+
datain_h,
|
| 393 |
+
datain_l,
|
| 394 |
+
inclock,
|
| 395 |
+
inclocken,
|
| 396 |
+
outclock,
|
| 397 |
+
outclocken,
|
| 398 |
+
aset,
|
| 399 |
+
aclr,
|
| 400 |
+
sset,
|
| 401 |
+
sclr,
|
| 402 |
+
oe,
|
| 403 |
+
dataout_h,
|
| 404 |
+
dataout_l,
|
| 405 |
+
combout,
|
| 406 |
+
oe_out,
|
| 407 |
+
dqsundelayedout,
|
| 408 |
+
padio
|
| 409 |
+
);
|
| 410 |
+
|
| 411 |
+
// GLOBAL PARAMETER DECLARATION
|
| 412 |
+
parameter width = 1; // required parameter
|
| 413 |
+
parameter power_up_high = "OFF";
|
| 414 |
+
parameter oe_reg = "UNUSED";
|
| 415 |
+
parameter extend_oe_disable = "UNUSED";
|
| 416 |
+
parameter implement_input_in_lcell = "UNUSED";
|
| 417 |
+
parameter invert_output = "OFF";
|
| 418 |
+
parameter intended_device_family = "Stratix";
|
| 419 |
+
parameter lpm_type = "altddio_bidir";
|
| 420 |
+
parameter lpm_hint = "UNUSED";
|
| 421 |
+
|
| 422 |
+
// INPUT PORT DECLARATION
|
| 423 |
+
input [width-1:0] datain_h;
|
| 424 |
+
input [width-1:0] datain_l;
|
| 425 |
+
input inclock;
|
| 426 |
+
input inclocken;
|
| 427 |
+
input outclock;
|
| 428 |
+
input outclocken;
|
| 429 |
+
input aset;
|
| 430 |
+
input aclr;
|
| 431 |
+
input sset;
|
| 432 |
+
input sclr;
|
| 433 |
+
input oe;
|
| 434 |
+
|
| 435 |
+
// OUTPUT PORT DECLARATION
|
| 436 |
+
output [width-1:0] dataout_h;
|
| 437 |
+
output [width-1:0] dataout_l;
|
| 438 |
+
output [width-1:0] combout;
|
| 439 |
+
output [width-1:0] oe_out;
|
| 440 |
+
output [width-1:0] dqsundelayedout;
|
| 441 |
+
// BIDIRECTIONAL PORT DECLARATION
|
| 442 |
+
inout [width-1:0] padio;
|
| 443 |
+
|
| 444 |
+
endmodule
|
| 445 |
+
|
| 446 |
+
|
| 447 |
+
(* blackbox *)
|
| 448 |
+
module altiobuf_in(datain, dataout);
|
| 449 |
+
|
| 450 |
+
parameter enable_bus_hold = "FALSE";
|
| 451 |
+
parameter use_differential_mode = "FALSE";
|
| 452 |
+
parameter number_of_channels = 1;
|
| 453 |
+
|
| 454 |
+
input [number_of_channels-1:0] datain;
|
| 455 |
+
output [number_of_channels-1:0] dataout;
|
| 456 |
+
|
| 457 |
+
endmodule
|
| 458 |
+
|
| 459 |
+
(* blackbox *)
|
| 460 |
+
module altiobuf_out(datain, dataout);
|
| 461 |
+
|
| 462 |
+
parameter enable_bus_hold = "FALSE";
|
| 463 |
+
parameter use_differential_mode = "FALSE";
|
| 464 |
+
parameter use_oe = "FALSE";
|
| 465 |
+
parameter number_of_channels = 1;
|
| 466 |
+
|
| 467 |
+
input [number_of_channels-1:0] datain;
|
| 468 |
+
output [number_of_channels-1:0] dataout;
|
| 469 |
+
|
| 470 |
+
endmodule
|
| 471 |
+
|
| 472 |
+
(* blackbox *)
|
| 473 |
+
module altiobuf_bidir(dataio, oe, datain, dataout);
|
| 474 |
+
|
| 475 |
+
parameter number_of_channels = 1;
|
| 476 |
+
parameter enable_bus_hold = "OFF";
|
| 477 |
+
|
| 478 |
+
inout [number_of_channels-1:0] dataio;
|
| 479 |
+
input [number_of_channels-1:0] datain;
|
| 480 |
+
output [number_of_channels-1:0] dataout;
|
| 481 |
+
input [number_of_channels-1:0] oe;
|
| 482 |
+
|
| 483 |
+
endmodule
|
| 484 |
+
|
| 485 |
+
(* blackbox *)
|
| 486 |
+
module altsyncram(clock0, clock1, address_a, data_a, rden_a, wren_a, byteena_a, q_a, addressstall_a, address_b, data_b, rden_b, wren_b, byteena_b, q_b, addressstall_b, clocken0, clocken1, clocken2, clocken3, aclr0, aclr1, eccstatus);
|
| 487 |
+
|
| 488 |
+
parameter lpm_type = "altsyncram";
|
| 489 |
+
parameter operation_mode = "dual_port";
|
| 490 |
+
parameter ram_block_type = "auto";
|
| 491 |
+
parameter intended_device_family = "auto";
|
| 492 |
+
parameter power_up_uninitialized = "false";
|
| 493 |
+
parameter read_during_write_mode_mixed_ports = "dontcare";
|
| 494 |
+
parameter byte_size = 8;
|
| 495 |
+
parameter widthad_a = 1;
|
| 496 |
+
parameter width_a = 1;
|
| 497 |
+
parameter width_byteena_a = 1;
|
| 498 |
+
parameter numwords_a = 1;
|
| 499 |
+
parameter clock_enable_input_a = "clocken0";
|
| 500 |
+
parameter widthad_b = 1;
|
| 501 |
+
parameter width_b = 1;
|
| 502 |
+
parameter numwords_b = 1;
|
| 503 |
+
parameter address_aclr_b = "aclr0";
|
| 504 |
+
parameter address_reg_b = "";
|
| 505 |
+
parameter outdata_aclr_b = "aclr0";
|
| 506 |
+
parameter outdata_reg_b = "";
|
| 507 |
+
parameter clock_enable_input_b = "clocken0";
|
| 508 |
+
parameter clock_enable_output_b = "clocken0";
|
| 509 |
+
|
| 510 |
+
input clock0, clock1;
|
| 511 |
+
input [widthad_a-1:0] address_a;
|
| 512 |
+
input [width_a-1:0] data_a;
|
| 513 |
+
input rden_a;
|
| 514 |
+
input wren_a;
|
| 515 |
+
input [(width_a/8)-1:0] byteena_a;
|
| 516 |
+
input addressstall_a;
|
| 517 |
+
|
| 518 |
+
output [width_a-1:0] q_a;
|
| 519 |
+
|
| 520 |
+
input wren_b;
|
| 521 |
+
input rden_b;
|
| 522 |
+
input [widthad_b-1:0] address_b;
|
| 523 |
+
input [width_b-1:0] data_b;
|
| 524 |
+
input [(width_b/8)-1:0] byteena_b;
|
| 525 |
+
input addressstall_b;
|
| 526 |
+
|
| 527 |
+
output [width_b-1:0] q_b;
|
| 528 |
+
|
| 529 |
+
input clocken0;
|
| 530 |
+
input clocken1;
|
| 531 |
+
input clocken2;
|
| 532 |
+
input clocken3;
|
| 533 |
+
|
| 534 |
+
input aclr0;
|
| 535 |
+
input aclr1;
|
| 536 |
+
|
| 537 |
+
output eccstatus;
|
| 538 |
+
|
| 539 |
+
endmodule
|
| 540 |
+
|
| 541 |
+
(* blackbox *)
|
| 542 |
+
module cyclonev_mlab_cell(portaaddr, portadatain, portbaddr, portbdataout, ena0, clk0, clk1);
|
| 543 |
+
|
| 544 |
+
parameter logical_ram_name = "";
|
| 545 |
+
parameter logical_ram_depth = 32;
|
| 546 |
+
parameter logical_ram_width = 20;
|
| 547 |
+
parameter mixed_port_feed_through_mode = "new";
|
| 548 |
+
parameter first_bit_number = 0;
|
| 549 |
+
parameter first_address = 0;
|
| 550 |
+
parameter last_address = 31;
|
| 551 |
+
parameter address_width = 5;
|
| 552 |
+
parameter data_width = 1;
|
| 553 |
+
parameter byte_enable_mask_width = 1;
|
| 554 |
+
parameter port_b_data_out_clock = "NONE";
|
| 555 |
+
parameter [639:0] mem_init0 = 640'b0;
|
| 556 |
+
|
| 557 |
+
input [address_width-1:0] portaaddr, portbaddr;
|
| 558 |
+
input [data_width-1:0] portadatain;
|
| 559 |
+
output [data_width-1:0] portbdataout;
|
| 560 |
+
input ena0, clk0, clk1;
|
| 561 |
+
|
| 562 |
+
endmodule
|
| 563 |
+
|
| 564 |
+
(* blackbox *)
|
| 565 |
+
module cyclonev_mac(ax, ay, resulta);
|
| 566 |
+
|
| 567 |
+
parameter ax_width = 9;
|
| 568 |
+
parameter signed_max = "true";
|
| 569 |
+
parameter ay_scan_in_width = 9;
|
| 570 |
+
parameter signed_may = "true";
|
| 571 |
+
parameter result_a_width = 18;
|
| 572 |
+
parameter operation_mode = "M9x9";
|
| 573 |
+
|
| 574 |
+
input [ax_width-1:0] ax;
|
| 575 |
+
input [ay_scan_in_width-1:0] ay;
|
| 576 |
+
output [result_a_width-1:0] resulta;
|
| 577 |
+
|
| 578 |
+
endmodule
|
| 579 |
+
|
| 580 |
+
(* blackbox *)
|
| 581 |
+
module cyclone10gx_mac(ax, ay, resulta);
|
| 582 |
+
|
| 583 |
+
parameter ax_width = 18;
|
| 584 |
+
parameter signed_max = "true";
|
| 585 |
+
parameter ay_scan_in_width = 18;
|
| 586 |
+
parameter signed_may = "true";
|
| 587 |
+
parameter result_a_width = 36;
|
| 588 |
+
parameter operation_mode = "M18X18_FULL";
|
| 589 |
+
|
| 590 |
+
input [ax_width-1:0] ax;
|
| 591 |
+
input [ay_scan_in_width-1:0] ay;
|
| 592 |
+
output [result_a_width-1:0] resulta;
|
| 593 |
+
|
| 594 |
+
endmodule
|
| 595 |
+
|
| 596 |
+
(* blackbox *)
|
| 597 |
+
module cyclonev_ram_block(portaaddr, portadatain, portawe, portbaddr, portbdataout, portbre, clk0);
|
| 598 |
+
|
| 599 |
+
parameter operation_mode = "dual_port";
|
| 600 |
+
parameter logical_ram_name = "";
|
| 601 |
+
parameter port_a_address_width = 10;
|
| 602 |
+
parameter port_a_data_width = 10;
|
| 603 |
+
parameter port_a_logical_ram_depth = 1024;
|
| 604 |
+
parameter port_a_logical_ram_width = 10;
|
| 605 |
+
parameter port_a_first_address = 0;
|
| 606 |
+
parameter port_a_last_address = 1023;
|
| 607 |
+
parameter port_a_first_bit_number = 0;
|
| 608 |
+
parameter port_b_address_width = 10;
|
| 609 |
+
parameter port_b_data_width = 10;
|
| 610 |
+
parameter port_b_logical_ram_depth = 1024;
|
| 611 |
+
parameter port_b_logical_ram_width = 10;
|
| 612 |
+
parameter port_b_first_address = 0;
|
| 613 |
+
parameter port_b_last_address = 1023;
|
| 614 |
+
parameter port_b_first_bit_number = 0;
|
| 615 |
+
parameter port_b_address_clock = "clock0";
|
| 616 |
+
parameter port_b_read_enable_clock = "clock0";
|
| 617 |
+
parameter mem_init0 = "";
|
| 618 |
+
parameter mem_init1 = "";
|
| 619 |
+
parameter mem_init2 = "";
|
| 620 |
+
parameter mem_init3 = "";
|
| 621 |
+
parameter mem_init4 = "";
|
| 622 |
+
|
| 623 |
+
input [port_a_address_width-1:0] portaaddr;
|
| 624 |
+
input [port_b_address_width-1:0] portbaddr;
|
| 625 |
+
input [port_a_data_width-1:0] portadatain;
|
| 626 |
+
output [port_b_data_width-1:0] portbdataout;
|
| 627 |
+
input clk0, portawe, portbre;
|
| 628 |
+
|
| 629 |
+
endmodule
|
| 630 |
+
|
| 631 |
+
(* blackbox *)
|
| 632 |
+
module cyclone10gx_io_ibuf(i, ibar, dynamicterminationcontrol, o);
|
| 633 |
+
|
| 634 |
+
parameter differential_mode ="false";
|
| 635 |
+
parameter bus_hold = "false";
|
| 636 |
+
parameter simulate_z_as = "Z";
|
| 637 |
+
parameter lpm_type = "cyclone10gx_io_ibuf";
|
| 638 |
+
|
| 639 |
+
(* iopad_external_pin *) input i;
|
| 640 |
+
(* iopad_external_pin *) input ibar;
|
| 641 |
+
input dynamicterminationcontrol;
|
| 642 |
+
output o;
|
| 643 |
+
|
| 644 |
+
endmodule
|
| 645 |
+
|
| 646 |
+
(* blackbox *)
|
| 647 |
+
module cyclone10gx_io_obuf(i, oe, dynamicterminationcontrol, seriesterminationcontrol, parallelterminationcontrol, devoe, o, obar);
|
| 648 |
+
|
| 649 |
+
parameter open_drain_output = "false";
|
| 650 |
+
parameter bus_hold = "false";
|
| 651 |
+
parameter shift_series_termination_control = "false";
|
| 652 |
+
parameter sim_dynamic_termination_control_is_connected = "false";
|
| 653 |
+
parameter lpm_type = "cyclone10gx_io_obuf";
|
| 654 |
+
|
| 655 |
+
input i;
|
| 656 |
+
input oe;
|
| 657 |
+
input devoe;
|
| 658 |
+
input dynamicterminationcontrol;
|
| 659 |
+
input [15:0] seriesterminationcontrol;
|
| 660 |
+
input [15:0] parallelterminationcontrol;
|
| 661 |
+
(* iopad_external_pin *) output o;
|
| 662 |
+
(* iopad_external_pin *) output obar;
|
| 663 |
+
|
| 664 |
+
endmodule
|
| 665 |
+
|
| 666 |
+
(* blackbox *)
|
| 667 |
+
module cyclonev_clkena(inclk, ena, enaout, outclk);
|
| 668 |
+
|
| 669 |
+
parameter clock_type = "auto";
|
| 670 |
+
parameter ena_register_mode = "always enabled";
|
| 671 |
+
parameter lpm_type = "cyclonev_clkena";
|
| 672 |
+
parameter ena_register_power_up = "high";
|
| 673 |
+
parameter disable_mode = "low";
|
| 674 |
+
parameter test_syn = "high";
|
| 675 |
+
|
| 676 |
+
input inclk;
|
| 677 |
+
input ena;
|
| 678 |
+
output enaout;
|
| 679 |
+
output outclk;
|
| 680 |
+
|
| 681 |
+
endmodule
|
| 682 |
+
|
| 683 |
+
(* blackbox *)
|
| 684 |
+
module cyclone10gx_clkena(inclk, ena, enaout, outclk);
|
| 685 |
+
|
| 686 |
+
parameter clock_type = "auto";
|
| 687 |
+
parameter ena_register_mode = "always enabled";
|
| 688 |
+
parameter lpm_type = "cyclone10gx_clkena";
|
| 689 |
+
parameter ena_register_power_up = "high";
|
| 690 |
+
parameter disable_mode = "low";
|
| 691 |
+
parameter test_syn = "high";
|
| 692 |
+
|
| 693 |
+
input inclk;
|
| 694 |
+
input ena;
|
| 695 |
+
output enaout;
|
| 696 |
+
output outclk;
|
| 697 |
+
|
| 698 |
+
endmodule
|
| 699 |
+
|
| 700 |
+
// Internal interfaces
|
| 701 |
+
(* keep *)
|
| 702 |
+
module cyclonev_oscillator(oscena, clkout, clkout1);
|
| 703 |
+
|
| 704 |
+
input oscena;
|
| 705 |
+
output clkout;
|
| 706 |
+
output clkout1;
|
| 707 |
+
|
| 708 |
+
endmodule
|
| 709 |
+
|
| 710 |
+
// HPS interfaces
|
| 711 |
+
(* keep *)
|
| 712 |
+
module cyclonev_hps_interface_mpu_general_purpose(gp_in, gp_out);
|
| 713 |
+
|
| 714 |
+
input [31:0] gp_in;
|
| 715 |
+
output [31:0] gp_out;
|
| 716 |
+
|
| 717 |
+
endmodule
|
chips/yosys/techlibs/intel_alm/common/mem_sim.v
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// The MLAB
|
| 2 |
+
// --------
|
| 3 |
+
// In addition to Logic Array Blocks (LABs) that contain ten Adaptive Logic
|
| 4 |
+
// Modules (ALMs, see alm_sim.v), the Cyclone V also contains
|
| 5 |
+
// Memory/Logic Array Blocks (MLABs) that can act as either ten ALMs, or utilise
|
| 6 |
+
// the memory the ALM uses to store the look-up table data for general usage,
|
| 7 |
+
// producing a 32 address by 20-bit block of memory. MLABs are spread out
|
| 8 |
+
// around the chip, so they can be placed near where they are needed, rather than
|
| 9 |
+
// being comparatively limited in placement for a deep but narrow memory such as
|
| 10 |
+
// the M10K memory block.
|
| 11 |
+
//
|
| 12 |
+
// MLABs are used mainly for shallow but wide memories, such as CPU register
|
| 13 |
+
// files (which have perhaps 32 registers that are comparatively wide (16/32-bit))
|
| 14 |
+
// or shift registers (by using the output of the Nth bit as input for the N+1th
|
| 15 |
+
// bit).
|
| 16 |
+
//
|
| 17 |
+
// For historical reasons a MISTRAL_MLAB cell represents a 32 address by 1-bit cell,
|
| 18 |
+
// and 20 of them represent a physical MLAB.
|
| 19 |
+
//
|
| 20 |
+
// How the MLAB works
|
| 21 |
+
// ------------------
|
| 22 |
+
// MLABs are poorly documented, so the following information is based mainly
|
| 23 |
+
// on the simulation model and my knowledge of how memories like these work.
|
| 24 |
+
// Additionally, note that the ports of MISTRAL_MLAB are the ones auto-generated
|
| 25 |
+
// by the Yosys `memory_bram` pass, and it doesn't make sense to me to use
|
| 26 |
+
// `techmap` just for the sake of renaming the cell ports.
|
| 27 |
+
//
|
| 28 |
+
// The MLAB can be initialised to any value.
|
| 29 |
+
//
|
| 30 |
+
// The MLAB takes in data from A1DATA at the rising edge of CLK1, and if A1EN
|
| 31 |
+
// is high, writes it to the address in A1ADDR. A1EN can therefore be used to
|
| 32 |
+
// conditionally write data to the MLAB.
|
| 33 |
+
//
|
| 34 |
+
// Simultaneously, the MLAB reads data from B1ADDR, and outputs it to B1DATA,
|
| 35 |
+
// asynchronous to CLK1 and ignoring A1EN. If a synchronous read is needed
|
| 36 |
+
// then the output can be fed to embedded flops.
|
| 37 |
+
|
| 38 |
+
// The vendor sim model outputs 'x for a very short period (a few
|
| 39 |
+
// combinational delta cycles) after each write. This has been omitted from
|
| 40 |
+
// the following model because it's very difficult to trigger this in practice
|
| 41 |
+
// as clock cycles will be much longer than any potential blip of 'x, so the
|
| 42 |
+
// model can be treated as always returning a defined result.
|
| 43 |
+
|
| 44 |
+
(* abc9_box, lib_whitebox *)
|
| 45 |
+
module MISTRAL_MLAB(input [4:0] A1ADDR, input A1DATA, A1EN,
|
| 46 |
+
(* clkbuf_sink *) input CLK1,
|
| 47 |
+
input [4:0] B1ADDR, output B1DATA);
|
| 48 |
+
|
| 49 |
+
reg [31:0] mem = 32'b0;
|
| 50 |
+
|
| 51 |
+
`ifdef cyclonev
|
| 52 |
+
specify
|
| 53 |
+
$setup(A1ADDR, posedge CLK1, 86);
|
| 54 |
+
$setup(A1DATA, posedge CLK1, 86);
|
| 55 |
+
$setup(A1EN, posedge CLK1, 86);
|
| 56 |
+
|
| 57 |
+
(B1ADDR[0] => B1DATA) = 487;
|
| 58 |
+
(B1ADDR[1] => B1DATA) = 475;
|
| 59 |
+
(B1ADDR[2] => B1DATA) = 382;
|
| 60 |
+
(B1ADDR[3] => B1DATA) = 284;
|
| 61 |
+
(B1ADDR[4] => B1DATA) = 96;
|
| 62 |
+
endspecify
|
| 63 |
+
`endif
|
| 64 |
+
|
| 65 |
+
always @(posedge CLK1)
|
| 66 |
+
if (A1EN) mem[A1ADDR] <= A1DATA;
|
| 67 |
+
|
| 68 |
+
assign B1DATA = mem[B1ADDR];
|
| 69 |
+
|
| 70 |
+
endmodule
|
| 71 |
+
|
| 72 |
+
// The M10K
|
| 73 |
+
// --------
|
| 74 |
+
// TODO
|
| 75 |
+
|
| 76 |
+
module MISTRAL_M10K(CLK1, A1ADDR, A1DATA, A1EN, B1ADDR, B1DATA, B1EN);
|
| 77 |
+
|
| 78 |
+
parameter INIT = 0;
|
| 79 |
+
|
| 80 |
+
parameter CFG_ABITS = 10;
|
| 81 |
+
parameter CFG_DBITS = 10;
|
| 82 |
+
|
| 83 |
+
(* clkbuf_sink *) input CLK1;
|
| 84 |
+
input [CFG_ABITS-1:0] A1ADDR, B1ADDR;
|
| 85 |
+
input [CFG_DBITS-1:0] A1DATA;
|
| 86 |
+
input A1EN, B1EN;
|
| 87 |
+
output reg [CFG_DBITS-1:0] B1DATA;
|
| 88 |
+
|
| 89 |
+
reg [2**CFG_ABITS * CFG_DBITS - 1 : 0] mem = INIT;
|
| 90 |
+
|
| 91 |
+
`ifdef cyclonev
|
| 92 |
+
specify
|
| 93 |
+
$setup(A1ADDR, posedge CLK1, 125);
|
| 94 |
+
$setup(A1DATA, posedge CLK1, 97);
|
| 95 |
+
$setup(A1EN, posedge CLK1, 140);
|
| 96 |
+
$setup(B1ADDR, posedge CLK1, 125);
|
| 97 |
+
$setup(B1EN, posedge CLK1, 161);
|
| 98 |
+
|
| 99 |
+
if (B1EN) (posedge CLK1 => (B1DATA : A1DATA)) = 1004;
|
| 100 |
+
endspecify
|
| 101 |
+
`endif
|
| 102 |
+
|
| 103 |
+
always @(posedge CLK1) begin
|
| 104 |
+
if (!A1EN)
|
| 105 |
+
mem[(A1ADDR + 1) * CFG_DBITS - 1 : A1ADDR * CFG_DBITS] <= A1DATA;
|
| 106 |
+
|
| 107 |
+
if (B1EN)
|
| 108 |
+
B1DATA <= mem[(B1ADDR + 1) * CFG_DBITS - 1 : B1ADDR * CFG_DBITS];
|
| 109 |
+
end
|
| 110 |
+
|
| 111 |
+
endmodule
|
chips/yosys/techlibs/intel_alm/common/misc_sim.v
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module MISTRAL_IB((* iopad_external_pin *) input PAD, output O);
|
| 2 |
+
assign O = PAD;
|
| 3 |
+
endmodule
|
| 4 |
+
|
| 5 |
+
module MISTRAL_OB((* iopad_external_pin *) output PAD, input I);
|
| 6 |
+
assign PAD = I;
|
| 7 |
+
endmodule
|
| 8 |
+
|
| 9 |
+
module MISTRAL_IO((* iopad_external_pin *) inout PAD, input I, input OE, output O);
|
| 10 |
+
assign PAD = OE ? I : 1'bz;
|
| 11 |
+
assign O = PAD;
|
| 12 |
+
endmodule
|
| 13 |
+
|
| 14 |
+
// Eventually, we should support clock enables and model them here too.
|
| 15 |
+
// For now, CLKENA is used as a basic entry point to global routing.
|
| 16 |
+
module MISTRAL_CLKBUF (
|
| 17 |
+
input A,
|
| 18 |
+
(* clkbuf_driver *) output Q
|
| 19 |
+
);
|
| 20 |
+
assign Q = A;
|
| 21 |
+
endmodule
|
chips/yosys/techlibs/intel_alm/cyclonev/cells_sim.v
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* yosys -- Yosys Open SYnthesis Suite
|
| 3 |
+
*
|
| 4 |
+
* Copyright (C) 2012 Claire Xenia Wolf <claire@yosyshq.com>
|
| 5 |
+
*
|
| 6 |
+
* Permission to use, copy, modify, and/or distribute this software for any
|
| 7 |
+
* purpose with or without fee is hereby granted, provided that the above
|
| 8 |
+
* copyright notice and this permission notice appear in all copies.
|
| 9 |
+
*
|
| 10 |
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
| 11 |
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
| 12 |
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
| 13 |
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 14 |
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 15 |
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
| 16 |
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
| 17 |
+
*
|
| 18 |
+
*/
|
| 19 |
+
module VCC (output V);
|
| 20 |
+
assign V = 1'b1;
|
| 21 |
+
endmodule // VCC
|
| 22 |
+
|
| 23 |
+
module GND (output G);
|
| 24 |
+
assign G = 1'b0;
|
| 25 |
+
endmodule // GND
|
| 26 |
+
|
| 27 |
+
/* Altera Cyclone V devices Input Buffer Primitive */
|
| 28 |
+
module cyclonev_io_ibuf
|
| 29 |
+
(output o,
|
| 30 |
+
(* iopad_external_pin *) input i,
|
| 31 |
+
(* iopad_external_pin *) input ibar,
|
| 32 |
+
input dynamicterminationcontrol);
|
| 33 |
+
|
| 34 |
+
parameter differential_mode = "false";
|
| 35 |
+
parameter bus_hold = "false";
|
| 36 |
+
parameter simulate_z_as = "Z";
|
| 37 |
+
parameter lpm_type = "cyclonev_io_ibuf";
|
| 38 |
+
|
| 39 |
+
assign o = i;
|
| 40 |
+
endmodule // cyclonev_io_ibuf
|
| 41 |
+
|
| 42 |
+
/* Altera Cyclone V devices Output Buffer Primitive */
|
| 43 |
+
module cyclonev_io_obuf
|
| 44 |
+
((* iopad_external_pin *) output o,
|
| 45 |
+
input i, oe, dynamicterminationcontrol,
|
| 46 |
+
input [15:0] seriesterminationcontrol, parallelterminationcontrol,
|
| 47 |
+
input devoe,
|
| 48 |
+
(* iopad_external_pin *) output obar);
|
| 49 |
+
|
| 50 |
+
parameter open_drain_output = "false";
|
| 51 |
+
parameter bus_hold = "false";
|
| 52 |
+
parameter shift_series_termination_control = "false";
|
| 53 |
+
parameter sim_dynamic_termination_control_is_connected = "false";
|
| 54 |
+
parameter lpm_type = "cyclonev_io_obuf";
|
| 55 |
+
|
| 56 |
+
assign o = oe ? i : 1'bz;
|
| 57 |
+
endmodule // cyclonev_io_obuf
|
| 58 |
+
|
| 59 |
+
/* Altera Cyclone V LUT Primitive */
|
| 60 |
+
module cyclonev_lcell_comb
|
| 61 |
+
(output combout, cout, sumout, shareout,
|
| 62 |
+
input dataa, datab, datac, datad,
|
| 63 |
+
input datae, dataf, datag, cin,
|
| 64 |
+
input sharein);
|
| 65 |
+
|
| 66 |
+
parameter lut_mask = 64'hFFFFFFFFFFFFFFFF;
|
| 67 |
+
parameter dont_touch = "off";
|
| 68 |
+
parameter lpm_type = "cyclonev_lcell_comb";
|
| 69 |
+
parameter shared_arith = "off";
|
| 70 |
+
parameter extended_lut = "off";
|
| 71 |
+
|
| 72 |
+
// Internal variables
|
| 73 |
+
// Sub mask for fragmented LUTs
|
| 74 |
+
wire [15:0] mask_a, mask_b, mask_c, mask_d;
|
| 75 |
+
// Independent output for fragmented LUTs
|
| 76 |
+
wire output_0, output_1, output_2, output_3;
|
| 77 |
+
// Extended mode uses mux to define the output
|
| 78 |
+
wire mux_0, mux_1;
|
| 79 |
+
// Input for hold the shared LUT mode value
|
| 80 |
+
wire shared_lut_alm;
|
| 81 |
+
|
| 82 |
+
// Simulation model of 4-input LUT
|
| 83 |
+
function lut4;
|
| 84 |
+
input [15:0] mask;
|
| 85 |
+
input dataa, datab, datac, datad;
|
| 86 |
+
reg [7:0] s3;
|
| 87 |
+
reg [3:0] s2;
|
| 88 |
+
reg [1:0] s1;
|
| 89 |
+
begin
|
| 90 |
+
s3 = datad ? mask[15:8] : mask[7:0];
|
| 91 |
+
s2 = datac ? s3[7:4] : s3[3:0];
|
| 92 |
+
s1 = datab ? s2[3:2] : s2[1:0];
|
| 93 |
+
lut4 = dataa ? s1[1] : s1[0];
|
| 94 |
+
end
|
| 95 |
+
endfunction // lut4
|
| 96 |
+
|
| 97 |
+
// Simulation model of 5-input LUT
|
| 98 |
+
function lut5;
|
| 99 |
+
input [31:0] mask; // wp-01003.pdf, page 3: "a 5-LUT can be built with two 4-LUTs and a multiplexer.
|
| 100 |
+
input dataa, datab, datac, datad, datae;
|
| 101 |
+
reg upper_lut_value;
|
| 102 |
+
reg lower_lut_value;
|
| 103 |
+
begin
|
| 104 |
+
upper_lut_value = lut4(mask[31:16], dataa, datab, datac, datad);
|
| 105 |
+
lower_lut_value = lut4(mask[15:0], dataa, datab, datac, datad);
|
| 106 |
+
lut5 = (datae) ? upper_lut_value : lower_lut_value;
|
| 107 |
+
end
|
| 108 |
+
endfunction // lut5
|
| 109 |
+
|
| 110 |
+
// Simulation model of 6-input LUT
|
| 111 |
+
function lut6;
|
| 112 |
+
input [63:0] mask;
|
| 113 |
+
input dataa, datab, datac, datad, datae, dataf;
|
| 114 |
+
reg upper_lut_value;
|
| 115 |
+
reg lower_lut_value;
|
| 116 |
+
reg out_0, out_1, out_2, out_3;
|
| 117 |
+
begin
|
| 118 |
+
upper_lut_value = lut5(mask[63:32], dataa, datab, datac, datad, datae);
|
| 119 |
+
lower_lut_value = lut5(mask[31:0], dataa, datab, datac, datad, datae);
|
| 120 |
+
lut6 = (dataf) ? upper_lut_value : lower_lut_value;
|
| 121 |
+
end
|
| 122 |
+
endfunction // lut6
|
| 123 |
+
|
| 124 |
+
assign {mask_a, mask_b, mask_c, mask_d} = {lut_mask[15:0], lut_mask[31:16], lut_mask[47:32], lut_mask[63:48]};
|
| 125 |
+
`ifdef ADVANCED_ALM
|
| 126 |
+
always @(*) begin
|
| 127 |
+
if(extended_lut == "on")
|
| 128 |
+
shared_lut_alm = datag;
|
| 129 |
+
else
|
| 130 |
+
shared_lut_alm = datac;
|
| 131 |
+
// Build the ALM behaviour
|
| 132 |
+
out_0 = lut4(mask_a, dataa, datab, datac, datad);
|
| 133 |
+
out_1 = lut4(mask_b, dataa, datab, shared_lut_alm, datad);
|
| 134 |
+
out_2 = lut4(mask_c, dataa, datab, datac, datad);
|
| 135 |
+
out_3 = lut4(mask_d, dataa, datab, shared_lut_alm, datad);
|
| 136 |
+
end
|
| 137 |
+
`else
|
| 138 |
+
`ifdef DEBUG
|
| 139 |
+
initial $display("Advanced ALM lut combine is not implemented yet");
|
| 140 |
+
`endif
|
| 141 |
+
`endif
|
| 142 |
+
endmodule // cyclonev_lcell_comb
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
/* Altera D Flip-Flop Primitive */
|
| 146 |
+
module dffeas
|
| 147 |
+
(output q,
|
| 148 |
+
input d, clk, clrn, prn, ena,
|
| 149 |
+
input asdata, aload, sclr, sload);
|
| 150 |
+
|
| 151 |
+
// Timing simulation is not covered
|
| 152 |
+
parameter power_up="dontcare";
|
| 153 |
+
parameter is_wysiwyg="false";
|
| 154 |
+
|
| 155 |
+
reg q_tmp;
|
| 156 |
+
wire reset;
|
| 157 |
+
reg [7:0] debug_net;
|
| 158 |
+
|
| 159 |
+
assign reset = (prn && sclr && ~clrn && ena);
|
| 160 |
+
assign q = q_tmp & 1'b1;
|
| 161 |
+
|
| 162 |
+
always @(posedge clk, posedge aload) begin
|
| 163 |
+
if(reset) q_tmp <= 0;
|
| 164 |
+
else q_tmp <= d;
|
| 165 |
+
end
|
| 166 |
+
assign q = q_tmp;
|
| 167 |
+
|
| 168 |
+
endmodule // dffeas
|