Internals: Rename some filename functions. No functional change.

This commit is contained in:
Wilson Snyder 2024-07-14 09:34:54 -04:00
parent e080f5c0cb
commit 8c3b754bac
6 changed files with 55 additions and 48 deletions

View File

@ -189,19 +189,19 @@ void DfgGraph::dumpDot(std::ostream& os, const string& label) const {
os << "}\n"; os << "}\n";
} }
void DfgGraph::dumpDotFile(const string& fileName, const string& label) const { void DfgGraph::dumpDotFile(const string& filename, const string& label) const {
// This generates a file used by graphviz, https://www.graphviz.org // This generates a file used by graphviz, https://www.graphviz.org
// "hardcoded" parameters: // "hardcoded" parameters:
const std::unique_ptr<std::ofstream> os{V3File::new_ofstream(fileName)}; const std::unique_ptr<std::ofstream> os{V3File::new_ofstream(filename)};
if (os->fail()) v3fatal("Cannot write to file: " << fileName); if (os->fail()) v3fatal("Cannot write to file: " << filename);
dumpDot(*os.get(), label); dumpDot(*os.get(), label);
os->close(); os->close();
} }
void DfgGraph::dumpDotFilePrefixed(const string& label) const { void DfgGraph::dumpDotFilePrefixed(const string& label) const {
string fileName = name(); string filename = name();
if (!label.empty()) fileName += "-" + label; if (!label.empty()) filename += "-" + label;
dumpDotFile(v3Global.debugFilename(fileName) + ".dot", label); dumpDotFile(v3Global.debugFilename(filename) + ".dot", label);
} }
// Dump upstream logic cone starting from given vertex // Dump upstream logic cone starting from given vertex

View File

@ -705,15 +705,15 @@ public:
// Dump graph in Graphviz format into the given stream 'os'. 'label' is added to the name of // Dump graph in Graphviz format into the given stream 'os'. 'label' is added to the name of
// the graph which is included in the output. // the graph which is included in the output.
void dumpDot(std::ostream& os, const string& label = "") const VL_MT_DISABLED; void dumpDot(std::ostream& os, const string& label = "") const VL_MT_DISABLED;
// Dump graph in Graphviz format into a new file with the given 'fileName'. 'label' is added to // Dump graph in Graphviz format into a new file with the given 'filename'. 'label' is added to
// the name of the graph which is included in the output. // the name of the graph which is included in the output.
void dumpDotFile(const string& fileName, const string& label = "") const VL_MT_DISABLED; void dumpDotFile(const string& filename, const string& label = "") const VL_MT_DISABLED;
// Dump graph in Graphviz format into a new automatically numbered debug file. 'label' is // Dump graph in Graphviz format into a new automatically numbered debug file. 'label' is
// added to the name of the graph, which is included in the file name and the output. // added to the name of the graph, which is included in the file name and the output.
void dumpDotFilePrefixed(const string& label = "") const VL_MT_DISABLED; void dumpDotFilePrefixed(const string& label = "") const VL_MT_DISABLED;
// Dump upstream (source) logic cone starting from given vertex into a file with the given // Dump upstream (source) logic cone starting from given vertex into a file with the given
// 'fileName'. 'name' is the name of the graph, which is included in the output. // 'filename'. 'name' is the name of the graph, which is included in the output.
void dumpDotUpstreamCone(const string& fileName, const DfgVertex& vtx, void dumpDotUpstreamCone(const string& filename, const DfgVertex& vtx,
const string& name = "") const VL_MT_DISABLED; const string& name = "") const VL_MT_DISABLED;
// Dump all individual logic cones driving external variables in Graphviz format into separate // Dump all individual logic cones driving external variables in Graphviz format into separate
// new automatically numbered debug files. 'label' is added to the name of the graph, which is // new automatically numbered debug files. 'label' is added to the name of the graph, which is

View File

@ -212,7 +212,7 @@ class CMakeEmitter final {
<< hblockp->modp()->name() << " DIRECTORY " << hblockp->modp()->name() << " DIRECTORY "
<< v3Global.opt.makeDir() + "/" + prefix << " SOURCES "; << v3Global.opt.makeDir() + "/" + prefix << " SOURCES ";
for (const auto& childr : children) { for (const auto& childr : children) {
*of << " " << v3Global.opt.makeDir() + "/" + childr->hierWrapper(true); *of << " " << v3Global.opt.makeDir() + "/" + childr->hierWrapperFilename(true);
} }
*of << " "; *of << " ";
const string vFile = hblockp->vFileIfNecessary(); const string vFile = hblockp->vFileIfNecessary();
@ -220,7 +220,7 @@ class CMakeEmitter final {
const V3StringList& vFiles = v3Global.opt.vFiles(); const V3StringList& vFiles = v3Global.opt.vFiles();
for (const string& i : vFiles) *of << V3Os::filenameRealPath(i) << " "; for (const string& i : vFiles) *of << V3Os::filenameRealPath(i) << " ";
*of << " VERILATOR_ARGS "; *of << " VERILATOR_ARGS ";
*of << "-f " << hblockp->commandArgsFileName(true) *of << "-f " << hblockp->commandArgsFilename(true)
<< " -CFLAGS -fPIC" // hierarchical block will be static, but may be linked << " -CFLAGS -fPIC" // hierarchical block will be static, but may be linked
// with .so // with .so
<< ")\n"; << ")\n";
@ -230,11 +230,11 @@ class CMakeEmitter final {
<< v3Global.rootp()->topModulep()->name() << " DIRECTORY " << v3Global.rootp()->topModulep()->name() << " DIRECTORY "
<< v3Global.opt.makeDir() << " SOURCES "; << v3Global.opt.makeDir() << " SOURCES ";
for (const auto& itr : *planp) { for (const auto& itr : *planp) {
*of << " " << v3Global.opt.makeDir() + "/" + itr.second->hierWrapper(true); *of << " " << v3Global.opt.makeDir() + "/" + itr.second->hierWrapperFilename(true);
} }
*of << " " << cmake_list(v3Global.opt.vFiles()); *of << " " << cmake_list(v3Global.opt.vFiles());
*of << " VERILATOR_ARGS "; *of << " VERILATOR_ARGS ";
*of << "-f " << planp->topCommandArgsFileName(true); *of << "-f " << planp->topCommandArgsFilename(true);
*of << ")\n"; *of << ")\n";
} }
} }

View File

@ -346,7 +346,7 @@ class EmitMkHierVerilation final {
= m_planp->hierBlocksSorted(); // leaf comes first = m_planp->hierBlocksSorted(); // leaf comes first
// List in order of leaf-last order so that linker can resolve dependency // List in order of leaf-last order so that linker can resolve dependency
for (const auto& block : vlstd::reverse_view(blocks)) { for (const auto& block : vlstd::reverse_view(blocks)) {
of.puts("\t" + block->hierLib(true) + " \\\n"); of.puts("\t" + block->hierLibFilename(true) + " \\\n");
} }
of.puts("\n"); of.puts("\n");
@ -365,12 +365,12 @@ class EmitMkHierVerilation final {
// Top level module // Top level module
{ {
const string argsFile = v3Global.hierPlanp()->topCommandArgsFileName(false); const string argsFile = v3Global.hierPlanp()->topCommandArgsFilename(false);
of.puts("\n# Verilate the top module\n"); of.puts("\n# Verilate the top module\n");
of.puts(v3Global.opt.prefix() of.puts(v3Global.opt.prefix()
+ ".mk: $(VM_HIER_INPUT_FILES) $(VM_HIER_VERILOG_LIBS) "); + ".mk: $(VM_HIER_INPUT_FILES) $(VM_HIER_VERILOG_LIBS) ");
of.puts(V3Os::filenameNonDir(argsFile) + " "); of.puts(V3Os::filenameNonDir(argsFile) + " ");
for (const auto& itr : *m_planp) of.puts(itr.second->hierWrapper(true) + " "); for (const auto& itr : *m_planp) of.puts(itr.second->hierWrapperFilename(true) + " ");
of.puts("\n"); of.puts("\n");
emitLaunchVerilator(of, argsFile); emitLaunchVerilator(of, argsFile);
} }
@ -379,29 +379,29 @@ class EmitMkHierVerilation final {
of.puts("\n# Verilate hierarchical blocks\n"); of.puts("\n# Verilate hierarchical blocks\n");
for (const V3HierBlock* const blockp : m_planp->hierBlocksSorted()) { for (const V3HierBlock* const blockp : m_planp->hierBlocksSorted()) {
const string prefix = blockp->hierPrefix(); const string prefix = blockp->hierPrefix();
const string argsFile = blockp->commandArgsFileName(false); const string argsFilename = blockp->commandArgsFilename(false);
of.puts(blockp->hierGenerated(true)); of.puts(blockp->hierGeneratedFilenames(true));
of.puts(": $(VM_HIER_INPUT_FILES) $(VM_HIER_VERILOG_LIBS) "); of.puts(": $(VM_HIER_INPUT_FILES) $(VM_HIER_VERILOG_LIBS) ");
of.puts(V3Os::filenameNonDir(argsFile) + " "); of.puts(V3Os::filenameNonDir(argsFilename) + " ");
const V3HierBlock::HierBlockSet& children = blockp->children(); const V3HierBlock::HierBlockSet& children = blockp->children();
for (V3HierBlock::HierBlockSet::const_iterator child = children.begin(); for (V3HierBlock::HierBlockSet::const_iterator child = children.begin();
child != children.end(); ++child) { child != children.end(); ++child) {
of.puts((*child)->hierWrapper(true) + " "); of.puts((*child)->hierWrapperFilename(true) + " ");
} }
of.puts("\n"); of.puts("\n");
emitLaunchVerilator(of, argsFile); emitLaunchVerilator(of, argsFilename);
// Rule to build lib*.a // Rule to build lib*.a
of.puts(blockp->hierLib(true)); of.puts(blockp->hierLibFilename(true));
of.puts(": "); of.puts(": ");
of.puts(blockp->hierMk(true)); of.puts(blockp->hierMkFilename(true));
of.puts(" "); of.puts(" ");
for (V3HierBlock::HierBlockSet::const_iterator child = children.begin(); for (V3HierBlock::HierBlockSet::const_iterator child = children.begin();
child != children.end(); ++child) { child != children.end(); ++child) {
of.puts((*child)->hierLib(true)); of.puts((*child)->hierLibFilename(true));
of.puts(" "); of.puts(" ");
} }
of.puts("\n\t$(MAKE) -f " + blockp->hierMk(false) + " -C " + prefix); of.puts("\n\t$(MAKE) -f " + blockp->hierMkFilename(false) + " -C " + prefix);
of.puts(" VM_PREFIX=" + prefix); of.puts(" VM_PREFIX=" + prefix);
of.puts("\n\n"); of.puts("\n\n");
} }

View File

@ -88,7 +88,7 @@
VL_DEFINE_DEBUG_FUNCTIONS; VL_DEFINE_DEBUG_FUNCTIONS;
static string V3HierCommandArgsFileName(const string& prefix, bool forCMake) { static string V3HierCommandArgsFilename(const string& prefix, bool forCMake) {
return v3Global.opt.makeDir() + "/" + prefix return v3Global.opt.makeDir() + "/" + prefix
+ (forCMake ? "__hierCMakeArgs.f" : "__hierMkArgs.f"); + (forCMake ? "__hierCMakeArgs.f" : "__hierMkArgs.f");
} }
@ -184,21 +184,27 @@ V3StringList V3HierBlock::hierBlockArgs() const {
string V3HierBlock::hierPrefix() const { return "V" + modp()->name(); } string V3HierBlock::hierPrefix() const { return "V" + modp()->name(); }
string V3HierBlock::hierSomeFile(bool withDir, const char* prefix, const char* suffix) const { string V3HierBlock::hierSomeFilename(bool withDir, const char* prefix, const char* suffix) const {
string s; string s;
if (withDir) s = hierPrefix() + '/'; if (withDir) s = hierPrefix() + '/';
s += prefix + modp()->name() + suffix; s += prefix + modp()->name() + suffix;
return s; return s;
} }
string V3HierBlock::hierWrapper(bool withDir) const { return hierSomeFile(withDir, "", ".sv"); } string V3HierBlock::hierWrapperFilename(bool withDir) const {
return hierSomeFilename(withDir, "", ".sv");
}
string V3HierBlock::hierMk(bool withDir) const { return hierSomeFile(withDir, "V", ".mk"); } string V3HierBlock::hierMkFilename(bool withDir) const {
return hierSomeFilename(withDir, "V", ".mk");
}
string V3HierBlock::hierLib(bool withDir) const { return hierSomeFile(withDir, "lib", ".a"); } string V3HierBlock::hierLibFilename(bool withDir) const {
return hierSomeFilename(withDir, "lib", ".a");
}
string V3HierBlock::hierGenerated(bool withDir) const { string V3HierBlock::hierGeneratedFilenames(bool withDir) const {
return hierWrapper(withDir) + ' ' + hierMk(withDir); return hierWrapperFilename(withDir) + ' ' + hierMkFilename(withDir);
} }
string V3HierBlock::vFileIfNecessary() const { string V3HierBlock::vFileIfNecessary() const {
@ -211,12 +217,12 @@ string V3HierBlock::vFileIfNecessary() const {
} }
void V3HierBlock::writeCommandArgsFile(bool forCMake) const { void V3HierBlock::writeCommandArgsFile(bool forCMake) const {
const std::unique_ptr<std::ofstream> of{V3File::new_ofstream(commandArgsFileName(forCMake))}; const std::unique_ptr<std::ofstream> of{V3File::new_ofstream(commandArgsFilename(forCMake))};
*of << "--cc\n"; *of << "--cc\n";
if (!forCMake) { if (!forCMake) {
for (const auto& hierblockp : m_children) { for (const auto& hierblockp : m_children) {
*of << v3Global.opt.makeDir() << "/" << hierblockp->hierWrapper(true) << "\n"; *of << v3Global.opt.makeDir() << "/" << hierblockp->hierWrapperFilename(true) << "\n";
} }
*of << "-Mdir " << v3Global.opt.makeDir() << "/" << hierPrefix() << " \n"; *of << "-Mdir " << v3Global.opt.makeDir() << "/" << hierPrefix() << " \n";
} }
@ -228,8 +234,8 @@ void V3HierBlock::writeCommandArgsFile(bool forCMake) const {
*of << v3Global.opt.allArgsStringForHierBlock(false, forCMake) << "\n"; *of << v3Global.opt.allArgsStringForHierBlock(false, forCMake) << "\n";
} }
string V3HierBlock::commandArgsFileName(bool forCMake) const { string V3HierBlock::commandArgsFilename(bool forCMake) const {
return V3HierCommandArgsFileName(hierPrefix(), forCMake); return V3HierCommandArgsFilename(hierPrefix(), forCMake);
} }
//###################################################################### //######################################################################
@ -394,11 +400,11 @@ void V3HierBlockPlan::writeCommandArgsFiles(bool forCMake) const {
} }
// For the top module // For the top module
const std::unique_ptr<std::ofstream> of{ const std::unique_ptr<std::ofstream> of{
V3File::new_ofstream(topCommandArgsFileName(forCMake))}; V3File::new_ofstream(topCommandArgsFilename(forCMake))};
if (!forCMake) { if (!forCMake) {
// Load wrappers first not to be overwritten by the original HDL // Load wrappers first not to be overwritten by the original HDL
for (const_iterator it = begin(); it != end(); ++it) { for (const_iterator it = begin(); it != end(); ++it) {
*of << it->second->hierWrapper(true) << "\n"; *of << it->second->hierWrapperFilename(true) << "\n";
} }
} }
V3HierWriteCommonInputs(nullptr, of.get(), forCMake); V3HierWriteCommonInputs(nullptr, of.get(), forCMake);
@ -425,6 +431,6 @@ void V3HierBlockPlan::writeCommandArgsFiles(bool forCMake) const {
*of << v3Global.opt.allArgsStringForHierBlock(true, forCMake) << "\n"; *of << v3Global.opt.allArgsStringForHierBlock(true, forCMake) << "\n";
} }
string V3HierBlockPlan::topCommandArgsFileName(bool forCMake) { string V3HierBlockPlan::topCommandArgsFilename(bool forCMake) {
return V3HierCommandArgsFileName(v3Global.opt.prefix(), forCMake); return V3HierCommandArgsFilename(v3Global.opt.prefix(), forCMake);
} }

View File

@ -77,16 +77,17 @@ public:
V3StringList commandArgs(bool forCMake) const VL_MT_DISABLED; V3StringList commandArgs(bool forCMake) const VL_MT_DISABLED;
V3StringList hierBlockArgs() const VL_MT_DISABLED; V3StringList hierBlockArgs() const VL_MT_DISABLED;
string hierPrefix() const VL_MT_DISABLED; string hierPrefix() const VL_MT_DISABLED;
string hierSomeFile(bool withDir, const char* prefix, const char* suffix) const VL_MT_DISABLED; string hierSomeFilename(bool withDir, const char* prefix,
string hierWrapper(bool withDir) const VL_MT_DISABLED; const char* suffix) const VL_MT_DISABLED;
string hierMk(bool withDir) const VL_MT_DISABLED; string hierWrapperFilename(bool withDir) const VL_MT_DISABLED;
string hierLib(bool withDir) const VL_MT_DISABLED; string hierMkFilename(bool withDir) const VL_MT_DISABLED;
string hierGenerated(bool withDir) const VL_MT_DISABLED; string hierLibFilename(bool withDir) const VL_MT_DISABLED;
string hierGeneratedFilenames(bool withDir) const VL_MT_DISABLED;
// Returns the original HDL file if it is not included in v3Global.opt.vFiles(). // Returns the original HDL file if it is not included in v3Global.opt.vFiles().
string vFileIfNecessary() const VL_MT_DISABLED; string vFileIfNecessary() const VL_MT_DISABLED;
// Write command line arguments to .f file for this hierarchical block // Write command line arguments to .f file for this hierarchical block
void writeCommandArgsFile(bool forCMake) const VL_MT_DISABLED; void writeCommandArgsFile(bool forCMake) const VL_MT_DISABLED;
string commandArgsFileName(bool forCMake) const VL_MT_DISABLED; string commandArgsFilename(bool forCMake) const VL_MT_DISABLED;
}; };
//###################################################################### //######################################################################
@ -117,7 +118,7 @@ public:
// Write command line arguments to .f files for child Verilation run // Write command line arguments to .f files for child Verilation run
void writeCommandArgsFiles(bool forCMake) const VL_MT_DISABLED; void writeCommandArgsFiles(bool forCMake) const VL_MT_DISABLED;
static string topCommandArgsFileName(bool forCMake) VL_MT_DISABLED; static string topCommandArgsFilename(bool forCMake) VL_MT_DISABLED;
static void createPlan(AstNetlist* nodep) VL_MT_DISABLED; static void createPlan(AstNetlist* nodep) VL_MT_DISABLED;
}; };