diff options
author | Rupert Swarbrick <rswarbrick@gmail.com> | 2020-04-20 16:06:53 +0100 |
---|---|---|
committer | Zachary Snow <zachary.j.snow@gmail.com> | 2021-08-13 17:11:35 -0600 |
commit | ee2b5b7ed186414897a8a570a9e503c438803ad8 (patch) | |
tree | 649b8773ac8f332439b1071086e55512bf356697 /frontends/ast/ast.cc | |
parent | f7913285067ed30bf5087f265db7e0bd523af2b6 (diff) | |
download | yosys-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 'frontends/ast/ast.cc')
-rw-r--r-- | frontends/ast/ast.cc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/frontends/ast/ast.cc b/frontends/ast/ast.cc index fe503c547..4fbc238b0 100644 --- a/frontends/ast/ast.cc +++ b/frontends/ast/ast.cc @@ -1310,6 +1310,11 @@ void AST::process(RTLIL::Design *design, AstNode *ast, bool dump_ast1, bool dump design->verilog_packages.push_back(child->clone()); current_scope.clear(); } + else if (child->type == AST_BIND) { + // top-level bind construct + for (RTLIL::Binding *binding : child->genBindings()) + design->add(binding); + } else { // must be global definition if (child->type == AST_PARAMETER) |