c9ab23426780db3592776fc7c805f98986c62f43
2 * yosys -- Yosys Open SYnthesis Suite
4 * Copyright (C) 2020 William D. Jones <wjones@wdj-consulting.com>
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.
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.
20 #include "kernel/register.h"
21 #include "kernel/celltypes.h"
22 #include "kernel/rtlil.h"
23 #include "kernel/log.h"
26 PRIVATE_NAMESPACE_BEGIN
28 struct SynthMachXO2Pass
: public ScriptPass
30 SynthMachXO2Pass() : ScriptPass("synth_machxo2", "synthesis for MachXO2 FPGAs") { }
34 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
36 log(" synth_machxo2 [options]\n");
38 log("This command runs synthesis for MachXO2 FPGAs.\n");
40 log(" -top <module>\n");
41 log(" use the specified module as top module\n");
43 log(" -blif <file>\n");
44 log(" write the design to the specified BLIF file. writing of an output file\n");
45 log(" is omitted if this parameter is not specified.\n");
47 log(" -edif <file>\n");
48 log(" write the design to the specified EDIF file. writing of an output file\n");
49 log(" is omitted if this parameter is not specified.\n");
51 log(" -json <file>\n");
52 log(" write the design to the specified JSON file. writing of an output file\n");
53 log(" is omitted if this parameter is not specified.\n");
55 log(" -run <from_label>:<to_label>\n");
56 log(" only run the commands between the labels (see below). an empty\n");
57 log(" from label is synonymous to 'begin', and empty to label is\n");
58 log(" synonymous to the end of the command list.\n");
61 log(" do not flatten design before synthesis\n");
64 log(" do not insert IO buffers\n");
67 log(" generate an output netlist (and BLIF file) suitable for VPR\n");
68 log(" (this feature is experimental and incomplete)\n");
71 log("The following commands are executed by this synthesis command:\n");
76 string top_opt
, blif_file
, edif_file
, json_file
;
77 bool flatten
, vpr
, noiopad
;
79 void clear_flags() override
81 top_opt
= "-auto-top";
90 void execute(std::vector
<std::string
> args
, RTLIL::Design
*design
) override
92 string run_from
, run_to
;
96 for (argidx
= 1; argidx
< args
.size(); argidx
++)
98 if (args
[argidx
] == "-top" && argidx
+1 < args
.size()) {
99 top_opt
= "-top " + args
[++argidx
];
102 if (args
[argidx
] == "-blif" && argidx
+1 < args
.size()) {
103 blif_file
= args
[++argidx
];
106 if (args
[argidx
] == "-edif" && argidx
+1 < args
.size()) {
107 edif_file
= args
[++argidx
];
110 if (args
[argidx
] == "-json" && argidx
+1 < args
.size()) {
111 json_file
= args
[++argidx
];
114 if (args
[argidx
] == "-run" && argidx
+1 < args
.size()) {
115 size_t pos
= args
[argidx
+1].find(':');
116 if (pos
== std::string::npos
)
118 run_from
= args
[++argidx
].substr(0, pos
);
119 run_to
= args
[argidx
].substr(pos
+1);
122 if (args
[argidx
] == "-flatten") {
126 if (args
[argidx
] == "-noflatten") {
130 if (args
[argidx
] == "-noiopad") {
134 if (args
[argidx
] == "-vpr") {
140 extra_args(args
, argidx
, design
);
142 if (!design
->full_selection())
143 log_cmd_error("This command only operates on fully selected designs!\n");
145 log_header(design
, "Executing SYNTH_MACHXO2 pass.\n");
148 run_script(design
, run_from
, run_to
);
153 void script() override
155 if (check_label("begin"))
157 run("read_verilog -lib +/machxo2/cells_sim.v");
158 run(stringf("hierarchy -check %s", help_mode
? "-top <top>" : top_opt
.c_str()));
161 if (check_label("flatten", "(unless -noflatten)"))
166 run("tribuf -logic");
171 if (check_label("coarse"))
173 run("synth -run coarse");
176 if (check_label("fine"))
180 run("techmap -map +/techmap.v");
184 if (check_label("map_ios"))
186 if (!noiopad
|| help_mode
)
187 run("iopadmap -bits -outpad $__FACADE_OUTPAD I:O -inpad $__FACADE_INPAD O:I -toutpad $__FACADE_TOUTPAD OE:I:O -tinoutpad $__FACADE_TINOUTPAD OE:O:I:B A:top", "(skip if '-noiopad')");
190 if (check_label("map_ffs"))
192 run("dfflegalize -cell $_DFF_P_ 0");
195 if (check_label("map_luts"))
197 run("abc -lut 4 -dress");
201 if (check_label("map_cells"))
203 run("techmap -map +/machxo2/cells_map.v");
207 if (check_label("check"))
209 run("hierarchy -check");
213 if (check_label("blif"))
215 if (!blif_file
.empty() || help_mode
) {
216 if (vpr
|| help_mode
) {
217 run(stringf("opt_clean -purge"),
219 run(stringf("write_blif -attr -cname -conn -param %s",
220 help_mode
? "<file-name>" : blif_file
.c_str()),
224 run(stringf("write_blif -gates -attr -param %s",
225 help_mode
? "<file-name>" : blif_file
.c_str()),
230 if (check_label("edif"))
232 if (!edif_file
.empty() || help_mode
)
233 run(stringf("write_edif %s", help_mode
? "<file-name>" : edif_file
.c_str()));
236 if (check_label("json"))
238 if (!json_file
.empty() || help_mode
)
239 run(stringf("write_json %s", help_mode
? "<file-name>" : json_file
.c_str()));
244 PRIVATE_NAMESPACE_END