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"
26 PRIVATE_NAMESPACE_BEGIN
28 struct MemoryPass
: public Pass
{
29 MemoryPass() : Pass("memory", "translate memories to basic cells") { }
30 void help() YS_OVERRIDE
32 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
34 log(" memory [-nomap] [-nordff] [-memx] [-bram <bram_rules>] [selection]\n");
36 log("This pass calls all the other memory_* passes in a useful order:\n");
38 log(" memory_dff [-nordff] (-memx implies -nordff)\n");
40 log(" memory_share\n");
42 log(" memory_memx (when called with -memx)\n");
43 log(" memory_collect\n");
44 log(" memory_bram -rules <bram_rules> (when called with -bram)\n");
45 log(" memory_map (skipped if called with -nomap)\n");
47 log("This converts memories to word-wide DFFs and address decoders\n");
48 log("or multiport memory blocks if called with the -nomap option.\n");
51 void execute(std::vector
<std::string
> args
, RTLIL::Design
*design
) YS_OVERRIDE
53 bool flag_nomap
= false;
54 bool flag_nordff
= false;
55 bool flag_memx
= false;
56 string memory_bram_opts
;
58 log_header(design
, "Executing MEMORY pass.\n");
62 for (argidx
= 1; argidx
< args
.size(); argidx
++) {
63 if (args
[argidx
] == "-nomap") {
67 if (args
[argidx
] == "-nordff") {
71 if (args
[argidx
] == "-memx") {
76 if (argidx
+1 < args
.size() && args
[argidx
] == "-bram") {
77 memory_bram_opts
+= " -rules " + args
[++argidx
];
82 extra_args(args
, argidx
, design
);
84 Pass::call(design
, flag_nordff
? "memory_dff -nordff" : "memory_dff");
85 Pass::call(design
, "opt_clean");
86 Pass::call(design
, "memory_share");
88 Pass::call(design
, "memory_memx");
89 Pass::call(design
, "opt_clean");
90 Pass::call(design
, "memory_collect");
92 if (!memory_bram_opts
.empty())
93 Pass::call(design
, "memory_bram" + memory_bram_opts
);
96 Pass::call(design
, "memory_map");
102 PRIVATE_NAMESPACE_END