Skip to content

Commit 448f01c

Browse files
committed
Const::decode_string() doesn't need to call bitvectorize
1 parent 90f4a8f commit 448f01c

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

kernel/rtlil.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,6 @@ std::string RTLIL::Const::decode_string() const
579579
if (auto str = get_if_str())
580580
return *str;
581581

582-
bitvectorize_internal();
583582
bitvectype& bv = get_bits();
584583
const int n = GetSize(bv);
585584
const int n_over_8 = n / 8;

tests/unit/kernel/rtlilTest.cc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,32 @@ namespace RTLIL {
131131
EXPECT_EQ(c.as_string(), "00000010");
132132
EXPECT_TRUE(c.is_str());
133133
}
134+
135+
{
136+
Const c(" ");
137+
EXPECT_TRUE(c.is_str());
138+
EXPECT_EQ(c.decode_string(), " ");
139+
EXPECT_TRUE(c.is_str());
140+
}
141+
142+
{
143+
Const c(" ");
144+
EXPECT_TRUE(c.is_str());
145+
EXPECT_EQ(c.decode_string(), " ");
146+
EXPECT_TRUE(c.is_str());
147+
}
148+
149+
{
150+
std::vector<State> v = {S0, S0, S0, S0, S0, S1, S0, S0};
151+
Const c(v);
152+
EXPECT_EQ(c.decode_string(), " ");
153+
}
154+
155+
{
156+
std::vector<State> v = {S0, S0, S0, S0, S0, S1, S0, Sx};
157+
Const c(v);
158+
EXPECT_EQ(c.decode_string(), " ");
159+
}
134160
}
135161

136162
TEST_F(KernelRtlilTest, ConstConstIteratorWorks) {

0 commit comments

Comments
 (0)