3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-08-08 04:01:25 +00:00

cxxrtl: Fix value::sshr

This commit is contained in:
Merry 2023-12-13 12:11:57 +00:00
parent ff53f3d2b6
commit ded63bedd5
2 changed files with 30 additions and 5 deletions

View file

@ -12,4 +12,28 @@ int main()
cxxrtl::value<6> c = a.shl(b);
assert(c.get<uint64_t>() == 0);
}
{
// sshr of unreasonably large size should sign extend correctly
cxxrtl::value<64> a(0u, 0x80000000u);
cxxrtl::value<64> b(0u, 1u);
cxxrtl::value<64> c = a.sshr(b);
assert(c.get<uint64_t>() == 0xffffffffffffffffu);
}
{
// sshr of exteeding Bits should sign extend correctly
cxxrtl::value<8> a(0x80u);
cxxrtl::value<8> b(10u);
cxxrtl::value<8> c = a.sshr(b);
assert(c.get<uint64_t>() == 0xffu);
}
{
// Sign extension should occur correctly
cxxrtl::value<64> a(0x23456789u, 0x8abcdef1u);
cxxrtl::value<8> b(32u);
cxxrtl::value<64> c = a.sshr(b);
assert(c.get<uint64_t>() == 0xffffffff8abcdef1u);
}
}