yosys-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
memory.cc
Go to the documentation of this file.
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 
27 
28 struct MemoryPass : public Pass {
29  MemoryPass() : Pass("memory", "translate memories to basic cells") { }
30  virtual void help()
31  {
32  // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
33  log("\n");
34  log(" memory [-nomap] [selection]\n");
35  log("\n");
36  log("This pass calls all the other memory_* passes in a useful order:\n");
37  log("\n");
38  log(" memory_dff\n");
39  log(" opt_clean\n");
40  log(" memory_share\n");
41  log(" opt_clean\n");
42  log(" memory_collect\n");
43  log(" memory_map (skipped if called with -nomap)\n");
44  log("\n");
45  log("This converts memories to word-wide DFFs and address decoders\n");
46  log("or multiport memory blocks if called with the -nomap option.\n");
47  log("\n");
48  }
49  virtual void execute(std::vector<std::string> args, RTLIL::Design *design)
50  {
51  bool flag_nomap = false;
52 
53  log_header("Executing MEMORY pass.\n");
54  log_push();
55 
56  size_t argidx;
57  for (argidx = 1; argidx < args.size(); argidx++) {
58  if (args[argidx] == "-nomap") {
59  flag_nomap = true;
60  continue;
61  }
62  break;
63  }
64  extra_args(args, argidx, design);
65 
66  Pass::call(design, "memory_dff");
67  Pass::call(design, "opt_clean");
68  Pass::call(design, "memory_share");
69  Pass::call(design, "opt_clean");
70  Pass::call(design, "memory_collect");
71 
72  if (!flag_nomap)
73  Pass::call(design, "memory_map");
74 
75  log_pop();
76  }
77 } MemoryPass;
78 
void log_header(const char *format,...)
Definition: log.cc:188
void log_pop()
Definition: log.cc:237
virtual void help()
Definition: memory.cc:30
virtual void execute(std::vector< std::string > args, RTLIL::Design *design)
Definition: memory.cc:49
#define PRIVATE_NAMESPACE_BEGIN
Definition: yosys.h:97
#define PRIVATE_NAMESPACE_END
Definition: yosys.h:98
Definition: register.h:27
MemoryPass()
Definition: memory.cc:29
#define USING_YOSYS_NAMESPACE
Definition: yosys.h:102
void log(const char *format,...)
Definition: log.cc:180
void log_push()
Definition: log.cc:232
void extra_args(std::vector< std::string > args, size_t argidx, RTLIL::Design *design, bool select=true)
Definition: register.cc:128
static void call(RTLIL::Design *design, std::string command)
Definition: register.cc:146
MemoryPass MemoryPass