Merge pull request #1309 from whitequark/proc_clean-fix-1268
[yosys.git] / passes / proc / proc.cc
1 /*
2 * yosys -- Yosys Open SYnthesis Suite
3 *
4 * Copyright (C) 2012 Clifford Wolf <clifford@clifford.at>
5 *
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.
9 *
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.
17 *
18 */
19
20 #include "kernel/register.h"
21 #include "kernel/log.h"
22 #include <stdlib.h>
23 #include <stdio.h>
24
25 USING_YOSYS_NAMESPACE
26 PRIVATE_NAMESPACE_BEGIN
27
28 struct ProcPass : public Pass {
29 ProcPass() : Pass("proc", "translate processes to netlists") { }
30 void help() YS_OVERRIDE
31 {
32 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
33 log("\n");
34 log(" proc [options] [selection]\n");
35 log("\n");
36 log("This pass calls all the other proc_* passes in the most common order.\n");
37 log("\n");
38 log(" proc_clean\n");
39 log(" proc_rmdead\n");
40 log(" proc_prune\n");
41 log(" proc_init\n");
42 log(" proc_arst\n");
43 log(" proc_mux\n");
44 log(" proc_dlatch\n");
45 log(" proc_dff\n");
46 log(" proc_clean\n");
47 log("\n");
48 log("This replaces the processes in the design with multiplexers,\n");
49 log("flip-flops and latches.\n");
50 log("\n");
51 log("The following options are supported:\n");
52 log("\n");
53 log(" -global_arst [!]<netname>\n");
54 log(" This option is passed through to proc_arst.\n");
55 log("\n");
56 log(" -ifx\n");
57 log(" This option is passed through to proc_mux. proc_rmdead is not\n");
58 log(" executed in -ifx mode.\n");
59 log("\n");
60 }
61 void execute(std::vector<std::string> args, RTLIL::Design *design) YS_OVERRIDE
62 {
63 std::string global_arst;
64 bool ifxmode = false;
65
66 log_header(design, "Executing PROC pass (convert processes to netlists).\n");
67 log_push();
68
69 size_t argidx;
70 for (argidx = 1; argidx < args.size(); argidx++)
71 {
72 if (args[argidx] == "-global_arst" && argidx+1 < args.size()) {
73 global_arst = args[++argidx];
74 continue;
75 }
76 if (args[argidx] == "-ifx") {
77 ifxmode = true;
78 continue;
79 }
80 break;
81 }
82 extra_args(args, argidx, design);
83
84 Pass::call(design, "proc_clean");
85 if (!ifxmode)
86 Pass::call(design, "proc_rmdead");
87 Pass::call(design, "proc_prune");
88 Pass::call(design, "proc_init");
89 if (global_arst.empty())
90 Pass::call(design, "proc_arst");
91 else
92 Pass::call(design, "proc_arst -global_arst " + global_arst);
93 Pass::call(design, ifxmode ? "proc_mux -ifx" : "proc_mux");
94 Pass::call(design, "proc_dlatch");
95 Pass::call(design, "proc_dff");
96 Pass::call(design, "proc_clean");
97
98 log_pop();
99 }
100 } ProcPass;
101
102 PRIVATE_NAMESPACE_END