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:
parent
ef2776034e
commit
e504e9aced
|
|
@ -571,10 +571,11 @@ private:
|
||||||
if (nodep->access().isWriteOnly()) {
|
if (nodep->access().isWriteOnly()) {
|
||||||
vscp->user2(true);
|
vscp->user2(true);
|
||||||
} else {
|
} else {
|
||||||
// If the variable is read before it is written, and is not in the sensitivity list,
|
// If the variable is read before it is written (and is not a never-changing value),
|
||||||
// then this cannot be optimized into a combinational process
|
// and is not in the sensitivity list, then this cannot be optimized into a
|
||||||
|
// combinational process
|
||||||
// TODO: live variable analysis would be more precise
|
// 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 {
|
void visit(AstAssignDly* nodep) override {
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,12 @@ compile(
|
||||||
verilator_flags2 => ["--stats"],
|
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, 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(
|
execute(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue