From ae328cfa7fba62a5a6d2f71d66827f831e3b30e8 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Tue, 26 Jul 2022 21:01:33 -0700 Subject: [PATCH] [lib] add more apis --- libopenfpga/libpcf/src/base/io_pin_table.cpp | 40 +++++++++++++++++++- libopenfpga/libpcf/src/base/io_pin_table.h | 13 +++++-- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/libopenfpga/libpcf/src/base/io_pin_table.cpp b/libopenfpga/libpcf/src/base/io_pin_table.cpp index fa7656111..742e5cf32 100644 --- a/libopenfpga/libpcf/src/base/io_pin_table.cpp +++ b/libopenfpga/libpcf/src/base/io_pin_table.cpp @@ -29,12 +29,30 @@ IoPinTable::io_pin_table_range IoPinTable::internal_pins() const { /************************************************************************ * Public Accessors : Basic data query ***********************************************************************/ -openfpga::BasicPort IoPinTable::internal_pin(const IoPinTableId& pin_id) const { +BasicPort IoPinTable::internal_pin(const IoPinTableId& pin_id) const { /* validate the pin_id */ VTR_ASSERT(valid_pin_id(pin_id)); return internal_pins_[pin_id]; } +BasicPort IoPinTable::external_pin(const IoPinTableId& pin_id) const { + /* validate the pin_id */ + VTR_ASSERT(valid_pin_id(pin_id)); + return external_pins_[pin_id]; +} + +e_side IoPinTable::pin_side(const IoPinTableId& pin_id) const { + /* validate the pin_id */ + VTR_ASSERT(valid_pin_id(pin_id)); + return pin_sides_[pin_id]; +} + +IoPinTable::e_io_direction IoPinTable::pin_direction(const IoPinTableId& pin_id) const { + /* validate the pin_id */ + VTR_ASSERT(valid_pin_id(pin_id)); + return pin_directions_[pin_id]; +} + bool IoPinTable::empty() const { return 0 == pin_ids_.size(); } @@ -63,6 +81,26 @@ IoPinTableId IoPinTable::create_pin() { return pin_id; } +void IoPinTable::set_internal_pin(const IoPinTableId& pin_id, const BasicPort& pin) { + VTR_ASSERT(valid_pin_id(pin_id)); + internal_pins_[pin_id] = pin; +} + +void IoPinTable::set_external_pin(const IoPinTableId& pin_id, const BasicPort& pin) { + VTR_ASSERT(valid_pin_id(pin_id)); + external_pins_[pin_id] = pin; +} + +void IoPinTable::set_pin_side(const IoPinTableId& pin_id, const e_side& side) { + VTR_ASSERT(valid_pin_id(pin_id)); + pin_sides_[pin_id] = side; +} + +void IoPinTable::set_pin_direction(const IoPinTableId& pin_id, const e_io_direction& direction) { + VTR_ASSERT(valid_pin_id(pin_id)); + pin_directions_[pin_id] = direction; +} + /************************************************************************ * Internal invalidators/validators ***********************************************************************/ diff --git a/libopenfpga/libpcf/src/base/io_pin_table.h b/libopenfpga/libpcf/src/base/io_pin_table.h index d01e2307e..879e3f259 100644 --- a/libopenfpga/libpcf/src/base/io_pin_table.h +++ b/libopenfpga/libpcf/src/base/io_pin_table.h @@ -72,18 +72,23 @@ class IoPinTable { */ io_pin_table_range internal_pins() const; public: /* Public Accessors: Basic data query */ - /* Get the internal pin */ + /* Get the basic information for a pin */ openfpga::BasicPort internal_pin(const IoPinTableId& pin_id) const; - + openfpga::BasicPort external_pin(const IoPinTableId& pin_id) const; + e_side pin_side(const IoPinTableId& pin_id) const; + e_io_direction pin_direction(const IoPinTableId& pin_id) const; /* Check if there are any pins */ bool empty() const; - public: /* Public Mutators */ /* Reserve to be memory efficent */ void reserve_pins(const size_t& num_pins); - /* Add a pin to storage */ IoPinTableId create_pin(); + /* Set pin attributes */ + void set_internal_pin(const IoPinTableId& pin_id, const BasicPort& pin); + void set_external_pin(const IoPinTableId& pin_id, const BasicPort& pin); + void set_pin_side(const IoPinTableId& pin_id, const e_side& side); + void set_pin_direction(const IoPinTableId& pin_id, const e_io_direction& direction); public: /* Public invalidators/validators */ /* Show if the pin id is a valid for data queries */