From 030f9d883762da2a95c4669e5721bea72b0116f7 Mon Sep 17 00:00:00 2001 From: ubuntu Date: Wed, 29 Nov 2023 02:12:07 -0800 Subject: [PATCH] changes according to code review --- .../src/base/repack_design_constraints.cpp | 31 ++++++++++++++++--- .../src/base/repack_design_constraints.h | 8 ++--- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/libs/libpcf/src/base/repack_design_constraints.cpp b/libs/libpcf/src/base/repack_design_constraints.cpp index 68f926042..8a3fa7f76 100644 --- a/libs/libpcf/src/base/repack_design_constraints.cpp +++ b/libs/libpcf/src/base/repack_design_constraints.cpp @@ -2,6 +2,8 @@ #include +#include "openfpga_port_parser.h" +#include "openfpga_tokenizer.h" #include "vtr_assert.h" #include "vtr_log.h" @@ -54,14 +56,14 @@ std::string RepackDesignConstraints::net( return repack_design_constraint_nets_[repack_design_constraint_id]; } -std::vector RepackDesignConstraints::ignore_net_on_pin( +std::set RepackDesignConstraints::ignore_net_on_pin( const std::string& net_name) const { - std::map>::const_iterator it = + std::map>::const_iterator it = ignore_net_pin_map_.find(net_name); if (it != ignore_net_pin_map_.end()) { return it->second; } else { - return std::vector(); + return std::set(); } } @@ -151,7 +153,28 @@ void RepackDesignConstraints::set_net( void RepackDesignConstraints::set_ignore_net_pin_map_( const std::string& net_name, const std::string pin_ctx) { - ignore_net_pin_map_[net_name].push_back(pin_ctx); + /* Extract the pb_type name and port name */ + openfpga::StringToken pin_tokenizer(pin_ctx); + std::vector pin_info = pin_tokenizer.split('.'); + /* Expect two contents, otherwise error out */ + if (pin_info.size() != 2) { + std::string err_msg = + std::string("Invalid content '") + pin_ctx + + std::string("' to skip, expect .\n"); + VTR_LOG_ERROR(err_msg.c_str()); + return; + } + std::string pb_type_name = pin_info[0]; + openfpga::PortParser port_parser(pin_info[1]); + openfpga::BasicPort curr_port = port_parser.port(); + if (!curr_port.is_valid()) { + std::string err_msg = + std::string("Invalid pin definition '") + pin_ctx + + std::string("', expect .[int:int]\n"); + VTR_LOG_ERROR(err_msg.c_str()); + return; + } + ignore_net_pin_map_[net_name].insert(pin_ctx); } /************************************************************************ * Internal invalidators/validators diff --git a/libs/libpcf/src/base/repack_design_constraints.h b/libs/libpcf/src/base/repack_design_constraints.h index c0de2bc85..6401b5f1b 100644 --- a/libs/libpcf/src/base/repack_design_constraints.h +++ b/libs/libpcf/src/base/repack_design_constraints.h @@ -7,7 +7,7 @@ #include #include #include - +#include /* Headers from vtrutil library */ #include "vtr_geometry.h" #include "vtr_vector.h" @@ -69,7 +69,7 @@ class RepackDesignConstraints { std::string net( const RepackDesignConstraintId& repack_design_constraint_id) const; - std::vector ignore_net_on_pin(const std::string& net_name) const; + std::set ignore_net_on_pin(const std::string& net_name) const; /* Find a constrained net */ std::string find_constrained_pin_net(const std::string& pb_type, const openfpga::BasicPort& pin) const; @@ -139,8 +139,8 @@ class RepackDesignConstraints { /* Nets to constraint */ vtr::vector repack_design_constraint_nets_; - - std::map> ignore_net_pin_map_; + + std::map> ignore_net_pin_map_; // std::set }; #endif