[OpenFPGA Tool] Add XML syntax for configurable regions

This commit is contained in:
tangxifan 2020-09-28 13:51:43 -06:00
parent 052b8b71c7
commit 1e70825383
3 changed files with 23 additions and 0 deletions

View File

@ -28,6 +28,10 @@ CircuitModelId ConfigProtocol::memory_model() const {
return memory_model_;
}
int ConfigProtocol::num_regions() const {
return num_regions_;
}
/************************************************************************
* Public Mutators
***********************************************************************/
@ -42,3 +46,7 @@ void ConfigProtocol::set_memory_model_name(const std::string& memory_model_name)
void ConfigProtocol::set_memory_model(const CircuitModelId& memory_model) {
memory_model_ = memory_model;
}
void ConfigProtocol::set_num_regions(const int& num_regions) {
num_regions_ = num_regions;
}

View File

@ -15,10 +15,12 @@ class ConfigProtocol {
e_config_protocol_type type() const;
std::string memory_model_name() const;
CircuitModelId memory_model() const;
int num_regions() const;
public: /* Public Mutators */
void set_type(const e_config_protocol_type& type);
void set_memory_model_name(const std::string& memory_model_name);
void set_memory_model(const CircuitModelId& memory_model);
void set_num_regions(const int& num_regions);
private: /* Internal data */
/* The type of configuration protocol.
* In other words, it is about how to organize and access each configurable memory
@ -28,6 +30,9 @@ class ConfigProtocol {
/* The circuit model of configuration memory to be used in the protocol */
std::string memory_model_name_;
CircuitModelId memory_model_;
/* Number of configurable regions */
int num_regions_;
};
#endif

View File

@ -53,8 +53,18 @@ void read_xml_config_organization(pugi::xml_node& xml_config_orgz,
config_protocol.set_type(config_orgz_type);
/* Find the circuit model used by the configuration protocol */
config_protocol.set_memory_model_name(get_attribute(xml_config_orgz, "circuit_model_name", loc_data).as_string());
/* Parse the number of configurable regions
* At least 1 region should be defined, otherwise error out
*/
config_protocol.set_num_regions(get_attribute(xml_config_orgz, "num_regions", loc_data, pugiutil::ReqOpt::OPTIONAL).as_int(1));
if (1 > config_protocol.num_regions()) {
archfpga_throw(loc_data.filename_c_str(), loc_data.line(xml_config_orgz),
"Invalid 'num_region=%d' definition. At least 1 region should be defined!\n",
config_protocol.num_regions());
}
}
/********************************************************************