Fix hierarchical library block source ordering (#8578) (#8579)

This commit is contained in:
Michael Bedford Taylor
2026-10-02 13:23:56 -04:00
committed by GitHub
parent a278652439
commit b080950f76
10 changed files with 157 additions and 11 deletions
+2 -7
View File
@@ -127,11 +127,7 @@ class V3EmitMkJsonEmitter final {
sources.emplace_back(makeDir + "/" + dependencyp->hierWrapperFilename(true));
}
const std::string vFile = hblockp->vFileIfNecessary();
if (!vFile.empty()) sources.emplace_back(vFile);
for (const VFileLibName& i : v3Global.opt.vFiles()) {
const std::string fname = i.filename();
for (const string& fname : V3HierGraph::sourceFiles(hblockp->vFileIfNecessary())) {
sources.emplace_back(V3Os::filenameSlashPath(V3Os::filenameRealPath(fname)));
}
@@ -159,8 +155,7 @@ class V3EmitMkJsonEmitter final {
sources.emplace_back(makeDir + "/" + blockp->hierWrapperFilename(true));
}
for (const VFileLibName& i : v3Global.opt.vFiles()) {
const std::string fname = i.filename();
for (const string& fname : V3HierGraph::sourceFiles()) {
sources.emplace_back(V3Os::filenameSlashPath(V3Os::filenameRealPath(fname)));
}
+12 -4
View File
@@ -112,11 +112,10 @@ static string V3HierParametersFileName(const string& prefix) {
}
static void V3HierWriteCommonInputs(const V3HierBlock* hblockp, std::ostream* of, bool forMkJson) {
string topModuleFile;
if (hblockp) topModuleFile = hblockp->vFileIfNecessary();
const string topModuleFile = hblockp ? hblockp->vFileIfNecessary() : "";
if (!forMkJson) {
if (!topModuleFile.empty()) *of << topModuleFile << "\n";
for (const auto& i : v3Global.opt.vFiles()) *of << i.filename() << "\n";
for (const string& filename : V3HierGraph::sourceFiles(topModuleFile))
*of << filename << "\n";
}
for (const auto& i : v3Global.opt.libraryFiles()) {
if (V3Os::filenameRealPath(i.filename()) != topModuleFile)
@@ -393,6 +392,15 @@ public:
}
};
VStringList V3HierGraph::sourceFiles(const string& topModuleFile) {
VStringList sources;
sources.reserve(v3Global.opt.vFiles().size() + 1);
for (const VFileLibName& vfile : v3Global.opt.vFiles()) sources.emplace_back(vfile.filename());
// Library-discovered blocks may depend on packages in the explicit input files.
if (!topModuleFile.empty()) sources.emplace_back(topModuleFile);
return sources;
}
void V3HierGraph::writeCommandArgsFiles(bool forMkJson) const {
for (const V3GraphVertex& vtx : vertices()) {
+2
View File
@@ -44,6 +44,8 @@ public:
VL_UNCOPYABLE(V3HierGraph);
VL_UNMOVABLE(V3HierGraph);
// Explicit HDL inputs followed by the library-discovered top module file, if any.
static VStringList sourceFiles(const string& topModuleFile = "") VL_MT_DISABLED;
// Write command line arguments to .f files for child Verilation run
void writeCommandArgsFiles(bool forMkJson) const VL_MT_DISABLED;
void writeParametersFiles() const VL_MT_DISABLED;