fd7a8567a05c9e2b5aa4cb954ab10548fc3980f0
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 struct SynthGreenPAK4Pass
: public ScriptPass
30 SynthGreenPAK4Pass() : ScriptPass("synth_greenpak4", "synthesis for GreenPAK4 FPGAs") { }
32 virtual void help() YS_OVERRIDE
34 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
36 log(" synth_greenpak4 [options]\n");
38 log("This command runs synthesis for GreenPAK4 FPGAs. This work is experimental.\n");
40 log(" -top <module>\n");
41 log(" use the specified module as top module (default='top')\n");
43 log(" -part <part>\n");
44 log(" synthesize for the specified part. Valid values are SLG46140V,\n");
45 log(" SLG46620V, and SLG46621V (default).\n");
47 log(" -json <file>\n");
48 log(" write the design to the specified JSON file. writing of an output file\n");
49 log(" is omitted if this parameter is not specified.\n");
51 log(" -run <from_label>:<to_label>\n");
52 log(" only run the commands between the labels (see below). an empty\n");
53 log(" from label is synonymous to 'begin', and empty to label is\n");
54 log(" synonymous to the end of the command list.\n");
57 log(" do not flatten design before synthesis\n");
60 log(" run 'abc' with -dff option\n");
63 log("The following commands are executed by this synthesis command:\n");
68 string top_opt
, part
, json_file
;
71 virtual void clear_flags() YS_OVERRIDE
73 top_opt
= "-auto-top";
80 virtual void execute(std::vector
<std::string
> args
, RTLIL::Design
*design
) YS_OVERRIDE
82 string run_from
, run_to
;
86 for (argidx
= 1; argidx
< args
.size(); argidx
++)
88 if (args
[argidx
] == "-top" && argidx
+1 < args
.size()) {
89 top_opt
= "-top " + args
[++argidx
];
92 if (args
[argidx
] == "-json" && argidx
+1 < args
.size()) {
93 json_file
= args
[++argidx
];
96 if (args
[argidx
] == "-part" && argidx
+1 < args
.size()) {
97 part
= args
[++argidx
];
100 if (args
[argidx
] == "-run" && argidx
+1 < args
.size()) {
101 size_t pos
= args
[argidx
+1].find(':');
102 if (pos
== std::string::npos
)
104 run_from
= args
[++argidx
].substr(0, pos
);
105 run_to
= args
[argidx
].substr(pos
+1);
108 if (args
[argidx
] == "-noflatten") {
112 if (args
[argidx
] == "-retime") {
118 extra_args(args
, argidx
, design
);
120 if (!design
->full_selection())
121 log_cmd_error("This comannd only operates on fully selected designs!\n");
123 if (part
!= "SLG46140V" && part
!= "SLG46620V" && part
!= "SLG46621V")
124 log_cmd_error("Invalid part name: '%s'\n", part
.c_str());
126 log_header(design
, "Executing SYNTH_GREENPAK4 pass.\n");
129 run_script(design
, run_from
, run_to
);
134 virtual void script() YS_OVERRIDE
136 if (check_label("begin"))
138 run("read_verilog -lib +/greenpak4/cells_sim.v");
139 run(stringf("hierarchy -check %s", help_mode
? "-top <top>" : top_opt
.c_str()));
142 if (flatten
&& check_label("flatten", "(unless -noflatten)"))
146 run("tribuf -logic");
149 if (check_label("coarse"))
151 run("synth -run coarse");
154 if (check_label("fine"))
156 run("greenpak4_counters");
158 run("opt -fast -mux_undef -undriven -fine");
160 run("opt -undriven -fine");
162 run("dfflibmap -prepare -liberty +/greenpak4/gp_dff.lib");
164 if (retime
|| help_mode
)
165 run("abc -dff", "(only if -retime)");
168 if (check_label("map_luts"))
170 if (help_mode
|| part
== "SLG46140V") run("nlutmap -luts 0,6,8,2", " (for -part SLG46140V)");
171 if (help_mode
|| part
== "SLG46620V") run("nlutmap -luts 2,8,16,2", "(for -part SLG46620V)");
172 if (help_mode
|| part
== "SLG46621V") run("nlutmap -luts 2,8,16,2", "(for -part SLG46621V)");
176 if (check_label("map_cells"))
178 run("shregmap -tech greenpak4");
179 run("iopadmap -bits -inpad GP_IBUF OUT:IN -outpad GP_OBUF IN:OUT -inoutpad GP_OBUF OUT:IN -toutpad GP_OBUFT OE:IN:OUT -tinoutpad GP_IOBUF OE:OUT:IN:IO");
180 run("dfflibmap -liberty +/greenpak4/gp_dff.lib");
181 run("techmap -map +/greenpak4/cells_map.v");
182 run("dffinit -ff GP_DFF Q INIT");
183 run("dffinit -ff GP_DFFR Q INIT");
184 run("dffinit -ff GP_DFFS Q INIT");
185 run("dffinit -ff GP_DFFSR Q INIT");
189 if (check_label("check"))
191 run("hierarchy -check");
193 run("check -noinit");
196 if (check_label("json"))
198 run("splitnets;;", "(temporary workaround for gp4par parser limitation)");
199 if (!json_file
.empty() || help_mode
)
200 run(stringf("write_json %s", help_mode
? "<file-name>" : json_file
.c_str()));
205 } SynthGreenPAK4Pass
;
207 PRIVATE_NAMESPACE_END