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 Nov 22, 2023
2 parents 3f7681e + 9773ebc commit b6721d2
Show file tree
Hide file tree
Showing 55 changed files with 550 additions and 290 deletions.
3 changes: 2 additions & 1 deletion IPXACTmodels/Component/BusInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,8 @@ QString BusInterface::getMemoryMapRef() const
//-----------------------------------------------------------------------------
QString BusInterface::getAddressSpaceRef() const
{
if (interfaceMode_ == General::MASTER || interfaceMode_ == General::MIRRORED_MASTER)
if (interfaceMode_ == General::MASTER || interfaceMode_ == General::MIRRORED_MASTER ||
interfaceMode_ == General::INITIATOR || interfaceMode_ == General::MIRRORED_INITIATOR)
{
if (!initiator_)
{
Expand Down
23 changes: 18 additions & 5 deletions IPXACTmodels/Component/Component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ QStringList Component::getTargetInterfaces( const QString& memoryMap ) const

for (const QSharedPointer<BusInterface> busif : *busInterfaces_)
{
if (busif->getInterfaceMode() == General::SLAVE && busif->getMemoryMapRef() == memoryMap)
if ((busif->getInterfaceMode() == interfaceModeName) && busif->getMemoryMapRef() == memoryMap)
{
names.append(busif->name());
}
Expand All @@ -1226,13 +1226,19 @@ QStringList Component::getTargetInterfaces( const QString& memoryMap ) const
//-----------------------------------------------------------------------------
// Function: Component::getMasterInterfaces()
//-----------------------------------------------------------------------------
QStringList Component::getMasterInterfaces( const QString& addressSpace ) const
QStringList Component::getInitiatorInterfaces( const QString& addressSpace ) const
{
QStringList names;

General::InterfaceMode initiatorModeName = getRevision() == Document::Revision::Std22
? General::INITIATOR : General::MASTER;

General::InterfaceMode mirroredInitiatorModeName = getRevision() == Document::Revision::Std22
? General::MIRRORED_INITIATOR : General::MIRRORED_MASTER;

for (const QSharedPointer<BusInterface> busif : *busInterfaces_)
{
if ((busif->getInterfaceMode() == General::MASTER || busif->getInterfaceMode() == General::MIRRORED_MASTER)
if ((busif->getInterfaceMode() == initiatorModeName || busif->getInterfaceMode() == mirroredInitiatorModeName)
&& (busif->getAddressSpaceRef() == addressSpace))
{
names.append(busif->name());
Expand All @@ -1245,12 +1251,19 @@ QStringList Component::getMasterInterfaces( const QString& addressSpace ) const
//-----------------------------------------------------------------------------
// Function: Component::getMasterInterfaces()
//-----------------------------------------------------------------------------
QStringList Component::getMasterInterfaces() const
QStringList Component::getInitiatorInterfaces() const
{
QStringList names;

General::InterfaceMode initiatorModeName = getRevision() == Document::Revision::Std22
? General::INITIATOR : General::MASTER;

General::InterfaceMode mirroredInitiatorModeName = getRevision() == Document::Revision::Std22
? General::MIRRORED_INITIATOR : General::MIRRORED_MASTER;

for (QSharedPointer<const BusInterface> busif : *busInterfaces_)
{
if (busif->getInterfaceMode() == General::MASTER || busif->getInterfaceMode() == General::MIRRORED_MASTER)
if (busif->getInterfaceMode() == initiatorModeName || busif->getInterfaceMode() == mirroredInitiatorModeName)
{
names.append(busif->name());
}
Expand Down
4 changes: 2 additions & 2 deletions IPXACTmodels/Component/Component.h
Original file line number Diff line number Diff line change
Expand Up @@ -765,14 +765,14 @@ class IPXACTMODELS_EXPORT Component: public Document
*
* @return QStringList containing names of the master and mirrored master interfaces.
*/
QStringList getMasterInterfaces(const QString& addressSpace) const;
QStringList getInitiatorInterfaces(const QString& addressSpace) const;

/*!
* Get list of the master and mirrored master interface names.
*
* @return QStringList containing the interface names.
*/
QStringList getMasterInterfaces() const;
QStringList getInitiatorInterfaces() const;

/*!
* Checks if the component contains bus interfaces.
Expand Down
19 changes: 12 additions & 7 deletions IPXACTmodels/Component/validators/FieldValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,17 +282,22 @@ bool FieldValidator::hasValidReserved(QSharedPointer<Field> field) const
//-----------------------------------------------------------------------------
bool FieldValidator::hasValidBitWidth(QSharedPointer<Field> field) const
{
QString solvedValue = expressionParser_->parseExpression(field->getBitWidth());
if (field->getFieldDefinitionRef().isEmpty())
{
QString solvedValue = expressionParser_->parseExpression(field->getBitWidth());

bool changeOk = true;
quint64 intValue = solvedValue.toULongLong(&changeOk);
bool changeOk = true;
quint64 intValue = solvedValue.toULongLong(&changeOk);

if (changeOk && intValue > 0)
{
return true;
if (changeOk && intValue > 0)
{
return true;
}

return false;
}

return false;
return true;
}

//-----------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void RegisterFileValidator::findErrorsInRegisterData(QVector<QString>& errors,
void RegisterFileValidator::findErrorsInAccessPolicies(QStringList& errors,
QSharedPointer<RegisterFile> selectedRegisterFile, QString const& context) const
{
QString registerFileContext = QStringLiteral("register ") + selectedRegisterFile->name() + QStringLiteral(" within ") + context;
QString registerFileContext = QStringLiteral("register file ") + selectedRegisterFile->name() + QStringLiteral(" within ") + context;

RegisterBaseValidator::findErrorsInAccessPolicies(errors, selectedRegisterFile, registerFileContext);
}
Expand Down
3 changes: 2 additions & 1 deletion KactusAPI/KactusAPI.pri
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ HEADERS += ./KactusAPI.h \
./include/IPluginUtility.h \
./include/IPXactSystemVerilogParser.h \
./include/LibraryInterface.h \
./include/ListHelper.h \
./include/ListParameterFinder.h \
./include/MasterPortInterface.h \
./include/MemoryBlockInterface.h \
Expand Down Expand Up @@ -115,7 +116,7 @@ SOURCES += ./KactusAPI.cpp \
./expressions/SystemVerilogExpressionParser.cpp \
./interfaces/bus/AbstractionTypeInterface.cpp \
./interfaces/bus/PortAbstractionInterface.cpp \
./include/AccessPolicyInterface.cpp \
./interfaces/component/AccessPolicyInterface.cpp \
./interfaces/component/AddressBlockInterface.cpp \
./interfaces/component/BusInterfaceInterface.cpp \
./interfaces/component/BusInterfaceInterfaceFactory.cpp \
Expand Down
2 changes: 1 addition & 1 deletion KactusAPI/KactusAPI.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@
<ClCompile Include="expressions\RegisterExpressionsGatherer.cpp" />
<ClCompile Include="expressions\RegisterFileExpressionsGatherer.cpp" />
<ClCompile Include="expressions\SystemVerilogExpressionParser.cpp" />
<ClCompile Include="include\AccessPolicyInterface.cpp" />
<ClCompile Include="interfaces\bus\AbstractionTypeInterface.cpp" />
<ClCompile Include="interfaces\bus\PortAbstractionInterface.cpp" />
<ClCompile Include="interfaces\common\AbstractParameterInterface.cpp" />
<ClCompile Include="interfaces\common\CommonInterface.cpp" />
<ClCompile Include="interfaces\common\NameGroupInterface.cpp" />
<ClCompile Include="interfaces\common\ParameterizableInterface.cpp" />
<ClCompile Include="interfaces\common\ParametersInterface.cpp" />
<ClCompile Include="interfaces\component\AccessPolicyInterface.cpp" />
<ClCompile Include="interfaces\component\AddressBlockInterface.cpp" />
<ClCompile Include="interfaces\component\BusInterfaceInterface.cpp" />
<ClCompile Include="interfaces\component\BusInterfaceInterfaceFactory.cpp" />
Expand Down
6 changes: 3 additions & 3 deletions KactusAPI/KactusAPI.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -494,15 +494,15 @@
<ClCompile Include="expressions\ComponentInstanceParameterFinder.cpp">
<Filter>Source Files\expressions</Filter>
</ClCompile>
<ClCompile Include="include\AccessPolicyInterface.cpp">
<Filter>Source Files\interfaces\component</Filter>
</ClCompile>
<ClCompile Include="expressions\ModeConditionParser.cpp">
<Filter>Source Files\expressions</Filter>
</ClCompile>
<ClCompile Include="interfaces\component\ModeReferenceInterface.cpp">
<Filter>Source Files\interfaces\component</Filter>
</ClCompile>
<ClCompile Include="interfaces\component\AccessPolicyInterface.cpp">
<Filter>Source Files\interfaces\component</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="include\ComponentInstanceInterface.h">
Expand Down
24 changes: 12 additions & 12 deletions KactusAPI/include/AddressBlockInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,34 +166,34 @@ class KACTUS2_API AddressBlockInterface : public MemoryBlockInterface
* accessPolicyIndex parameter. The default value of -1 returns the address block's access value. 0 and above
* returns an indexed access policy's access value.
*
* @param [in] blockName Name of the selected address block.
* @param [in] accessPolicyIndex The access policy to get the access value of.
* @param [in] blockName Name of the selected address block.
* @param [in] getAccessPolicyAccess Flag indicating if access is fetched from access policy or directly
* from address block.
*
* @return Access string of the selected address block or its access policy.
*/
std::string getAccessString(std::string const& blockName, int accessPolicyIndex = -1) const;
std::string getAccessString(std::string const& blockName, bool getAccessPolicyAccess = false) const;

/*!
* Get the access of the selected address block or one of its access policies specified by the
* accessPolicyIndex parameter. The default value of -1 returns the address block's access value. 0 and above
* returns an indexed access policy's access value.
* Get the access of the selected address block. Used in std14 access editor.
*
* @param [in] blockName Name of the selected address block.
* @param [in] accessPolicyIndex The access policy to get the access value of.
*
* @return Access of the selected address block or its access policy.
* @return Access of the selected address block.
*/
AccessTypes::Access getAccess(std::string const& blockName, int accessPolicyIndex = -1) const;
AccessTypes::Access getAccess(std::string const& blockName) const;

/*!
* Set a new access for the selected address block.
*
* @param [in] blockName Name of the selected address block.
* @param [in] newAccess New access value.
* @param [in] blockName Name of the selected address block.
* @param [in] newAccess New access value.
* @param [in] getAccessPolicyAccess Flag indicating if access is set to access policy or directly to
* address block.
*
* @return True, if successful, false otherwise.
*/
bool setAccess(std::string const& blockName, std::string const& newAccess, int accessPolicyIndex = -1) const;
bool setAccess(std::string const& blockName, std::string const& newAccess, bool setAccessPolicyAccess = false) const;

/*!
* Get the volatile value of the selected address block.
Expand Down
37 changes: 28 additions & 9 deletions KactusAPI/include/RegisterInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,15 @@ class KACTUS2_API RegisterInterface : public ParameterizableInterface, public Na
bool setVolatile(std::string const& registerName, std::string const& newVolatile);

/*!
* Get the access string of the selected register or access policy given by the access policy index.
* Use the default access policy index of -1 to fetch the access value stored directly in the register.
* Get the access string of the selected register or first access policy.
*
* @param [in] registerName Name of the selected register.
* @param [in] accessPolicyIndex The index of the selected access policy.
* @param [in] registerName Name of the selected register.
* @param [in] getAccessPolicyAccess Flag indicating if access is fetched from access policy or directly
* from register. Access is fetched from first access policy, if true.
*
* @return The access string of the selected register.
*/
std::string getAccessString(std::string const& registerName) const;
std::string getAccessString(std::string const& registerName, bool getAccessPolicyAccess = false) const;

/*!
* Get the access of the selected register or access policy given by the access policy index.
Expand All @@ -315,13 +315,32 @@ class KACTUS2_API RegisterInterface : public ParameterizableInterface, public Na
/*!
* Set the access value for the selected register or its access policy given by the access policy index.
*
* @param [in] registerName Name of the selected register.
* @param [in] newAccess The new access value.
* @param [in] accessPolicyIndex The index of the selected access policy.
* @param [in] registerName Name of the selected register.
* @param [in] newAccess The new access value.
* @param [in] getAccessPolicyAccess Flag indicating if access is set to access policy or directly
* to register. Access is set to first access policy, if true.
*
* @return True, if successful, false otherwise.
*/
bool setAccess(std::string const& registerName, std::string const& newAccess);
bool setAccess(std::string const& registerName, std::string const& newAccess, bool setAccessPolicyAccess = false);

/*!
* Get the number of access policies for a given register.
*
* @param [in] registerName The name of the register to get the number off access policies of.
*
* @return The number of access policies for the given register.
*/
int getAccessPolicyCount(std::string const& registerName) const;

/*!
* Adds a new access policy to the selected register.
*
* @param [in] registerName The selected register.
*
* @return True, if operation was successful, otherwise false.
*/
bool addAccessPolicy(std::string const& registerName);

/*!
* Calculate all the references to the selected ID in the selected item.
Expand Down
File renamed without changes.
58 changes: 22 additions & 36 deletions KactusAPI/interfaces/component/AddressBlockInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,20 +214,21 @@ bool AddressBlockInterface::setUsage(std::string const& blockName, std::string c
//-----------------------------------------------------------------------------
// Function: AddressBlockInterface::getAccessString()
//-----------------------------------------------------------------------------
std::string AddressBlockInterface::getAccessString(std::string const& blockName, int accessPolicyIndex /*= -1*/) const
std::string AddressBlockInterface::getAccessString(std::string const& blockName, bool getAccessPolicyAccess /*= false*/) const
{
if (auto selectedBlock = getAddressBlock(blockName))
{
if (accessPolicyIndex == -1)
if (!getAccessPolicyAccess)
{
return AccessTypes::access2Str(selectedBlock->getAccess()).toStdString();
}
else if (accessPolicyIndex >= 0)
else
{
if (auto accessPolicies = selectedBlock->getAccessPolicies();
accessPolicyIndex <= accessPolicies->size() - 1)
auto accessPolicies = selectedBlock->getAccessPolicies();

if (!accessPolicies->isEmpty())
{
return AccessTypes::access2Str(accessPolicies->at(accessPolicyIndex)->getAccess()).toStdString();
return AccessTypes::access2Str(accessPolicies->first()->getAccess()).toStdString();
}
}
}
Expand All @@ -238,22 +239,11 @@ std::string AddressBlockInterface::getAccessString(std::string const& blockName,
//-----------------------------------------------------------------------------
// Function: AddressBlockInterface::getAccess()
//-----------------------------------------------------------------------------
AccessTypes::Access AddressBlockInterface::getAccess(std::string const& blockName, int accessPolicyIndex /*= -1*/) const
AccessTypes::Access AddressBlockInterface::getAccess(std::string const& blockName) const
{
if (auto selectedBlock = getAddressBlock(blockName))
{
if (accessPolicyIndex == -1)
{
return selectedBlock->getAccess();
}
else if (accessPolicyIndex >= 0)
{
if (auto accessPolicies = selectedBlock->getAccessPolicies();
accessPolicyIndex <= accessPolicies->size() - 1)
{
return accessPolicies->at(accessPolicyIndex)->getAccess();
}
}
return selectedBlock->getAccess();
}

return AccessTypes::ACCESS_COUNT;
Expand All @@ -262,38 +252,34 @@ AccessTypes::Access AddressBlockInterface::getAccess(std::string const& blockNam
//-----------------------------------------------------------------------------
// Function: AddressBlockInterface::setAccess()
//-----------------------------------------------------------------------------
bool AddressBlockInterface::setAccess(std::string const& blockName, std::string const& newAccess, int accessPolicyIndex /*= -1*/) const
bool AddressBlockInterface::setAccess(std::string const& blockName, std::string const& newAccess, bool setAccessPolicyAccess /*= false*/) const
{
auto selectedBlock = getAddressBlock(blockName);
if (!selectedBlock)
{
return false;
}

if (accessPolicyIndex == -1)
if (!setAccessPolicyAccess)
{
selectedBlock->setAccess(AccessTypes::str2Access(QString::fromStdString(newAccess), AccessTypes::ACCESS_COUNT));
return true;
}
else if (accessPolicyIndex >= 0)
else
{
if (auto accessPolicies = selectedBlock->getAccessPolicies();
accessPolicyIndex <= accessPolicies->size() - 1)
{
auto accessPolicy = accessPolicies->at(accessPolicyIndex);

// Remove if empty.
if (newAccess.empty() && accessPolicy->getModeReferences()->isEmpty() &&
accessPolicy->getVendorExtensions()->isEmpty())
{
selectedBlock->getAccessPolicies()->removeAt(accessPolicyIndex);
return true;
}
auto accessPolicy = selectedBlock->getAccessPolicies()->first();

accessPolicy->setAccess(AccessTypes::str2Access(QString::fromStdString(newAccess),
AccessTypes::ACCESS_COUNT));
// Remove access policy, if new access is empty.
if (newAccess.empty() && accessPolicy->getModeReferences()->isEmpty() &&
accessPolicy->getVendorExtensions()->isEmpty())
{
selectedBlock->getAccessPolicies()->clear();
return true;
}

accessPolicy->setAccess(AccessTypes::str2Access(QString::fromStdString(newAccess),
AccessTypes::ACCESS_COUNT));
return true;
}

return false;
Expand Down
Loading

0 comments on commit b6721d2

Please sign in to comment.