Skip to content

Commit

Permalink
Merge branch 'std-update' of github.com:kactus2/kactus2dev into std-u…
Browse files Browse the repository at this point in the history
…pdate
  • Loading branch information
epekkar committed Dec 1, 2023
2 parents 3a148d6 + 6a72f13 commit 224bcc4
Show file tree
Hide file tree
Showing 18 changed files with 122 additions and 121 deletions.
4 changes: 3 additions & 1 deletion IPXACTmodels/Component/FileSetRef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ FileSetRef::FileSetRef(FileSetRef const& other) :
//-----------------------------------------------------------------------------
// Function: FileSetRef::FileSetRef()
//-----------------------------------------------------------------------------
FileSetRef::FileSetRef() : Extendable()
FileSetRef::FileSetRef(QString const& localName) :
Extendable(),
localName_(localName)
{

}
Expand Down
2 changes: 1 addition & 1 deletion IPXACTmodels/Component/FileSetRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class IPXACTMODELS_EXPORT FileSetRef : public Extendable
public:

//! The constructor.
FileSetRef();
explicit FileSetRef(QString const& localName = QString());

~FileSetRef() override = default;

Expand Down
4 changes: 2 additions & 2 deletions IPXACTmodels/Component/validators/AddressBlockValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,8 +774,8 @@ qint64 AddressBlockValidator::getRegisterSizeInLAU(QSharedPointer<Register> 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<qint64>(std::ceil(size / static_cast<double>(addressUnitBits)));

qint64 trueSize = dimensionlessSize * dimensionsProduct;

Expand Down
2 changes: 1 addition & 1 deletion IPXACTmodels/Component/validators/AddressBlockValidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class IPXACTMODELS_EXPORT AddressBlockValidator : public MemoryBlockValidator
bool hasMemoryBlockDataGroupDefined(QSharedPointer<AddressBlock> 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.
Expand Down
1 change: 0 additions & 1 deletion IPXACTmodels/Component/validators/MemoryMapValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down
32 changes: 21 additions & 11 deletions IPXACTmodels/utilities/ComponentSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,41 @@
#include "Search.h"

#include <IPXACTmodels/Component/Model.h>
#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>
#include <IPXACTmodels/Design/Design.h>

#include <KactusAPI/include/LibraryInterface.h>

//-----------------------------------------------------------------------------
// Function: ComponentSearch::findDesignReference()
//-----------------------------------------------------------------------------
VLNV ComponentSearch::findDesignReference(QSharedPointer<Component> component, QString const& viewName)
VLNV ComponentSearch::findDesignReference(QSharedPointer<Component> 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> component, QSharedPointer<View> view)
VLNV ComponentSearch::findDesignReference(QSharedPointer<Component> component, LibraryInterface* libraryHandler,
QSharedPointer<View> 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<DesignConfiguration>(designConfigRef))
{
return designCfg->getDesignRef();
}
}

return VLNV();
Expand Down Expand Up @@ -75,11 +87,9 @@ QSharedPointer<View> ComponentSearch::findView(QSharedPointer<Component> compone
QSharedPointer<ComponentInstantiation> ComponentSearch::findComponentInstantiation(
QSharedPointer<Component> component, QString const& viewName)
{
QSharedPointer<View> view = findView(component, viewName);

if (view)
if (QSharedPointer<View> view = findView(component, viewName))
{
foreach(QSharedPointer<ComponentInstantiation> instantiation, *component->getComponentInstantiations())
for (auto const& instantiation : *component->getComponentInstantiations())
{
if (instantiation->name() == view->getComponentInstantiationRef())
{
Expand Down
6 changes: 4 additions & 2 deletions IPXACTmodels/utilities/ComponentSearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@

#include <QSharedPointer>

class LibraryInterface;

//-----------------------------------------------------------------------------
//! Utilities for searching items in Component.
//-----------------------------------------------------------------------------
namespace ComponentSearch
{
VLNV findDesignReference(QSharedPointer<Component> component, QString const& viewName);
VLNV findDesignReference(QSharedPointer<Component> component, LibraryInterface* libraryHandler, QString const& viewName);

VLNV findDesignReference(QSharedPointer<Component> component, QSharedPointer<View> view);
VLNV findDesignReference(QSharedPointer<Component> component, LibraryInterface* libraryHandler, QSharedPointer<View> view);

VLNV findDesignConfigurationReference(QSharedPointer<Component> component, QSharedPointer<View> view);

Expand Down
12 changes: 5 additions & 7 deletions KactusAPI/interfaces/component/FieldInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,14 +679,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;
}
}

Expand Down
23 changes: 4 additions & 19 deletions Plugins/QuartusProjectGenerator/QuartusGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,30 +393,15 @@ void QuartusGenerator::parseFileSets(QSharedPointer<Component> component, QStrin
//-----------------------------------------------------------------------------
void QuartusGenerator::parseFilesFromHierarchicalView(QSharedPointer<View> view, QSharedPointer<Component> component)
{
VLNV designVLNV = ComponentSearch::findDesignReference(component, view);
VLNV designVLNV = ComponentSearch::findDesignReference(component, handler_, view);
VLNV desConfVLNV = ComponentSearch::findDesignConfigurationReference(component, view);

QSharedPointer<const DesignConfiguration> designConf;

if (desConfVLNV.isValid())
{
designConf = handler_->getModelReadOnly<DesignConfiguration>(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<const DesignConfiguration> designConf = handler_->getModelReadOnly<DesignConfiguration>(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;
}

Expand Down
33 changes: 8 additions & 25 deletions Plugins/VHDLGenerator/vhdlgenerator2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,7 @@ static const QString BLACK_BOX_ASSIGN_END = "-- ##KACTUS2_BLACK_BOX_ASSIGNMENTS_
//-----------------------------------------------------------------------------
VhdlGenerator2::VhdlGenerator2(QSharedPointer<ExpressionParser> 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);

Expand Down Expand Up @@ -124,7 +107,7 @@ bool VhdlGenerator2::parse( QSharedPointer<Component> topLevelComponent, const Q
}

// get the types that are used for the ports.
foreach ( QSharedPointer<Port> port, *component_->getPorts() )
for (auto const& port : *component_->getPorts())
{
typeDefinitions_.append( port->getTypeDefinitions() );
}
Expand All @@ -142,13 +125,13 @@ bool VhdlGenerator2::parse( QSharedPointer<Component> topLevelComponent, const Q
mapPorts2Signals();

// tell each instance to use the default port value for the unconnected ports.
foreach (QSharedPointer<VhdlComponentInstance> 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<VhdlComponentDeclaration> comp, components_)
for (auto const& comp : components_)
{
comp->checkPortConnections();
}
Expand Down Expand Up @@ -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);
Expand All @@ -435,13 +418,13 @@ bool VhdlGenerator2::parseDesignAndConfiguration()
{
if (!designvalidator_->validate(design_))
{
QVector<QString> 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);
}
Expand All @@ -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);
}
Expand Down
20 changes: 15 additions & 5 deletions editors/ComponentEditor/memoryMaps/FieldAccessPoliciesEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ FieldAccessPoliciesEditor::FieldAccessPoliciesEditor(QString const& fieldName, F
QSharedPointer<ParameterFinder> parameterFinder, QSharedPointer<ExpressionParser> 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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
class FieldInterface;
class ParameterFinder;
class ExpressionParser;
class QSortFilterProxyModel;

class FieldAccessPoliciesEditor : public QGroupBox
{
Expand All @@ -35,6 +36,8 @@ class FieldAccessPoliciesEditor : public QGroupBox
FieldAccessPoliciesEditor(FieldAccessPoliciesEditor& other) = delete;
FieldAccessPoliciesEditor& operator=(FieldAccessPoliciesEditor& other) = delete;

void refresh();

signals:

/*!
Expand Down Expand Up @@ -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
4 changes: 3 additions & 1 deletion editors/ComponentEditor/memoryMaps/SingleFieldEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -207,6 +208,7 @@ void SingleFieldEditor::refresh()

changeExpressionEditorSignalBlockStatus(false);


volatileEditor_->setCurrentValue(QString::fromStdString(fieldInterface_->getVolatile(fieldName_)));

if (component()->getRevision() == Document::Revision::Std14)
Expand Down Expand Up @@ -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();
}
Expand Down
4 changes: 4 additions & 0 deletions editors/ComponentEditor/memoryMaps/registereditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
6 changes: 6 additions & 0 deletions editors/ComponentEditor/memoryMaps/registertablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Loading

0 comments on commit 224bcc4

Please sign in to comment.