Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repair CI (Temporary solution) #60

Closed
wants to merge 68 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
eff8b60
Change CMakeLists.txt
SmaranTum Jun 17, 2022
ac39bf0
adding tt to qmdd files
SmaranTum Jun 17, 2022
c6363ea
codestyle change
SmaranTum Jun 17, 2022
3fdd7d5
Merge pull request #2 from cda-tum/main
SmaranTum Jun 23, 2022
534abea
Added truth_table class and truth_table to dd function
SmaranTum Jun 23, 2022
f04da59
test added for tt to dd functionality
SmaranTum Jun 24, 2022
8a5daec
test added for tt to dd functionality
SmaranTum Jun 24, 2022
cf3b1ec
Resolved test error, commented the most of the stuff of class truth_t…
SmaranTum Jun 24, 2022
4f19374
Resolved tiny test error
SmaranTum Jun 24, 2022
1ce162f
Resolved tiny test error
SmaranTum Jun 24, 2022
208365c
Added additional test
SmaranTum Jun 24, 2022
2f6b852
Merge pull request #3 from cda-tum/main
SmaranTum Jun 27, 2022
daa1c7b
Added new truth Table class with test
SmaranTum Jul 1, 2022
b4d8bbe
Added new truth Table class with test
SmaranTum Jul 1, 2022
7b5cec1
Merge remote-tracking branch 'origin/truthtable_to_qmdd' into truthta…
SmaranTum Jul 2, 2022
b685f45
resolved minor error
SmaranTum Jul 2, 2022
4648555
Added addtional tests and Params
SmaranTum Jul 2, 2022
9bf728c
resolved tiny error
SmaranTum Jul 2, 2022
1c41773
resolved tiny error
SmaranTum Jul 2, 2022
858c995
🎨 fix format
burgholzer Jul 5, 2022
f836f93
🎨 fix format
burgholzer Jul 5, 2022
447870d
Merge pull request #5 from cda-tum/main
SmaranTum Jul 6, 2022
c781891
Changes based on linter.
SmaranTum Jul 6, 2022
4271f1f
Changes based on linter.
SmaranTum Jul 7, 2022
dc0a27b
Changes based on linter.
SmaranTum Jul 7, 2022
af5f8cb
Changes based on linter.
SmaranTum Jul 7, 2022
145d962
Changes based on linter.
SmaranTum Jul 7, 2022
57a450c
Changes based on linter.
SmaranTum Jul 7, 2022
1725d93
Changes based on linter.
SmaranTum Jul 7, 2022
fea64ee
Changes based on linter.
SmaranTum Jul 7, 2022
fbf79de
Changes based on linter.
SmaranTum Jul 7, 2022
3f9e8ef
Changes based on linter.
SmaranTum Jul 7, 2022
021fff6
Changes based on linter.
SmaranTum Jul 7, 2022
00b6a8d
Changes based on linter.
SmaranTum Jul 7, 2022
3587286
Changes based on linter.
SmaranTum Jul 7, 2022
701ded2
Changes based on linter.
SmaranTum Jul 7, 2022
97fa9b2
Changes based on linter.
SmaranTum Jul 7, 2022
3faffb7
Changes based on linter.
SmaranTum Jul 7, 2022
ef26230
Changes based on linter.
SmaranTum Jul 7, 2022
6ca08c1
Changes based on linter.
SmaranTum Jul 7, 2022
0114fc6
Changes based on linter.
SmaranTum Jul 7, 2022
9fa02cc
Changes based on linter.
SmaranTum Jul 7, 2022
01d0f91
Changes based on linter.
SmaranTum Jul 7, 2022
148d2a9
Added struct for cube type.
SmaranTum Jul 7, 2022
f7c40bf
Added member functions for cube type struct.
SmaranTum Jul 7, 2022
a4fc8c7
Added insert zero member function for cube type struct.
SmaranTum Jul 7, 2022
d1802ea
minor change in minHeap struct
SmaranTum Jul 7, 2022
f25bda6
minor change in minHeap struct
SmaranTum Jul 7, 2022
bd32730
minor change in minHeap struct
SmaranTum Jul 7, 2022
4355e0c
Change class truthTable to TruthTable
SmaranTum Jul 7, 2022
2373da5
changes to typedefs
SmaranTum Jul 7, 2022
bc50171
Minor renaming and codestyle
SmaranTum Jul 7, 2022
a7ea13b
Test check
SmaranTum Jul 8, 2022
ff18610
♻️refactor truth table code
burgholzer Jul 17, 2022
d0f9726
🔥remove unnecessary files
burgholzer Jul 17, 2022
f3e8b7e
♻️refactor tests
burgholzer Jul 17, 2022
4c3d866
🎨 code format
burgholzer Jul 17, 2022
cb2f9ff
Merge branch 'main' into truthtable_to_qmdd
burgholzer Jul 17, 2022
19631db
Made minor changes to the TruthTable class i.e., modify contents of c…
SmaranTum Jul 19, 2022
84be8df
Minor changes to dd_synthesis.cpp and added additional tests.
SmaranTum Jul 25, 2022
e3be3f5
Merge remote-tracking branch 'origin/main' into truthtable_to_qmdd
burgholzer Aug 20, 2022
6b224fd
Minor changes to dd_synthesis.cpp so that it works for all the cases …
SmaranTum Aug 22, 2022
3e16cc6
Merge remote-tracking branch 'origin/truthtable_to_qmdd' into truthta…
SmaranTum Aug 22, 2022
26ffc4b
code-style
SmaranTum Aug 22, 2022
2dbddaa
Added Pla parser functionality, added corresponding tests as well.
SmaranTum Aug 22, 2022
618d2f5
Update pyproject.toml
SmaranTum Aug 22, 2022
6df9a47
Update pyproject.toml
SmaranTum Aug 22, 2022
00b7405
Update pyproject.toml
SmaranTum Aug 22, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions include/core/truthTable/dd_synthesis.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include "core/truthTable/truth_table.hpp"

namespace syrec {

void rootPath(dd::mNode* src, dd::mNode* dst, TruthTable::Cube::Vector& sigVec, TruthTable::Cube& tempVec);

void sigPath(dd::mNode* src, TruthTable::Cube::Vector& sigVec, TruthTable::Cube& tempVec);

bool algoP3(dd::mNode* current);

void algoP4(dd::mEdge& src, dd::mNode* current, syrec::TruthTable::Cube::Vector& p1SigVec, syrec::TruthTable::Cube::Vector& p2SigVec, const std::vector<std::size_t>& indices, std::unique_ptr<dd::Package<>>& dd);

void algoP1(dd::mEdge& src, dd::mNode* current, std::unique_ptr<dd::Package<>>& dd);

void algoP2(dd::mEdge& src, dd::mNode* current, std::unique_ptr<dd::Package<>>& dd);

void algoP(dd::mEdge& src, dd::mNode* current, std::unique_ptr<dd::Package<>>& dd);

void algoQ(dd::mEdge& src, std::unique_ptr<dd::Package<>>& dd);
} // namespace syrec
39 changes: 39 additions & 0 deletions include/core/truthTable/pla_parser.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once

#include "core/truthTable/truth_table.hpp"

namespace syrec {

[[maybe_unused]] inline syrec::TruthTable::Cube::Value transform_pla_to_constants(const char& c) {
syrec::TruthTable::Cube::Value constant;
syrec::TruthTable::Cube::Value one = true;
syrec::TruthTable::Cube::Value zero = false;
switch (c) {
case '-':
case '~':
return constant;

case '0':
return zero;
case '1':
return one;

default:
assert(false);
return constant;
}
}

[[maybe_unused]] inline std::string trim(std::string& str) {
str.erase(str.find_last_not_of(' ') + 1); //suffixing spaces
str.erase(0, str.find_first_not_of(' ')); //prefixing spaces
return str;
}

[[maybe_unused]] void pla_parser(std::istream& in, syrec::TruthTable& reader);

[[maybe_unused]] void read_pla(TruthTable& spec, std::istream& in);

bool read_pla(TruthTable& spec, const std::string& filename);

} // namespace syrec
211 changes: 211 additions & 0 deletions include/core/truthTable/truth_table.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
#pragma once

#include "dd/Package.hpp"

#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <optional>
#include <queue>
#include <utility>
#include <vector>

namespace syrec {

class TruthTable {
public:
class Cube {
public:
using Value = std::optional<bool>;
using Vector = std::vector<Cube>;

private:
std::vector<Value> cube{};

public:
Cube() = default;
explicit Cube(std::vector<Value> cube):
cube(std::move(cube)) {}

Cube(const std::size_t bw, const Value& initializer) {
cube.resize(bw, initializer);
}

template<class InputIt>
Cube(InputIt first, InputIt last) {
std::copy(first, last, std::back_inserter(cube));
}

// construct a cube from a (64bit) number with a given bitwidth
static auto fromInteger(const std::uint64_t number, const std::size_t bw) -> Cube {
assert(bw <= 64U);
Cube cube{};
cube.reserve(bw);
for (std::size_t i = 0U; i < bw; ++i) {
cube.emplace_back((number & (1ULL << (bw - 1U - i))) != 0U);
}
return cube;
}
// return integer representation of the cube
[[nodiscard]] auto toInteger() const -> std::uint64_t {
assert(cube.size() <= 64U);
assert(std::none_of(cube.cbegin(), cube.cend(), [](auto const& v) { return !v.has_value(); }));
std::uint64_t result = 0U;
for (std::size_t i = 0U; i < cube.size(); ++i) {
if (*cube[i]) {
result |= (1ULL << (cube.size() - 1U - i));
}
}
return result;
}

[[nodiscard]] auto completeCubes() const -> Vector;

auto insertZero() -> void {
cube.insert(cube.begin(), false);
}
[[nodiscard]] auto append(const Value& v) const -> Cube {
auto c = cube;
c.emplace_back(v);
return Cube(c);
}
[[nodiscard]] auto appendZero() const -> Cube {
return append(false);
}
[[nodiscard]] auto appendOne() const -> Cube {
return append(true);
}

// pass-through functions for underlying vector

auto at(std::size_t pos) -> Value& {
return cube[pos];
}

auto operator[](std::size_t pos) const -> Value {
return cube[pos];
}

auto operator<(const Cube& cv) const -> bool {
return (cube < cv.cube);
}

auto operator==(const Cube& cv) const -> bool {
return (cube == cv.cube);
}

auto reserve(const std::size_t n) -> void {
cube.reserve(n);
}
auto resize(const std::size_t n, const Value& val = Value()) -> void {
cube.resize(n, val);
}
auto emplace_back(const Value& v) -> void {
cube.emplace_back(v);
}

auto pop_back() -> void {
cube.pop_back();
}

[[nodiscard]] auto size() const -> std::size_t {
return cube.size();
}
[[nodiscard]] auto empty() const -> bool {
return cube.empty();
}
[[nodiscard]] auto begin() const -> decltype(cube.begin()) {
return cube.begin();
}
[[nodiscard]] auto cbegin() const -> decltype(cube.cbegin()) {
return cube.cbegin();
}
[[nodiscard]] auto end() const -> decltype(cube.end()) {
return cube.end();
}
[[nodiscard]] auto cend() const -> decltype(cube.cend()) {
return cube.cend();
}
};

using CubeMap = std::map<Cube, Cube>;

[[nodiscard]] auto nInputs() const -> std::size_t {
if (cubeMap.empty()) {
return 0U;
}
return cubeMap.begin()->first.size();
}

[[nodiscard]] auto nOutputs() const -> std::size_t {
if (cubeMap.empty()) {
return 0U;
}
return cubeMap.begin()->second.size();
}

auto insert(const Cube& input, const Cube& output) -> void {
assert(cubeMap.empty() || (input.size() == nInputs() && output.size() == nOutputs()));
cubeMap.try_emplace(input, output);
}
auto insert(Cube&& input, Cube&& output) -> void {
assert(cubeMap.empty() || (input.size() == nInputs() && output.size() == nOutputs()));
cubeMap.try_emplace(std::move(input), std::move(output));
}

auto clear() -> void {
cubeMap.clear();
}

[[nodiscard]] const CubeMap& ioCube() const {
return cubeMap;
}

auto extend() -> void;

auto encodeHuffman() -> void;

auto augmentWithConstants() -> void;

auto buildDD(std::unique_ptr<dd::Package<>>& dd) const -> dd::mEdge;

private:
CubeMap cubeMap{};

struct MinHeapNode {
Cube data;

std::size_t freq{};

std::shared_ptr<MinHeapNode> left{};
std::shared_ptr<MinHeapNode> right{};

MinHeapNode(Cube data, const std::size_t freq):
data(std::move(data)), freq(freq) {}

auto operator>(const MinHeapNode& other) const -> bool {
return freq > other.freq;
}

auto traverse(Cube&& encodedCube, CubeMap& encoding) const -> void {
// leaf node -> add encoding
if (!data.empty()) {
encoding.try_emplace(data, std::move(encodedCube));
return;
}

// non-leaf node -> traverse left and right subtree
if (left) {
left->traverse(encodedCube.appendZero(), encoding);
}
if (right) {
right->traverse(encodedCube.appendOne(), encoding);
}
}
};
};
} // namespace syrec
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = [
"setuptools>=45",
"setuptools<64",
"setuptools_scm>=6.4",
"wheel>=0.37",
"ninja>=1.10; sys_platform != 'win32'",
Expand Down
8 changes: 7 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ add_library(${PROJECT_NAME}
${CMAKE_CURRENT_SOURCE_DIR}/core/syrec/parser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/core/syrec/program.cpp
${CMAKE_CURRENT_SOURCE_DIR}/core/syrec/variable.cpp
${CMAKE_CURRENT_SOURCE_DIR}/core/truthTable/truth_table.cpp
${CMAKE_CURRENT_SOURCE_DIR}/core/truthTable/dd_synthesis.cpp
${CMAKE_CURRENT_SOURCE_DIR}/core/truthTable/pla_parser.cpp

${${PROJECT_NAME}_SOURCE_DIR}/include/core/gate.hpp
${${PROJECT_NAME}_SOURCE_DIR}/include/core/circuit.hpp
Expand All @@ -19,7 +22,10 @@ add_library(${PROJECT_NAME}
${${PROJECT_NAME}_SOURCE_DIR}/include/core/syrec/program.hpp
${${PROJECT_NAME}_SOURCE_DIR}/include/core/syrec/statement.hpp
${${PROJECT_NAME}_SOURCE_DIR}/include/core/syrec/variable.hpp
${${PROJECT_NAME}_SOURCE_DIR}/include/core/utils/timer.hpp)
${${PROJECT_NAME}_SOURCE_DIR}/include/core/utils/timer.hpp
${${PROJECT_NAME}_SOURCE_DIR}/include/core/truthTable/truth_table.hpp
${${PROJECT_NAME}_SOURCE_DIR}/include/core/truthTable/dd_synthesis.hpp
${${PROJECT_NAME}_SOURCE_DIR}/include/core/truthTable/pla_parser.hpp)

# set include directories
target_include_directories(${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${${PROJECT_NAME}_SOURCE_DIR}/include>)
Expand Down
Loading