463971d41808c5cee48abc1ac2da40c24ba8f72f
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 SynthGreenPAK4Pass
: public Pass
{
38 SynthGreenPAK4Pass() : Pass("synth_greenpak4", "synthesis for GreenPAK4 FPGAs") { }
41 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
43 log(" synth_greenpak4 [options]\n");
45 log("This command runs synthesis for GreenPAK4 FPGAs. This work is experimental.\n");
47 log(" -top <module>\n");
48 log(" use the specified module as top module (default='top')\n");
50 log(" -part <part>\n");
51 log(" synthesize for the specified part. Valid values are SLG46140V,\n");
52 log(" SLG46620V, and SLG46621V (default).\n");
54 log(" -json <file>\n");
55 log(" write the design to the specified JSON file. writing of an output file\n");
56 log(" is omitted if this parameter is not specified.\n");
58 log(" -run <from_label>:<to_label>\n");
59 log(" only run the commands between the labels (see below). an empty\n");
60 log(" from label is synonymous to 'begin', and empty to label is\n");
61 log(" synonymous to the end of the command list.\n");
64 log(" do not flatten design before synthesis\n");
67 log(" run 'abc' with -dff option\n");
70 log("The following commands are executed by this synthesis command:\n");
73 log(" read_verilog -lib +/greenpak4/cells_sim.v\n");
74 log(" hierarchy -check -top <top>\n");
76 log(" flatten: (unless -noflatten)\n");
79 log(" tribuf -logic\n");
82 log(" synth -run coarse\n");
85 log(" greenpak4_counters\n");
87 log(" opt -fast -mux_undef -undriven -fine\n");
89 log(" opt -undriven -fine\n");
91 log(" dfflibmap -prepare -liberty +/greenpak4/gp_dff.lib\n");
93 log(" abc -dff (only if -retime)\n");
96 log(" nlutmap -luts 0,6,8,2 (for -part SLG46140V)\n");
97 log(" nlutmap -luts 0,8,16,2 (for -part SLG46620V)\n");
98 log(" nlutmap -luts 0,8,16,2 (for -part SLG46621V)\n");
101 log(" map_cells:\n");
102 log(" dfflibmap -liberty +/greenpak4/gp_dff.lib\n");
103 log(" techmap -map +/greenpak4/cells_map.v\n");
104 log(" dffinit -ff GP_DFF Q INIT\n");
105 log(" dffinit -ff GP_DFFR Q INIT\n");
106 log(" dffinit -ff GP_DFFS Q INIT\n");
107 log(" dffinit -ff GP_DFFSR Q INIT\n");
111 log(" hierarchy -check\n");
113 log(" check -noinit\n");
116 log(" splitnets (temporary workaround for gp4par parser limitation)\n");
117 log(" write_json <file-name>\n");
120 virtual void execute(std::vector
<std::string
> args
, RTLIL::Design
*design
)
122 std::string top_opt
= "-auto-top";
123 std::string part
= "SLG46621V";
124 std::string run_from
, run_to
;
125 std::string json_file
;
130 for (argidx
= 1; argidx
< args
.size(); argidx
++)
132 if (args
[argidx
] == "-top" && argidx
+1 < args
.size()) {
133 top_opt
= "-top " + args
[++argidx
];
136 if (args
[argidx
] == "-json" && argidx
+1 < args
.size()) {
137 json_file
= args
[++argidx
];
140 if (args
[argidx
] == "-part" && argidx
+1 < args
.size()) {
141 part
= args
[++argidx
];
144 if (args
[argidx
] == "-run" && argidx
+1 < args
.size()) {
145 size_t pos
= args
[argidx
+1].find(':');
146 if (pos
== std::string::npos
)
148 run_from
= args
[++argidx
].substr(0, pos
);
149 run_to
= args
[argidx
].substr(pos
+1);
152 if (args
[argidx
] == "-noflatten") {
156 if (args
[argidx
] == "-retime") {
162 extra_args(args
, argidx
, design
);
164 if (!design
->full_selection())
165 log_cmd_error("This comannd only operates on fully selected designs!\n");
167 if (part
!= "SLG46140V" && part
!= "SLG46620V" && part
!= "SLG46621V")
168 log_cmd_error("Invalid part name: '%s'\n", part
.c_str());
170 bool active
= run_from
.empty();
172 log_header(design
, "Executing SYNTH_GREENPAK4 pass.\n");
175 if (check_label(active
, run_from
, run_to
, "begin"))
177 Pass::call(design
, "read_verilog -lib +/greenpak4/cells_sim.v");
178 Pass::call(design
, stringf("hierarchy -check %s", top_opt
.c_str()));
181 if (flatten
&& check_label(active
, run_from
, run_to
, "flatten"))
183 Pass::call(design
, "proc");
184 Pass::call(design
, "flatten");
185 Pass::call(design
, "tribuf -logic");
188 if (check_label(active
, run_from
, run_to
, "coarse"))
190 Pass::call(design
, "synth -run coarse");
193 if (check_label(active
, run_from
, run_to
, "fine"))
195 Pass::call(design
, "greenpak4_counters");
196 Pass::call(design
, "clean");
197 Pass::call(design
, "opt -fast -mux_undef -undriven -fine");
198 Pass::call(design
, "memory_map");
199 Pass::call(design
, "opt -undriven -fine");
200 Pass::call(design
, "techmap");
201 Pass::call(design
, "dfflibmap -prepare -liberty +/greenpak4/gp_dff.lib");
202 Pass::call(design
, "opt -fast");
204 Pass::call(design
, "abc -dff");
207 if (check_label(active
, run_from
, run_to
, "map_luts"))
209 if (part
== "SLG46140V") Pass::call(design
, "nlutmap -luts 0,6,8,2");
210 if (part
== "SLG46620V") Pass::call(design
, "nlutmap -luts 2,8,16,2");
211 if (part
== "SLG46621V") Pass::call(design
, "nlutmap -luts 2,8,16,2");
212 Pass::call(design
, "clean");
215 if (check_label(active
, run_from
, run_to
, "map_cells"))
217 Pass::call(design
, "dfflibmap -liberty +/greenpak4/gp_dff.lib");
218 Pass::call(design
, "techmap -map +/greenpak4/cells_map.v");
219 Pass::call(design
, "dffinit -ff GP_DFF Q INIT");
220 Pass::call(design
, "dffinit -ff GP_DFFR Q INIT");
221 Pass::call(design
, "dffinit -ff GP_DFFS Q INIT");
222 Pass::call(design
, "dffinit -ff GP_DFFSR Q INIT");
223 Pass::call(design
, "clean");
226 if (check_label(active
, run_from
, run_to
, "check"))
228 Pass::call(design
, "hierarchy -check");
229 Pass::call(design
, "stat");
230 Pass::call(design
, "check -noinit");
233 if (check_label(active
, run_from
, run_to
, "json"))
235 Pass::call(design
, "splitnets");
236 if (!json_file
.empty())
237 Pass::call(design
, stringf("write_json %s", json_file
.c_str()));
242 } SynthGreenPAK4Pass
;
244 PRIVATE_NAMESPACE_END