diff options
-rw-r--r-- | frontends/ast/ast.cc | 2 | ||||
-rw-r--r-- | frontends/ast/ast.h | 2 | ||||
-rw-r--r-- | kernel/rtlil.cc | 4 | ||||
-rw-r--r-- | kernel/rtlil.h | 2 | ||||
-rw-r--r-- | passes/hierarchy/hierarchy.cc | 20 | ||||
-rw-r--r-- | passes/techmap/libparse.cc | 24 |
6 files changed, 44 insertions, 10 deletions
diff --git a/frontends/ast/ast.cc b/frontends/ast/ast.cc index be04d5536..037a9f3ee 100644 --- a/frontends/ast/ast.cc +++ b/frontends/ast/ast.cc @@ -1067,7 +1067,7 @@ AstModule::~AstModule() } // create a new parametric module (when needed) and return the name of the generated module -RTLIL::IdString AstModule::derive(RTLIL::Design *design, dict<RTLIL::IdString, RTLIL::Const> parameters) +RTLIL::IdString AstModule::derive(RTLIL::Design *design, dict<RTLIL::IdString, RTLIL::Const> parameters, bool) { std::string stripped_name = name.str(); diff --git a/frontends/ast/ast.h b/frontends/ast/ast.h index a5d5ee30a..d1e2c78d1 100644 --- a/frontends/ast/ast.h +++ b/frontends/ast/ast.h @@ -283,7 +283,7 @@ namespace AST AstNode *ast; bool nolatches, nomeminit, nomem2reg, mem2reg, lib, noopt, icells, autowire; virtual ~AstModule(); - virtual RTLIL::IdString derive(RTLIL::Design *design, dict<RTLIL::IdString, RTLIL::Const> parameters); + virtual RTLIL::IdString derive(RTLIL::Design *design, dict<RTLIL::IdString, RTLIL::Const> parameters, bool mayfail); virtual RTLIL::Module *clone() const; }; diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index 3e873054f..fb3d9dbe9 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -639,8 +639,10 @@ RTLIL::Module::~Module() delete it->second; } -RTLIL::IdString RTLIL::Module::derive(RTLIL::Design*, dict<RTLIL::IdString, RTLIL::Const>) +RTLIL::IdString RTLIL::Module::derive(RTLIL::Design*, dict<RTLIL::IdString, RTLIL::Const>, bool mayfail) { + if (mayfail) + return RTLIL::IdString(); log_error("Module `%s' is used with parameters but is not parametric!\n", id2cstr(name)); } diff --git a/kernel/rtlil.h b/kernel/rtlil.h index fc29e1e65..a251b4252 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -906,7 +906,7 @@ public: Module(); virtual ~Module(); - virtual RTLIL::IdString derive(RTLIL::Design *design, dict<RTLIL::IdString, RTLIL::Const> parameters); + virtual RTLIL::IdString derive(RTLIL::Design *design, dict<RTLIL::IdString, RTLIL::Const> parameters, bool mayfail = false); virtual size_t count_id(RTLIL::IdString id); virtual void sort(); diff --git a/passes/hierarchy/hierarchy.cc b/passes/hierarchy/hierarchy.cc index c460fbbfc..c680dbbd8 100644 --- a/passes/hierarchy/hierarchy.cc +++ b/passes/hierarchy/hierarchy.cc @@ -620,17 +620,26 @@ struct HierarchyPass : public Pass { } } + std::set<Module*> blackbox_derivatives; + for (auto module : design->modules()) for (auto cell : module->cells()) { - if (GetSize(cell->parameters) != 0) - continue; - Module *m = design->module(cell->type); - if (m == nullptr || m->get_bool_attribute("\\blackbox")) + if (m == nullptr) continue; + if (m->get_bool_attribute("\\blackbox") && !cell->parameters.empty()) { + IdString new_m_name = m->derive(design, cell->parameters, true); + if (new_m_name.empty()) + continue; + if (new_m_name != m->name) { + m = design->module(new_m_name); + blackbox_derivatives.insert(m); + } + } + for (auto &conn : cell->connections()) { Wire *w = m->wire(conn.first); @@ -673,6 +682,9 @@ struct HierarchyPass : public Pass { } } + for (auto module : blackbox_derivatives) + design->remove(module); + log_pop(); } } HierarchyPass; diff --git a/passes/techmap/libparse.cc b/passes/techmap/libparse.cc index d5254c029..d3b1ff02f 100644 --- a/passes/techmap/libparse.cc +++ b/passes/techmap/libparse.cc @@ -100,8 +100,15 @@ int LibertyParser::lexer(std::string &str) break; } f.unget(); - // fprintf(stderr, "LEX: identifier >>%s<<\n", str.c_str()); - return 'v'; + if (str == "+" || str == "-") { + /* Single operator is not an identifier */ + // fprintf(stderr, "LEX: char >>%s<<\n", str.c_str()); + return str[0]; + } + else { + // fprintf(stderr, "LEX: identifier >>%s<<\n", str.c_str()); + return 'v'; + } } if (c == '"') { @@ -191,6 +198,19 @@ LibertyAst *LibertyParser::parse() tok = lexer(ast->value); if (tok != 'v') error(); + tok = lexer(str); + while (tok == '+' || tok == '-' || tok == '*' || tok == '/') { + ast->value += tok; + tok = lexer(str); + if (tok != 'v') + error(); + ast->value += str; + tok = lexer(str); + } + if (tok == ';') + break; + else + error(); continue; } |