2021-01-16 17:35:13 -06:00
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include "vtr_assert.h"
|
|
|
|
#include "vtr_log.h"
|
|
|
|
|
|
|
|
#include "repack_design_constraints.h"
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* Member functions for class RepackDesignConstraints
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* Constructors
|
|
|
|
***********************************************************************/
|
|
|
|
RepackDesignConstraints::RepackDesignConstraints() {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* Public Accessors : aggregates
|
|
|
|
***********************************************************************/
|
|
|
|
RepackDesignConstraints::repack_design_constraint_range RepackDesignConstraints::design_constraints() const {
|
|
|
|
return vtr::make_range(repack_design_constraint_ids_.begin(), repack_design_constraint_ids_.end());
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* Public Accessors : Basic data query
|
|
|
|
***********************************************************************/
|
|
|
|
RepackDesignConstraints::e_design_constraint_type RepackDesignConstraints::type(const RepackDesignConstraintId& repack_design_constraint_id) const {
|
|
|
|
/* validate the design_constraint_id */
|
|
|
|
VTR_ASSERT(valid_design_constraint_id(repack_design_constraint_id));
|
|
|
|
return repack_design_constraint_types_[repack_design_constraint_id];
|
|
|
|
}
|
|
|
|
|
2021-01-16 22:35:43 -06:00
|
|
|
std::string RepackDesignConstraints::pb_type(const RepackDesignConstraintId& repack_design_constraint_id) const {
|
2021-01-16 17:35:13 -06:00
|
|
|
/* validate the design_constraint_id */
|
|
|
|
VTR_ASSERT(valid_design_constraint_id(repack_design_constraint_id));
|
2021-01-16 22:35:43 -06:00
|
|
|
return repack_design_constraint_pb_types_[repack_design_constraint_id];
|
2021-01-16 17:35:13 -06:00
|
|
|
}
|
|
|
|
|
2021-01-16 18:34:22 -06:00
|
|
|
openfpga::BasicPort RepackDesignConstraints::pin(const RepackDesignConstraintId& repack_design_constraint_id) const {
|
2021-01-16 17:35:13 -06:00
|
|
|
/* validate the design_constraint_id */
|
|
|
|
VTR_ASSERT(valid_design_constraint_id(repack_design_constraint_id));
|
|
|
|
return repack_design_constraint_pins_[repack_design_constraint_id];
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string RepackDesignConstraints::net(const RepackDesignConstraintId& repack_design_constraint_id) const {
|
|
|
|
/* validate the design_constraint_id */
|
|
|
|
VTR_ASSERT(valid_design_constraint_id(repack_design_constraint_id));
|
|
|
|
return repack_design_constraint_nets_[repack_design_constraint_id];
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RepackDesignConstraints::empty() const {
|
2021-01-16 18:34:22 -06:00
|
|
|
return 0 == repack_design_constraint_ids_.size();
|
2021-01-16 17:35:13 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* Public Mutators
|
|
|
|
***********************************************************************/
|
|
|
|
void RepackDesignConstraints::reserve_design_constraints(const size_t& num_design_constraints) {
|
|
|
|
repack_design_constraint_ids_.reserve(num_design_constraints);
|
2021-01-16 18:34:22 -06:00
|
|
|
repack_design_constraint_types_.reserve(num_design_constraints);
|
2021-01-16 22:35:43 -06:00
|
|
|
repack_design_constraint_pb_types_.reserve(num_design_constraints);
|
2021-01-16 17:35:13 -06:00
|
|
|
repack_design_constraint_pins_.reserve(num_design_constraints);
|
|
|
|
repack_design_constraint_nets_.reserve(num_design_constraints);
|
|
|
|
}
|
|
|
|
|
2021-01-16 18:34:22 -06:00
|
|
|
RepackDesignConstraintId RepackDesignConstraints::create_design_constraint(const RepackDesignConstraints::e_design_constraint_type& repack_design_constraint_type) {
|
2021-01-16 17:35:13 -06:00
|
|
|
/* Create a new id */
|
2021-01-16 18:34:22 -06:00
|
|
|
RepackDesignConstraintId repack_design_constraint_id = RepackDesignConstraintId(repack_design_constraint_ids_.size());
|
2021-01-16 17:35:13 -06:00
|
|
|
|
|
|
|
repack_design_constraint_ids_.push_back(repack_design_constraint_id);
|
|
|
|
repack_design_constraint_types_.push_back(repack_design_constraint_type);
|
2021-01-16 22:35:43 -06:00
|
|
|
repack_design_constraint_pb_types_.emplace_back();
|
2021-01-16 18:34:22 -06:00
|
|
|
repack_design_constraint_pins_.emplace_back();
|
|
|
|
repack_design_constraint_nets_.emplace_back();
|
2021-01-16 17:35:13 -06:00
|
|
|
|
|
|
|
return repack_design_constraint_id;
|
|
|
|
}
|
|
|
|
|
2021-01-16 22:35:43 -06:00
|
|
|
void RepackDesignConstraints::set_pb_type(const RepackDesignConstraintId& repack_design_constraint_id,
|
|
|
|
const std::string& pb_type) {
|
2021-01-16 17:35:13 -06:00
|
|
|
/* validate the design_constraint_id */
|
|
|
|
VTR_ASSERT(valid_design_constraint_id(repack_design_constraint_id));
|
2021-01-16 22:35:43 -06:00
|
|
|
repack_design_constraint_pb_types_[repack_design_constraint_id] = pb_type;
|
2021-01-16 17:35:13 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void RepackDesignConstraints::set_pin(const RepackDesignConstraintId& repack_design_constraint_id,
|
2021-01-16 18:34:22 -06:00
|
|
|
const openfpga::BasicPort& pin) {
|
2021-01-16 17:35:13 -06:00
|
|
|
/* validate the design_constraint_id */
|
|
|
|
VTR_ASSERT(valid_design_constraint_id(repack_design_constraint_id));
|
2021-01-16 18:34:22 -06:00
|
|
|
repack_design_constraint_pins_[repack_design_constraint_id] = pin;
|
2021-01-16 17:35:13 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void RepackDesignConstraints::set_net(const RepackDesignConstraintId& repack_design_constraint_id,
|
|
|
|
const std::string& net) {
|
|
|
|
/* validate the design_constraint_id */
|
|
|
|
VTR_ASSERT(valid_design_constraint_id(repack_design_constraint_id));
|
2021-01-16 18:34:22 -06:00
|
|
|
repack_design_constraint_nets_[repack_design_constraint_id] = net;
|
2021-01-16 17:35:13 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* Internal invalidators/validators
|
|
|
|
***********************************************************************/
|
|
|
|
/* Validators */
|
2021-01-16 18:34:22 -06:00
|
|
|
bool RepackDesignConstraints::valid_design_constraint_id(const RepackDesignConstraintId& design_constraint_id) const {
|
2021-01-16 17:35:13 -06:00
|
|
|
return ( size_t(design_constraint_id) < repack_design_constraint_ids_.size() ) && ( design_constraint_id == repack_design_constraint_ids_[design_constraint_id] );
|
|
|
|
}
|