Optimize clocked processes to comb when referencing const variables

In V3Active, we try hard to turn `always @(a or b or c)` into an
`always_comb` if the only variables read in the block are also in the
sensitivity list. In addition, also allow this optimization when reading
variables that are not in the sensitivity list, but are known to be
constant/never changing after initialization. In particular lookup
tables introduced by V3Table are covered by this. This can have a
significant impact on designs that use the `always @(a or b or c)` style
for combinational logic.
This commit is contained in:
Geza Lore 2022-10-27 18:32:10 +01:00
parent ef2776034e
commit e504e9aced
2 changed files with 9 additions and 5 deletions

View File

@ -571,10 +571,11 @@ private:
if (nodep->access().isWriteOnly()) {
vscp->user2(true);
} else {
// If the variable is read before it is written, and is not in the sensitivity list,
// then this cannot be optimized into a combinational process
// If the variable is read before it is written (and is not a never-changing value),
// and is not in the sensitivity list, then this cannot be optimized into a
// combinational process
// TODO: live variable analysis would be more precise
if (!vscp->user2() && !vscp->user1()) m_canBeComb = false;
if (!vscp->user2() && !vscp->varp()->valuep() && !vscp->user1()) m_canBeComb = false;
}
}
void visit(AstAssignDly* nodep) override {

View File

@ -14,9 +14,12 @@ compile(
verilator_flags2 => ["--stats"],
);
if ($Self->{vlt_all}) {
if ($Self->{vlt}) {
file_grep($Self->{stats}, qr/Optimizations, Tables created\s+(\d+)/i, 10);
file_grep($Self->{stats}, qr/Optimizations, Combined CFuncs\s+(\d+)/i, 0);
file_grep($Self->{stats}, qr/Optimizations, Combined CFuncs\s+(\d+)/i, 8);
} elsif ($Self->{vltmt}) {
file_grep($Self->{stats}, qr/Optimizations, Tables created\s+(\d+)/i, 10);
file_grep($Self->{stats}, qr/Optimizations, Combined CFuncs\s+(\d+)/i, 9);
}
execute(