Skip to content

Commit

Permalink
Changes based on review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
SmaranTum committed Nov 30, 2022
1 parent e3029c7 commit 1ef4b39
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
12 changes: 1 addition & 11 deletions include/core/truthTable/truth_table.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,17 +329,7 @@ namespace syrec {
cubeMap.insert(std::move(nh));
}

static auto equal(TruthTable& tt1, TruthTable& tt2, const bool equalityUpToDontCare = true) -> bool {
if (!equalityUpToDontCare) {
return (tt1 == tt2);
}
for (auto const& [input, output]: tt1) {
if (!Cube::checkCubeEquality(tt1[input], tt2[input])) {
return false;
}
}
return true;
}
static auto equal(TruthTable& tt1, TruthTable& tt2, bool equalityUpToDontCare = true) -> bool;

auto clear() -> void {
cubeMap.clear();
Expand Down
34 changes: 34 additions & 0 deletions src/core/truthTable/truth_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,38 @@ namespace syrec {
return result;
}

auto TruthTable::equal(TruthTable& tt1, TruthTable& tt2, bool equalityUpToDontCare) -> bool {
if (!equalityUpToDontCare) {
return (tt1 == tt2);
}

if (tt1.nInputs() != tt2.nInputs()) {
return false;
}

const auto nBits = tt1.nInputs();
assert(nBits < 65U);
const auto totalInputs = 1U << nBits;

std::uint64_t n = 0U;

while (n < totalInputs) {
const auto input = TruthTable::Cube::fromInteger(n, nBits);
++n;

const auto foundtt1 = tt1.find(input) != tt1.end();
const auto foundtt2 = tt2.find(input) != tt2.end();

if (!foundtt1 || !foundtt2) {
continue;
}

if (!Cube::checkCubeEquality(tt1[input], tt2[input])) {
return false;
}
}

return true;
}

} // namespace syrec

0 comments on commit 1ef4b39

Please sign in to comment.