Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
01db414
:memo: Update pyfiction docstrings
actions-user Jan 2, 2025
35099de
Merge remote-tracking branch 'origin/main'
hibenj Jan 15, 2025
896c8b7
Merge branch 'cda-tum:main' into main
hibenj Jan 21, 2025
7488fd7
Merge branch 'cda-tum:main' into main
hibenj Jan 24, 2025
be30509
Merge branch 'cda-tum:main' into main
hibenj May 5, 2025
6b7da02
Merge branch 'cda-tum:main' into main
hibenj Jun 20, 2025
fe7fe1d
Merge branch 'cda-tum:main' into main
hibenj Jun 30, 2025
28838cb
Merge branch 'cda-tum:main' into main
hibenj Jul 15, 2025
86e65a8
Merge branch 'cda-tum:main' into main
hibenj Sep 26, 2025
447db87
Merge branch 'cda-tum:main' into main
hibenj Sep 29, 2025
fea6fda
:heavy_plus_sign: starting files
hibenj Oct 2, 2025
12a817b
:memo: Update pyfiction docstrings
actions-user Oct 2, 2025
c2f2ca9
:heavy_plus_sign: starting files
hibenj Oct 2, 2025
e3fc515
Merge remote-tracking branch 'origin/planar_ortho_pr' into planar_ort…
hibenj Oct 2, 2025
78c11ce
:memo: Update pyfiction docstrings
actions-user Oct 2, 2025
1a6f535
:art: modified mutable_rank_view.hpp
hibenj Oct 2, 2025
c493a05
Merge remote-tracking branch 'origin/planar_ortho_pr' into planar_ort…
hibenj Oct 2, 2025
9c43e06
:art: updated all files
hibenj Oct 6, 2025
263d0e3
:memo: Update pyfiction docstrings
actions-user Oct 6, 2025
a73295c
:art: updated docstring
hibenj Oct 7, 2025
ec3197d
Merge remote-tracking branch 'origin/planar_ortho_pr' into planar_ort…
hibenj Oct 7, 2025
ee39d01
:memo: Update pyfiction docstrings
actions-user Oct 7, 2025
875f136
:art: updated docstring
hibenj Oct 7, 2025
13c6bac
Merge remote-tracking branch 'origin/planar_ortho_pr' into planar_ort…
hibenj Oct 7, 2025
0d9677d
:memo: Update pyfiction docstrings
actions-user Oct 7, 2025
47121e6
:art: updated name conservation
hibenj Oct 7, 2025
7a51997
Merge remote-tracking branch 'origin/planar_ortho_pr' into planar_ort…
hibenj Oct 7, 2025
ecc189a
🎨 Incorporated pre-commit fixes
pre-commit-ci[bot] Oct 7, 2025
d2aeef5
:memo: Update pyfiction docstrings
actions-user Oct 7, 2025
0a3833e
Merge branch 'cda-tum:main' into main
hibenj Oct 9, 2025
f3c537f
Merge branch 'cda-tum:main' into main
hibenj Oct 10, 2025
b0be14a
:art: nitpick comments
hibenj Oct 13, 2025
18d3440
:memo: Update pyfiction docstrings
actions-user Oct 13, 2025
29c85a2
:art: coderabbitai comments
hibenj Oct 13, 2025
9da449e
Merge remote-tracking branch 'origin/planar_ortho_pr' into planar_ort…
hibenj Oct 13, 2025
aa1e9fd
:memo: Update pyfiction docstrings
actions-user Oct 13, 2025
3950220
Merge branch 'cda-tum:main' into main
hibenj Oct 14, 2025
cb06b6a
Merge branch 'cda-tum:main' into main
hibenj Oct 21, 2025
7bc1872
Merge branch 'cda-tum:main' into main
hibenj Oct 24, 2025
71972db
Merge branch 'main' into planar_ortho_pr
hibenj Oct 24, 2025
be3bad4
Merge remote-tracking branch 'origin/planar_ortho_pr' into planar_ort…
hibenj Oct 24, 2025
fee1f7d
Merge branch 'cda-tum:main' into main
hibenj Oct 27, 2025
699cdc5
Merge branch 'main' into planar_ortho_pr
hibenj Oct 27, 2025
6115d67
:repeat: replaced check_planarity with mincross
hibenj Oct 27, 2025
14ae015
🎨 Incorporated pre-commit fixes
pre-commit-ci[bot] Oct 27, 2025
58b8af7
:memo: Update pyfiction docstrings
actions-user Oct 27, 2025
ccb3704
:adhesive_bandage: small changes to also include complemented signals
hibenj Oct 27, 2025
7c9c5f8
Merge remote-tracking branch 'origin/planar_ortho_pr' into planar_ort…
hibenj Oct 27, 2025
3c40183
🎨 Incorporated pre-commit fixes
pre-commit-ci[bot] Oct 27, 2025
db8fd96
:memo: Update pyfiction docstrings
actions-user Oct 27, 2025
cb7db4f
:repeat: refactored using raw pointers to indexed values in node_pair
hibenj Oct 27, 2025
d5186d9
Merge remote-tracking branch 'origin/planar_ortho_pr' into planar_ort…
hibenj Oct 27, 2025
cbb94ca
:memo: Update pyfiction docstrings
actions-user Oct 27, 2025
2b0d49b
:art: clang-format
hibenj Oct 27, 2025
264a78f
Merge remote-tracking branch 'origin/planar_ortho_pr' into planar_ort…
hibenj Oct 27, 2025
51b404d
:art: coderabbitai
hibenj Oct 28, 2025
daf845f
:art: codecoverage
hibenj Oct 28, 2025
feca457
:art: codecoverage
hibenj Oct 28, 2025
56eed96
:art: coderabbitai
hibenj Oct 28, 2025
de57c61
🎨 Incorporated pre-commit fixes
pre-commit-ci[bot] Oct 28, 2025
7678638
:book: docstring updated
hibenj Oct 28, 2025
24f3c19
Merge remote-tracking branch 'origin/planar_ortho_pr' into planar_ort…
hibenj Oct 28, 2025
4af9552
:memo: Update pyfiction docstrings
actions-user Oct 28, 2025
013407e
:art: coderabbitai
hibenj Oct 28, 2025
98976eb
Merge remote-tracking branch 'origin/planar_ortho_pr' into planar_ort…
hibenj Oct 28, 2025
85fefbb
:art: suppress unchecked access to optional value
hibenj Oct 28, 2025
3cde343
:art: suppress unchecked access to optional value
hibenj Oct 28, 2025
46884ab
:art: suppress unchecked access to optional value
hibenj Oct 28, 2025
be38caa
:art: suppress unchecked access to optional value
hibenj Oct 28, 2025
40fda74
:art: clang-tidy
hibenj Oct 28, 2025
f0eb038
:art: clang-tidy
hibenj Oct 28, 2025
b12e84c
:art: clang-tidy
hibenj Oct 28, 2025
fd90c54
Merge branch 'main' into planar_ortho_pr
hibenj Nov 21, 2025
7464430
Merge branch 'cda-tum:main' into main
hibenj Nov 21, 2025
7abfccc
:heavy_plus_sign: commands added
hibenj Nov 21, 2025
f93aa9a
:art: clang-tidy
hibenj Nov 21, 2025
ba10e4e
:pencil2: renaming
hibenj Nov 24, 2025
360cca5
🎨 Incorporated pre-commit fixes
pre-commit-ci[bot] Nov 24, 2025
e948de2
:pencil2: renaming
hibenj Nov 24, 2025
150a00b
Merge remote-tracking branch 'origin/planar_ortho_pr' into planar_ort…
hibenj Nov 24, 2025
d56ede7
:pencil2: renaming
hibenj Nov 24, 2025
86f66a4
Merge branch 'main' into planar_ortho_pr
hibenj Nov 24, 2025
11488fe
Merge branch 'cda-tum:main' into main
hibenj Nov 24, 2025
342a7bd
:memo: Update pyfiction docstrings
actions-user Nov 24, 2025
d0afed2
Merge branch 'cda-tum:main' into main
hibenj Dec 3, 2025
7ff571b
Merge branch 'main' into planar_ortho_pr
hibenj Dec 3, 2025
33973c9
:art: added small changes
hibenj Dec 9, 2025
7dfe329
:memo: Update pyfiction docstrings
actions-user Dec 9, 2025
4f4ddc3
:art: small change for node order in equal delay cases
hibenj Dec 9, 2025
46c38b1
Merge remote-tracking branch 'origin/planar_ortho_pr' into planar_ort…
hibenj Dec 9, 2025
1c9fde5
:art: nitpick comments
hibenj Dec 9, 2025
c180359
:memo: Update pyfiction docstrings
actions-user Dec 9, 2025
51e464f
Merge branch 'cda-tum:main' into main
hibenj Dec 9, 2025
0c1863b
Merge branch 'main' into planar_ortho_pr
hibenj Dec 9, 2025
f0edfe8
Merge remote-tracking branch 'origin/planar_ortho_pr' into planar_ort…
hibenj Dec 9, 2025
643925f
🎨 Incorporated pre-commit fixes
pre-commit-ci[bot] Dec 9, 2025
e3c229d
:art: clang-tidy
hibenj Dec 9, 2025
9228a06
:art: added more verbose docstring to plane.hpp
hibenj Dec 18, 2025
0d0aac4
:art: corrected naming convention
hibenj Dec 18, 2025
8a4b48d
:art: improved readability
hibenj Dec 18, 2025
45fa8a1
:art: revert accidental changes in changelog.rst
hibenj Dec 18, 2025
f7a554b
:art: refactored enums for readability
hibenj Dec 18, 2025
97bde8c
:art: refactored enums for readability
hibenj Dec 18, 2025
76857e8
:memo: Update pyfiction docstrings
actions-user Dec 18, 2025
02f28ec
:art: small modifications
hibenj Dec 18, 2025
68bbcc6
Merge remote-tracking branch 'origin/planar_ortho_pr' into planar_ort…
hibenj Dec 18, 2025
f71bb36
:memo: Update pyfiction docstrings
actions-user Dec 18, 2025
b000f61
Merge branch 'cda-tum:main' into main
hibenj Jan 12, 2026
cd66e74
Merge branch 'main' into planar_ortho_pr
hibenj Jan 12, 2026
123febd
Merge remote-tracking branch 'origin/planar_ortho_pr' into planar_ort…
hibenj Jan 12, 2026
77957dd
:art: added support for virtual PIs
hibenj Jan 19, 2026
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
469 changes: 469 additions & 0 deletions bindings/mnt/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions cli/cmd/physical_design/cmd_physical_design.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#endif
#include "include/optimize.hpp"
#include "include/ortho.hpp"
#include "include/plane.hpp"
// NOLINTEND(misc-include-cleaner)

namespace alice
Expand All @@ -36,6 +37,7 @@ ALICE_ADD_COMMAND(onepass, FICTION_CLI_CATEGORY_PHYSICAL_DESIGN)
#endif
ALICE_ADD_COMMAND(optimize, FICTION_CLI_CATEGORY_PHYSICAL_DESIGN)
ALICE_ADD_COMMAND(ortho, FICTION_CLI_CATEGORY_PHYSICAL_DESIGN)
ALICE_ADD_COMMAND(plane, FICTION_CLI_CATEGORY_PHYSICAL_DESIGN)

} // namespace alice

Expand Down
82 changes: 82 additions & 0 deletions cli/cmd/physical_design/include/plane.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//
// Created by benjamin on 21.11.25.
//

#ifndef FICTION_CMD_PLANE_HPP
#define FICTION_CMD_PLANE_HPP

#include <fiction/algorithms/network_transformation/fanout_substitution.hpp>
#include <fiction/algorithms/network_transformation/network_balancing.hpp>
#include <fiction/algorithms/network_transformation/node_duplication_planarization.hpp>
#include <fiction/algorithms/physical_design/planar_layout_from_network_embedding.hpp>

#include <alice/alice.hpp>
#include <nlohmann/json.hpp>

#include <cstdint>

namespace alice
{
/**
* Executes the physical design approach Planar Layout from Network Embedding (PLANE), which finds a valid placement and
* routing without crossings given a planar network embedding.
*
* See include/fiction/algorithms/physical_design/planar_layout_from_network_embedding.hpp for more details.
*/
class plane_command final : public command
{
public:
/**
* Standard constructor. Adds descriptive information, options, and flags.
*
* @param e alice::environment that specifies stores etc.
*/
explicit plane_command(const environment::ptr& e);

protected:
/**
* Function to perform the physical design call. Generates a placed and routed FCN gate layout.
*/
void execute() override;

/**
* Logs the resulting information in a log file.
*
* @return JSON object containing information about the physical design process.
*/
nlohmann::json log() const override;

private:
/**
* Parameters for fanout substitution.
*/
fiction::fanout_substitution_params fan_ps{};
/**
* Parameters for network path balancing.
*/
fiction::network_balancing_params bal_ps{};
/**
* Parameters for planarization via node duplication.
*/
fiction::node_duplication_planarization_params dup_ps{};
/**
* Parameters for planar layout generation from the network embedding.
*/
fiction::planar_layout_from_network_embedding_params ps{};
/**
* Statistics collected during planar layout generation.
*/
fiction::planar_layout_from_network_embedding_stats st{};
/**
* Number of clock phases used in the layout.
*/
uint8_t num_clock_phases = 4u;
/**
* Determines whether primary output order is kept (0) or randomized (1).
*/
uint32_t po_order{0u};
};

} // namespace alice

#endif // FICTION_CMD_PLANE_HPP
133 changes: 133 additions & 0 deletions cli/cmd/physical_design/src/plane.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
//
// Created by benjamin on 21.11.25.
//

#include "cmd/physical_design/include/plane.hpp"

#include "stores.hpp" // NOLINT(misc-include-cleaner)

#include <fiction/algorithms/network_transformation/fanout_substitution.hpp>
#include <fiction/algorithms/network_transformation/network_balancing.hpp>
#include <fiction/algorithms/network_transformation/node_duplication_planarization.hpp>
#include <fiction/algorithms/physical_design/planar_layout_from_network_embedding.hpp>
#include <fiction/layouts/clocking_scheme.hpp>
#include <fiction/networks/views/mutable_rank_view.hpp>
#include <fiction/types.hpp>
#include <fiction/utils/network_utils.hpp>

#include <alice/alice.hpp>
#include <fmt/format.h>
#include <mockturtle/utils/stopwatch.hpp>
#include <nlohmann/json.hpp>

#include <exception>
#include <memory>
#include <stdexcept>
#include <string>
#include <variant>

namespace alice
{

plane_command::plane_command(const environment::ptr& e) :
command(e, "First, a planar embedding is obtained by performing fanout substitution, path balancing, and "
"planarization (node duplication). Then, scalable placement and routing are carried out on the "
"planar layout of the current logic network in store. Compared to the gold algorithm, the "
"resulting layout may occupy more area, but it is generated in reasonable runtime.")
{
// fanout substitution options
fan_ps.degree = 2;
// balancing option
bal_ps.unify_outputs = true;
// planarization option
add_option("--po-order, -p", po_order, "PO order: keep=0, random=1")->set_type_name("{0,1}");
// plane options
add_option("--clock_numbers,-n", num_clock_phases, "Number of clock phases to be used {3 or 4}");
add_flag("--verbose,-v", ps.verbose, "Be verbose");
}

void plane_command::execute()
{
auto& lns = store<fiction::logic_network_t>();
auto& gls = store<fiction::gate_layout_t>();

if (lns.empty())
{
env->out() << "[w] no logic network in store\n";
return;
}
// error case: phases out of range
if (num_clock_phases != 3u && num_clock_phases != 4u)
{
env->out() << "[e] only 3- and 4-phase clocking schemes are supported\n";
ps = {};
return;
}
Comment on lines +60 to +65
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Inconsistent parameter reset on error path.

On invalid clock phases, only ps is reset, but fan_ps, bal_ps, and dup_ps are not. Conversely, at the end of execute() (lines 119-121), only those three are reset but not ps. Consider resetting all parameters consistently in both locations to avoid stale state across invocations.

🔎 Suggested fix
     if (num_clock_phases != 3u && num_clock_phases != 4u)
     {
         env->out() << "[e] only 3- and 4-phase clocking schemes are supported\n";
-        ps = {};
+        fan_ps = {};
+        bal_ps = {};
+        dup_ps = {};
+        ps     = {};
         return;
     }

And at end of execute():

     fan_ps = {};
     bal_ps = {};
     dup_ps = {};
+    ps     = {};
 }

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In cli/cmd/physical_design/src/plane.cpp around lines 60-65, the error path for
unsupported num_clock_phases only resets ps but leaves fan_ps, bal_ps, and
dup_ps stale; likewise at the end of execute() (around lines 119-121) only
fan_ps, bal_ps, and dup_ps are cleared while ps is left. Fix by consistently
clearing all four parameters (ps, fan_ps, bal_ps, dup_ps) in both places so any
early return or normal exit leaves no stale state.


ps.number_of_clock_phases = num_clock_phases == 3 ? fiction::num_clks::THREE : fiction::num_clks::FOUR;

switch (po_order)
{
case 0u:
{
dup_ps.po_order = fiction::node_duplication_planarization_params::output_order::KEEP_PO_ORDER;
break;
}
case 1u:
{
dup_ps.po_order = fiction::node_duplication_planarization_params::output_order::RANDOM_PO_ORDER;
break;
}
default:
{
env->out() << "[w] invalid --po-order, defaulting to keep\n";
dup_ps.po_order = fiction::node_duplication_planarization_params::output_order::KEEP_PO_ORDER;
break;
}
}

const auto perform_fanouts_and_balance = [this](auto&& ntk_ptr)
{
auto tec_f = fiction::fanout_substitution<fiction::tec_nt>(*ntk_ptr, fan_ps);
return std::make_shared<fiction::tec_nt>(fiction::network_balancing<fiction::tec_nt>(tec_f, bal_ps));
};

auto tec_b = std::visit(perform_fanouts_and_balance, lns.current());

const fiction::mutable_rank_view vpi_r(*tec_b);

auto planarized_ntk = fiction::node_duplication_planarization(vpi_r, dup_ps);

try
{
gls.extend() = std::make_shared<fiction::cart_gate_clk_lyt>(
fiction::plane<fiction::cart_gate_clk_lyt>(planarized_ntk, ps, &st));
}
catch (const fiction::high_degree_fanin_exception& e)
{
env->out() << fmt::format("[e] {}\n", e.what());
}
catch (const std::invalid_argument& e)
{
env->out() << fmt::format("[e] {}\n", e.what());
}
catch (const std::exception& e)
{
env->out() << fmt::format("[e] unexpected error: {}\n", e.what());
}

fan_ps = {};
bal_ps = {};
dup_ps = {};
}

nlohmann::json plane_command::log() const
{
return nlohmann::json{{"runtime in seconds", mockturtle::to_seconds(st.time_total)},
{"number of gates", st.num_gates},
{"number of wires", st.num_wires},
{"number of crossings", st.num_crossings},
{"layout", {{"x-size", st.x_size}, {"y-size", st.y_size}, {"area", st.x_size * st.y_size}}}};
}

} // namespace alice
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Unreleased

Added
#####
- Algorithms:
- Node Duplication Planarization, reimplemented from "Fabricatable Interconnect and Molecular QCA Circuits" by Amitabh Chaudhary, Danny Ziyi Chen, Xiaobo Sharon Hu, Michael T. Niemier, Ramprasad Ravichandran, and Kevin Whitton.
- Planar Layout from Network Embedding (PLANE) for generating planar 2DDWave-clocked Cartesian gate-level layouts in a fast and scalable fashion.
- Documentation:
- Added ``AGENTS.md`` to guide AI agents in the repository

Expand Down
Loading
Loading