From 0a64add5fc7540e5aaafb6ab957bea4ee474cc75 Mon Sep 17 00:00:00 2001 From: hagantsa Date: Thu, 30 Nov 2023 10:10:27 +0200 Subject: [PATCH 1/4] [CORRECTIVE] Fix catalog reader tests. --- .../Catalog/tst_CatalogReader.cpp | 39 +++++++------------ 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/tests/IPXACTmodels/Catalog/tst_CatalogReader.cpp b/tests/IPXACTmodels/Catalog/tst_CatalogReader.cpp index 3695d7c0d..a5ae5ad97 100644 --- a/tests/IPXACTmodels/Catalog/tst_CatalogReader.cpp +++ b/tests/IPXACTmodels/Catalog/tst_CatalogReader.cpp @@ -89,8 +89,7 @@ void tst_CatalogReader::testReadMinimalCatalog() "Catalog description" "\n")); - CatalogReader busReader; - QSharedPointer testCatalog = busReader.createCatalogFrom(document); + QSharedPointer testCatalog = CatalogReader::createCatalogFrom(document); VLNV catalogVLNV = testCatalog->getVlnv(); QCOMPARE(catalogVLNV.getVendor(), QString("tut.fi")); @@ -124,8 +123,7 @@ void tst_CatalogReader::testReadTopComments() "" "")); - CatalogReader catalogReader; - QSharedPointer testCatalog = catalogReader.createCatalogFrom(document); + QSharedPointer testCatalog = CatalogReader::createCatalogFrom(document); QCOMPARE(testCatalog->getTopComments().size(), 2); QCOMPARE(testCatalog->getTopComments().first(), QString("Commented line 1")); @@ -154,8 +152,7 @@ void tst_CatalogReader::testProcessingInstructionsAreParsed() "" "")); - CatalogReader catalogReader; - QSharedPointer testCatalog = catalogReader.createCatalogFrom(document); + QSharedPointer testCatalog = CatalogReader::createCatalogFrom(document); QCOMPARE(testCatalog->getXmlProcessingInstructions().count(), 1); @@ -198,8 +195,7 @@ void tst_CatalogReader::testReadOtherCatalogs() "" "\n")); - CatalogReader catalogReader; - QSharedPointer testCatalog = catalogReader.createCatalogFrom(document); + QSharedPointer testCatalog = CatalogReader::createCatalogFrom(document); QCOMPARE(testCatalog->getCatalogs()->size(), 2); @@ -248,8 +244,7 @@ void tst_CatalogReader::testReadBusDefinitions() "" "\n")); - CatalogReader catalogReader; - QSharedPointer testCatalog = catalogReader.createCatalogFrom(document); + QSharedPointer testCatalog = CatalogReader::createCatalogFrom(document); QCOMPARE(testCatalog->getBusDefinitions()->size(), 2); @@ -298,8 +293,7 @@ void tst_CatalogReader::testReadAbstractionDefinitions() "" "\n")); - CatalogReader catalogReader; - QSharedPointer testCatalog = catalogReader.createCatalogFrom(document); + QSharedPointer testCatalog = CatalogReader::createCatalogFrom(document); QCOMPARE(testCatalog->getAbstractionDefinitions()->size(), 2); @@ -348,8 +342,7 @@ void tst_CatalogReader::testReadComponents() "" "\n")); - CatalogReader catalogReader; - QSharedPointer testCatalog = catalogReader.createCatalogFrom(document); + QSharedPointer testCatalog = CatalogReader::createCatalogFrom(document); QCOMPARE(testCatalog->getComponents()->size(), 2); @@ -398,8 +391,7 @@ void tst_CatalogReader::testReadAbstractors() "" "\n")); - CatalogReader catalogReader; - QSharedPointer testCatalog = catalogReader.createCatalogFrom(document); + QSharedPointer testCatalog = CatalogReader::createCatalogFrom(document); QCOMPARE(testCatalog->getAbstractors()->size(), 2); @@ -448,8 +440,7 @@ void tst_CatalogReader::testReadDesigns() "" "\n")); - CatalogReader catalogReader; - QSharedPointer testCatalog = catalogReader.createCatalogFrom(document); + QSharedPointer testCatalog = CatalogReader::createCatalogFrom(document); QCOMPARE(testCatalog->getDesigns()->size(), 2); @@ -498,8 +489,7 @@ void tst_CatalogReader::testReadDesignConfigurations() "" "\n")); - CatalogReader catalogReader; - QSharedPointer testCatalog = catalogReader.createCatalogFrom(document); + QSharedPointer testCatalog = CatalogReader::createCatalogFrom(document); QCOMPARE(testCatalog->getDesignConfigurations()->size(), 2); @@ -548,8 +538,7 @@ void tst_CatalogReader::testReadGeneratorChains() "" "\n")); - CatalogReader catalogReader; - QSharedPointer testCatalog = catalogReader.createCatalogFrom(document); + QSharedPointer testCatalog = CatalogReader::createCatalogFrom(document); QCOMPARE(testCatalog->getGeneratorChains()->size(), 2); @@ -596,8 +585,7 @@ void tst_CatalogReader::testReadTypeDefinitions() "" "\n")); - CatalogReader catalogReader; - QSharedPointer testCatalog = catalogReader.createCatalogFrom(document); + QSharedPointer testCatalog = CatalogReader::createCatalogFrom(document); QCOMPARE(testCatalog->getTypeDefinitions()->size(), 1); QCOMPARE(testCatalog->getShortDescription(), QString("a short description")); QCOMPARE(testCatalog->getDisplayName(), QString("testDisplayName")); @@ -679,8 +667,7 @@ void tst_CatalogReader::testReadAllElements() "" "\n")); - CatalogReader catalogReader; - QSharedPointer testCatalog = catalogReader.createCatalogFrom(document); + QSharedPointer testCatalog = CatalogReader::createCatalogFrom(document); QCOMPARE(testCatalog->getCatalogs()->size(), 1); QCOMPARE(testCatalog->getBusDefinitions()->size(), 1); From e1aa2832d4108e2a2636b464d7a1167fdeec113e Mon Sep 17 00:00:00 2001 From: hagantsa Date: Thu, 30 Nov 2023 11:32:05 +0200 Subject: [PATCH 2/4] [CORRECTIVE] Fix VHDL generator not looking for design reference in design configuration. Fix Quartus genereator tests. --- IPXACTmodels/Component/FileSetRef.cpp | 4 +- IPXACTmodels/Component/FileSetRef.h | 2 +- IPXACTmodels/utilities/ComponentSearch.cpp | 32 +++++++++----- IPXACTmodels/utilities/ComponentSearch.h | 6 ++- .../QuartusGenerator.cpp | 23 ++-------- Plugins/VHDLGenerator/vhdlgenerator2.cpp | 33 ++++---------- .../tst_QuartusProjectGenerator.cpp | 43 +++++++++++-------- 7 files changed, 66 insertions(+), 77 deletions(-) diff --git a/IPXACTmodels/Component/FileSetRef.cpp b/IPXACTmodels/Component/FileSetRef.cpp index 2fb93b8fe..7986ea3b8 100644 --- a/IPXACTmodels/Component/FileSetRef.cpp +++ b/IPXACTmodels/Component/FileSetRef.cpp @@ -25,7 +25,9 @@ FileSetRef::FileSetRef(FileSetRef const& other) : //----------------------------------------------------------------------------- // Function: FileSetRef::FileSetRef() //----------------------------------------------------------------------------- -FileSetRef::FileSetRef() : Extendable() +FileSetRef::FileSetRef(QString const& localName) : + Extendable(), + localName_(localName) { } diff --git a/IPXACTmodels/Component/FileSetRef.h b/IPXACTmodels/Component/FileSetRef.h index 37c1dd617..1181d3d7d 100644 --- a/IPXACTmodels/Component/FileSetRef.h +++ b/IPXACTmodels/Component/FileSetRef.h @@ -23,7 +23,7 @@ class IPXACTMODELS_EXPORT FileSetRef : public Extendable public: //! The constructor. - FileSetRef(); + explicit FileSetRef(QString const& localName = QString()); ~FileSetRef() override = default; diff --git a/IPXACTmodels/utilities/ComponentSearch.cpp b/IPXACTmodels/utilities/ComponentSearch.cpp index c74afde04..26cb3159e 100644 --- a/IPXACTmodels/utilities/ComponentSearch.cpp +++ b/IPXACTmodels/utilities/ComponentSearch.cpp @@ -14,29 +14,41 @@ #include "Search.h" #include +#include +#include + +#include //----------------------------------------------------------------------------- // Function: ComponentSearch::findDesignReference() //----------------------------------------------------------------------------- -VLNV ComponentSearch::findDesignReference(QSharedPointer component, QString const& viewName) +VLNV ComponentSearch::findDesignReference(QSharedPointer component, LibraryInterface* libraryHandler, + QString const& viewName) { - return findDesignReference(component, Search::findByName(viewName, *component->getViews())); + return findDesignReference(component, libraryHandler, Search::findByName(viewName, *component->getViews())); } //----------------------------------------------------------------------------- // Function: ComponentSearch::findDesignReference() //----------------------------------------------------------------------------- -VLNV ComponentSearch::findDesignReference(QSharedPointer component, QSharedPointer view) +VLNV ComponentSearch::findDesignReference(QSharedPointer component, LibraryInterface* libraryHandler, + QSharedPointer view) { if (view.isNull() == false) { - auto designInstantion = Search::findByName(view->getDesignInstantiationRef(), - *component->getDesignInstantiations()); - - if (designInstantion) + if (auto designInstantion = Search::findByName(view->getDesignInstantiationRef(), + *component->getDesignInstantiations())) { return VLNV(*designInstantion->getDesignReference()); } + + // Look for design reference in design configuration if no design instantiation. + auto designConfigRef = findDesignConfigurationReference(component, view); + + if (auto designCfg = libraryHandler->getModelReadOnly(designConfigRef)) + { + return designCfg->getDesignRef(); + } } return VLNV(); @@ -75,11 +87,9 @@ QSharedPointer ComponentSearch::findView(QSharedPointer compone QSharedPointer ComponentSearch::findComponentInstantiation( QSharedPointer component, QString const& viewName) { - QSharedPointer view = findView(component, viewName); - - if (view) + if (QSharedPointer view = findView(component, viewName)) { - foreach(QSharedPointer instantiation, *component->getComponentInstantiations()) + for (auto const& instantiation : *component->getComponentInstantiations()) { if (instantiation->name() == view->getComponentInstantiationRef()) { diff --git a/IPXACTmodels/utilities/ComponentSearch.h b/IPXACTmodels/utilities/ComponentSearch.h index 5b55100c7..d46df7844 100644 --- a/IPXACTmodels/utilities/ComponentSearch.h +++ b/IPXACTmodels/utilities/ComponentSearch.h @@ -19,14 +19,16 @@ #include +class LibraryInterface; + //----------------------------------------------------------------------------- //! Utilities for searching items in Component. //----------------------------------------------------------------------------- namespace ComponentSearch { - VLNV findDesignReference(QSharedPointer component, QString const& viewName); + VLNV findDesignReference(QSharedPointer component, LibraryInterface* libraryHandler, QString const& viewName); - VLNV findDesignReference(QSharedPointer component, QSharedPointer view); + VLNV findDesignReference(QSharedPointer component, LibraryInterface* libraryHandler, QSharedPointer view); VLNV findDesignConfigurationReference(QSharedPointer component, QSharedPointer view); diff --git a/Plugins/QuartusProjectGenerator/QuartusGenerator.cpp b/Plugins/QuartusProjectGenerator/QuartusGenerator.cpp index 9f0ffeae5..f540336d7 100644 --- a/Plugins/QuartusProjectGenerator/QuartusGenerator.cpp +++ b/Plugins/QuartusProjectGenerator/QuartusGenerator.cpp @@ -393,30 +393,15 @@ void QuartusGenerator::parseFileSets(QSharedPointer component, QStrin //----------------------------------------------------------------------------- void QuartusGenerator::parseFilesFromHierarchicalView(QSharedPointer view, QSharedPointer component) { - VLNV designVLNV = ComponentSearch::findDesignReference(component, view); + VLNV designVLNV = ComponentSearch::findDesignReference(component, handler_, view); VLNV desConfVLNV = ComponentSearch::findDesignConfigurationReference(component, view); - QSharedPointer designConf; - - if (desConfVLNV.isValid()) - { - designConf = handler_->getModelReadOnly(desConfVLNV); - - if (designVLNV.isValid() == false) - { - designVLNV = designConf->getDesignRef(); - } - } - else if (designVLNV.isValid() == false) - { - utility_->printError(tr("Could not find valid design. Stopping generation.")); - return; - } + QSharedPointer designConf = handler_->getModelReadOnly(desConfVLNV); if (!handler_->contains(designVLNV)) { - utility_->printError(tr("Design %1 referenced withing design configuration %2 was not found within " - "library. Stopping generation.").arg(designVLNV.toString(), desConfVLNV.getName())); + utility_->printError(tr("Design %1 was not found in library. Stopping generation.") + .arg(designVLNV.toString())); return; } diff --git a/Plugins/VHDLGenerator/vhdlgenerator2.cpp b/Plugins/VHDLGenerator/vhdlgenerator2.cpp index 2682fdec0..ed214def4 100644 --- a/Plugins/VHDLGenerator/vhdlgenerator2.cpp +++ b/Plugins/VHDLGenerator/vhdlgenerator2.cpp @@ -66,24 +66,7 @@ static const QString BLACK_BOX_ASSIGN_END = "-- ##KACTUS2_BLACK_BOX_ASSIGNMENTS_ //----------------------------------------------------------------------------- VhdlGenerator2::VhdlGenerator2(QSharedPointer parser, LibraryInterface* handler, QObject* parent): QObject(parent), -handler_(handler), -component_(), -design_(), -desConf_(), -viewName_(), -topLevelEntity_(), -libraries_(), -typeDefinitions_(), -userModifiedDeclarations_(), -userModifiedAssignments_(), -topGenerics_(), -topPorts_(), -signals_(), -components_(), -instances_(), -designvalidator_(), -designConfigurationValidator_(), -topComponentParser_() +handler_(handler) { Q_ASSERT(handler); @@ -124,7 +107,7 @@ bool VhdlGenerator2::parse( QSharedPointer topLevelComponent, const Q } // get the types that are used for the ports. - foreach ( QSharedPointer port, *component_->getPorts() ) + for (auto const& port : *component_->getPorts()) { typeDefinitions_.append( port->getTypeDefinitions() ); } @@ -142,13 +125,13 @@ bool VhdlGenerator2::parse( QSharedPointer topLevelComponent, const Q mapPorts2Signals(); // tell each instance to use the default port value for the unconnected ports. - foreach (QSharedPointer instance, instances_) + for (auto const& instance : instances_) { instance->useDefaultsForOtherPorts(); } // tell each component declaration to check for it's ports and uncomment those that are needed - foreach (QSharedPointer comp, components_) + for (auto const& comp : components_) { comp->checkPortConnections(); } @@ -420,7 +403,7 @@ bool VhdlGenerator2::parseDesignAndConfiguration() } else if (view->isHierarchical()) { - VLNV designVLNV = ComponentSearch::findDesignReference(component_, view); + VLNV designVLNV = ComponentSearch::findDesignReference(component_, handler_, view); VLNV configurationVLNV = ComponentSearch::findDesignConfigurationReference(component_, view); design_ = handler_->getDesign(designVLNV); @@ -435,13 +418,13 @@ bool VhdlGenerator2::parseDesignAndConfiguration() { if (!designvalidator_->validate(design_)) { - QVector errorList; + QStringList errorList; designvalidator_->findErrorsIn(errorList, design_); emit noticeMessage(tr("The design '%1' contained the following errors:"). arg(design_->getVlnv().toString())); - foreach (QString designError, errorList) + for (auto const& designError : errorList) { emit errorMessage(designError); } @@ -459,7 +442,7 @@ bool VhdlGenerator2::parseDesignAndConfiguration() emit noticeMessage(tr("The design configuration '%1' contained the following errors:"). arg(desConf_->getVlnv().toString())); - foreach(QString configurationError, errorList) + for (auto const& configurationError : errorList) { emit errorMessage(configurationError); } diff --git a/tests/Plugins/QuartusProjectGenerator/tst_QuartusProjectGenerator.cpp b/tests/Plugins/QuartusProjectGenerator/tst_QuartusProjectGenerator.cpp index 0a5b07c07..88da3054e 100644 --- a/tests/Plugins/QuartusProjectGenerator/tst_QuartusProjectGenerator.cpp +++ b/tests/Plugins/QuartusProjectGenerator/tst_QuartusProjectGenerator.cpp @@ -235,7 +235,7 @@ void tst_QuartusProjectGenerator::testGeneratorWithDesignContainingTopComponentV topComponent_->getFileSets()->append(topComponentFileSet); QSharedPointer cimpTop( new ComponentInstantiation("TOP-INSTANTIATION") ); - cimpTop->getFileSetReferences()->append(topComponentFileSet->name()); + cimpTop->getFileSetReferences()->append(QSharedPointer(new FileSetRef(topComponentFileSet->name()))); topComponent_->getComponentInstantiations()->append(cimpTop); QSharedPointer dist( new DesignInstantiation("joku" )); @@ -288,7 +288,7 @@ void tst_QuartusProjectGenerator::testGeneratorWithDesignContainingInstances() componentOne->getFileSets()->append(componentOneFileset); QSharedPointer cimpOne( new ComponentInstantiation("ONE-INSTANTIATION") ); - cimpOne->getFileSetReferences()->append(componentOneFileset->name()); + cimpOne->getFileSetReferences()->append(QSharedPointer(new FileSetRef(componentOneFileset->name()))); componentOne->getComponentInstantiations()->append(cimpOne); QSharedPointer componentOneView (new View("vhdlView")); @@ -304,7 +304,7 @@ void tst_QuartusProjectGenerator::testGeneratorWithDesignContainingInstances() componentTwo->getFileSets()->append(componentTwoFileset); QSharedPointer cimpTwo( new ComponentInstantiation("TWO-INSTANTIATION") ); - cimpTwo->getFileSetReferences()->append(componentTwoFileset->name()); + cimpTwo->getFileSetReferences()->append(QSharedPointer(new FileSetRef(componentTwoFileset->name()))); componentTwo->getComponentInstantiations()->append(cimpTwo); QSharedPointer componentTwoView (new View("qipView")); @@ -321,7 +321,7 @@ void tst_QuartusProjectGenerator::testGeneratorWithDesignContainingInstances() QSharedPointer componentThreeView (new View("sdcView")); QSharedPointer cimpThree( new ComponentInstantiation("THREE-INSTANTIATION") ); - cimpThree->getFileSetReferences()->append(componentThreeFileSet->name()); + cimpThree->getFileSetReferences()->append(QSharedPointer(new FileSetRef(componentThreeFileSet->name()))); componentThreeView->setComponentInstantiationRef(cimpThree->name()); componentThree->getViews()->append(componentThreeView); componentThree->getComponentInstantiations()->append(cimpThree); @@ -354,7 +354,7 @@ void tst_QuartusProjectGenerator::testGeneratorWithDesignContainingInstances() topComponent_->getDesignConfigurationInstantiations()->append(disg); QSharedPointer cimpTop( new ComponentInstantiation("TOP-INSTANTIATION") ); - cimpTop->getFileSetReferences()->append(topComponentFileSet->name()); + cimpTop->getFileSetReferences()->append(QSharedPointer(new FileSetRef(topComponentFileSet->name()))); topComponent_->getComponentInstantiations()->append(cimpTop); QSharedPointer quartusDesignView (new View("quartusView")); @@ -410,7 +410,7 @@ void tst_QuartusProjectGenerator::testGeneratorWithConfiguredViews() QSharedPointer componentOneView (new View("vhdlView")); QSharedPointer cimpOne( new ComponentInstantiation("ONE-INSTANTIATION") ); - cimpOne->getFileSetReferences()->append(componentOneFileset->name()); + cimpOne->getFileSetReferences()->append(QSharedPointer(new FileSetRef(componentOneFileset->name()))); componentOneView->setComponentInstantiationRef(cimpOne->name()); componentOne->getViews()->append(componentOneView); componentOne->getComponentInstantiations()->append(cimpOne); @@ -425,7 +425,7 @@ void tst_QuartusProjectGenerator::testGeneratorWithConfiguredViews() QSharedPointer componentOneOtherView (new View("restView")); QSharedPointer cimpOneOther( new ComponentInstantiation("ONE-OTHER-INSTANTIATION") ); - cimpOneOther->getFileSetReferences()->append(componentOneOtherFileset->name()); + cimpOneOther->getFileSetReferences()->append(QSharedPointer(new FileSetRef(componentOneOtherFileset->name()))); componentOneOtherView->setComponentInstantiationRef(cimpOneOther->name()); componentOne->getViews()->append(componentOneOtherView); componentOne->getComponentInstantiations()->append(cimpOneOther); @@ -440,7 +440,7 @@ void tst_QuartusProjectGenerator::testGeneratorWithConfiguredViews() QSharedPointer componentTwoView (new View("qipView")); QSharedPointer cimpTwo( new ComponentInstantiation("TWO-INSTANTIATION") ); - cimpTwo->getFileSetReferences()->append(componentTwoFileset->name()); + cimpTwo->getFileSetReferences()->append(QSharedPointer(new FileSetRef(componentTwoFileset->name()))); componentTwoView->setComponentInstantiationRef(cimpTwo->name()); componentTwo->getViews()->append(componentTwoView); componentTwo->getComponentInstantiations()->append(cimpTwo); @@ -537,7 +537,7 @@ void tst_QuartusProjectGenerator::testGeneratorInInstancesWithoutActiveViews() componentTwo->getFileSets()->append(componentTwoOtherFileset); QSharedPointer cimpTwo( new ComponentInstantiation("Two-INSTANTIATION") ); - cimpTwo->getFileSetReferences()->append(componentTwoFileset->name()); + cimpTwo->getFileSetReferences()->append(QSharedPointer(new FileSetRef(componentTwoFileset->name()))); componentTwo->getComponentInstantiations()->append(cimpTwo); QSharedPointer componentTwoView (new View("qipView")); @@ -690,7 +690,7 @@ QString tst_QuartusProjectGenerator::getQuartusHeader(QString const& currentTime QSharedPointer tst_QuartusProjectGenerator::createTestComponent(QString const& componentName) { VLNV newVlnv(VLNV::COMPONENT, "TUT", "TestLibrary", componentName, "1.0"); - QSharedPointer newComponent = QSharedPointer(new Component(newVlnv)); + QSharedPointer newComponent = QSharedPointer(new Component(newVlnv, Document::Revision::Std14)); library_.writeModelToFile(QFileInfo(".").absoluteFilePath() + "/", newComponent); library_.addComponent(newComponent); @@ -705,7 +705,7 @@ QSharedPointer tst_QuartusProjectGenerator::createTestDesign(QString con QList > containedComponents) { VLNV designVLNV(VLNV::DESIGN, "TUT", "TestLibrary", designName, "1.0"); - QSharedPointer newDesign = QSharedPointer(new Design(designVLNV)); + QSharedPointer newDesign = QSharedPointer(new Design(designVLNV, Document::Revision::Std14)); library_.writeModelToFile(QFileInfo(".").absoluteFilePath() + "/", newDesign); library_.addComponent(newDesign); @@ -713,7 +713,7 @@ QSharedPointer tst_QuartusProjectGenerator::createTestDesign(QString con QSharedPointer > > componentInstances( new QList >()); QMap usedInstances; - foreach (QSharedPointer currentComponent, containedComponents) + for (auto const& currentComponent : containedComponents) { int instanceNumber = usedInstances.value(currentComponent->getVlnv().getName(), 0); QString instanceName = currentComponent->getVlnv().getName() + "_" + QString::number(instanceNumber); @@ -739,14 +739,14 @@ QSharedPointer tst_QuartusProjectGenerator::createTestDesig { VLNV designConfigurationVLNV(VLNV::DESIGNCONFIGURATION, "TUT", "TestLibrary", name, "1.0"); QSharedPointer newDesignConfiguration = - QSharedPointer(new DesignConfiguration(designConfigurationVLNV)); + QSharedPointer(new DesignConfiguration(designConfigurationVLNV, Document::Revision::Std14)); library_.writeModelToFile(QFileInfo(".").absoluteFilePath() + "/", newDesignConfiguration); library_.addComponent(newDesignConfiguration); newDesignConfiguration->setDesignRef(referencedDesign->getVlnv()); - foreach (QSharedPointer currentInstance, *referencedDesign->getComponentInstances()) + for (auto const& currentInstance : *referencedDesign->getComponentInstances()) { VLNV componentReference = *currentInstance->getComponentRef(); QSharedPointer referencedComponent = @@ -769,7 +769,7 @@ QSharedPointer tst_QuartusProjectGenerator::createTestFileset(QString c { QSharedPointer newFileSet (new FileSet(filesetName)); - foreach (QString fileName, filesToAdd) + for (auto const& fileName : filesToAdd) { QSharedPointer newFileForFileSet (new File(fileName)); @@ -798,7 +798,7 @@ void tst_QuartusProjectGenerator::setViewOverridesForDesignConfiguration( QShare QSharedPointer > > componentInstances) { QMap viewOverrides; - foreach (QSharedPointer instance, *componentInstances) + for (auto const& instance : *componentInstances) { VLNV componentReferenceVLNV = *instance->getComponentRef(); QSharedPointer referencedComponent = @@ -818,9 +818,16 @@ void tst_QuartusProjectGenerator::setViewOverridesForDesignConfiguration( QShare //----------------------------------------------------------------------------- void tst_QuartusProjectGenerator::setFileTypesForFileSet(QSharedPointer selectedFileset, QSharedPointer fileTypes) { - foreach (QSharedPointer currentFile, *selectedFileset->getFiles()) + QSharedPointer > fileTypeObjs(new QList()); + + for (auto const& fileType : *fileTypes) + { + fileTypeObjs->append(FileType(fileType)); + } + + for (auto const& currentFile : *selectedFileset->getFiles()) { - currentFile->setFileTypes(fileTypes); + currentFile->setFileTypes(fileTypeObjs); } } From 61caa965edc485d80a34f81ae90a4826b22707b8 Mon Sep 17 00:00:00 2001 From: hagantsa Date: Thu, 30 Nov 2023 12:52:00 +0200 Subject: [PATCH 3/4] [CORRECTIVE] Remove field access policy related columns from field table editor in register editor. Selecting empty access value for field now removes the (only) field access policy of the field. --- .../interfaces/component/FieldInterface.cpp | 12 +++++------ .../memoryMaps/FieldAccessPoliciesEditor.cpp | 20 ++++++++++++++----- .../memoryMaps/FieldAccessPoliciesEditor.h | 6 ++++++ .../memoryMaps/SingleFieldEditor.cpp | 4 +++- .../memoryMaps/registereditor.cpp | 4 ++++ .../memoryMaps/registertablemodel.cpp | 6 ++++++ version.h | 16 +++++++-------- 7 files changed, 47 insertions(+), 21 deletions(-) diff --git a/KactusAPI/interfaces/component/FieldInterface.cpp b/KactusAPI/interfaces/component/FieldInterface.cpp index 64aebaf8b..74307aac3 100644 --- a/KactusAPI/interfaces/component/FieldInterface.cpp +++ b/KactusAPI/interfaces/component/FieldInterface.cpp @@ -680,14 +680,12 @@ bool FieldInterface::setAccess(std::string const& fieldName, std::string const& field->setAccess(newAccess); return true; } - else if (accessPolicyIndex >= 0) + + if (auto accessPolicies = field->getFieldAccessPolicies(); + accessPolicyIndex <= accessPolicies->size() - 1 && accessPolicyIndex >= 0) { - if (auto accessPolicies = field->getFieldAccessPolicies(); - accessPolicyIndex <= accessPolicies->size() - 1) - { - accessPolicies->at(accessPolicyIndex)->setAccess(newAccess); - return true; - } + accessPolicies->at(accessPolicyIndex)->setAccess(newAccess); + return true; } } diff --git a/editors/ComponentEditor/memoryMaps/FieldAccessPoliciesEditor.cpp b/editors/ComponentEditor/memoryMaps/FieldAccessPoliciesEditor.cpp index 55f706412..3732d8191 100644 --- a/editors/ComponentEditor/memoryMaps/FieldAccessPoliciesEditor.cpp +++ b/editors/ComponentEditor/memoryMaps/FieldAccessPoliciesEditor.cpp @@ -28,13 +28,14 @@ FieldAccessPoliciesEditor::FieldAccessPoliciesEditor(QString const& fieldName, F QSharedPointer parameterFinder, QSharedPointer expressionParser, QWidget* parent): QGroupBox(QStringLiteral("Access policies"), parent), -view_(new EditableTableView(this)) +view_(new EditableTableView(this)), +proxy_(new QSortFilterProxyModel(this)) { QVBoxLayout* topLayout = new QVBoxLayout(this); topLayout->addWidget(view_); auto model = new FieldAccessPoliciesModel(fieldName, parameterFinder, fieldInterface, expressionParser, this); - auto proxy = new QSortFilterProxyModel(this); + proxy_ = new QSortFilterProxyModel(this); ComponentParameterModel* componentParameterModel = new ComponentParameterModel(parameterFinder, this); componentParameterModel->setExpressionParser(expressionParser); @@ -43,8 +44,8 @@ view_(new EditableTableView(this)) fieldInterface->getModeReferenceInterface(), this); view_->setSortingEnabled(true); - proxy->setSourceModel(model); - view_->setModel(proxy); + proxy_->setSourceModel(model); + view_->setModel(proxy_); view_->setItemDelegate(delegate); view_->horizontalHeader()->setStretchLastSection(false); view_->setAllowElementCopying(true); @@ -61,7 +62,7 @@ view_(new EditableTableView(this)) model, SLOT(onCopyRows(QModelIndexList)), Qt::UniqueConnection); connect(view_, SIGNAL(pasteRows()), model, SLOT(onPasteRows()), Qt::UniqueConnection); - connect(model, SIGNAL(invalidateFilter()), proxy, SLOT(invalidate()), Qt::UniqueConnection); + connect(model, SIGNAL(invalidateFilter()), proxy_, SLOT(invalidate()), Qt::UniqueConnection); connect(model, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection); connect(model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SIGNAL(contentChanged()), Qt::UniqueConnection); @@ -75,3 +76,12 @@ view_(new EditableTableView(this)) connect(delegate, SIGNAL(decreaseReferences(QString const&)), this, SIGNAL(decreaseReferences(QString const&)), Qt::UniqueConnection); } + +//----------------------------------------------------------------------------- +// Function: FieldAccessPoliciesEditor::refresh() +//----------------------------------------------------------------------------- +void FieldAccessPoliciesEditor::refresh() +{ + view_->update(); + proxy_->invalidate(); +} diff --git a/editors/ComponentEditor/memoryMaps/FieldAccessPoliciesEditor.h b/editors/ComponentEditor/memoryMaps/FieldAccessPoliciesEditor.h index 4ea0eb3b2..89ae6a81f 100644 --- a/editors/ComponentEditor/memoryMaps/FieldAccessPoliciesEditor.h +++ b/editors/ComponentEditor/memoryMaps/FieldAccessPoliciesEditor.h @@ -19,6 +19,7 @@ class FieldInterface; class ParameterFinder; class ExpressionParser; +class QSortFilterProxyModel; class FieldAccessPoliciesEditor : public QGroupBox { @@ -35,6 +36,8 @@ class FieldAccessPoliciesEditor : public QGroupBox FieldAccessPoliciesEditor(FieldAccessPoliciesEditor& other) = delete; FieldAccessPoliciesEditor& operator=(FieldAccessPoliciesEditor& other) = delete; + void refresh(); + signals: /*! @@ -62,6 +65,9 @@ class FieldAccessPoliciesEditor : public QGroupBox //! The table view to display the field access policies. EditableTableView* view_; + + //! Proxy to sort field access policies. + QSortFilterProxyModel* proxy_; }; #endif // FIELDACCESSPOLICIESEDITOR_H \ No newline at end of file diff --git a/editors/ComponentEditor/memoryMaps/SingleFieldEditor.cpp b/editors/ComponentEditor/memoryMaps/SingleFieldEditor.cpp index 4888a6fe3..0071ab45a 100644 --- a/editors/ComponentEditor/memoryMaps/SingleFieldEditor.cpp +++ b/editors/ComponentEditor/memoryMaps/SingleFieldEditor.cpp @@ -170,6 +170,7 @@ void SingleFieldEditor::refresh() nameEditor_.refresh(); resetsEditor_->refresh(); enumerationsEditor_->refresh(); + accessPoliciesEditor_->refresh(); // Block signals from here for the duration of refreshing editors. blockSignals(true); @@ -207,6 +208,7 @@ void SingleFieldEditor::refresh() changeExpressionEditorSignalBlockStatus(false); + volatileEditor_->setCurrentValue(QString::fromStdString(fieldInterface_->getVolatile(fieldName_))); if (component()->getRevision() == Document::Revision::Std14) @@ -295,7 +297,7 @@ void SingleFieldEditor::onVolatileSelected(QString const& newVolatileValue) //----------------------------------------------------------------------------- void SingleFieldEditor::onAccessSelected(QString const& newAccessValue) { - fieldInterface_->setAccess(fieldName_, newAccessValue.toStdString()); + fieldInterface_->setAccess(fieldName_, newAccessValue.toStdString(), -1); emit contentChanged(); } diff --git a/editors/ComponentEditor/memoryMaps/registereditor.cpp b/editors/ComponentEditor/memoryMaps/registereditor.cpp index 583d0eb69..431dafa28 100644 --- a/editors/ComponentEditor/memoryMaps/registereditor.cpp +++ b/editors/ComponentEditor/memoryMaps/registereditor.cpp @@ -80,6 +80,10 @@ fields_(fields) if (component->getRevision() == Document::Revision::Std22) { + view_->hideColumn(RegisterColumns::MOD_WRITE_COLUMN); + view_->hideColumn(RegisterColumns::READ_ACTION_COLUMN); + view_->hideColumn(RegisterColumns::TESTABLE_COLUMN); + view_->hideColumn(RegisterColumns::TEST_CONSTR_COLUMN); view_->hideColumn(RegisterColumns::IS_PRESENT_COLUMN); } diff --git a/editors/ComponentEditor/memoryMaps/registertablemodel.cpp b/editors/ComponentEditor/memoryMaps/registertablemodel.cpp index 59bc6507d..f97e891b2 100644 --- a/editors/ComponentEditor/memoryMaps/registertablemodel.cpp +++ b/editors/ComponentEditor/memoryMaps/registertablemodel.cpp @@ -746,6 +746,12 @@ bool RegisterTableModel::setStd14ColumnData(QModelIndex const& index, QVariant c if (index.column() == RegisterColumns::ACCESS_COLUMN) { fieldInterface_->setAccess(fieldName, value.toString().toStdString(), fieldAccessPolicyIndex); + + // Remove field access policy, if new access is empty. + if (value.toString().isEmpty()) + { + fieldInterface_->removeFieldAccessPolicy(fieldName, 0); + } } else if (index.column() == RegisterColumns::MOD_WRITE_COLUMN) { diff --git a/version.h b/version.h index f86256d7a..6f77ce9ca 100644 --- a/version.h +++ b/version.h @@ -10,20 +10,20 @@ #ifndef VERSIONNO__H #define VERSIONNO__H -#define VERSION_FULL 3.12.1074.0 +#define VERSION_FULL 3.12.1078.0 #define VERSION_BASEYEAR 0 -#define VERSION_DATE "2023-11-28" -#define VERSION_TIME "15:33:34" +#define VERSION_DATE "2023-11-30" +#define VERSION_TIME "11:37:29" #define VERSION_MAJOR 3 #define VERSION_MINOR 12 -#define VERSION_BUILDNO 1074 +#define VERSION_BUILDNO 1078 #define VERSION_EXTEND 0 -#define VERSION_FILE 3,12,1074,0 -#define VERSION_PRODUCT 3,12,1074,0 -#define VERSION_FILESTR "3,12,1074,0" -#define VERSION_PRODUCTSTR "3,12,1074,0" +#define VERSION_FILE 3,12,1078,0 +#define VERSION_PRODUCT 3,12,1078,0 +#define VERSION_FILESTR "3,12,1078,0" +#define VERSION_PRODUCTSTR "3,12,1078,0" #endif From be13e39d8c5a95dcf4a368ff28fa490ce7d7e926 Mon Sep 17 00:00:00 2001 From: hagantsa Date: Thu, 30 Nov 2023 12:53:40 +0200 Subject: [PATCH 4/4] [PERFECTIVE] Clarify register size calculation in address block validator. --- IPXACTmodels/Component/validators/AddressBlockValidator.cpp | 4 ++-- IPXACTmodels/Component/validators/AddressBlockValidator.h | 2 +- IPXACTmodels/Component/validators/MemoryMapValidator.cpp | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/IPXACTmodels/Component/validators/AddressBlockValidator.cpp b/IPXACTmodels/Component/validators/AddressBlockValidator.cpp index 60da7295b..db4ea1935 100644 --- a/IPXACTmodels/Component/validators/AddressBlockValidator.cpp +++ b/IPXACTmodels/Component/validators/AddressBlockValidator.cpp @@ -774,8 +774,8 @@ qint64 AddressBlockValidator::getRegisterSizeInLAU(QSharedPointer targ } } - qint64 topPart = size + addressUnitBits - 1; - qint64 dimensionlessSize = topPart / addressUnitBits; + // Round register size up to closest multiple of AUB to get size in least addressable units/AUB. + qint64 dimensionlessSize = static_cast(std::ceil(size / static_cast(addressUnitBits))); qint64 trueSize = dimensionlessSize * dimensionsProduct; diff --git a/IPXACTmodels/Component/validators/AddressBlockValidator.h b/IPXACTmodels/Component/validators/AddressBlockValidator.h index 2faf49aa4..6777aa117 100644 --- a/IPXACTmodels/Component/validators/AddressBlockValidator.h +++ b/IPXACTmodels/Component/validators/AddressBlockValidator.h @@ -246,7 +246,7 @@ class IPXACTMODELS_EXPORT AddressBlockValidator : public MemoryBlockValidator bool hasMemoryBlockDataGroupDefined(QSharedPointer addressBlock) const; /*! - * Gets the register size in LAU. + * Gets the register size in LAU (least addressable unit). * * @param [in] targetRegister The selected register. * @param [in] addressUnitBits The address unit bits of a memory map. diff --git a/IPXACTmodels/Component/validators/MemoryMapValidator.cpp b/IPXACTmodels/Component/validators/MemoryMapValidator.cpp index dd7a562f6..ee1219f9f 100644 --- a/IPXACTmodels/Component/validators/MemoryMapValidator.cpp +++ b/IPXACTmodels/Component/validators/MemoryMapValidator.cpp @@ -276,7 +276,6 @@ void MemoryMapValidator::findErrorsInRemapModeRefs(QStringList& errors, QSharedP for (auto const& ref : *modeRefs) { QString const& referenceValue = ref->getReference(); - auto referencePriority = ref->getPriority(); if (referenceValue.isEmpty()) {