Skip to content

Commit

Permalink
[ADDITIVE] Update validation of bus interfaces, cpus, indirect interf…
Browse files Browse the repository at this point in the history
…aces, ports and power domains to use hierarchical validation.
  • Loading branch information
hagantsa committed Oct 3, 2024
1 parent 1df7be8 commit f70c2f2
Show file tree
Hide file tree
Showing 27 changed files with 456 additions and 156 deletions.
4 changes: 3 additions & 1 deletion IPXACTmodels/Component/validators/BusInterfaceValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ BusInterfaceValidator::BusInterfaceValidator(QSharedPointer<ExpressionParser> ex
QSharedPointer<PortMapValidator> portMapValidator,
QSharedPointer<ParameterValidator> parameterValidator,
LibraryInterface* libraryHandler):
HierarchicalValidator(),
expressionParser_(expressionParser),
availableChoices_(choices),
availableViews_(views),
Expand Down Expand Up @@ -124,7 +125,8 @@ bool BusInterfaceValidator::validate(QSharedPointer<BusInterface> busInterface,
return hasValidName(busInterface) && hasValidIsPresent(busInterface->getIsPresent()) &&
hasValidBusType(busInterface) && hasValidAbstractionTypes(busInterface) &&
hasValidInterfaceMode(busInterface) && hasValidBitsInLAU(busInterface) &&
hasValidBitSteering(busInterface, docRevision) && hasValidParameters(busInterface);
hasValidBitSteering(busInterface, docRevision) && hasValidParameters(busInterface) &&
validComparedToSiblings(busInterface);
}

//-----------------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion IPXACTmodels/Component/validators/BusInterfaceValidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <IPXACTmodels/Component/Mode.h>

#include <IPXACTmodels/common/validators/ParameterValidator.h>
#include <IPXACTmodels/common/validators/HierarchicalValidator.h>

#include <QSharedPointer>
#include <QString>
Expand All @@ -46,7 +47,7 @@ class PortMapValidator;
//-----------------------------------------------------------------------------
//! Validator for the ipxact:busInterface.
//-----------------------------------------------------------------------------
class IPXACTMODELS_EXPORT BusInterfaceValidator
class IPXACTMODELS_EXPORT BusInterfaceValidator : public HierarchicalValidator
{
public:

Expand Down
15 changes: 8 additions & 7 deletions IPXACTmodels/Component/validators/CPUValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ CPUValidator::CPUValidator(QSharedPointer<ParameterValidator> parameterValidator
QSharedPointer<QList<QSharedPointer<AddressSpace> > > addressSpaces,
QSharedPointer<QList<QSharedPointer<MemoryMap> > > memoryMaps,
Document::Revision revision) :
parameterValidator_(parameterValidator),
regionValidator_(new RegionValidator(expressionParser)),
expressionParser_(expressionParser),
addressSpaces_(addressSpaces),
memoryMaps_(memoryMaps),
revision_(revision)
HierarchicalValidator(),
parameterValidator_(parameterValidator),
regionValidator_(new RegionValidator(expressionParser)),
expressionParser_(expressionParser),
addressSpaces_(addressSpaces),
memoryMaps_(memoryMaps),
revision_(revision)
{

}
Expand Down Expand Up @@ -95,7 +96,7 @@ bool CPUValidator::validate(QSharedPointer<Cpu> cpu) const
}
}

return true;
return validComparedToSiblings(cpu);
}

//-----------------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion IPXACTmodels/Component/validators/CPUValidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include <IPXACTmodels/common/Document.h>

#include <IPXACTmodels/common/validators/HierarchicalValidator.h>

#include "RegionValidator.h"

#include <QList>
Expand All @@ -32,7 +34,7 @@ class ParameterValidator;
//-----------------------------------------------------------------------------
//! Validator for ipxact:CPU.
//-----------------------------------------------------------------------------
class IPXACTMODELS_EXPORT CPUValidator
class IPXACTMODELS_EXPORT CPUValidator : public HierarchicalValidator
{
public:

Expand Down
176 changes: 176 additions & 0 deletions IPXACTmodels/Component/validators/CollectionValidators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@
#include <IPXACTmodels/Component/View.h>
#include <IPXACTmodels/Component/validators/ViewValidator.h>

#include <IPXACTmodels/Component/Port.h>
#include <IPXACTmodels/Component/validators/PortValidator.h>

#include <IPXACTmodels/Component/BusInterface.h>
#include <IPXACTmodels/Component/validators/BusInterfaceValidator.h>

#include <IPXACTmodels/Component/IndirectInterface.h>
#include <IPXACTmodels/Component/validators/IndirectInterfaceValidator.h>

#include <IPXACTmodels/Component/Cpu.h>
#include <IPXACTmodels/Component/validators/CPUValidator.h>

#include <IPXACTmodels/Component/PowerDomain.h>
#include <IPXACTmodels/Component/validators/PowerDomainValidator.h>

#include <IPXACTmodels/Component/Component.h>
#include <IPXACTmodels/Component/validators/InstantiationsValidator.h>

Expand Down Expand Up @@ -206,6 +221,7 @@ bool AllInstantiationsValidator::hasValidDesignInstantiations(QSharedPointer<Com
// Function: ViewsValidator::ViewsValidator()
//-----------------------------------------------------------------------------
ViewsValidator::ViewsValidator(QSharedPointer<ViewValidator> viewValidator) :
HierarchicalValidator(),
viewValidator_(viewValidator)
{
setChildValidator(viewValidator);
Expand All @@ -232,3 +248,163 @@ bool ViewsValidator::validate(QSharedPointer<QList<QSharedPointer<View> > > view

return true;
}

//-----------------------------------------------------------------------------
// Function: PortsValidator::PortsValidator()
//-----------------------------------------------------------------------------
PortsValidator::PortsValidator(QSharedPointer<PortValidator> portValidator):
HierarchicalValidator(),
portValidator_(portValidator)
{
setChildValidator(portValidator);
}

//-----------------------------------------------------------------------------
// Function: PortsValidator::validate()
//-----------------------------------------------------------------------------
bool PortsValidator::validate(QSharedPointer<QList<QSharedPointer<Port> > > ports)
{
if (auto portsAsNameGroup = CollectionValidators::itemListToNameGroupList(ports);
!childrenHaveUniqueNames(portsAsNameGroup))
{
return false;
}

for (auto const& child : *ports)
{
if (!portValidator_->validate(child))
{
return false;
}
}

return true;
}

//-----------------------------------------------------------------------------
// Function: BusInterfacesValidator::BusInterfacesValidator()
//-----------------------------------------------------------------------------
BusInterfacesValidator::BusInterfacesValidator(QSharedPointer<BusInterfaceValidator> busInterfaceValidator) :
HierarchicalValidator(),
busInterfaceValidator_(busInterfaceValidator)
{
setChildValidator(busInterfaceValidator);
}

//-----------------------------------------------------------------------------
// Function: BusInterfacesValidator::validate()
//-----------------------------------------------------------------------------
bool BusInterfacesValidator::validate(QSharedPointer<QList<QSharedPointer<BusInterface> > > interfaces,
Document::Revision docRevision)
{
if (auto busInterfacesAsNameGroup = CollectionValidators::itemListToNameGroupList(interfaces);
!childrenHaveUniqueNames(busInterfacesAsNameGroup))
{
return false;
}

for (auto const& child : *interfaces)
{
if (!busInterfaceValidator_->validate(child, docRevision))
{
return false;
}
}

return true;
}

//-----------------------------------------------------------------------------
// Function: IndirectInterfacesValidator::IndirectInterfacesValidator()
//-----------------------------------------------------------------------------
IndirectInterfacesValidator::IndirectInterfacesValidator(QSharedPointer<IndirectInterfaceValidator> indirectInterfaceValidator) :
HierarchicalValidator(),
indirectInterfaceValidator_(indirectInterfaceValidator)
{
setChildValidator(indirectInterfaceValidator);
}

//-----------------------------------------------------------------------------
// Function: IndirectInterfacesValidator::validate()
//-----------------------------------------------------------------------------
bool IndirectInterfacesValidator::validate(QSharedPointer<QList<QSharedPointer<IndirectInterface> > > indirectInterfaces)
{
if (auto indirectInterfacesAsNameGroup = CollectionValidators::itemListToNameGroupList(indirectInterfaces);
!childrenHaveUniqueNames(indirectInterfacesAsNameGroup))
{
return false;
}

for (auto const& child : *indirectInterfaces)
{
if (!indirectInterfaceValidator_->validate(child))
{
return false;
}
}

return true;
}

//-----------------------------------------------------------------------------
// Function: CPUsValidator::CPUsValidator()
//-----------------------------------------------------------------------------
CPUsValidator::CPUsValidator(QSharedPointer<CPUValidator> cpuValidator):
cpuValidator_(cpuValidator)
{
setChildValidator(cpuValidator);
}

//-----------------------------------------------------------------------------
// Function: CPUsValidator::validate()
//-----------------------------------------------------------------------------
bool CPUsValidator::validate(QSharedPointer<QList<QSharedPointer<Cpu> > > cpus)
{
if (auto cpusAsNameGroup = CollectionValidators::itemListToNameGroupList(cpus);
!childrenHaveUniqueNames(cpusAsNameGroup))
{
return false;
}

for (auto const& child : *cpus)
{
if (!cpuValidator_->validate(child))
{
return false;
}
}

return true;
}

//-----------------------------------------------------------------------------
// Function: PowerDomainsValidator::PowerDomainsValidator()
//-----------------------------------------------------------------------------
PowerDomainsValidator::PowerDomainsValidator(QSharedPointer<PowerDomainValidator> powerDomainValidator):
HierarchicalValidator(),
powerDomainValidator_(powerDomainValidator)
{
setChildValidator(powerDomainValidator);
}

//-----------------------------------------------------------------------------
// Function: PowerDomainsValidator::validate()
//-----------------------------------------------------------------------------
bool PowerDomainsValidator::validate(QSharedPointer<QList<QSharedPointer<PowerDomain> > > powerDomains)
{
if (auto powerDomainsAsNameGroup = CollectionValidators::itemListToNameGroupList(powerDomains);
!childrenHaveUniqueNames(powerDomainsAsNameGroup))
{
return false;
}

for (auto const& child : *powerDomains)
{
if (!powerDomainValidator_->validate(child))
{
return false;
}
}

return true;
}
Loading

0 comments on commit f70c2f2

Please sign in to comment.