From ba0ddd01d304293aa17d82ec132de68886d3bfd5 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Tue, 23 Aug 2022 10:52:05 -0700 Subject: [PATCH] [engine] fixing the bugs on subtiles --- .../annotation/annotate_physical_tiles.cpp | 4 +++ .../src/annotation/vpr_device_annotation.cpp | 26 +++++++++++++++++++ .../src/annotation/vpr_device_annotation.h | 7 +++++ 3 files changed, 37 insertions(+) diff --git a/openfpga/src/annotation/annotate_physical_tiles.cpp b/openfpga/src/annotation/annotate_physical_tiles.cpp index db368ca7a..a6c3b072b 100644 --- a/openfpga/src/annotation/annotate_physical_tiles.cpp +++ b/openfpga/src/annotation/annotate_physical_tiles.cpp @@ -38,6 +38,10 @@ void build_physical_tile_pin2port_info(const DeviceContext& vpr_device_ctx, vpr_device_annotation.add_physical_tile_pin_subtile_index(&physical_tile, absolute_pin_index, subtile_index); + vpr_device_annotation.add_physical_tile_z_to_subtile_index(&physical_tile, + subtile_index, + &sub_tile - &(physical_tile.sub_tiles[0]) + ); } } /* Count the number of pins for each sub tile */ diff --git a/openfpga/src/annotation/vpr_device_annotation.cpp b/openfpga/src/annotation/vpr_device_annotation.cpp index eef4fafbb..9d7e29f25 100644 --- a/openfpga/src/annotation/vpr_device_annotation.cpp +++ b/openfpga/src/annotation/vpr_device_annotation.cpp @@ -348,6 +348,26 @@ int VprDeviceAnnotation::physical_tile_pin_subtile_index(t_physical_tile_type_pt return pin_search_result->second; } +int VprDeviceAnnotation::physical_tile_z_to_subtile_index(t_physical_tile_type_ptr physical_tile, + const int& sub_tile_z) const { + /* Try to find the physical tile in the fast look-up */ + auto physical_tile_search_result = physical_tile_z_to_subtile_indices_.find(physical_tile); + if (physical_tile_search_result == physical_tile_z_to_subtile_indices_.end()) { + /* Not found. Return an invalid index */ + return -1; + } + + /* Try to find the physical tile port info with pin index */ + auto pin_search_result = physical_tile_search_result->second.find(sub_tile_z); + if (pin_search_result == physical_tile_search_result->second.end()) { + /* Not found. Return an invalid index */ + return -1; + } + + /* Reach here, we should find a port. Return the port information */ + return pin_search_result->second; +} + /************************************************************************ * Public mutators ***********************************************************************/ @@ -637,4 +657,10 @@ void VprDeviceAnnotation::add_physical_tile_pin_subtile_index(t_physical_tile_ty physical_tile_pin_subtile_indices_[physical_tile][pin_index] = subtile_index; } +void VprDeviceAnnotation::add_physical_tile_z_to_subtile_index(t_physical_tile_type_ptr physical_tile, + const int& subtile_z, + const int& subtile_index) { + physical_tile_z_to_subtile_indices_[physical_tile][subtile_z] = subtile_index; +} + } /* End namespace openfpga*/ diff --git a/openfpga/src/annotation/vpr_device_annotation.h b/openfpga/src/annotation/vpr_device_annotation.h index d1a0f8e99..d389d41eb 100644 --- a/openfpga/src/annotation/vpr_device_annotation.h +++ b/openfpga/src/annotation/vpr_device_annotation.h @@ -90,6 +90,8 @@ class VprDeviceAnnotation { const int& pin_index) const; int physical_tile_pin_subtile_index(t_physical_tile_type_ptr physical_tile, const int& pin_index) const; + int physical_tile_z_to_subtile_index(t_physical_tile_type_ptr physical_tile, + const int& subtile_z) const; public: /* Public mutators */ void add_pb_type_physical_mode(t_pb_type* pb_type, t_mode* physical_mode); void add_physical_pb_type(t_pb_type* operating_pb_type, t_pb_type* physical_pb_type); @@ -130,6 +132,9 @@ class VprDeviceAnnotation { void add_physical_tile_pin_subtile_index(t_physical_tile_type_ptr physical_tile, const int& pin_index, const int& subtile_index); + void add_physical_tile_z_to_subtile_index(t_physical_tile_type_ptr physical_tile, + const int& subtile_z, + const int& subtile_index); private: /* Internal data */ /* Pair a regular pb_type to its physical pb_type */ std::map physical_pb_types_; @@ -225,6 +230,8 @@ class VprDeviceAnnotation { std::map> physical_tile_pin2port_info_map_; /* A fast look-up from pin index in physical tile to sub tile index */ std::map> physical_tile_pin_subtile_indices_; + /* A fast look-up from z (absolute coordinate) in physical tile to the index in sub tile array */ + std::map> physical_tile_z_to_subtile_indices_; }; } /* End namespace openfpga*/