3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-09-14 13:41:27 +00:00

Make Const::as_bool and Const::as_int work with packed bits without decaying to vector<State>

This commit is contained in:
Robert O'Callahan 2025-08-29 03:09:19 +00:00
parent e206b059f6
commit 60099e5005
2 changed files with 35 additions and 9 deletions

View file

@ -92,12 +92,14 @@ namespace RTLIL {
Const c(0x12345678);
EXPECT_TRUE(c.is_str());
EXPECT_EQ(c.as_int(), 0x12345678);
EXPECT_TRUE(c.is_str());
}
{
Const c(0xab, 8);
EXPECT_TRUE(c.is_str());
EXPECT_EQ(c.as_int(), 0xab);
EXPECT_TRUE(c.is_str());
}
{
@ -105,6 +107,7 @@ namespace RTLIL {
EXPECT_TRUE(c.is_str());
EXPECT_EQ(c.as_int(), 0x12345678);
EXPECT_EQ(c[79], S0);
EXPECT_TRUE(c.is_str());
}
{
@ -112,6 +115,14 @@ namespace RTLIL {
EXPECT_TRUE(c.is_str());
EXPECT_EQ(c.as_int(), -1);
EXPECT_EQ(c[79], S1);
EXPECT_TRUE(c.is_str());
}
{
Const c(1 << 24);
EXPECT_TRUE(c.is_str());
EXPECT_TRUE(c.as_bool());
EXPECT_TRUE(c.is_str());
}
}