Skip to content

Commit

Permalink
[ADDITIVE] Update master-slave path search to also look for opaque br…
Browse files Browse the repository at this point in the history
…idges.

[ADDITIVE] Allow opaque bridge components to be added to bridge columns in HW design.
  • Loading branch information
hagantsa committed May 2, 2024
1 parent e7be0cc commit df3c931
Show file tree
Hide file tree
Showing 14 changed files with 196 additions and 39 deletions.
6 changes: 3 additions & 3 deletions IPXACTmodels/Component/BusInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,16 +514,16 @@ void BusInterface::setMirroredTarget(QSharedPointer<MirroredTargetInterface> mir
}

//-----------------------------------------------------------------------------
// Function: BusInterface::hasBridge()
// Function: BusInterface::hasTransparentBridge()
//-----------------------------------------------------------------------------
bool BusInterface::hasBridge() const
bool BusInterface::hasTransparentBridge() const
{
if (!target_)
{
return false;
}

return target_->hasBridge();
return target_->hasTransparentBridge();
}

//-----------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions IPXACTmodels/Component/BusInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,11 @@ class IPXACTMODELS_EXPORT BusInterface : public NameGroup, public Extendable
void setMirroredTarget(QSharedPointer<MirroredTargetInterface> mirroredTarget);

/*!
* Does this bus interface have a bridge element defined.
* Does this bus interface have a transparent bridge element defined.
*
* @return True if a bridge is found, otherwise false.
*/
bool hasBridge() const;
bool hasTransparentBridge() const;

/*!
* Get the attributes of the bus interface.
Expand Down
37 changes: 34 additions & 3 deletions IPXACTmodels/Component/Component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ QSharedPointer<Document> Component::clone() const
//-----------------------------------------------------------------------------
bool Component::isBus() const
{
return isChannel() || isBridge();
return isChannel() || isTransparentBridge() || isOpaqueBridge();
}

//-----------------------------------------------------------------------------
Expand All @@ -156,10 +156,41 @@ bool Component::isChannel() const
//-----------------------------------------------------------------------------
// Function: Component::isBridge()
//-----------------------------------------------------------------------------
bool Component::isBridge() const
bool Component::isTransparentBridge() const
{
return std::any_of(busInterfaces_->cbegin(), busInterfaces_->cend(),
[](auto busif) { return busif->hasBridge(); });
[](auto busif) { return busif->hasTransparentBridge(); });
}

//-----------------------------------------------------------------------------
// Function: Component::isOpaqueBridge()
//-----------------------------------------------------------------------------
bool Component::isOpaqueBridge() const
{
auto memMapHasSubspaceMapWithInitRef = [](QSharedPointer<MemoryMap> memMap)
{
for (auto const& memoryBlock : *memMap->getMemoryBlocks())
{
if (auto subspaceMap = memoryBlock.dynamicCast<SubSpaceMap>();
!subspaceMap->getInitiatorReference().isEmpty())
{
return true;
}
}
return false;
};

auto busInterfaceIsBridged = [this, memMapHasSubspaceMapWithInitRef](QSharedPointer<BusInterface> busIf)
{
if (busIf->getMemoryMapRef().isEmpty())
{
return false;
}

return std::any_of(memoryMaps_->cbegin(), memoryMaps_->cend(), memMapHasSubspaceMapWithInitRef);
};

return std::any_of(busInterfaces_->cbegin(), busInterfaces_->cend(), busInterfaceIsBridged);
}

//-----------------------------------------------------------------------------
Expand Down
13 changes: 10 additions & 3 deletions IPXACTmodels/Component/Component.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,18 @@ class IPXACTMODELS_EXPORT Component: public Document
bool isChannel() const;

/*!
* Does the component contain a bridge element.
* Does the component contain a transparent bridge element.
*
* @return True if a bridge-element is found.
* @return True if a transparent bridge element is found.
*/
bool isBridge() const;
bool isTransparentBridge() const;

/*!
* Does the component contain an opaque bridge.
*
* @return True if an opaque bridge is found.
*/
bool isOpaqueBridge() const;

/*!
* Is this component a cpu.
Expand Down
4 changes: 2 additions & 2 deletions IPXACTmodels/Component/TargetInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ QSharedPointer<QList<QSharedPointer<TransparentBridge> > > TargetInterface::getB
}

//-----------------------------------------------------------------------------
// Function: TargetInterface::hasBridge()
// Function: TargetInterface::hasTransparentBridge()
//-----------------------------------------------------------------------------
bool TargetInterface::hasBridge() const
bool TargetInterface::hasTransparentBridge() const
{
return !bridges_->isEmpty();
}
Expand Down
4 changes: 2 additions & 2 deletions IPXACTmodels/Component/TargetInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ class IPXACTMODELS_EXPORT TargetInterface
*/
QSharedPointer<QList<QSharedPointer<TransparentBridge> > > getBridges() const;

/*! Check if the slave is connected to a master interface through bridge.
/*! Check if the slave is connected to a master interface through transparent bridge.
*
* @return True if at least one bridge is found, otherwise false.
*/
bool hasBridge() const;
bool hasTransparentBridge() const;

/*! Get list of the master interfaces referred to through the contained bridge-elements.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ void GlobalMemoryMapHeaderWriter::parseSlaveInterface(qint64 offset, QSharedPoin
}*/
}

if (slave->hasBridge())
if (slave->hasTransparentBridge())
{
QStringList masterNames = slave->getMasterReferences();
foreach (QString masterRef, masterNames)
Expand Down
2 changes: 1 addition & 1 deletion editors/HWDesign/HWDesignDiagram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ void HWDesignDiagram::dragEnterEvent(QGraphicsSceneDragDropEvent * event)
return;
}

if (component->isBridge())
if (component->isTransparentBridge() ||component->isOpaqueBridge())
{
dragCompType_ = ColumnTypes::BRIDGE;
}
Expand Down
2 changes: 1 addition & 1 deletion editors/HWDesign/columnview/HWColumn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ bool HWColumn::isItemAllowed(QGraphicsItem* item, unsigned int allowedItems) con
// Check if this is a packaged component (and has a strict type).
if (comp->getVlnv().isValid())
{
return ((comp->isBridge() && (allowedItems & ColumnTypes::BRIDGE)) ||
return (((comp->isTransparentBridge() || comp->isOpaqueBridge()) && (allowedItems & ColumnTypes::BRIDGE)) ||
(comp->isChannel() && (allowedItems & ColumnTypes::CHANNEL)) ||
(!comp->isBus() && (allowedItems & ColumnTypes::COMPONENT)));
}
Expand Down
61 changes: 54 additions & 7 deletions editors/MemoryDesigner/ConnectivityGraphFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
#include <IPXACTmodels/Design/Design.h>
#include <IPXACTmodels/DesignConfiguration/DesignConfiguration.h>

#include <IPXACTmodels/utilities/Search.h>

//-----------------------------------------------------------------------------
// Function: ConnectivityGraphFactory::ConnectivityGraphFactory()
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -132,7 +134,7 @@ void ConnectivityGraphFactory::analyzeDesign(QSharedPointer<DesignInstantiation>
QVector<QSharedPointer<ConnectivityInterface> > instanceInterfaces =
createInterfacesForInstance(instancedComponent, instanceNode, graph);

createInteralConnectionsAndDesigns(instancedComponent, instanceNode,
createInternalConnectionsAndDesigns(instancedComponent, instanceNode,
componentInstance->getInstanceName(), activeView, instanceInterfaces, graph);

interfacesInDesign += instanceInterfaces;
Expand Down Expand Up @@ -780,9 +782,9 @@ QSharedPointer<ConnectivityInterface> ConnectivityGraphFactory::createInterfaceD
}

//-----------------------------------------------------------------------------
// Function: ConnectivityGraphFactory::createInteralConnectionsAndDesigns()
// Function: ConnectivityGraphFactory::createInternalConnectionsAndDesigns()
//-----------------------------------------------------------------------------
void ConnectivityGraphFactory::createInteralConnectionsAndDesigns(
void ConnectivityGraphFactory::createInternalConnectionsAndDesigns(
QSharedPointer<const Component> instancedComponent, QSharedPointer<ConnectivityComponent> instanceNode,
QString const& instanceName, QString const& activeView,
QVector<QSharedPointer<ConnectivityInterface> > instanceInterfaces, QSharedPointer<ConnectivityGraph> graph)
Expand All @@ -800,9 +802,13 @@ void ConnectivityGraphFactory::createInteralConnectionsAndDesigns(

for (QSharedPointer<BusInterface> busInterface : *instancedComponent->getBusInterfaces())
{
if (busInterface->hasBridge())
if (busInterface->hasTransparentBridge())
{
createInternalConnectionsForTransparentBridge(busInterface, instanceName, instanceInterfaces, graph);
}
else if (!busInterface->getMemoryMapRef().isEmpty())
{
createInternalConnectionsForBridge(busInterface, instanceName, instanceInterfaces, graph);
createInternalConnectionsForOpaqueBridge(busInterface, instanceName, instanceInterfaces, graph, instancedComponent);
}
}

Expand Down Expand Up @@ -1075,9 +1081,9 @@ void ConnectivityGraphFactory::createInternalConnectionsForChannel(QSharedPointe
}

//-----------------------------------------------------------------------------
// Function: ConnectivityGraphFactory::createInternalConnectionsForBridge()
// Function: ConnectivityGraphFactory::createInternalConnectionsForTransparentBridge()
//-----------------------------------------------------------------------------
void ConnectivityGraphFactory::createInternalConnectionsForBridge(QSharedPointer<const BusInterface> busInterface,
void ConnectivityGraphFactory::createInternalConnectionsForTransparentBridge(QSharedPointer<const BusInterface> busInterface,
QString const& instanceName, QVector<QSharedPointer<ConnectivityInterface> > const& instanceInterfaces,
QSharedPointer<ConnectivityGraph> graph) const
{
Expand All @@ -1100,6 +1106,47 @@ void ConnectivityGraphFactory::createInternalConnectionsForBridge(QSharedPointer
}
}

//-----------------------------------------------------------------------------
// Function: ConnectivityGraphFactory::createInternalConnectionsForOpaqueBridge()
//-----------------------------------------------------------------------------
void ConnectivityGraphFactory::createInternalConnectionsForOpaqueBridge(QSharedPointer<const BusInterface> busInterface,
QString const& instanceName, QVector<QSharedPointer<ConnectivityInterface> > const& instanceInterfaces,
QSharedPointer<ConnectivityGraph> graph, QSharedPointer<const Component> component) const
{
// Find memory map connected to target, look through subspace maps and their initiator references.
// Create connections between each referenced initiator and the target connected to memory map.

auto targetInterface = busInterface->getTarget();
auto memMapRef = targetInterface->getMemoryMapRef();

auto memoryMap = Search::findByName(memMapRef, component->getMemoryMaps());
if (!memoryMap)
{
return;
}

QSharedPointer<ConnectivityInterface> startInterface =
getInterface(busInterface->name(), instanceName, instanceInterfaces);

for (auto const& memoryBlock : *memoryMap->getMemoryBlocks())
{
if (auto subspaceMap = memoryBlock.dynamicCast<SubSpaceMap>())
{
startInterface->setBridged();

QSharedPointer<ConnectivityInterface> endInterface =
getInterface(subspaceMap->getInitiatorReference(), instanceName, instanceInterfaces);

if (endInterface)
{
QString bridgeName = startInterface->getName() + "_bridge_to_" + endInterface->getName();
createConnectionData(bridgeName, startInterface, endInterface, graph);
endInterface->setBridged();
}
}
}
}

//-----------------------------------------------------------------------------
// Function: ConnectivityGraphFactory::getHierarchicalDesignConfiguration()
//-----------------------------------------------------------------------------
Expand Down
21 changes: 17 additions & 4 deletions editors/MemoryDesigner/ConnectivityGraphFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ class ConnectivityGraphFactory
* @param [in] instanceInterfaces The graph interfaces for the instanced component.
* @param [in/out] graph The graph to add elements into.
*/
void createInteralConnectionsAndDesigns(QSharedPointer<const Component> instancedComponent,
void createInternalConnectionsAndDesigns(QSharedPointer<const Component> instancedComponent,
QSharedPointer<ConnectivityComponent> instanceNode, QString const& instanceName, QString const& activeView,
QVector<QSharedPointer<ConnectivityInterface> > instanceInterfaces,
QSharedPointer<ConnectivityGraph> graph) const;
Expand Down Expand Up @@ -447,17 +447,30 @@ class ConnectivityGraphFactory
QSharedPointer<ConnectivityGraph> graph) const;

/*!
* Creates the graph edges for the given bridged bus interface.
* Creates the graph edges for the given transparently bridged bus interface.
*
* @param [in] busInterface The interface whose bridges to transform into edge(s).
* @param [in] busInterface The interface whose bridge(s) to transform into edge(s).
* @param [in] instanceName The name of the containing component instance.
* @param [in] instanceInterfaces The interface vertices of the instance.
* @param [in/out] graph The graph to add elements into.
*/
void createInternalConnectionsForBridge(QSharedPointer<const BusInterface> busInterface,
void createInternalConnectionsForTransparentBridge(QSharedPointer<const BusInterface> busInterface,
QString const& instanceName, QVector<QSharedPointer<ConnectivityInterface> > const& instanceInterfaces,
QSharedPointer<ConnectivityGraph> graph) const;

/*!
* Creates the graph edges for the given opaquely bridged bus interface.
*
* @param [in] busInterface The interface whose bridge(s) to transform into edge(s).
* @param [in] instanceName The name of the containing component instance.
* @param [in] instanceInterfaces The interface vertices of the instance.
* @param [in/out] graph The graph to add elements into.
* @param [in] component The containing component.
*/
void createInternalConnectionsForOpaqueBridge(QSharedPointer<const BusInterface> busInterface,
QString const& instanceName, QVector<QSharedPointer<ConnectivityInterface> > const& instanceInterfaces,
QSharedPointer<ConnectivityGraph> graph, QSharedPointer<const Component> component) const;

/*!
* Get the design configuration from the selected view.
*
Expand Down
2 changes: 1 addition & 1 deletion editors/common/ComponentDesignDiagram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,7 @@ bool ComponentDesignDiagram::componentItemIsAllowedInColumnAtPosition(QPointF co
{
ColumnTypes::ColumnItemType itemType = ColumnTypes::COMPONENT;

if (draggedComponent->isBridge())
if (draggedComponent->isTransparentBridge() || draggedComponent->isOpaqueBridge())
{
itemType = ColumnTypes::BRIDGE;
}
Expand Down
Loading

0 comments on commit df3c931

Please sign in to comment.