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/log.h"
25 struct FsmPass
: public Pass
{
26 FsmPass() : Pass("fsm", "extract and optimize finite state machines") { }
29 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
31 log(" fsm [options] [selection]\n");
33 log("This pass calls all the other fsm_* passes in a useful order. This performs\n");
34 log("FSM extraction and optimiziation. It also calls opt_clean as needed:\n");
36 log(" fsm_detect unless got option -nodetect\n");
37 log(" fsm_extract\n");
43 log(" fsm_expand if got option -expand\n");
44 log(" opt_clean if got option -expand\n");
45 log(" fsm_opt if got option -expand\n");
47 log(" fsm_recode unless got option -norecode\n");
51 log(" fsm_export if got option -export\n");
52 log(" fsm_map unless got option -nomap\n");
56 log(" -expand, -norecode, -export, -nomap\n");
57 log(" enable or disable passes as indicated above\n");
59 log(" -encoding tye\n");
60 log(" -fm_set_fsm_file file\n");
61 log(" passed through to fsm_recode pass\n");
64 virtual void execute(std::vector
<std::string
> args
, RTLIL::Design
*design
)
66 bool flag_nomap
= false;
67 bool flag_norecode
= false;
68 bool flag_nodetect
= false;
69 bool flag_expand
= false;
70 bool flag_export
= false;
71 std::string fm_set_fsm_file_opt
;
72 std::string encoding_opt
;
74 log_header("Executing FSM pass (extract and optimize FSM).\n");
78 for (argidx
= 1; argidx
< args
.size(); argidx
++) {
79 std::string arg
= args
[argidx
];
80 if (arg
== "-fm_set_fsm_file" && argidx
+1 < args
.size() && fm_set_fsm_file_opt
.empty()) {
81 fm_set_fsm_file_opt
= " -fm_set_fsm_file " + args
[++argidx
];
84 if (arg
== "-encoding" && argidx
+1 < args
.size() && fm_set_fsm_file_opt
.empty()) {
85 encoding_opt
= " -encoding " + args
[++argidx
];
88 if (arg
== "-nodetect") {
92 if (arg
== "-norecode") {
96 if (arg
== "-nomap") {
100 if (arg
== "-expand") {
104 if (arg
== "-export") {
110 extra_args(args
, argidx
, design
);
113 Pass::call(design
, "fsm_detect");
114 Pass::call(design
, "fsm_extract");
116 Pass::call(design
, "fsm_opt");
117 Pass::call(design
, "opt_clean");
118 Pass::call(design
, "fsm_opt");
121 Pass::call(design
, "fsm_expand");
122 Pass::call(design
, "opt_clean");
123 Pass::call(design
, "fsm_opt");
127 Pass::call(design
, "fsm_recode" + fm_set_fsm_file_opt
+ encoding_opt
);
128 Pass::call(design
, "fsm_info");
131 Pass::call(design
, "fsm_map");
134 Pass::call(design
, "fsm_export");