@@ -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
0 commit comments