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:
parent
e206b059f6
commit
60099e5005
2 changed files with 35 additions and 9 deletions
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue