Skip to content

Commit 6cd34e1

Browse files
committed
[CORRECTIVE] Make modelsim generator include only files from top-level component file sets and non-hierarchical instances
1 parent fc1b4db commit 6cd34e1

2 files changed

Lines changed: 29 additions & 9 deletions

File tree

Plugins/ModelSimGenerator/ModelSimWriterFactory/ModelSimWriterFactory.cpp

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,41 @@ QList<QSharedPointer<GenerationOutput> > ModelSimWriterFactory::prepareDesign(QL
5252

5353
QList<QSharedPointer<MetaInstance> > components;
5454

55-
for (QSharedPointer<MetaDesign> mDesign : designs)
56-
{
57-
components.append(mDesign->getTopInstance());
58-
components.append(mDesign->getInstances()->values());
59-
}
55+
// Instead of including every file in the hierarchy, include only files from the file sets of the top level design component,
56+
// and any leaf components. Any components in between in the hierarchy shouldn't ideally have any manually created
57+
// rtl files, only kactus2-generated structural rtl which should be generated from the topmost component.
6058

59+
QList<QSharedPointer<GenerationOutput> > retval;
60+
if (designs.isEmpty()) return retval;
61+
6162
QSharedPointer<ModelSimWriter> writer(new ModelSimWriter);
62-
6363
document->writer_ = writer;
6464
document->fileName_ = designs.first()->getTopInstance()->getModuleName() + ".do";
6565
document->vlnv_ = designs.first()->getTopInstance()->getComponent()->getVlnv().toString();
6666
document->metaDesign_ = designs.first();
6767

68+
for (auto const& design : designs)
69+
{
70+
// Always add files of topmost design component
71+
if (design == designs.first())
72+
{
73+
components.append(design->getTopInstance());
74+
}
75+
76+
// Add design instances if they contain no design themselves
77+
for (auto const& instance : *design->getInstances())
78+
{
79+
// Figure out through the active view if the component instance is hierarchical
80+
auto view = instance->getActiveView();
81+
82+
if (view != nullptr && instance->getComponent()->getHierRef(view->name()).isValid() == false)
83+
{
84+
components.append(instance);
85+
}
86+
}
87+
}
88+
89+
// Finally add the files of the selected components to be included
6890
for (QSharedPointer<MetaComponent> mComponent : components)
6991
{
7092
QString basePath = library_->getPath(mComponent->getComponent()->getVlnv());
@@ -81,9 +103,7 @@ QList<QSharedPointer<GenerationOutput> > ModelSimWriterFactory::prepareDesign(QL
81103
}
82104
}
83105

84-
QList<QSharedPointer<GenerationOutput> > retval;
85106
retval.append(document);
86-
87107
return retval;
88108
}
89109

Plugins/common/HDLParser/MetaDesign.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ void MetaDesign::parseAdHocAssignmentForPort(QSharedPointer<MetaPort> mPort,
705705
}
706706

707707
// Determine the part of the wire that shall be assigned to the port:
708-
// This is [abs(physical.left – physical.right):0]
708+
// This is [abs(physical.left physical.right):0]
709709
QPair<QString, QString> newBounds;
710710
newBounds.first = QString::number(assignment->physicalBounds_.first.toInt() -
711711
assignment->physicalBounds_.second.toInt());

0 commit comments

Comments
 (0)