diff options
author | Eddie Hung <eddie@fpgeh.com> | 2020-02-21 09:15:17 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-21 09:15:17 -0800 |
commit | 760096e8d2e9e2431bd5f97034bbd4ba01326649 (patch) | |
tree | f19ca177b826e856b117f9812900959dc4d6f14e /passes | |
parent | cd044a2bb6adf7a5e00d4a6c075e9489d852d733 (diff) | |
parent | ea4bd161b68cda30b5300b9275ebc0723896be02 (diff) | |
download | yosys-760096e8d2e9e2431bd5f97034bbd4ba01326649.tar.gz yosys-760096e8d2e9e2431bd5f97034bbd4ba01326649.tar.bz2 yosys-760096e8d2e9e2431bd5f97034bbd4ba01326649.zip |
Merge pull request #1703 from YosysHQ/eddie/specify_improve
Improve specify parser
Diffstat (limited to 'passes')
-rw-r--r-- | passes/opt/opt_clean.cc | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/passes/opt/opt_clean.cc b/passes/opt/opt_clean.cc index 2f69b3d4c..f5bb40050 100644 --- a/passes/opt/opt_clean.cc +++ b/passes/opt/opt_clean.cc @@ -51,20 +51,26 @@ struct keep_cache_t if (cache.count(module)) return cache.at(module); - cache[module] = true; - if (!module->get_bool_attribute(ID::keep)) { - bool found_keep = false; + bool found_keep = false; + if (module->get_bool_attribute(ID::keep)) + found_keep = true; + else for (auto cell : module->cells()) - if (query(cell)) found_keep = true; - cache[module] = found_keep; - } + if (query(cell, true /* ignore_specify */)) { + found_keep = true; + break; + } + cache[module] = found_keep; - return cache[module]; + return found_keep; } - bool query(Cell *cell) + bool query(Cell *cell, bool ignore_specify = false) { - if (cell->type.in(ID($memwr), ID($meminit), ID($assert), ID($assume), ID($live), ID($fair), ID($cover), ID($specify2), ID($specify3), ID($specrule))) + if (cell->type.in(ID($memwr), ID($meminit), ID($assert), ID($assume), ID($live), ID($fair), ID($cover))) + return true; + + if (!ignore_specify && cell->type.in(ID($specify2), ID($specify3), ID($specrule))) return true; if (cell->has_keep_attr()) |