From 4d7757327c2aa3fdcf923e299cabc94def0e01d5 Mon Sep 17 00:00:00 2001 From: Simon Hofmann Date: Tue, 7 Nov 2023 09:44:13 +0100 Subject: [PATCH] substitute po signals --- .../algorithms/physical_design/orthogonal.hpp | 7 +++-- test/networks/technology_network.cpp | 31 +++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/include/fiction/algorithms/physical_design/orthogonal.hpp b/include/fiction/algorithms/physical_design/orthogonal.hpp index 92f29b077..22dc66f8f 100644 --- a/include/fiction/algorithms/physical_design/orthogonal.hpp +++ b/include/fiction/algorithms/physical_design/orthogonal.hpp @@ -394,8 +394,11 @@ class orthogonal_impl { // measure run time mockturtle::stopwatch stop{pst.time_total}; + ntk.substitute_po_signals(); + mockturtle::topo_view ntk_topo{ntk}; + // compute a coloring - const auto ctn = east_south_edge_coloring(ntk); + const auto ctn = east_south_edge_coloring(ntk_topo); mockturtle::node_map, decltype(ctn.color_ntk)> node2pos{ctn.color_ntk}; @@ -598,7 +601,7 @@ class orthogonal_impl } private: - mockturtle::topo_view>> ntk; + mockturtle::fanout_view> ntk; orthogonal_physical_design_params ps; orthogonal_physical_design_stats& pst; diff --git a/test/networks/technology_network.cpp b/test/networks/technology_network.cpp index 33244588a..6dba12415 100644 --- a/test/networks/technology_network.cpp +++ b/test/networks/technology_network.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include @@ -823,3 +824,33 @@ TEST_CASE("substitute PO signals", "[technology-network]") CHECK(tec.fanout_size(i) == 2); CHECK(tec.fanout_size(b) == 1); } + +TEST_CASE("substitute PO signals corner case", "[technology-network]") +{ + technology_network tec{}; + + const auto x1 = tec.create_pi(); + const auto x2 = tec.create_pi(); + + const auto a = tec.create_and(x1, x2); + + tec.create_po(a); + tec.create_po(a); + + CHECK(tec.size() == 5); + CHECK(tec.is_po(a)); + CHECK(tec.fanout_size(a) == 2); + + tec.substitute_po_signals(); + mockturtle::topo_view tec_topo{tec}; + + CHECK(tec.size() == 7); + CHECK(!tec_topo.is_po(a)); + CHECK(tec_topo.fanout_size(a) == 2); + + std::vector nodes{}; + tec_topo.foreach_node([&](const auto& node) { nodes.push_back(node); }); + + tec_topo.foreach_po([&](const auto& gate) + { CHECK(std::find(nodes.begin(), nodes.end(), tec_topo.get_node(gate)) != nodes.end()); }); +}