2 * yosys -- Yosys Open SYnthesis Suite
4 * Copyright (C) 2012 Clifford Wolf <clifford@clifford.at>
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 bool check_label(bool &active
, std::string run_from
, std::string run_to
, std::string label
)
30 if (label
== run_from
)
37 struct SynthXilinxPass
: public Pass
{
38 SynthXilinxPass() : Pass("synth_xilinx", "synthesis for Xilinx FPGAs") { }
41 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
43 log(" synth_xilinx [options]\n");
45 log("This command runs synthesis for Xilinx FPGAs. This command does not operate on\n");
46 log("partly selected designs.\n");
48 log(" -top <module>\n");
49 log(" use the specified module as top module (default='top')\n");
51 log(" -arch <arch>\n");
52 log(" select architecture. the following architectures are supported:\n");
53 log(" spartan6 (default), artix7, kintex7, virtex7, zynq7000\n");
54 log(" (this parameter is not used by the command at the moment)\n");
56 log(" -edif <file>\n");
57 log(" write the design to the specified edif file. writing of an output file\n");
58 log(" is omitted if this parameter is not specified.\n");
60 log(" -run <from_label>:<to_label>\n");
61 log(" only run the commands between the labels (see below). an empty\n");
62 log(" from label is synonymous to 'begin', and empty to label is\n");
63 log(" synonymous to the end of the command list.\n");
66 log("The following commands are executed by this synthesis command:\n");
69 log(" hierarchy -check -top <top>\n");
72 log(" synth -run coarse\n");
73 log(" memory_bram -rules +/xilinx/brams.txt\n");
74 log(" techmap -map +/xilinx/brams.v\n");
77 log(" synth -run fine\n");
84 log(" techmap -map +/xilinx/cells.v\n");
89 log(" opt -fast -full\n");
92 log(" select -set xilinx_clocks <top>/t:FDRE %%x:+FDRE[C] <top>/t:FDRE %%d\n");
93 log(" iopadmap -bits -inpad BUFGP O:I @xilinx_clocks\n");
96 log(" select -set xilinx_nonclocks <top>/w:* <top>/t:BUFGP %%x:+BUFGP[I] %%d\n");
97 log(" iopadmap -bits -outpad OBUF I:O -inpad IBUF O:I @xilinx_nonclocks\n");
100 log(" write_edif synth.edif\n");
103 virtual void execute(std::vector
<std::string
> args
, RTLIL::Design
*design
)
105 std::string top_module
= "top";
106 std::string arch_name
= "spartan6";
107 std::string edif_file
;
108 std::string run_from
, run_to
;
111 for (argidx
= 1; argidx
< args
.size(); argidx
++)
113 if (args
[argidx
] == "-top" && argidx
+1 < args
.size()) {
114 top_module
= args
[++argidx
];
117 if (args
[argidx
] == "-arch" && argidx
+1 < args
.size()) {
118 arch_name
= args
[++argidx
];
121 if (args
[argidx
] == "-edif" && argidx
+1 < args
.size()) {
122 edif_file
= args
[++argidx
];
125 if (args
[argidx
] == "-run" && argidx
+1 < args
.size()) {
126 size_t pos
= args
[argidx
+1].find(':');
127 if (pos
== std::string::npos
)
129 run_from
= args
[++argidx
].substr(0, pos
);
130 run_to
= args
[argidx
].substr(pos
+1);
135 extra_args(args
, argidx
, design
);
137 if (!design
->full_selection())
138 log_cmd_error("This comannd only operates on fully selected designs!\n");
140 if (arch_name
== "spartan6") {
143 if (arch_name
== "artix7") {
146 if (arch_name
== "kintex7") {
149 if (arch_name
== "zynq7000") {
152 log_cmd_error("Architecture '%s' is not supported!\n", arch_name
.c_str());
154 bool active
= run_from
.empty();
156 log_header("Executing SYNTH_XILINX pass.\n");
159 if (check_label(active
, run_from
, run_to
, "begin"))
161 Pass::call(design
, stringf("hierarchy -check -top %s", top_module
.c_str()));
164 if (check_label(active
, run_from
, run_to
, "coarse"))
166 Pass::call(design
, "synth -run coarse");
167 Pass::call(design
, "memory_bram -rules +/xilinx/brams.txt");
168 Pass::call(design
, "techmap -map +/xilinx/brams.v");
171 if (check_label(active
, run_from
, run_to
, "fine"))
173 Pass::call(design
, "synth -run fine");
176 if (check_label(active
, run_from
, run_to
, "map_luts"))
178 Pass::call(design
, "abc -lut 6");
179 Pass::call(design
, "clean");
182 if (check_label(active
, run_from
, run_to
, "map_cells"))
184 Pass::call(design
, "techmap -map +/xilinx/cells.v");
185 Pass::call(design
, "clean");
188 if (check_label(active
, run_from
, run_to
, "flatten"))
190 Pass::call(design
, "flatten");
191 Pass::call(design
, "opt -fast -full");
194 if (check_label(active
, run_from
, run_to
, "clkbuf"))
196 Pass::call(design
, stringf("select -set xilinx_clocks %s/t:FDRE %%x:+FDRE[C] %s/t:FDRE %%d", top_module
.c_str(), top_module
.c_str()));
197 Pass::call(design
, "iopadmap -bits -inpad BUFGP O:I @xilinx_clocks");
200 if (check_label(active
, run_from
, run_to
, "iobuf"))
202 Pass::call(design
, stringf("select -set xilinx_nonclocks %s/w:* %s/t:BUFGP %%x:+BUFGP[I] %%d", top_module
.c_str(), top_module
.c_str()));
203 Pass::call(design
, "iopadmap -bits -outpad OBUF I:O -inpad IBUF O:I @xilinx_nonclocks");
206 if (check_label(active
, run_from
, run_to
, "edif"))
208 if (!edif_file
.empty())
209 Pass::call(design
, stringf("write_edif %s", edif_file
.c_str()));
216 PRIVATE_NAMESPACE_END