3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-07-20 22:25:49 +00:00

Merge pull request #120 from Silimate/is_mostly_const_param

rtlil: parameterize SigSpec::is_mostly_const
This commit is contained in:
Akash Levy 2026-03-06 18:37:18 -08:00 committed by GitHub
commit 168d64ab19
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View file

@ -5605,13 +5605,13 @@ bool RTLIL::SigSpec::is_chunk() const
return ++it == cs.end();
}
bool RTLIL::SigSpec::is_mostly_const() const
bool RTLIL::SigSpec::is_mostly_const(double const_ratio_threshold) const
{
int constbits = 0;
for (auto &chunk : chunks())
if (chunk.width > 0 && chunk.wire == NULL)
constbits += chunk.width;
return (constbits > size()/2);
return (constbits > size() * const_ratio_threshold);
}
bool RTLIL::SigSpec::known_driver() const

View file

@ -1684,7 +1684,9 @@ public:
bool known_driver() const;
bool is_mostly_const() const;
// const_ratio_threshold is expected in [0.0, 1.0]
// boundary is exclusive, returns true only if const bit ratio > const_ratio_threshold
bool is_mostly_const(double const_ratio_threshold = 0.5) const;
bool is_fully_const() const;
bool is_fully_zero() const;
bool is_fully_ones() const;