Skip to content

Commit d4bf617

Browse files
burgholzerGeremia
authored andcommitted
🔒 update lockfile
1 parent abbdcc5 commit d4bf617

File tree

4 files changed

+193
-171
lines changed

4 files changed

+193
-171
lines changed

src/algorithms/simulation/simple_simulation.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <boost/dynamic_bitset/dynamic_bitset.hpp>
99
#include <cstddef>
1010
#include <iostream>
11+
#include <ranges>
1112

1213
namespace syrec {
1314

@@ -48,7 +49,7 @@ namespace syrec {
4849
}
4950

5051
void simpleSimulation(boost::dynamic_bitset<>& output, const Circuit& circ, const boost::dynamic_bitset<>& input,
51-
const Properties::ptr& statistics) {
52+
const Properties::ptr& statistics, const bool reverse) {
5253
Timer<PropertiesTimer> t;
5354

5455
if (statistics) {
@@ -57,8 +58,14 @@ namespace syrec {
5758
}
5859

5960
output = input;
60-
for (const auto& g: circ) {
61+
if (reverse) {
62+
for (const auto& g: std::ranges::reverse_view(circ)) {
6163
coreGateSimulation(*g, output);
64+
}
65+
} else {
66+
for (const auto& g: circ) {
67+
coreGateSimulation(*g, output);
68+
}
6269
}
6370

6471
if (statistics) {

test/unittests/test_cost_aware_simulation.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ class SyrecAddLinesSimulationTest: public testing::TestWithParam<std::string> {
2121
std::string testCircuitsDir = "./circuits/";
2222
std::string fileName;
2323
boost::dynamic_bitset<> input;
24-
boost::dynamic_bitset<> output;
24+
boost::dynamic_bitset<> output, output2;
2525
std::vector<int> setLines;
26-
std::string expectedSimOut;
26+
std::string expectedSimOut, expectedSimIn;
2727
std::string outputString;
2828

2929
void SetUp() override {
@@ -68,11 +68,18 @@ TEST_P(SyrecAddLinesSimulationTest, GenericSimulationTest) {
6868
}
6969

7070
output.resize(circ.getLines());
71+
output2.resize(circ.getLines());
7172

7273
simpleSimulation(output, circ, input, statistics);
7374

7475
boost::to_string(output, outputString);
7576
std::reverse(outputString.begin(), outputString.end());
7677

7778
EXPECT_EQ(expectedSimOut, outputString);
79+
80+
// Check reversed simulation
81+
simpleSimulation(output2, circ, output, statistics, true);
82+
boost::to_string(output2, outputString);
83+
boost::to_string(input, expectedSimIn);
84+
EXPECT_EQ(expectedSimIn, outputString);
7885
}

test/unittests/test_line_aware_simulation.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ class SyrecSimulationTest: public testing::TestWithParam<std::string> {
2121
std::string testCircuitsDir = "./circuits/";
2222
std::string fileName;
2323
boost::dynamic_bitset<> input;
24-
boost::dynamic_bitset<> output;
24+
boost::dynamic_bitset<> output, output2;
2525
std::vector<int> setLines;
26-
std::string expectedSimOut;
26+
std::string expectedSimOut, expectedSimIn;
2727
std::string outputString;
2828

2929
void SetUp() override {
@@ -68,11 +68,18 @@ TEST_P(SyrecSimulationTest, GenericSimulationTest) {
6868
}
6969

7070
output.resize(circ.getLines());
71+
output2.resize(circ.getLines());
7172

7273
simpleSimulation(output, circ, input, statistics);
7374

7475
boost::to_string(output, outputString);
7576
std::reverse(outputString.begin(), outputString.end());
7677

7778
EXPECT_EQ(expectedSimOut, outputString);
79+
80+
// Check reversed simulation
81+
simpleSimulation(output2, circ, output, statistics, true);
82+
boost::to_string(output2, outputString);
83+
boost::to_string(input, expectedSimIn);
84+
EXPECT_EQ(expectedSimIn, outputString);
7885
}

0 commit comments

Comments
 (0)