[lib] add more apis

This commit is contained in:
tangxifan 2022-07-26 21:01:33 -07:00
parent b8bd19a234
commit ae328cfa7f
2 changed files with 48 additions and 5 deletions

View File

@ -29,12 +29,30 @@ IoPinTable::io_pin_table_range IoPinTable::internal_pins() const {
/************************************************************************ /************************************************************************
* Public Accessors : Basic data query * 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 */ /* validate the pin_id */
VTR_ASSERT(valid_pin_id(pin_id)); VTR_ASSERT(valid_pin_id(pin_id));
return internal_pins_[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 { bool IoPinTable::empty() const {
return 0 == pin_ids_.size(); return 0 == pin_ids_.size();
} }
@ -63,6 +81,26 @@ IoPinTableId IoPinTable::create_pin() {
return pin_id; 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 * Internal invalidators/validators
***********************************************************************/ ***********************************************************************/

View File

@ -72,18 +72,23 @@ class IoPinTable {
*/ */
io_pin_table_range internal_pins() const; io_pin_table_range internal_pins() const;
public: /* Public Accessors: Basic data query */ 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 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 */ /* Check if there are any pins */
bool empty() const; bool empty() const;
public: /* Public Mutators */ public: /* Public Mutators */
/* Reserve to be memory efficent */ /* Reserve to be memory efficent */
void reserve_pins(const size_t& num_pins); void reserve_pins(const size_t& num_pins);
/* Add a pin to storage */ /* Add a pin to storage */
IoPinTableId create_pin(); 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 */ public: /* Public invalidators/validators */
/* Show if the pin id is a valid for data queries */ /* Show if the pin id is a valid for data queries */