2021-02-01 18:43:46 -06:00
|
|
|
#include "bitstream_setting.h"
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
#include "vtr_assert.h"
|
|
|
|
|
2021-02-01 18:43:46 -06:00
|
|
|
/* namespace openfpga begins */
|
|
|
|
namespace openfpga {
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* Member functions for class BitstreamSetting
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* Public Accessors : aggregates
|
|
|
|
***********************************************************************/
|
2022-10-06 19:08:50 -05:00
|
|
|
BitstreamSetting::bitstream_pb_type_setting_range
|
|
|
|
BitstreamSetting::pb_type_settings() const {
|
|
|
|
return vtr::make_range(pb_type_setting_ids_.begin(),
|
|
|
|
pb_type_setting_ids_.end());
|
2021-02-01 18:43:46 -06:00
|
|
|
}
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
BitstreamSetting::bitstream_interconnect_setting_range
|
|
|
|
BitstreamSetting::interconnect_settings() const {
|
|
|
|
return vtr::make_range(interconnect_setting_ids_.begin(),
|
|
|
|
interconnect_setting_ids_.end());
|
2021-04-19 14:42:12 -05:00
|
|
|
}
|
|
|
|
|
2021-02-01 18:43:46 -06:00
|
|
|
/************************************************************************
|
|
|
|
* Constructors
|
|
|
|
***********************************************************************/
|
2022-10-06 19:08:50 -05:00
|
|
|
BitstreamSetting::BitstreamSetting() { return; }
|
2021-02-01 18:43:46 -06:00
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* Public Accessors
|
|
|
|
***********************************************************************/
|
2022-10-06 19:08:50 -05:00
|
|
|
std::string BitstreamSetting::pb_type_name(
|
|
|
|
const BitstreamPbTypeSettingId& pb_type_setting_id) const {
|
2021-02-01 18:43:46 -06:00
|
|
|
VTR_ASSERT(true == valid_bitstream_pb_type_setting_id(pb_type_setting_id));
|
|
|
|
return pb_type_names_[pb_type_setting_id];
|
|
|
|
}
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
std::vector<std::string> BitstreamSetting::parent_pb_type_names(
|
|
|
|
const BitstreamPbTypeSettingId& pb_type_setting_id) const {
|
2021-02-01 18:43:46 -06:00
|
|
|
VTR_ASSERT(true == valid_bitstream_pb_type_setting_id(pb_type_setting_id));
|
|
|
|
return parent_pb_type_names_[pb_type_setting_id];
|
|
|
|
}
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
std::vector<std::string> BitstreamSetting::parent_mode_names(
|
|
|
|
const BitstreamPbTypeSettingId& pb_type_setting_id) const {
|
2021-02-01 18:43:46 -06:00
|
|
|
VTR_ASSERT(true == valid_bitstream_pb_type_setting_id(pb_type_setting_id));
|
|
|
|
return parent_mode_names_[pb_type_setting_id];
|
|
|
|
}
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
std::string BitstreamSetting::pb_type_bitstream_source(
|
|
|
|
const BitstreamPbTypeSettingId& pb_type_setting_id) const {
|
2021-02-01 18:43:46 -06:00
|
|
|
VTR_ASSERT(true == valid_bitstream_pb_type_setting_id(pb_type_setting_id));
|
|
|
|
return pb_type_bitstream_sources_[pb_type_setting_id];
|
|
|
|
}
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
std::string BitstreamSetting::pb_type_bitstream_content(
|
|
|
|
const BitstreamPbTypeSettingId& pb_type_setting_id) const {
|
2021-02-01 18:43:46 -06:00
|
|
|
VTR_ASSERT(true == valid_bitstream_pb_type_setting_id(pb_type_setting_id));
|
|
|
|
return pb_type_bitstream_contents_[pb_type_setting_id];
|
|
|
|
}
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
bool BitstreamSetting::is_mode_select_bitstream(
|
|
|
|
const BitstreamPbTypeSettingId& pb_type_setting_id) const {
|
2021-03-10 21:45:48 -06:00
|
|
|
VTR_ASSERT(true == valid_bitstream_pb_type_setting_id(pb_type_setting_id));
|
|
|
|
return is_mode_select_bitstreams_[pb_type_setting_id];
|
|
|
|
}
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
size_t BitstreamSetting::bitstream_offset(
|
|
|
|
const BitstreamPbTypeSettingId& pb_type_setting_id) const {
|
2021-03-10 21:45:48 -06:00
|
|
|
VTR_ASSERT(true == valid_bitstream_pb_type_setting_id(pb_type_setting_id));
|
|
|
|
return bitstream_offsets_[pb_type_setting_id];
|
|
|
|
}
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
std::string BitstreamSetting::interconnect_name(
|
|
|
|
const BitstreamInterconnectSettingId& interconnect_setting_id) const {
|
|
|
|
VTR_ASSERT(true ==
|
|
|
|
valid_bitstream_interconnect_setting_id(interconnect_setting_id));
|
2021-04-19 14:42:12 -05:00
|
|
|
return interconnect_names_[interconnect_setting_id];
|
|
|
|
}
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
std::vector<std::string> BitstreamSetting::parent_pb_type_names(
|
|
|
|
const BitstreamInterconnectSettingId& interconnect_setting_id) const {
|
|
|
|
VTR_ASSERT(true ==
|
|
|
|
valid_bitstream_interconnect_setting_id(interconnect_setting_id));
|
2021-04-19 14:42:12 -05:00
|
|
|
return interconnect_parent_pb_type_names_[interconnect_setting_id];
|
|
|
|
}
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
std::vector<std::string> BitstreamSetting::parent_mode_names(
|
|
|
|
const BitstreamInterconnectSettingId& interconnect_setting_id) const {
|
|
|
|
VTR_ASSERT(true ==
|
|
|
|
valid_bitstream_interconnect_setting_id(interconnect_setting_id));
|
2021-04-19 14:42:12 -05:00
|
|
|
return interconnect_parent_mode_names_[interconnect_setting_id];
|
|
|
|
}
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
std::string BitstreamSetting::default_path(
|
|
|
|
const BitstreamInterconnectSettingId& interconnect_setting_id) const {
|
|
|
|
VTR_ASSERT(true ==
|
|
|
|
valid_bitstream_interconnect_setting_id(interconnect_setting_id));
|
2021-04-19 14:42:12 -05:00
|
|
|
return interconnect_default_paths_[interconnect_setting_id];
|
|
|
|
}
|
2021-03-10 21:45:48 -06:00
|
|
|
|
2024-02-13 12:36:17 -06:00
|
|
|
std::vector<NoneFabricBitstreamSetting> BitstreamSetting::none_fabric() const {
|
|
|
|
return none_fabric_;
|
|
|
|
}
|
|
|
|
|
2021-02-01 18:43:46 -06:00
|
|
|
/************************************************************************
|
|
|
|
* Public Mutators
|
|
|
|
***********************************************************************/
|
2022-10-06 19:08:50 -05:00
|
|
|
BitstreamPbTypeSettingId BitstreamSetting::add_bitstream_pb_type_setting(
|
|
|
|
const std::string& pb_type_name,
|
|
|
|
const std::vector<std::string>& parent_pb_type_names,
|
|
|
|
const std::vector<std::string>& parent_mode_names,
|
|
|
|
const std::string& bitstream_source, const std::string& bitstream_content) {
|
|
|
|
BitstreamPbTypeSettingId pb_type_setting_id =
|
|
|
|
BitstreamPbTypeSettingId(pb_type_setting_ids_.size());
|
2021-02-01 18:43:46 -06:00
|
|
|
pb_type_setting_ids_.push_back(pb_type_setting_id);
|
|
|
|
pb_type_names_.push_back(pb_type_name);
|
|
|
|
parent_pb_type_names_.push_back(parent_pb_type_names);
|
|
|
|
parent_mode_names_.push_back(parent_mode_names);
|
|
|
|
pb_type_bitstream_sources_.push_back(bitstream_source);
|
|
|
|
pb_type_bitstream_contents_.push_back(bitstream_content);
|
2021-03-10 21:45:48 -06:00
|
|
|
is_mode_select_bitstreams_.push_back(false);
|
|
|
|
bitstream_offsets_.push_back(0);
|
2021-02-01 18:43:46 -06:00
|
|
|
|
|
|
|
return pb_type_setting_id;
|
|
|
|
}
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
void BitstreamSetting::set_mode_select_bitstream(
|
|
|
|
const BitstreamPbTypeSettingId& pb_type_setting_id,
|
|
|
|
const bool& is_mode_select_bitstream) {
|
2021-03-10 21:45:48 -06:00
|
|
|
VTR_ASSERT(true == valid_bitstream_pb_type_setting_id(pb_type_setting_id));
|
|
|
|
is_mode_select_bitstreams_[pb_type_setting_id] = is_mode_select_bitstream;
|
|
|
|
}
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
void BitstreamSetting::set_bitstream_offset(
|
|
|
|
const BitstreamPbTypeSettingId& pb_type_setting_id, const size_t& offset) {
|
2021-03-10 21:45:48 -06:00
|
|
|
VTR_ASSERT(true == valid_bitstream_pb_type_setting_id(pb_type_setting_id));
|
|
|
|
bitstream_offsets_[pb_type_setting_id] = offset;
|
|
|
|
}
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
BitstreamInterconnectSettingId
|
|
|
|
BitstreamSetting::add_bitstream_interconnect_setting(
|
|
|
|
const std::string& interconnect_name,
|
|
|
|
const std::vector<std::string>& parent_pb_type_names,
|
|
|
|
const std::vector<std::string>& parent_mode_names,
|
|
|
|
const std::string& default_path) {
|
|
|
|
BitstreamInterconnectSettingId interc_setting_id =
|
|
|
|
BitstreamInterconnectSettingId(interconnect_setting_ids_.size());
|
2021-04-19 14:42:12 -05:00
|
|
|
interconnect_setting_ids_.push_back(interc_setting_id);
|
|
|
|
interconnect_names_.push_back(interconnect_name);
|
|
|
|
interconnect_parent_pb_type_names_.push_back(parent_pb_type_names);
|
|
|
|
interconnect_parent_mode_names_.push_back(parent_mode_names);
|
|
|
|
interconnect_default_paths_.push_back(default_path);
|
|
|
|
|
|
|
|
return interc_setting_id;
|
|
|
|
}
|
|
|
|
|
2024-02-13 12:36:17 -06:00
|
|
|
void BitstreamSetting::add_none_fabric(const std::string& name,
|
|
|
|
const std::string& file) {
|
|
|
|
VTR_ASSERT(name.size());
|
|
|
|
VTR_ASSERT(file.size());
|
|
|
|
none_fabric_.push_back(NoneFabricBitstreamSetting(name, file));
|
|
|
|
}
|
|
|
|
|
|
|
|
void BitstreamSetting::add_none_fabric_pb(const std::string& pb,
|
|
|
|
const std::string& type,
|
|
|
|
const std::string& content) {
|
|
|
|
VTR_ASSERT(none_fabric_.size());
|
|
|
|
VTR_ASSERT(type == "param" || type == "attr");
|
|
|
|
VTR_ASSERT(content.size());
|
|
|
|
none_fabric_.back().add_pb(pb, type, content);
|
|
|
|
}
|
|
|
|
|
2021-02-01 18:43:46 -06:00
|
|
|
/************************************************************************
|
|
|
|
* Public Validators
|
|
|
|
***********************************************************************/
|
2022-10-06 19:08:50 -05:00
|
|
|
bool BitstreamSetting::valid_bitstream_pb_type_setting_id(
|
|
|
|
const BitstreamPbTypeSettingId& pb_type_setting_id) const {
|
|
|
|
return (size_t(pb_type_setting_id) < pb_type_setting_ids_.size()) &&
|
|
|
|
(pb_type_setting_id == pb_type_setting_ids_[pb_type_setting_id]);
|
2021-02-01 18:43:46 -06:00
|
|
|
}
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
bool BitstreamSetting::valid_bitstream_interconnect_setting_id(
|
|
|
|
const BitstreamInterconnectSettingId& interconnect_setting_id) const {
|
|
|
|
return (size_t(interconnect_setting_id) < interconnect_setting_ids_.size()) &&
|
|
|
|
(interconnect_setting_id ==
|
|
|
|
interconnect_setting_ids_[interconnect_setting_id]);
|
2021-04-19 14:42:12 -05:00
|
|
|
}
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
} // namespace openfpga
|