forked from github/verilator
Add --xml-output option.
This commit is contained in:
parent
8f6efdaf5c
commit
f781085755
2
Changes
2
Changes
@ -14,6 +14,8 @@ The contributors that suggested a given feature are shown in []. Thanks!
|
||||
|
||||
*** Add --trace-coverage.
|
||||
|
||||
*** Add --xml-output.
|
||||
|
||||
*** Support multithreading on Windows. [Patrick Stewart]
|
||||
|
||||
*** Suppress 'command failed' on normal errors.
|
||||
|
@ -405,6 +405,7 @@ detailed descriptions in L</"VERILATION ARGUMENTS"> for more information.
|
||||
--x-initial <mode> Assign initial Xs to this value
|
||||
--x-initial-edge Enable initial X->0 and X->1 edge triggers
|
||||
--xml-only Create XML parser output
|
||||
--xml-output XML output filename
|
||||
-y <dir> Directory to search for modules
|
||||
|
||||
This is a short summary of the arguments to run-time Verilated arguments.
|
||||
@ -1660,6 +1661,11 @@ The XML format is intended to be used to leverage Verilator's parser and
|
||||
elaboration to feed to other downstream tools. Be aware that the XML format
|
||||
is still evolving; there will be some changes in future versions.
|
||||
|
||||
=item --xml-output I<filename>
|
||||
|
||||
Filename for XML output file. Using this option automatically sets
|
||||
--xml-only.
|
||||
|
||||
=item -y I<dir>
|
||||
|
||||
Add the directory to the list of directories that should be searched for
|
||||
|
@ -338,7 +338,10 @@ public:
|
||||
void V3EmitXml::emitxml() {
|
||||
UINFO(2,__FUNCTION__<<": "<<endl);
|
||||
// All-in-one file
|
||||
V3OutXmlFile of (v3Global.opt.makeDir()+"/"+v3Global.opt.prefix()+".xml");
|
||||
string filename = (v3Global.opt.xmlOutput().empty()
|
||||
? v3Global.opt.makeDir()+"/"+v3Global.opt.prefix()+".xml"
|
||||
: v3Global.opt.xmlOutput());
|
||||
V3OutXmlFile of(filename);
|
||||
of.putsHeader();
|
||||
of.puts("<!-- DESCR" "IPTION: Verilator output: XML representation of netlist -->\n");
|
||||
of.puts("<verilator_xml>\n");
|
||||
|
@ -307,7 +307,13 @@ void V3File::writeTimes(const string& filename, const string& cmdlineIn) {
|
||||
bool V3File::checkTimes(const string& filename, const string& cmdlineIn) {
|
||||
return dependImp.checkTimes(filename, cmdlineIn);
|
||||
}
|
||||
|
||||
void V3File::createMakeDirFor(const string& filename) {
|
||||
if (filename != VL_DEV_NULL
|
||||
// If doesn't start with makeDir then some output file user requested
|
||||
&& filename.substr(0, v3Global.opt.makeDir().length()+1) == v3Global.opt.makeDir()+"/") {
|
||||
createMakeDir();
|
||||
}
|
||||
}
|
||||
void V3File::createMakeDir() {
|
||||
static bool created = false;
|
||||
if (!created) {
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
return new_ofstream_nodepend(filename, append);
|
||||
}
|
||||
static std::ofstream* new_ofstream_nodepend(const string& filename, bool append=false) {
|
||||
if (filename != VL_DEV_NULL) createMakeDir();
|
||||
createMakeDirFor(filename);
|
||||
if (append) {
|
||||
return new std::ofstream(filename.c_str(), std::ios::app);
|
||||
} else {
|
||||
@ -57,7 +57,7 @@ public:
|
||||
}
|
||||
}
|
||||
static FILE* new_fopen_w(const string& filename) {
|
||||
if (filename != VL_DEV_NULL) createMakeDir();
|
||||
createMakeDirFor(filename);
|
||||
addTgtDepend(filename);
|
||||
return fopen(filename.c_str(), "w");
|
||||
}
|
||||
@ -71,6 +71,7 @@ public:
|
||||
static bool checkTimes(const string& filename, const string& cmdlineIn);
|
||||
|
||||
// Directory utilities
|
||||
static void createMakeDirFor(const string& filename);
|
||||
static void createMakeDir();
|
||||
};
|
||||
|
||||
|
@ -567,14 +567,16 @@ void V3Options::notify() {
|
||||
!v3Global.opt.cdc()
|
||||
&& !v3Global.opt.dpiHdrOnly()
|
||||
&& !v3Global.opt.lintOnly()
|
||||
&& !v3Global.opt.preprocOnly());
|
||||
&& !v3Global.opt.preprocOnly()
|
||||
&& !v3Global.opt.xmlOnly());
|
||||
}
|
||||
if (v3Global.opt.makeDepend().isDefault()) {
|
||||
v3Global.opt.m_makeDepend.setTrueOrFalse(
|
||||
!v3Global.opt.cdc()
|
||||
&& !v3Global.opt.dpiHdrOnly()
|
||||
&& !v3Global.opt.lintOnly()
|
||||
&& !v3Global.opt.preprocOnly());
|
||||
&& !v3Global.opt.preprocOnly()
|
||||
&& !v3Global.opt.xmlOnly());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1189,6 +1191,10 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
||||
fl->v3fatal("Unknown setting for --x-initial: "<<argv[i]);
|
||||
}
|
||||
}
|
||||
else if (!strcmp(sw, "-xml-output") && (i+1)<argc) {
|
||||
shift; m_xmlOutput = argv[i];
|
||||
m_xmlOnly = true;
|
||||
}
|
||||
else if (!strcmp(sw, "-y") && (i+1)<argc) {
|
||||
shift; addIncDirUser(parseFileArg(optdir, string(argv[i])));
|
||||
}
|
||||
|
@ -232,6 +232,7 @@ class V3Options {
|
||||
string m_unusedRegexp; // main switch: --unused-regexp
|
||||
string m_xAssign; // main switch: --x-assign
|
||||
string m_xInitial; // main switch: --x-initial
|
||||
string m_xmlOutput; // main switch: --xml-output
|
||||
|
||||
// Language is now held in FileLine, on a per-node basis. However we still
|
||||
// have a concept of the default language at a global level.
|
||||
@ -413,6 +414,7 @@ class V3Options {
|
||||
string unusedRegexp() const { return m_unusedRegexp; }
|
||||
string xAssign() const { return m_xAssign; }
|
||||
string xInitial() const { return m_xInitial; }
|
||||
string xmlOutput() const { return m_xmlOutput; }
|
||||
|
||||
const V3StringSet& cppFiles() const { return m_cppFiles; }
|
||||
const V3StringList& cFlags() const { return m_cFlags; }
|
||||
|
@ -11,8 +11,8 @@ scenarios(vlt => 1);
|
||||
|
||||
lint();
|
||||
|
||||
foreach my $file (glob("$Self->{obj_dir}/*t_lint_only*")) {
|
||||
next if $file =~ /simx_compile.log/; # Made by driver.pl, not Verilator
|
||||
foreach my $file (glob("$Self->{obj_dir}/*")) {
|
||||
next if $file =~ /\.log/; # Made by driver.pl, not Verilator
|
||||
next if $file =~ /\.status/; # Made by driver.pl, not Verilator
|
||||
error("%Error: Created $file, but --lint-only shouldn't create files");
|
||||
}
|
||||
|
24
test_regress/t/t_xml_output.out
Normal file
24
test_regress/t/t_xml_output.out
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" ?>
|
||||
<!-- DESCRIPTION: Verilator output: XML representation of netlist -->
|
||||
<verilator_xml>
|
||||
<files>
|
||||
<file id="a" filename="<built-in>" language="1800-2017"/>
|
||||
<file id="b" filename="<command-line>" language="1800-2017"/>
|
||||
<file id="c" filename="input.vc" language="1800-2017"/>
|
||||
<file id="d" filename="t/t_xml_output.v" language="1800-2017"/>
|
||||
</files>
|
||||
<module_files>
|
||||
<file id="d" filename="t/t_xml_output.v" language="1800-2017"/>
|
||||
</module_files>
|
||||
<cells>
|
||||
<cell fl="d6" name="m" submodname="m" hier="m"/>
|
||||
</cells>
|
||||
<netlist>
|
||||
<module fl="d6" name="m" origName="m">
|
||||
<var fl="d7" name="clk" tag="foo_op" dtype_id="1" dir="input" vartype="logic" origName="clk"/>
|
||||
</module>
|
||||
<typetable fl="a0">
|
||||
<basicdtype fl="d7" id="1" name="logic"/>
|
||||
</typetable>
|
||||
</netlist>
|
||||
</verilator_xml>
|
31
test_regress/t/t_xml_output.pl
Executable file
31
test_regress/t/t_xml_output.pl
Executable file
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/perl
|
||||
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2012 by Wilson Snyder. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||
# Version 2.0.
|
||||
|
||||
scenarios(vlt => 1);
|
||||
|
||||
my $out_filename = "$Self->{obj_dir}/renamed-$Self->{name}.xml";
|
||||
|
||||
compile(
|
||||
verilator_flags2 => ["--xml-only --xml-output $out_filename"],
|
||||
verilator_make_gmake => 0,
|
||||
make_top_shell => 0,
|
||||
make_main => 0,
|
||||
);
|
||||
|
||||
files_identical("$out_filename", $Self->{golden_filename});
|
||||
|
||||
foreach my $file (glob("$Self->{obj_dir}/*")) {
|
||||
next if $file =~ /\.log/; # Made by driver.pl, not Verilator
|
||||
next if $file =~ /\.status/; # Made by driver.pl, not Verilator
|
||||
next if $file =~ /renamed-/; # Requested output
|
||||
error("%Error: Created $file, but --xml-only shouldn't create files");
|
||||
}
|
||||
|
||||
ok(1);
|
||||
1;
|
9
test_regress/t/t_xml_output.v
Normal file
9
test_regress/t/t_xml_output.v
Normal file
@ -0,0 +1,9 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2019 by Wilson Snyder.
|
||||
|
||||
module m
|
||||
(input clk); // verilator tag foo_op
|
||||
|
||||
endmodule
|
Loading…
Reference in New Issue
Block a user