mirror of
https://github.com/YosysHQ/yosys
synced 2025-09-14 13:41:27 +00:00
Fast path for Const::operator==
This commit is contained in:
parent
60099e5005
commit
ec52d6c649
2 changed files with 23 additions and 0 deletions
|
@ -352,6 +352,11 @@ bool RTLIL::Const::operator<(const RTLIL::Const &other) const
|
||||||
|
|
||||||
bool RTLIL::Const::operator ==(const RTLIL::Const &other) const
|
bool RTLIL::Const::operator ==(const RTLIL::Const &other) const
|
||||||
{
|
{
|
||||||
|
if (is_str() && other.is_str())
|
||||||
|
return get_str() == other.get_str();
|
||||||
|
if (is_bits() && other.is_bits())
|
||||||
|
return get_bits() == other.get_bits();
|
||||||
|
|
||||||
if (size() != other.size())
|
if (size() != other.size())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -204,6 +204,24 @@ namespace RTLIL {
|
||||||
EXPECT_EQ(c, Const(0xe, 4));
|
EXPECT_EQ(c, Const(0xe, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(KernelRtlilTest, ConstEqualStr) {
|
||||||
|
EXPECT_EQ(Const("abc"), Const("abc"));
|
||||||
|
EXPECT_NE(Const("abc"), Const("def"));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(KernelRtlilTest, ConstEqualBits) {
|
||||||
|
std::vector<State> v1 = {S0, S1};
|
||||||
|
std::vector<State> v2 = {S1, S0};
|
||||||
|
EXPECT_EQ(Const(v1), Const(v1));
|
||||||
|
EXPECT_NE(Const(v1), Const(v2));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(KernelRtlilTest, ConstEqualStrBits) {
|
||||||
|
std::vector<State> v1 = {S0, S0, S0, S0, S0, S1, S0, S0};
|
||||||
|
EXPECT_EQ(Const(v1), Const(" "));
|
||||||
|
EXPECT_NE(Const(v1), Const("a"));
|
||||||
|
}
|
||||||
|
|
||||||
class WireRtlVsHdlIndexConversionTest :
|
class WireRtlVsHdlIndexConversionTest :
|
||||||
public KernelRtlilTest,
|
public KernelRtlilTest,
|
||||||
public testing::WithParamInterface<std::tuple<bool, int, int>>
|
public testing::WithParamInterface<std::tuple<bool, int, int>>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue