yosys-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
scatter.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/celltypes.h"
22 #include "kernel/rtlil.h"
23 #include "kernel/log.h"
24 
27 
28 struct ScatterPass : public Pass {
29  ScatterPass() : Pass("scatter", "add additional intermediate nets") { }
30  virtual void help()
31  {
32  // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
33  log("\n");
34  log(" scatter [selection]\n");
35  log("\n");
36  log("This command adds additional intermediate nets on all cell ports. This is used\n");
37  log("for testing the correct use of the SigMap helper in passes. If you don't know\n");
38  log("what this means: don't worry -- you only need this pass when testing your own\n");
39  log("extensions to Yosys.\n");
40  log("\n");
41  log("Use the opt_clean command to get rid of the additional nets.\n");
42  log("\n");
43  }
44  virtual void execute(std::vector<std::string> args, RTLIL::Design *design)
45  {
46  CellTypes ct(design);
47  extra_args(args, 1, design);
48 
49  for (auto &mod_it : design->modules_)
50  {
51  if (!design->selected(mod_it.second))
52  continue;
53 
54  for (auto &c : mod_it.second->cells_)
55  for (auto &p : c.second->connections_)
56  {
57  RTLIL::Wire *wire = mod_it.second->addWire(NEW_ID, p.second.size());
58 
59  if (ct.cell_output(c.second->type, p.first)) {
60  RTLIL::SigSig sigsig(p.second, wire);
61  mod_it.second->connect(sigsig);
62  } else {
63  RTLIL::SigSig sigsig(wire, p.second);
64  mod_it.second->connect(sigsig);
65  }
66 
67  p.second = wire;
68  }
69  }
70  }
71 } ScatterPass;
72 
bool selected(T1 *module) const
Definition: rtlil.h:551
ScatterPass ScatterPass
virtual void help()
Definition: scatter.cc:30
CellTypes ct
Definition: opt_clean.cc:33
ScatterPass()
Definition: scatter.cc:29
#define PRIVATE_NAMESPACE_BEGIN
Definition: yosys.h:97
bool cell_output(RTLIL::IdString type, RTLIL::IdString port)
Definition: celltypes.h:193
#define NEW_ID
Definition: yosys.h:166
#define PRIVATE_NAMESPACE_END
Definition: yosys.h:98
Definition: register.h:27
#define USING_YOSYS_NAMESPACE
Definition: yosys.h:102
std::map< RTLIL::IdString, RTLIL::Module * > modules_
Definition: rtlil.h:507
void log(const char *format,...)
Definition: log.cc:180
void extra_args(std::vector< std::string > args, size_t argidx, RTLIL::Design *design, bool select=true)
Definition: register.cc:128
std::pair< SigSpec, SigSpec > SigSig
Definition: rtlil.h:71
virtual void execute(std::vector< std::string > args, RTLIL::Design *design)
Definition: scatter.cc:44