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

🎨 Improved usability of the on-the-fly SiDB gate library #634

Open
wants to merge 88 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
9477cf8
:memo: Update pyfiction docstrings
actions-user Dec 12, 2024
35fed45
Merge branch 'cda-tum:main' into main
Drewniok Dec 26, 2024
bc905b7
Merge branch 'cda-tum:main' into main
Drewniok Jan 2, 2025
f188a69
Merge branch 'cda-tum:main' into main
Drewniok Jan 7, 2025
65ec0a5
Merge branch 'cda-tum:main' into main
Drewniok Jan 8, 2025
24c2421
Merge branch 'cda-tum:main' into main
Drewniok Jan 9, 2025
4113659
:memo: Update pyfiction docstrings
actions-user Jan 9, 2025
72e08f4
Merge branch 'cda-tum:main' into main
Drewniok Jan 11, 2025
dfb71fb
Merge branch 'cda-tum:main' into main
Drewniok Jan 12, 2025
d5c5ff5
Merge branch 'cda-tum:main' into main
Drewniok Jan 13, 2025
9d45592
Merge branch 'cda-tum:main' into main
Drewniok Jan 13, 2025
dfaf039
Merge branch 'cda-tum:main' into main
Drewniok Jan 14, 2025
09c654e
:art: small changes.
Drewniok Jan 14, 2025
da5bc9d
:sparkles: add function to count charged and uncharged defects.
Drewniok Jan 15, 2025
fc096de
:white_check_mark: add test files for apply gate library.
Drewniok Jan 15, 2025
ca3f957
:construction_worker: add TEST_PATH to cmake.
Drewniok Jan 15, 2025
6c4f457
:art: small changes.
Drewniok Jan 15, 2025
bc58c7d
:art: restructure code to make the on-the-fly circuit design more acc…
Drewniok Jan 15, 2025
50fc4cc
:white_check_mark: add test for the apply gate library function.
Drewniok Jan 15, 2025
593bb30
:sparkles: add function to detect defects.
Drewniok Jan 15, 2025
6dd2c89
:art: several smaller fixes and changes.
Drewniok Jan 15, 2025
0d54041
:art: small fix.
Drewniok Jan 15, 2025
be59657
:memo: Update pyfiction docstrings
actions-user Jan 15, 2025
af15694
Merge branch 'cda-tum:main' into main
Drewniok Jan 15, 2025
83f354d
Merge branch 'main' into make_on_the_fly_more_accessible
Drewniok Jan 15, 2025
9b44258
:memo: Update pyfiction docstrings
actions-user Jan 15, 2025
54c0d00
:art: solve merge issue.
Drewniok Jan 15, 2025
3daff0b
Merge remote-tracking branch 'origin/make_on_the_fly_more_accessible'…
Drewniok Jan 15, 2025
7889a43
:memo: Update pyfiction docstrings
actions-user Jan 15, 2025
49ebab6
:art: solve merge issue.
Drewniok Jan 15, 2025
e516acd
:art: solve merge issue.
Drewniok Jan 15, 2025
952a0a5
Merge remote-tracking branch 'origin/make_on_the_fly_more_accessible'…
Drewniok Jan 15, 2025
762a0ff
:art: solve merge issue.
Drewniok Jan 15, 2025
29c480a
:memo: Update pyfiction docstrings
actions-user Jan 15, 2025
4444544
:art: small fix.
Drewniok Jan 18, 2025
78b5962
:alembic: update experiment after renaming.
Drewniok Jan 18, 2025
74dfaab
Merge branch 'cda-tum:main' into main
Drewniok Jan 19, 2025
5598bce
Merge branch 'cda-tum:main' into main
Drewniok Jan 23, 2025
7a1cde8
Merge branch 'cda-tum:main' into main
Drewniok Jan 24, 2025
ecb1fbb
Merge branch 'cda-tum:main' into main
Drewniok Jan 25, 2025
8c6bd0a
Merge branch 'cda-tum:main' into main
Drewniok Jan 28, 2025
7e83ea4
:white_check_mark: add test files.
Drewniok Jan 28, 2025
884e1bb
:art: implement Marcel's feedback.
Drewniok Jan 28, 2025
c669c9a
Merge branch 'main' into make_on_the_fly_more_accessible
Drewniok Jan 28, 2025
afd8ee6
:memo: Update pyfiction docstrings
actions-user Jan 28, 2025
fd2e3eb
:memo: update docu.
Drewniok Jan 28, 2025
3a78118
:art: Slight revamp of the CMake test configuration
marcelwa Jan 28, 2025
2c83095
Merge remote-tracking branch 'origin/make_on_the_fly_more_accessible'…
marcelwa Jan 28, 2025
308da48
:bug: fix typo.
Drewniok Jan 28, 2025
5004cc8
:white_check_mark: update test.
Drewniok Jan 28, 2025
e1b3bed
:white_check_mark: update test.
Drewniok Jan 28, 2025
581e18d
:white_check_mark: add test files.
Drewniok Jan 29, 2025
d1b9fb3
:art: restructuring.
Drewniok Jan 29, 2025
f94f5ab
:memo: Update pyfiction docstrings
actions-user Jan 29, 2025
1c5e90e
:art: small fix.
Drewniok Jan 29, 2025
a8736b8
:art: small fix.
Drewniok Jan 29, 2025
fc8e96d
Merge branch 'cda-tum:main' into main
Drewniok Jan 30, 2025
b2231cc
Merge branch 'main' into make_on_the_fly_more_accessible
Drewniok Jan 30, 2025
e50b86f
:art: small fix.
Drewniok Jan 30, 2025
43dccab
:art: revert changes.
Drewniok Jan 30, 2025
f13556f
:art: try to fix windows CI.
Drewniok Jan 30, 2025
a4ec5fd
:art: small fixes.
Drewniok Jan 30, 2025
affdf46
:memo: Update pyfiction docstrings
actions-user Jan 30, 2025
d99ce1e
:green_heart: try to fix windows CI.
Drewniok Jan 30, 2025
7016d22
:green_heart: try to fix windows CI.
Drewniok Jan 31, 2025
9f1d8a1
Merge branch 'cda-tum:main' into main
Drewniok Jan 31, 2025
3a89613
Merge branch 'main' into make_on_the_fly_more_accessible
Drewniok Jan 31, 2025
82485b8
:green_heart: try to fix windows CI.
Drewniok Jan 31, 2025
943391d
:green_heart: try to fix windows CI.
Drewniok Jan 31, 2025
5073c49
:green_heart: update docu.
Drewniok Jan 31, 2025
71d4430
:green_heart: fix windows CI.
Drewniok Jan 31, 2025
df35a98
:memo: small fix.
Drewniok Jan 31, 2025
9bd5238
Merge branch 'main' into make_on_the_fly_more_accessible
Drewniok Feb 3, 2025
4003bc4
Merge branch 'main' into make_on_the_fly_more_accessible
Drewniok Feb 4, 2025
efcf859
:children_crossing: structure test files in folders.
Drewniok Feb 5, 2025
8e4670d
:art: implement Marcel's feedback.
Drewniok Feb 6, 2025
244101a
:art: implement Marcel's feedback.
Drewniok Feb 6, 2025
4ef728a
:memo: Update pyfiction docstrings
actions-user Feb 6, 2025
28c5311
:art: fix typo.
Drewniok Feb 6, 2025
7ef7b78
:art: small fix.
Drewniok Feb 6, 2025
2ea3faf
:memo: Update pyfiction docstrings
actions-user Feb 6, 2025
0379d50
:art: revert test line.
Drewniok Feb 6, 2025
14b393e
Merge branch 'main' into make_on_the_fly_more_accessible
Drewniok Feb 13, 2025
c5438a1
:memo: adjust readme.
Drewniok Feb 14, 2025
39d528a
Merge branch 'main' into make_on_the_fly_more_accessible
Drewniok Feb 14, 2025
6b05f22
Merge branch 'main' into make_on_the_fly_more_accessible
Drewniok Feb 16, 2025
73ffff3
:art: implement Marcel's feedback.
Drewniok Feb 18, 2025
511f11a
Merge branch 'main' into make_on_the_fly_more_accessible
Drewniok Feb 18, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ void fcn_technology_cell_level_layout(pybind11::module& m)
.def("is_pi", &py_cartesian_technology_cell_layout::is_pi, py::arg("c"), DOC(fiction_cell_level_layout_is_pi))
.def("is_po", &py_cartesian_technology_cell_layout::is_po, py::arg("c"), DOC(fiction_cell_level_layout_is_po))

// todo add docu
.def("get_cell_type", &py_cartesian_technology_cell_layout::get_cell_type, py::arg("c"))
.def("get_cells_by_type", &py_cartesian_technology_cell_layout::get_cells_by_type, py::arg("type"))
.def("num_cells_of_given_type", &py_cartesian_technology_cell_layout::num_cells_of_given_type, py::arg("type"))

.def("cells",
[](const py_cartesian_technology_cell_layout& lyt)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ template <typename LatticeOrientation>
void sidb_lattice_cell_level_layout(pybind11::module& m)
{
namespace py = pybind11;
namespace py = pybind11;

// fetch technology name
auto orientation = std::string{fiction::sidb_lattice_name<LatticeOrientation>};
Expand Down
3 changes: 3 additions & 0 deletions bindings/mnt/pyfiction/test/layouts/test_cell_level_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ def test_cell_type_assignment(self):
layout.assign_cell_type((3, 2), qca_technology.cell_type.NORMAL)
layout.assign_cell_type((4, 2), qca_technology.cell_type.OUTPUT)

self.assertEqual(layout.get_cells_by_type(qca_technology.cell_type.OUTPUT), [(4, 2)])
self.assertEqual(layout.num_cells_of_given_type(qca_technology.cell_type.INPUT), 2)

self.assertFalse(layout.is_empty())

layout.assign_cell_name((0, 2), "a")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ int main() // NOLINT
params.exact_design_parameters.upper_bound_y = 30; // 12 x 31 tiles
params.exact_design_parameters.timeout = 3'600'000; // 1h in ms

params.sidb_on_the_fly_gate_library_parameters.defect_surface = std::optional{surface_lattice};
params.sidb_on_the_fly_gate_library_parameters.defect_surface = surface_lattice;
params.sidb_on_the_fly_gate_library_parameters.design_gate_params = design_gate_params;

fiction::on_the_fly_circuit_design_on_defective_surface_stats<gate_lyt> st{};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,28 @@
#include <cstdio>
#include <optional>
#include <stdexcept>
#include <string_view>
#include <utility>

namespace fiction
{

/**
* Exception thrown when no valid placement and routing is found for the given blacklist.
*/
class unsuccessful_pr_error : public std::runtime_error
{
public:
explicit unsuccessful_pr_error(const std::string_view& msg) noexcept : std::runtime_error(msg.data()) {}
};
/**
* Exception thrown when the gate design was unsuccessful.
*/
class unsuccessful_gate_design_error : public std::runtime_error
{
public:
explicit unsuccessful_gate_design_error(const std::string_view& msg) noexcept : std::runtime_error(msg.data()) {}
};
/**
* This struct stores the parameters to design an SiDB circuit on a defective surface.
*
Expand Down Expand Up @@ -101,7 +118,7 @@ struct on_the_fly_circuit_design_on_defective_surface_stats
* @param defective_surface The defective surface on which the SiDB circuit is designed.
* @param params The parameters used for designing the circuit, encapsulated in an
* `on_the_fly_sidb_circuit_design_params` object.
* @param stats Pointer to a structure for collecting statistics. If nullptr, statistics are not collected.
* @param stats Pointer to a structure for collecting statistics. If `nullptr`, statistics are discarded.
* @return A `sidb_defect_surface<CellLyt>` representing the designed circuit on the defective surface.
*/
template <typename Ntk, typename CellLyt, typename GateLyt>
Expand Down Expand Up @@ -171,20 +188,30 @@ template <typename Ntk, typename CellLyt, typename GateLyt>
fmt::print(stderr, "[e] Terminating loop due to critical error.\n");
break;
}

catch (...)
{
fmt::print(stderr, "[e] An unexpected error occurred during gate design.\n");
fmt::print(stderr, "[e] Terminating loop due to critical error.\n");
break;
}
}
// P&R was unsuccessful
else
{
throw std::runtime_error("P&R was unsuccessful");
throw unsuccessful_pr_error("Placement and routing was unsuccessful");
}
}

sidb_defect_surface<CellLyt> sidbs_and_defects{lyt};

// add defects to the circuit.
params.sidb_on_the_fly_gate_library_parameters.defect_surface.value().foreach_sidb_defect(
[&sidbs_and_defects](const auto& defect)
{ sidbs_and_defects.assign_sidb_defect(defect.first, defect.second); });
if (params.sidb_on_the_fly_gate_library_parameters.defect_surface.has_value())
{
// add defects to the circuit.
params.sidb_on_the_fly_gate_library_parameters.defect_surface.value().foreach_sidb_defect(
[&sidbs_and_defects](const auto& defect)
{ sidbs_and_defects.assign_sidb_defect(defect.first, defect.second); });
}

result = sidbs_and_defects;
}
Expand All @@ -209,7 +236,7 @@ template <typename Ntk, typename CellLyt, typename GateLyt>
* @param lattice_tiling The lattice tiling used for the circuit design.
* @param params The parameters used for designing the circuit, encapsulated in an
* `on_the_fly_sidb_circuit_design_params` object.
* @param stats Pointer to a structure for collecting statistics. If `nullptr`, statistics are not collected.
* @param stats Pointer to a structure for collecting statistics. If `nullptr`, statistics are discarded.
* @return A `CellLyt` representing the designed SiDB circuit.
*/
template <typename CellLyt, typename GateLyt>
Expand All @@ -234,7 +261,7 @@ template <typename CellLyt, typename GateLyt>
// blacklist and the process is rerun.
catch (const gate_design_exception<tt, GateLyt>& e)
{
throw std::runtime_error("Gate design was unsuccessful");
throw unsuccessful_gate_design_error("Gate design was unsuccessful");
}
}

Expand Down
10 changes: 7 additions & 3 deletions include/fiction/technology/fcn_gate_library.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class unsupported_gate_type_exception : public std::exception

private:
/**
* Coordinate of teh layout where the unsupported gate type was found.
* Coordinate at which the unsupported gate type was found.
*/
const CoordinateType coord;
};
Expand All @@ -59,14 +59,18 @@ class unsupported_gate_orientation_exception : public std::exception
ports{p}
{}
/**
* Coordinate of the layout where the unsupported gate orientation was found.
* Coordinate at which the unsupported gate orientation was found.
*
* @return Coordinate.
*/
[[nodiscard]] CoordinateType where() const noexcept
{
return coord;
}
/**
* Ports of the unsupported gate orientation.
*
* @return Ports.
*/
[[nodiscard]] port_list<PortType> which_ports() const noexcept
{
Expand All @@ -75,7 +79,7 @@ class unsupported_gate_orientation_exception : public std::exception

private:
/**
* Coordinate of the layout where the unsupported gate orientation was found.
* Coordinate at which the unsupported gate orientation was found.
*/
const CoordinateType coord;
/**
Expand Down
36 changes: 28 additions & 8 deletions include/fiction/technology/sidb_defect_surface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <phmap.h>

#include <cassert>
#include <cstddef>
#include <cstdint>
#include <memory>
#include <optional>
Expand Down Expand Up @@ -184,24 +185,43 @@ class sidb_defect_surface<Lyt, false> : public Lyt
return strg->defective_coordinates.size();
}
/**
* Returns the number of charged defects.
*
* @return Number of charged defects.
*/
[[nodiscard]] std::size_t num_charged_defects() const noexcept
[[nodiscard]] std::size_t num_positively_charged_defects() const noexcept
{
std::size_t number_of_charged_defects = 0;
std::size_t number_of_positively_charged_defects = 0;

this->foreach_sidb_defect(
[&number_of_charged_defects](const auto& defect)
[&number_of_positively_charged_defects](const auto& defect)
{
if (is_charged_defect_type(defect.second))
if (is_positively_charged_defect(defect.second))
{
number_of_charged_defects++;
number_of_positively_charged_defects++;
}
});

return number_of_charged_defects;
return number_of_positively_charged_defects;
}

[[nodiscard]] std::size_t num_negatively_charged_defects() const noexcept
{
std::size_t number_of_negatively_charged_defects = 0;

this->foreach_sidb_defect(
[&number_of_negatively_charged_defects](const auto& defect)
{
if (is_negatively_charged_defect(defect.second))
{
number_of_negatively_charged_defects++;
}
});

return number_of_negatively_charged_defects;
}

[[nodiscard]] std::size_t num_charged_defects() const noexcept
{
return num_positively_charged_defects() + num_negatively_charged_defects();
}
/**
* Returns the number of neutral defects.
Expand Down
28 changes: 13 additions & 15 deletions include/fiction/technology/sidb_on_the_fly_gate_library.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ struct sidb_on_the_fly_gate_library_params
*/
double influence_radius_charged_defects = 15; // (unit: nm)
/**
* This layout stores all atomic defects. ``std::nullopt`` if no defect surface is given.
* This layout stores all atomic defects. `std::nullopt` if no defect surface is given.
*/
std::optional<sidb_defect_surface<Lyt>> defect_surface{std::nullopt};
};
Expand Down Expand Up @@ -234,7 +234,7 @@ class sidb_on_the_fly_gate_library : public fcn_gate_library<sidb_technology, 60
defect_surface.value(), skeleton, params.influence_radius_charged_defects,
center_cell, absolute_cell);

if (is_bestagon_gate_applicable(
if (is_predefined_bestagon_gate_applicable(
cell_list_to_cell_level_layout<CellLyt>(DOUBLE_WIRE), skeleton_with_defects,
create_double_wire_tt(), params))
{
Expand All @@ -261,9 +261,9 @@ class sidb_on_the_fly_gate_library : public fcn_gate_library<sidb_technology, 60
defect_surface.value(), skeleton, params.influence_radius_charged_defects,
center_cell, absolute_cell);

if (is_bestagon_gate_applicable(cell_list_to_cell_level_layout<CellLyt>(CROSSING),
skeleton_with_defects, create_crossing_wire_tt(),
params))
if (is_predefined_bestagon_gate_applicable(
cell_list_to_cell_level_layout<CellLyt>(CROSSING), skeleton_with_defects,
create_crossing_wire_tt(), params))
{
return CROSSING;
}
Expand Down Expand Up @@ -525,23 +525,23 @@ class sidb_on_the_fly_gate_library : public fcn_gate_library<sidb_technology, 60

private:
/**
* This function evaluates whether a Bestagon gate can be applied to the given node by considering
* This function evaluates whether a predefined Bestagon gate can be applied to the given node by considering
* various conditions, including the presence of defects and spacing requirements.
*
* @tparam Lyt The type of the cell-level layout.
* @tparam TT Truth table type.
* @tparam Params Type of the parameters used for the parametrized gate library.
* @param bestagon_lyt The Bestagon gate which is to be applied.
* @param skeleton_with_defects The skeleton layout with atomic defects.
* @param truth_table The truth table representing the gate's logic function.
* @param parameters Parameters for the gate design and simulation.
* @return `true` if the Bestagon gate is applicable to the layout, considering the provided conditions;
* otherwise, returns `false`.
*/
template <typename Lyt, typename TT>
[[nodiscard]] static bool is_bestagon_gate_applicable(const Lyt& bestagon_lyt,
const sidb_defect_surface<Lyt>& skeleton_with_defects,
const std::vector<TT>& truth_table,
const sidb_on_the_fly_gate_library_params<Lyt>& parameters)
[[nodiscard]] static bool is_predefined_bestagon_gate_applicable(
const Lyt& bestagon_lyt, const sidb_defect_surface<Lyt>& skeleton_with_defects,
const std::vector<TT>& truth_table, const sidb_on_the_fly_gate_library_params<Lyt>& parameters)
{
const auto sidbs_affected_by_defects = skeleton_with_defects.all_affected_sidbs(std::pair(0, 0));

Expand All @@ -551,12 +551,10 @@ class sidb_on_the_fly_gate_library : public fcn_gate_library<sidb_technology, 60

assert(!logic_cells.empty() && "No Logic cells are found");

for (const auto& l_cells : logic_cells)
if (std::any_of(logic_cells.cbegin(), logic_cells.cend(),
[&](const auto& l_cell) { return sidbs_affected_by_defects.count(l_cell); }))
{
if (sidbs_affected_by_defects.count(l_cells))
{
return false;
}
return false;
}

for (const auto& l_cells : logic_cells)
Expand Down
Loading