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

🐛 Place inputs and outputs in the same order during hexagonalization #342

Merged
merged 2 commits into from
Nov 30, 2023
Merged
Changes from all commits
Commits
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
35 changes: 29 additions & 6 deletions include/fiction/algorithms/physical_design/hexagonalization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,16 @@ template <typename HexLyt, typename CartLyt>
// calculate offset
const auto offset = detail::get_offset<HexLyt, CartLyt>(lyt, layout_width, layout_height);

// inputs
lyt.foreach_pi(
[&lyt, &hex_layout, &offset, &layout_height](const auto& gate)
{
const auto old_coord = lyt.get_tile(gate);
tile<CartLyt> hex{detail::to_hex<CartLyt, HexLyt>(old_coord, layout_height)};
hex.x -= offset;
hex_layout.create_pi(lyt.get_name(lyt.get_node(old_coord)), hex);
});

// iterate through cartesian layout diagonally
for (uint64_t k = 0; k < layout_width + layout_height - 1; ++k)
{
Expand All @@ -189,7 +199,7 @@ template <typename HexLyt, typename CartLyt>

if (lyt.is_pi(node))
{
hex_layout.create_pi(lyt.get_name(lyt.get_node(old_coord)), hex);
continue;
}

if (const auto signals = lyt.incoming_data_flow(old_coord); signals.size() == 1)
Expand All @@ -202,11 +212,7 @@ template <typename HexLyt, typename CartLyt>

const auto hex_signal = hex_layout.make_signal(hex_layout.get_node(hex_tile));

if (lyt.is_po(node))
{
hex_layout.create_po(hex_signal, lyt.get_name(lyt.get_node(old_coord)), hex);
}
else if (lyt.is_wire(node))
if (!lyt.is_po(node) and lyt.is_wire(node))
{
hex_layout.create_buf(hex_signal, hex);
}
Expand Down Expand Up @@ -264,6 +270,23 @@ template <typename HexLyt, typename CartLyt>
}
}
}

// outputs
lyt.foreach_po(
[&lyt, &hex_layout, &offset, &layout_height](const auto& gate)
{
const auto old_coord = lyt.get_tile(lyt.get_node(gate));
const auto signal = lyt.incoming_data_flow(old_coord)[0];

tile<CartLyt> hex{detail::to_hex<CartLyt, HexLyt>(old_coord, layout_height)};
auto hex_tile = detail::to_hex<CartLyt, HexLyt>(signal, layout_height);
hex.x -= offset;
hex_tile.x -= offset;

const auto hex_signal = hex_layout.make_signal(hex_layout.get_node(hex_tile));
hex_layout.create_po(hex_signal, lyt.get_name(lyt.get_node(old_coord)), hex);
});

// calculate bounding box
const auto bounding_box = bounding_box_2d(hex_layout);
const auto layout_max = bounding_box.get_max();
Expand Down
Loading