aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/rtlil.h
diff options
context:
space:
mode:
authorRupert Swarbrick <rswarbrick@gmail.com>2020-04-20 16:06:53 +0100
committerZachary Snow <zachary.j.snow@gmail.com>2021-08-13 17:11:35 -0600
commitee2b5b7ed186414897a8a570a9e503c438803ad8 (patch)
tree649b8773ac8f332439b1071086e55512bf356697 /kernel/rtlil.h
parentf7913285067ed30bf5087f265db7e0bd523af2b6 (diff)
downloadyosys-ee2b5b7ed186414897a8a570a9e503c438803ad8.tar.gz
yosys-ee2b5b7ed186414897a8a570a9e503c438803ad8.tar.bz2
yosys-ee2b5b7ed186414897a8a570a9e503c438803ad8.zip
Generate an RTLIL representation of bind constructs
This code now takes the AST nodes of type AST_BIND and generates a representation in the RTLIL for them. This is a little tricky, because a binding of the form: bind baz foo_t foo_i (.arg (1 + bar)); means "make an instance of foo_t called foo_i, instantiate it inside baz and connect the port arg to the result of the expression 1+bar". Of course, 1+bar needs a cell for the addition. Where should that cell live? With this patch, the Binding structure that represents the construct is itself an AST::AstModule module. This lets us put the adder cell inside it. We'll pull the contents out and plonk them into 'baz' when we actually do the binding operation as part of the hierarchy pass. Of course, we don't want RTLIL::Binding to contain an AST::AstModule (since kernel code shouldn't depend on a frontend), so we define RTLIL::Binding as an abstract base class and put the AST-specific code into an AST::Binding subclass. This is analogous to the AST::AstModule class.
Diffstat (limited to 'kernel/rtlil.h')
-rw-r--r--kernel/rtlil.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/kernel/rtlil.h b/kernel/rtlil.h
index dc0d5234b..50707c0ae 100644
--- a/kernel/rtlil.h
+++ b/kernel/rtlil.h
@@ -72,6 +72,7 @@ namespace RTLIL
struct MemWriteAction;
struct SyncRule;
struct Process;
+ struct Binding;
typedef std::pair<SigSpec, SigSpec> SigSig;
@@ -1033,6 +1034,8 @@ struct RTLIL::Design
int refcount_modules_;
dict<RTLIL::IdString, RTLIL::Module*> modules_;
+ std::vector<RTLIL::Binding*> bindings_;
+
std::vector<AST::AstNode*> verilog_packages, verilog_globals;
std::unique_ptr<define_map_t> verilog_defines;
@@ -1053,6 +1056,8 @@ struct RTLIL::Design
}
void add(RTLIL::Module *module);
+ void add(RTLIL::Binding *binding);
+
RTLIL::Module *addModule(RTLIL::IdString name);
void remove(RTLIL::Module *module);
void rename(RTLIL::Module *module, RTLIL::IdString new_name);
@@ -1140,7 +1145,9 @@ public:
dict<RTLIL::IdString, RTLIL::Wire*> wires_;
dict<RTLIL::IdString, RTLIL::Cell*> cells_;
- std::vector<RTLIL::SigSig> connections_;
+
+ std::vector<RTLIL::SigSig> connections_;
+ std::vector<RTLIL::Binding*> bindings_;
RTLIL::IdString name;
idict<RTLIL::IdString> avail_parameters;
@@ -1207,6 +1214,8 @@ public:
RTLIL::ObjRange<RTLIL::Wire*> wires() { return RTLIL::ObjRange<RTLIL::Wire*>(&wires_, &refcount_wires_); }
RTLIL::ObjRange<RTLIL::Cell*> cells() { return RTLIL::ObjRange<RTLIL::Cell*>(&cells_, &refcount_cells_); }
+ void add(RTLIL::Binding *binding);
+
// Removing wires is expensive. If you have to remove wires, remove them all at once.
void remove(const pool<RTLIL::Wire*> &wires);
void remove(RTLIL::Cell *cell);