diff --git a/libopenfpga/libarchopenfpga/src/config_protocol.cpp b/libopenfpga/libarchopenfpga/src/config_protocol.cpp index 485297c3a..1499a4baf 100644 --- a/libopenfpga/libarchopenfpga/src/config_protocol.cpp +++ b/libopenfpga/libarchopenfpga/src/config_protocol.cpp @@ -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; +} diff --git a/libopenfpga/libarchopenfpga/src/config_protocol.h b/libopenfpga/libarchopenfpga/src/config_protocol.h index 4915d5bb1..550401098 100644 --- a/libopenfpga/libarchopenfpga/src/config_protocol.h +++ b/libopenfpga/libarchopenfpga/src/config_protocol.h @@ -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 diff --git a/libopenfpga/libarchopenfpga/src/read_xml_config_protocol.cpp b/libopenfpga/libarchopenfpga/src/read_xml_config_protocol.cpp index 04833d33a..1cbbb40c0 100644 --- a/libopenfpga/libarchopenfpga/src/read_xml_config_protocol.cpp +++ b/libopenfpga/libarchopenfpga/src/read_xml_config_protocol.cpp @@ -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()); + } } /********************************************************************