summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2014-09-29 12:51:54 +0200
committerClifford Wolf <clifford@clifford.at>2014-09-29 12:51:54 +0200
commit0b8cfbc6fde8e7500c5df38c74e1da2d74e588bd (patch)
tree8915aeb7d1af113469fc4e1f101d3dd157f6ba57
parentf9a307a50b5ce67b67d2b53e8c1334ea23ffd997 (diff)
Added support for "keep" on modules
-rw-r--r--README2
-rw-r--r--kernel/rtlil.h5
-rw-r--r--passes/opt/opt_clean.cc2
-rw-r--r--passes/opt/opt_share.cc2
4 files changed, 9 insertions, 2 deletions
diff --git a/README b/README
index d7f5aaa4..32a47cbf 100644
--- a/README
+++ b/README
@@ -273,6 +273,8 @@ Verilog Attributes and non-standard features
- The "keep" attribute on cells and wires is used to mark objects that should
never be removed by the optimizer. This is used for example for cells that
have hidden connections that are not part of the netlist, such as IO pads.
+ Setting the "keep" attribute on a module has the same effect as setting it
+ on all instances of the module.
- The "init" attribute on wires is set by the frontend when a register is
initialized "FPGA-style" with 'reg foo = val'. It can be used during synthesis
diff --git a/kernel/rtlil.h b/kernel/rtlil.h
index a0ae8f08..8df0bfe1 100644
--- a/kernel/rtlil.h
+++ b/kernel/rtlil.h
@@ -857,6 +857,11 @@ public:
void check();
void fixup_parameters(bool set_a_signed = false, bool set_b_signed = false);
+ bool has_keep_attr() const {
+ return get_bool_attribute("\\keep") || (module && module->design && module->design->module(type) &&
+ module->design->module(type)->get_bool_attribute("\\keep"));
+ }
+
template<typename T> void rewrite_sigspecs(T functor);
};
diff --git a/passes/opt/opt_clean.cc b/passes/opt/opt_clean.cc
index d589518a..0e5ed238 100644
--- a/passes/opt/opt_clean.cc
+++ b/passes/opt/opt_clean.cc
@@ -48,7 +48,7 @@ void rmunused_module_cells(RTLIL::Module *module, bool verbose)
wire2driver.insert(sig, cell);
}
}
- if (cell->type == "$memwr" || cell->type == "$assert" || cell->get_bool_attribute("\\keep"))
+ if (cell->type == "$memwr" || cell->type == "$assert" || cell->has_keep_attr())
queue.insert(cell);
unused.insert(cell);
}
diff --git a/passes/opt/opt_share.cc b/passes/opt/opt_share.cc
index 33115349..f8bc0220 100644
--- a/passes/opt/opt_share.cc
+++ b/passes/opt/opt_share.cc
@@ -196,7 +196,7 @@ struct OptShareWorker
if (!ct.cell_known(cell1->type))
return cell1 < cell2;
- if (cell1->get_bool_attribute("\\keep") || cell2->get_bool_attribute("\\keep"))
+ if (cell1->has_keep_attr() || cell2->has_keep_attr())
return cell1 < cell2;
bool lt;