3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-07-31 00:13:18 +00:00

Check overflow condition is power of 2 without using int32

This commit is contained in:
Eddie Hung 2019-09-18 12:16:03 -07:00
parent c9fe4d7992
commit 347cbf59bd
2 changed files with 15 additions and 5 deletions

View file

@ -361,8 +361,8 @@ match overflow
select overflow->type.in($ge)
select GetSize(port(overflow, \Y)) <= 48
select port(overflow, \B).is_fully_const()
// Check is exact power of 2
select (port(overflow, \B).as_int() & (port(overflow, \B).as_int()-1)) == 0
define <Const> B port(overflow, \B).as_const()
select std::count(B.bits.begin(), B.bits.end(), State::S1) == 1
index <SigSpec> port(overflow, \A) === sigP
optional
endmatch