From a65cc0b5c0297e744d3cd268c230876087c08a22 Mon Sep 17 00:00:00 2001 From: Nav Date: Sun, 6 Jun 2021 20:06:43 +0100 Subject: [PATCH] More TDF refactoring Moved address space, module, property group, variant, pinout and peripheral module extraction to TDF initialisation. Also some other bits of tidying. --- src/Targets/Microchip/AVR/AVR8/Avr8.cpp | 2 +- .../TargetDescriptionFile.cpp | 18 +- .../TargetDescriptionFile.cpp | 369 ++++++++---------- .../TargetDescriptionFile.hpp | 85 ++-- src/Targets/TargetDescription/Variant.hpp | 2 +- 5 files changed, 241 insertions(+), 235 deletions(-) diff --git a/src/Targets/Microchip/AVR/AVR8/Avr8.cpp b/src/Targets/Microchip/AVR/AVR8/Avr8.cpp index b0c227d4..531f3878 100644 --- a/src/Targets/Microchip/AVR/AVR8/Avr8.cpp +++ b/src/Targets/Microchip/AVR/AVR8/Avr8.cpp @@ -231,7 +231,7 @@ void Avr8::loadTargetVariants() { auto targetVariant = TargetVariant(); targetVariant.id = static_cast(this->targetVariantsById.size()); - targetVariant.name = tdVariant.orderCode; + targetVariant.name = tdVariant.name; targetVariant.packageName = tdVariant.package; if (tdVariant.package.find("QFP") == 0 || tdVariant.package.find("TQFP") == 0) { diff --git a/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.cpp b/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.cpp index 80fdcc23..32fae59a 100644 --- a/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.cpp +++ b/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.cpp @@ -100,7 +100,7 @@ QJsonObject TargetDescriptionFile::getTargetDescriptionMapping() { } TargetSignature TargetDescriptionFile::getTargetSignature() const { - auto propertyGroups = this->getPropertyGroupsMappedByName(); + auto& propertyGroups = this->propertyGroupsMappedByName; auto signaturePropertyGroupIt = propertyGroups.find("signatures"); if (signaturePropertyGroupIt == propertyGroups.end()) { @@ -154,7 +154,7 @@ Family TargetDescriptionFile::getFamily() const { } std::optional TargetDescriptionFile::getFlashMemorySegment() const { - auto addressMapping = this->getAddressSpacesMappedById(); + auto& addressMapping = this->addressSpacesMappedById; auto programAddressSpaceIt = addressMapping.find("prog"); // Flash memory attributes are typically found in memory segments within the program address space. @@ -183,7 +183,7 @@ std::optional TargetDescriptionFile::getFlashMemorySegment() cons } std::optional TargetDescriptionFile::getRamMemorySegment() const { - auto addressMapping = this->getAddressSpacesMappedById(); + auto& addressMapping = this->addressSpacesMappedById; // Internal RAM ®ister attributes are usually found in the data address space auto dataAddressSpaceIt = addressMapping.find("data"); @@ -206,7 +206,7 @@ std::optional TargetDescriptionFile::getRamMemorySegment() const } std::optional TargetDescriptionFile::getRegisterMemorySegment() const { - auto addressMapping = this->getAddressSpacesMappedById(); + auto& addressMapping = this->addressSpacesMappedById; // Internal RAM ®ister attributes are usually found in the data address space auto dataAddressSpaceIt = addressMapping.find("data"); @@ -229,7 +229,7 @@ std::optional TargetDescriptionFile::getRegisterMemorySegment() c } std::optional TargetDescriptionFile::getEepromMemorySegment() const { - auto addressMapping = this->getAddressSpacesMappedById(); + auto& addressMapping = this->addressSpacesMappedById; if (addressMapping.contains("eeprom")) { auto& eepromAddressSpace = addressMapping.at("eeprom"); @@ -254,7 +254,7 @@ std::optional TargetDescriptionFile::getEepromMemorySegment() con } std::optional TargetDescriptionFile::getFirstBootSectionMemorySegment() const { - auto addressMapping = this->getAddressSpacesMappedById(); + auto& addressMapping = this->addressSpacesMappedById; auto programAddressSpaceIt = addressMapping.find("prog"); if (programAddressSpaceIt != addressMapping.end()) { @@ -277,7 +277,7 @@ std::optional TargetDescriptionFile::getFirstBootSectionMemorySeg } std::optional TargetDescriptionFile::getCpuRegisterGroup() const { - auto& modulesByName = this->getModulesMappedByName(); + auto& modulesByName = this->modulesMappedByName; if (modulesByName.find("cpu") != modulesByName.end()) { auto cpuModule = modulesByName.find("cpu")->second; @@ -292,7 +292,7 @@ std::optional TargetDescriptionFile::getCpuRegisterGroup() const } std::optional TargetDescriptionFile::getBootLoadRegisterGroup() const { - auto& modulesByName = this->getModulesMappedByName(); + auto& modulesByName = this->modulesMappedByName; if (modulesByName.contains("boot_load")) { auto& bootLoadModule = modulesByName.at("boot_load"); @@ -307,7 +307,7 @@ std::optional TargetDescriptionFile::getBootLoadRegisterGroup() c } std::optional TargetDescriptionFile::getEepromRegisterGroup() const { - auto& modulesByName = this->getModulesMappedByName(); + auto& modulesByName = this->modulesMappedByName; if (modulesByName.find("eeprom") != modulesByName.end()) { auto eepromModule = modulesByName.find("eeprom")->second; diff --git a/src/Targets/TargetDescription/TargetDescriptionFile.cpp b/src/Targets/TargetDescription/TargetDescriptionFile.cpp index 4e1a52df..f8f5e422 100644 --- a/src/Targets/TargetDescription/TargetDescriptionFile.cpp +++ b/src/Targets/TargetDescription/TargetDescriptionFile.cpp @@ -31,6 +31,13 @@ void TargetDescriptionFile::init(const QDomDocument& xml) { } this->deviceElement = device; + + this->loadAddressSpaces(); + this->loadPropertyGroups(); + this->loadModules(); + this->loadPeripheralModules(); + this->loadVariants(); + this->loadPinouts(); } std::string TargetDescriptionFile::getTargetName() const { @@ -208,147 +215,7 @@ Register TargetDescriptionFile::generateRegisterFromXml(const QDomElement& xmlEl return reg; } -const std::map& TargetDescriptionFile::getPropertyGroupsMappedByName() const { - if (!this->cachedPropertyGroupMapping.has_value()) { - if (!this->deviceElement.isElement()) { - throw TargetDescriptionParsingFailureException("Device element not found."); - } - - std::map output; - auto propertyGroupNodes = this->deviceElement.elementsByTagName("property-groups").item(0).toElement() - .elementsByTagName("property-group"); - - for (int propertyGroupIndex = 0; propertyGroupIndex < propertyGroupNodes.count(); propertyGroupIndex++) { - auto propertyGroupElement = propertyGroupNodes.item(propertyGroupIndex).toElement(); - auto propertyGroupName = propertyGroupElement.attributes().namedItem("name").nodeValue().toLower().toStdString(); - PropertyGroup propertyGroup; - propertyGroup.name = propertyGroupName; - - auto propertyNodes = propertyGroupElement.elementsByTagName("property"); - for (int propertyIndex = 0; propertyIndex < propertyNodes.count(); propertyIndex++) { - auto propertyElement = propertyNodes.item(propertyIndex).toElement(); - auto propertyName = propertyElement.attributes().namedItem("name").nodeValue(); - - Property property; - property.name = propertyName.toStdString(); - property.value = propertyElement.attributes().namedItem("value").nodeValue(); - - propertyGroup.propertiesMappedByName.insert(std::pair(propertyName.toLower().toStdString(), property)); - } - - output.insert(std::pair(propertyGroup.name, propertyGroup)); - } - - this->cachedPropertyGroupMapping.emplace(output); - } - - return this->cachedPropertyGroupMapping.value(); -} - -const std::map& TargetDescriptionFile::getModulesMappedByName() const { - if (!this->cachedModuleByNameMapping.has_value()) { - std::map output; - auto moduleNodes = this->xml.elementsByTagName("modules").item(0).toElement() - .elementsByTagName("module"); - - for (int moduleIndex = 0; moduleIndex < moduleNodes.count(); moduleIndex++) { - auto moduleElement = moduleNodes.item(moduleIndex).toElement(); - auto moduleName = moduleElement.attributes().namedItem("name").nodeValue().toLower().toStdString(); - Module module; - module.name = moduleName; - - auto registerGroupNodes = moduleElement.elementsByTagName("register-group"); - for (int registerGroupIndex = 0; registerGroupIndex < registerGroupNodes.count(); registerGroupIndex++) { - auto registerGroup = TargetDescriptionFile::generateRegisterGroupFromXml( - registerGroupNodes.item(registerGroupIndex).toElement() - ); - - module.registerGroupsMappedByName.insert(std::pair(registerGroup.name, registerGroup)); - } - - output.insert(std::pair(module.name, module)); - } - - this->cachedModuleByNameMapping.emplace(output); - } - - return this->cachedModuleByNameMapping.value(); -} - -const std::map& TargetDescriptionFile::getPeripheralModulesMappedByName() const { - if (!this->cachedPeripheralModuleByNameMapping.has_value()) { - std::map output; - auto moduleNodes = this->deviceElement.elementsByTagName("peripherals").item(0).toElement() - .elementsByTagName("module"); - - for (int moduleIndex = 0; moduleIndex < moduleNodes.count(); moduleIndex++) { - auto moduleElement = moduleNodes.item(moduleIndex).toElement(); - auto moduleName = moduleElement.attributes().namedItem("name").nodeValue().toLower().toStdString(); - Module module; - module.name = moduleName; - - auto registerGroupNodes = moduleElement.elementsByTagName("register-group"); - for (int registerGroupIndex = 0; registerGroupIndex < registerGroupNodes.count(); registerGroupIndex++) { - auto registerGroup = TargetDescriptionFile::generateRegisterGroupFromXml( - registerGroupNodes.item(registerGroupIndex).toElement() - ); - - module.registerGroupsMappedByName.insert(std::pair(registerGroup.name, registerGroup)); - } - - auto instanceNodes = moduleElement.elementsByTagName("instance"); - for (int instanceIndex = 0; instanceIndex < instanceNodes.count(); instanceIndex++) { - auto instanceXml = instanceNodes.item(instanceIndex).toElement(); - auto instance = ModuleInstance(); - instance.name = instanceXml.attribute("name").toLower().toStdString(); - - auto registerGroupNodes = instanceXml.elementsByTagName("register-group"); - for (int registerGroupIndex = 0; registerGroupIndex < registerGroupNodes.count(); registerGroupIndex++) { - auto registerGroup = TargetDescriptionFile::generateRegisterGroupFromXml( - registerGroupNodes.item(registerGroupIndex).toElement() - ); - - instance.registerGroupsMappedByName.insert(std::pair(registerGroup.name, registerGroup)); - } - - auto signalNodes = instanceXml.elementsByTagName("signals").item(0).toElement() - .elementsByTagName("signal"); - for (int signalIndex = 0; signalIndex < signalNodes.count(); signalIndex++) { - auto signalXml = signalNodes.item(signalIndex).toElement(); - auto signal = Signal(); - - if (!signalXml.hasAttribute("pad")) { - continue; - } - - signal.padName = signalXml.attribute("pad").toLower().toStdString(); - signal.function = signalXml.attribute("function").toStdString(); - signal.group = signalXml.attribute("group").toStdString(); - auto indexAttribute = signalXml.attribute("index"); - bool indexValid = false; - auto indexValue = indexAttribute.toInt(&indexValid, 10); - - if (!indexAttribute.isEmpty() && indexValid) { - signal.index = indexValue; - } - - instance.instanceSignals.emplace_back(signal); - } - - module.instancesMappedByName.insert(std::pair(instance.name, instance)); - } - - output.insert(std::pair(module.name, module)); - } - - this->cachedPeripheralModuleByNameMapping.emplace(output); - } - - return this->cachedPeripheralModuleByNameMapping.value(); -} - -std::map TargetDescriptionFile::getAddressSpacesMappedById() const { - std::map output; +void TargetDescriptionFile::loadAddressSpaces() { auto addressSpaceNodes = this->deviceElement.elementsByTagName("address-spaces").item(0).toElement() .elementsByTagName("address-space"); @@ -358,19 +225,133 @@ std::map TargetDescriptionFile::getAddressSpacesMappe auto addressSpace = TargetDescriptionFile::generateAddressSpaceFromXml( addressSpaceNodes.item(addressSpaceIndex).toElement() ); - output.insert(std::pair(addressSpace.id, addressSpace)); + this->addressSpacesMappedById.insert(std::pair(addressSpace.id, addressSpace)); } catch (const Exception& exception) { Logger::debug("Failed to extract address space from target description element - " + exception.getMessage()); } } - - return output; } -std::vector TargetDescriptionFile::getVariants() const { - std::vector output; +void TargetDescriptionFile::loadPropertyGroups() { + if (!this->deviceElement.isElement()) { + throw TargetDescriptionParsingFailureException("Device element not found."); + } + auto propertyGroupNodes = this->deviceElement.elementsByTagName("property-groups").item(0).toElement() + .elementsByTagName("property-group"); + + for (int propertyGroupIndex = 0; propertyGroupIndex < propertyGroupNodes.count(); propertyGroupIndex++) { + auto propertyGroupElement = propertyGroupNodes.item(propertyGroupIndex).toElement(); + auto propertyGroupName = propertyGroupElement.attributes().namedItem("name").nodeValue().toLower().toStdString(); + PropertyGroup propertyGroup; + propertyGroup.name = propertyGroupName; + + auto propertyNodes = propertyGroupElement.elementsByTagName("property"); + for (int propertyIndex = 0; propertyIndex < propertyNodes.count(); propertyIndex++) { + auto propertyElement = propertyNodes.item(propertyIndex).toElement(); + auto propertyName = propertyElement.attributes().namedItem("name").nodeValue(); + + Property property; + property.name = propertyName.toStdString(); + property.value = propertyElement.attributes().namedItem("value").nodeValue(); + + propertyGroup.propertiesMappedByName.insert(std::pair(propertyName.toLower().toStdString(), property)); + } + + this->propertyGroupsMappedByName.insert(std::pair(propertyGroup.name, propertyGroup)); + } +} + +void TargetDescriptionFile::loadModules() { + auto moduleNodes = this->xml.elementsByTagName("modules").item(0).toElement() + .elementsByTagName("module"); + + for (int moduleIndex = 0; moduleIndex < moduleNodes.count(); moduleIndex++) { + auto moduleElement = moduleNodes.item(moduleIndex).toElement(); + auto moduleName = moduleElement.attributes().namedItem("name").nodeValue().toLower().toStdString(); + Module module; + module.name = moduleName; + + auto registerGroupNodes = moduleElement.elementsByTagName("register-group"); + for (int registerGroupIndex = 0; registerGroupIndex < registerGroupNodes.count(); registerGroupIndex++) { + auto registerGroup = TargetDescriptionFile::generateRegisterGroupFromXml( + registerGroupNodes.item(registerGroupIndex).toElement() + ); + + module.registerGroupsMappedByName.insert(std::pair(registerGroup.name, registerGroup)); + } + + this->modulesMappedByName.insert(std::pair(module.name, module)); + } +} + +void TargetDescriptionFile::loadPeripheralModules() { + auto moduleNodes = this->deviceElement.elementsByTagName("peripherals").item(0).toElement() + .elementsByTagName("module"); + + for (int moduleIndex = 0; moduleIndex < moduleNodes.count(); moduleIndex++) { + auto moduleElement = moduleNodes.item(moduleIndex).toElement(); + auto moduleName = moduleElement.attributes().namedItem("name").nodeValue().toLower().toStdString(); + Module module; + module.name = moduleName; + + auto registerGroupNodes = moduleElement.elementsByTagName("register-group"); + for (int registerGroupIndex = 0; registerGroupIndex < registerGroupNodes.count(); registerGroupIndex++) { + auto registerGroup = TargetDescriptionFile::generateRegisterGroupFromXml( + registerGroupNodes.item(registerGroupIndex).toElement() + ); + + module.registerGroupsMappedByName.insert(std::pair(registerGroup.name, registerGroup)); + } + + auto instanceNodes = moduleElement.elementsByTagName("instance"); + for (int instanceIndex = 0; instanceIndex < instanceNodes.count(); instanceIndex++) { + auto instanceXml = instanceNodes.item(instanceIndex).toElement(); + auto instance = ModuleInstance(); + instance.name = instanceXml.attribute("name").toLower().toStdString(); + + auto registerGroupNodes = instanceXml.elementsByTagName("register-group"); + for (int registerGroupIndex = 0; registerGroupIndex < registerGroupNodes.count(); registerGroupIndex++) { + auto registerGroup = TargetDescriptionFile::generateRegisterGroupFromXml( + registerGroupNodes.item(registerGroupIndex).toElement() + ); + + instance.registerGroupsMappedByName.insert(std::pair(registerGroup.name, registerGroup)); + } + + auto signalNodes = instanceXml.elementsByTagName("signals").item(0).toElement() + .elementsByTagName("signal"); + for (int signalIndex = 0; signalIndex < signalNodes.count(); signalIndex++) { + auto signalXml = signalNodes.item(signalIndex).toElement(); + auto signal = Signal(); + + if (!signalXml.hasAttribute("pad")) { + continue; + } + + signal.padName = signalXml.attribute("pad").toLower().toStdString(); + signal.function = signalXml.attribute("function").toStdString(); + signal.group = signalXml.attribute("group").toStdString(); + auto indexAttribute = signalXml.attribute("index"); + bool indexValid = false; + auto indexValue = indexAttribute.toInt(&indexValid, 10); + + if (!indexAttribute.isEmpty() && indexValid) { + signal.index = indexValue; + } + + instance.instanceSignals.emplace_back(signal); + } + + module.instancesMappedByName.insert(std::pair(instance.name, instance)); + } + + this->peripheralModulesMappedByName.insert(std::pair(module.name, module)); + } +} + +void TargetDescriptionFile::loadVariants() { auto variantNodes = this->xml.elementsByTagName("variants").item(0).toElement() .elementsByTagName("variant"); @@ -391,7 +372,7 @@ std::vector TargetDescriptionFile::getVariants() const { } auto variant = Variant(); - variant.orderCode = variantXml.attribute("ordercode").toStdString(); + variant.name = variantXml.attribute("ordercode").toStdString(); variant.pinoutName = variantXml.attribute("pinout").toLower().toStdString(); variant.package = variantXml.attribute("package").toUpper().toStdString(); @@ -399,67 +380,59 @@ std::vector TargetDescriptionFile::getVariants() const { variant.disabled = (variantXml.attribute("disabled") == "1"); } - output.push_back(variant); + this->variants.push_back(variant); } catch (const Exception& exception) { Logger::debug("Failed to extract variant from target description element - " + exception.getMessage()); } } - - return output; } -const std::map& TargetDescriptionFile::getPinoutsMappedByName() const { - if (!this->cachedPinoutByNameMapping.has_value()) { - this->cachedPinoutByNameMapping = std::map(); +void TargetDescriptionFile::loadPinouts() { + auto pinoutNodes = this->xml.elementsByTagName("pinouts").item(0).toElement() + .elementsByTagName("pinout"); - auto pinoutNodes = this->xml.elementsByTagName("pinouts").item(0).toElement() - .elementsByTagName("pinout"); + for (int pinoutIndex = 0; pinoutIndex < pinoutNodes.count(); pinoutIndex++) { + try { + auto pinoutXml = pinoutNodes.item(pinoutIndex).toElement(); - for (int pinoutIndex = 0; pinoutIndex < pinoutNodes.count(); pinoutIndex++) { - try { - auto pinoutXml = pinoutNodes.item(pinoutIndex).toElement(); - - if (!pinoutXml.hasAttribute("name")) { - throw Exception("Missing name attribute"); - } - - auto pinout = Pinout(); - pinout.name = pinoutXml.attribute("name").toLower().toStdString(); - - auto pinNodes = pinoutXml.elementsByTagName("pin"); - - for (int pinIndex = 0; pinIndex < pinNodes.count(); pinIndex++) { - auto pinXml = pinNodes.item(pinIndex).toElement(); - - if (!pinXml.hasAttribute("position")) { - throw Exception("Missing position attribute on pin element " + std::to_string(pinIndex)); - } - - if (!pinXml.hasAttribute("pad")) { - throw Exception("Missing pad attribute on pin element " + std::to_string(pinIndex)); - } - - auto pin = Pin(); - bool positionConversionSucceeded = true; - pin.position = pinXml.attribute("position").toInt(&positionConversionSucceeded, 10); - pin.pad = pinXml.attribute("pad").toLower().toStdString(); - - if (!positionConversionSucceeded) { - throw Exception("Failed to convert position attribute value to integer on pin element " - + std::to_string(pinIndex)); - } - - pinout.pins.push_back(pin); - } - - this->cachedPinoutByNameMapping->insert(std::pair(pinout.name, pinout)); - - } catch (const Exception& exception) { - Logger::debug("Failed to extract pinout from target description element - " + exception.getMessage()); + if (!pinoutXml.hasAttribute("name")) { + throw Exception("Missing name attribute"); } + + auto pinout = Pinout(); + pinout.name = pinoutXml.attribute("name").toLower().toStdString(); + + auto pinNodes = pinoutXml.elementsByTagName("pin"); + + for (int pinIndex = 0; pinIndex < pinNodes.count(); pinIndex++) { + auto pinXml = pinNodes.item(pinIndex).toElement(); + + if (!pinXml.hasAttribute("position")) { + throw Exception("Missing position attribute on pin element " + std::to_string(pinIndex)); + } + + if (!pinXml.hasAttribute("pad")) { + throw Exception("Missing pad attribute on pin element " + std::to_string(pinIndex)); + } + + auto pin = Pin(); + bool positionConversionSucceeded = true; + pin.position = pinXml.attribute("position").toInt(&positionConversionSucceeded, 10); + pin.pad = pinXml.attribute("pad").toLower().toStdString(); + + if (!positionConversionSucceeded) { + throw Exception("Failed to convert position attribute value to integer on pin element " + + std::to_string(pinIndex)); + } + + pinout.pins.push_back(pin); + } + + this->pinoutsMappedByName.insert(std::pair(pinout.name, pinout)); + + } catch (const Exception& exception) { + Logger::debug("Failed to extract pinout from target description element - " + exception.getMessage()); } } - - return this->cachedPinoutByNameMapping.value(); } diff --git a/src/Targets/TargetDescription/TargetDescriptionFile.hpp b/src/Targets/TargetDescription/TargetDescriptionFile.hpp index ad853d58..8c1ccc64 100644 --- a/src/Targets/TargetDescription/TargetDescriptionFile.hpp +++ b/src/Targets/TargetDescription/TargetDescriptionFile.hpp @@ -36,15 +36,18 @@ namespace Bloom::Targets::TargetDescription QDomDocument xml; QDomElement deviceElement; + std::map addressSpacesMappedById; + std::map propertyGroupsMappedByName; + std::map modulesMappedByName; + std::map peripheralModulesMappedByName; + std::vector variants; + std::map pinoutsMappedByName; + + void init(const QDomDocument& xml); void init(const QString& xmlFilePath); private: - mutable std::optional> cachedPropertyGroupMapping; - mutable std::optional> cachedModuleByNameMapping; - mutable std::optional> cachedPeripheralModuleByNameMapping; - mutable std::optional> cachedPinoutByNameMapping; - /** * Constructs an AddressSpace object from an XML element. * @@ -77,6 +80,36 @@ namespace Bloom::Targets::TargetDescription */ static Register generateRegisterFromXml(const QDomElement& xmlElement); + /** + * Extracts all address spaces and loads them into this->addressSpacesMappedById. + */ + void loadAddressSpaces(); + + /** + * Extracts all property groups and loads them into this->propertyGroupsMappedByName. + */ + void loadPropertyGroups(); + + /** + * Extracts all modules and loads them into this->modulesMappedByName. + */ + void loadModules(); + + /** + * Extracts all peripheral modules and loads them into this->peripheralModulesMappedByName. + */ + void loadPeripheralModules(); + + /** + * Extracts all variants and loads them into this->variants. + */ + void loadVariants(); + + /** + * Extracts all pinouts and loads them into this->pinoutsMappedByName. + */ + void loadPinouts(); + public: TargetDescriptionFile() = default; @@ -104,51 +137,51 @@ namespace Bloom::Targets::TargetDescription * * @return */ - std::string getTargetName() const; + [[nodiscard]] std::string getTargetName() const; /** - * Extracts all address spaces for the target. - * - * Will return a mapping of the extracted address spaces, mapped by id. + * Returns a mapping of all property groups, with the property group name being the key. * * @return */ - std::map getAddressSpacesMappedById() const; + [[nodiscard]] const std::map& getPropertyGroupsMappedByName() const { + return this->propertyGroupsMappedByName; + } /** - * Extracts all property groups and returns a mapping of them, with the property group name being the key. + * Returns a mapping of all modules, with the module name being the key. * * @return */ - const std::map& getPropertyGroupsMappedByName() const; + [[nodiscard]] const std::map& getModulesMappedByName() const { + return this->modulesMappedByName; + } /** - * Extracts all modules and returns a mapping of them, with the module name being the key. + * Returns a mapping of all peripheral modules, with the peripheral module name being the key. * * @return */ - const std::map& getModulesMappedByName() const; + [[nodiscard]] const std::map& getPeripheralModulesMappedByName() const { + return this->peripheralModulesMappedByName; + } /** - * Extracts all peripheral modules and returns a mapping of this, with the peripheral module name being - * the key. + * Returns all variants found in the TDF. * * @return */ - const std::map& getPeripheralModulesMappedByName() const; + [[nodiscard]] const std::vector& getVariants() const { + return this->variants; + } /** - * Extracts all variants. + * Returns a mapping of pinouts, with the pinout name being the key. * * @return */ - std::vector getVariants() const; - - /** - * Extracts all pinouts and returns a mapping of them, with the pinout name being the key. - * - * @return - */ - const std::map& getPinoutsMappedByName() const; + [[nodiscard]] const std::map& getPinoutsMappedByName() const { + return this->pinoutsMappedByName; + } }; } diff --git a/src/Targets/TargetDescription/Variant.hpp b/src/Targets/TargetDescription/Variant.hpp index 3cf298ff..6fcbdbcb 100644 --- a/src/Targets/TargetDescription/Variant.hpp +++ b/src/Targets/TargetDescription/Variant.hpp @@ -6,7 +6,7 @@ namespace Bloom::Targets::TargetDescription { struct Variant { - std::string orderCode; + std::string name; std::string pinoutName; std::string package; bool disabled = false;