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";
}
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
// "hardcoded" parameters:
const std::unique_ptr<std::ofstream> os{V3File::new_ofstream(fileName)};
if (os->fail()) v3fatal("Cannot write to file: " << fileName);
const std::unique_ptr<std::ofstream> os{V3File::new_ofstream(filename)};
if (os->fail()) v3fatal("Cannot write to file: " << filename);
dumpDot(*os.get(), label);
os->close();
}
void DfgGraph::dumpDotFilePrefixed(const string& label) const {
string fileName = name();
if (!label.empty()) fileName += "-" + label;
dumpDotFile(v3Global.debugFilename(fileName) + ".dot", label);
string filename = name();
if (!label.empty()) filename += "-" + label;
dumpDotFile(v3Global.debugFilename(filename) + ".dot", label);
}
// 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
// the graph which is included in the output.
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.
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
// 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;
// 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.
void dumpDotUpstreamCone(const string& fileName, const DfgVertex& vtx,
// 'filename'. 'name' is the name of the graph, which is included in the output.
void dumpDotUpstreamCone(const string& filename, const DfgVertex& vtx,
const string& name = "") const VL_MT_DISABLED;
// 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

View File

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

View File

@ -346,7 +346,7 @@ class EmitMkHierVerilation final {
= m_planp->hierBlocksSorted(); // leaf comes first
// List in order of leaf-last order so that linker can resolve dependency
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");
@ -365,12 +365,12 @@ class EmitMkHierVerilation final {
// 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(v3Global.opt.prefix()
+ ".mk: $(VM_HIER_INPUT_FILES) $(VM_HIER_VERILOG_LIBS) ");
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");
emitLaunchVerilator(of, argsFile);
}
@ -379,29 +379,29 @@ class EmitMkHierVerilation final {
of.puts("\n# Verilate hierarchical blocks\n");
for (const V3HierBlock* const blockp : m_planp->hierBlocksSorted()) {
const string prefix = blockp->hierPrefix();
const string argsFile = blockp->commandArgsFileName(false);
of.puts(blockp->hierGenerated(true));
const string argsFilename = blockp->commandArgsFilename(false);
of.puts(blockp->hierGeneratedFilenames(true));
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();
for (V3HierBlock::HierBlockSet::const_iterator child = children.begin();
child != children.end(); ++child) {
of.puts((*child)->hierWrapper(true) + " ");
of.puts((*child)->hierWrapperFilename(true) + " ");
}
of.puts("\n");
emitLaunchVerilator(of, argsFile);
emitLaunchVerilator(of, argsFilename);
// Rule to build lib*.a
of.puts(blockp->hierLib(true));
of.puts(blockp->hierLibFilename(true));
of.puts(": ");
of.puts(blockp->hierMk(true));
of.puts(blockp->hierMkFilename(true));
of.puts(" ");
for (V3HierBlock::HierBlockSet::const_iterator child = children.begin();
child != children.end(); ++child) {
of.puts((*child)->hierLib(true));
of.puts((*child)->hierLibFilename(true));
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("\n\n");
}

View File

@ -88,7 +88,7 @@
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
+ (forCMake ? "__hierCMakeArgs.f" : "__hierMkArgs.f");
}
@ -184,21 +184,27 @@ V3StringList V3HierBlock::hierBlockArgs() const {
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;
if (withDir) s = hierPrefix() + '/';
s += prefix + modp()->name() + suffix;
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 {
return hierWrapper(withDir) + ' ' + hierMk(withDir);
string V3HierBlock::hierGeneratedFilenames(bool withDir) const {
return hierWrapperFilename(withDir) + ' ' + hierMkFilename(withDir);
}
string V3HierBlock::vFileIfNecessary() const {
@ -211,12 +217,12 @@ string V3HierBlock::vFileIfNecessary() 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";
if (!forCMake) {
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";
}
@ -228,8 +234,8 @@ void V3HierBlock::writeCommandArgsFile(bool forCMake) const {
*of << v3Global.opt.allArgsStringForHierBlock(false, forCMake) << "\n";
}
string V3HierBlock::commandArgsFileName(bool forCMake) const {
return V3HierCommandArgsFileName(hierPrefix(), forCMake);
string V3HierBlock::commandArgsFilename(bool forCMake) const {
return V3HierCommandArgsFilename(hierPrefix(), forCMake);
}
//######################################################################
@ -394,11 +400,11 @@ void V3HierBlockPlan::writeCommandArgsFiles(bool forCMake) const {
}
// For the top module
const std::unique_ptr<std::ofstream> of{
V3File::new_ofstream(topCommandArgsFileName(forCMake))};
V3File::new_ofstream(topCommandArgsFilename(forCMake))};
if (!forCMake) {
// Load wrappers first not to be overwritten by the original HDL
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);
@ -425,6 +431,6 @@ void V3HierBlockPlan::writeCommandArgsFiles(bool forCMake) const {
*of << v3Global.opt.allArgsStringForHierBlock(true, forCMake) << "\n";
}
string V3HierBlockPlan::topCommandArgsFileName(bool forCMake) {
return V3HierCommandArgsFileName(v3Global.opt.prefix(), forCMake);
string V3HierBlockPlan::topCommandArgsFilename(bool forCMake) {
return V3HierCommandArgsFilename(v3Global.opt.prefix(), forCMake);
}

View File

@ -77,16 +77,17 @@ public:
V3StringList commandArgs(bool forCMake) const VL_MT_DISABLED;
V3StringList hierBlockArgs() 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 hierWrapper(bool withDir) const VL_MT_DISABLED;
string hierMk(bool withDir) const VL_MT_DISABLED;
string hierLib(bool withDir) const VL_MT_DISABLED;
string hierGenerated(bool withDir) const VL_MT_DISABLED;
string hierSomeFilename(bool withDir, const char* prefix,
const char* suffix) const VL_MT_DISABLED;
string hierWrapperFilename(bool withDir) const VL_MT_DISABLED;
string hierMkFilename(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().
string vFileIfNecessary() const VL_MT_DISABLED;
// Write command line arguments to .f file for this hierarchical block
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
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;
};