mirror of
https://github.com/verilator/verilator.git
synced 2025-01-01 04:07:34 +00:00
Add --dpi-hdr-only, bug1491.
This commit is contained in:
parent
e1e4bde125
commit
ec620387af
2
Changes
2
Changes
@ -26,6 +26,8 @@ The contributors that suggested a given feature are shown in []. Thanks!
|
||||
|
||||
**** Fix internal error on gate optimization of assign, bug1475. [Oyvind Harboe]
|
||||
|
||||
**** Add --dpi-hdr-only, bug1491. [Todd Strader]
|
||||
|
||||
|
||||
* Verilator 4.016 2019-06-16
|
||||
|
||||
|
@ -298,6 +298,7 @@ detailed descriptions in L</"VERILATION ARGUMENTS"> for more information.
|
||||
--debugi-<srcfile> <level> Enable debugging a source file at a level
|
||||
--default-language <lang> Default language to parse
|
||||
+define+<var>=<value> Set preprocessor define
|
||||
--dpi-hdr-only Only produce the DPI header file
|
||||
--dump-defines Show preprocessor defines with -E
|
||||
--dump-tree Enable dumping .tree files
|
||||
--dump-treei <level> Enable dumping .tree files at a level
|
||||
@ -741,6 +742,11 @@ Defines the given preprocessor symbol, or multiple symbols if separated by
|
||||
plusses. Similar to -D; +define is fairly standard across Verilog tools
|
||||
while -D is an alias for GCC compatibility.
|
||||
|
||||
=item --dpi-hdr-only
|
||||
|
||||
Only generate the DPI header file. This option has no effect on the name
|
||||
or location of the file.
|
||||
|
||||
=item --dump-defines
|
||||
|
||||
With -E, suppress normal output, and instead print a list of all defines
|
||||
|
@ -33,7 +33,7 @@ class V3EmitC {
|
||||
public:
|
||||
static void emitc();
|
||||
static void emitcInlines();
|
||||
static void emitcSyms();
|
||||
static void emitcSyms(bool dpiHdrOnly = false);
|
||||
static void emitcTrace();
|
||||
};
|
||||
|
||||
|
@ -90,6 +90,7 @@ class EmitCSyms : EmitCBaseVisitor {
|
||||
V3LanguageWords m_words; // Reserved word detector
|
||||
int m_coverBins; // Coverage bin number
|
||||
int m_labelNum; // Next label number
|
||||
bool m_dpiHdrOnly; // Only emit the DPI header
|
||||
|
||||
// METHODS
|
||||
void emitSymHdr();
|
||||
@ -181,11 +182,13 @@ class EmitCSyms : EmitCBaseVisitor {
|
||||
stable_sort(m_dpis.begin(), m_dpis.end(), CmpDpi());
|
||||
|
||||
// Output
|
||||
emitSymHdr();
|
||||
emitSymImp();
|
||||
if (!m_dpiHdrOnly) {
|
||||
emitSymHdr();
|
||||
emitSymImp();
|
||||
}
|
||||
if (v3Global.dpi()) {
|
||||
emitDpiHdr();
|
||||
emitDpiImp();
|
||||
if (!m_dpiHdrOnly) emitDpiImp();
|
||||
}
|
||||
}
|
||||
virtual void visit(AstNodeModule* nodep) {
|
||||
@ -253,7 +256,9 @@ class EmitCSyms : EmitCBaseVisitor {
|
||||
//---------------------------------------
|
||||
// ACCESSORS
|
||||
public:
|
||||
explicit EmitCSyms(AstNetlist* nodep) {
|
||||
explicit EmitCSyms(AstNetlist* nodep, bool dpiHdrOnly):
|
||||
m_dpiHdrOnly(dpiHdrOnly)
|
||||
{
|
||||
m_funcp = NULL;
|
||||
m_modp = NULL;
|
||||
m_coverBins = 0;
|
||||
@ -661,7 +666,7 @@ void EmitCSyms::emitDpiImp() {
|
||||
//######################################################################
|
||||
// EmitC class functions
|
||||
|
||||
void V3EmitC::emitcSyms() {
|
||||
void V3EmitC::emitcSyms(bool dpiHdrOnly) {
|
||||
UINFO(2,__FUNCTION__<<": "<<endl);
|
||||
EmitCSyms syms (v3Global.rootp());
|
||||
EmitCSyms syms (v3Global.rootp(), dpiHdrOnly);
|
||||
}
|
||||
|
@ -677,6 +677,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
||||
else if (!strcmp(sw, "-debug-sigsegv")) { throwSigsegv(); } // Undocumented, see also --debug-abort
|
||||
else if (!strcmp(sw, "-debug-fatalsrc")) { v3fatalSrc("--debug-fatal-src"); } // Undocumented, see also --debug-abort
|
||||
else if ( onoff (sw, "-decoration", flag/*ref*/)) { m_decoration = flag; }
|
||||
else if ( onoff (sw, "-dpi-hdr-only", flag/*ref*/)) { m_dpiHdrOnly = flag; }
|
||||
else if ( onoff (sw, "-dump-defines", flag/*ref*/)) { m_dumpDefines = flag; }
|
||||
else if ( onoff (sw, "-dump-tree", flag/*ref*/)) { m_dumpTree = flag ? 3 : 0; } // Also see --dump-treei
|
||||
else if ( onoff (sw, "-exe", flag/*ref*/)) { m_exe = flag; }
|
||||
@ -1276,6 +1277,7 @@ V3Options::V3Options() {
|
||||
m_debugPartition = false;
|
||||
m_debugSelfTest = false;
|
||||
m_decoration = true;
|
||||
m_dpiHdrOnly = false;
|
||||
m_dumpDefines = false;
|
||||
m_exe = false;
|
||||
m_ignc = false;
|
||||
|
@ -120,6 +120,7 @@ class V3Options {
|
||||
bool m_debugPartition; // main switch: --debug-partition
|
||||
bool m_debugSelfTest; // main switch: --debug-self-test
|
||||
bool m_decoration; // main switch: --decoration
|
||||
bool m_dpiHdrOnly; // main switch: --dpi-hdr-only
|
||||
bool m_dumpDefines; // main switch: --dump-defines
|
||||
bool m_exe; // main switch: --exe
|
||||
bool m_ignc; // main switch: --ignc
|
||||
@ -287,6 +288,7 @@ class V3Options {
|
||||
bool debugPartition() const { return m_debugPartition; }
|
||||
bool debugSelfTest() const { return m_debugSelfTest; }
|
||||
bool decoration() const { return m_decoration; }
|
||||
bool dpiHdrOnly() const { return m_dpiHdrOnly; }
|
||||
bool dumpDefines() const { return m_dumpDefines; }
|
||||
bool exe() const { return m_exe; }
|
||||
bool threadsDpiPure() const { return m_threadsDpiPure; }
|
||||
|
@ -519,11 +519,14 @@ void process() {
|
||||
|
||||
// Output the text
|
||||
if (!v3Global.opt.lintOnly()
|
||||
&& !v3Global.opt.xmlOnly()) {
|
||||
&& !v3Global.opt.xmlOnly()
|
||||
&& !v3Global.opt.dpiHdrOnly()) {
|
||||
// emitcInlines is first, as it may set needHInlines which other emitters read
|
||||
V3EmitC::emitcInlines();
|
||||
V3EmitC::emitcSyms();
|
||||
V3EmitC::emitcTrace();
|
||||
} else if (v3Global.opt.dpiHdrOnly()) {
|
||||
V3EmitC::emitcSyms(true);
|
||||
}
|
||||
if (!v3Global.opt.xmlOnly()
|
||||
&& v3Global.opt.mtasks()) {
|
||||
@ -533,12 +536,14 @@ void process() {
|
||||
// costs of mtasks.
|
||||
V3Partition::finalize();
|
||||
}
|
||||
if (!v3Global.opt.xmlOnly()) { // Unfortunately we have some lint checks in emitc.
|
||||
if (!v3Global.opt.xmlOnly()
|
||||
&& !v3Global.opt.dpiHdrOnly()) { // Unfortunately we have some lint checks in emitc.
|
||||
V3EmitC::emitc();
|
||||
}
|
||||
if (v3Global.opt.xmlOnly()
|
||||
// Check XML when debugging to make sure no missing node types
|
||||
|| (v3Global.opt.debugCheck() && !v3Global.opt.lintOnly())) {
|
||||
|| (v3Global.opt.debugCheck() && !v3Global.opt.lintOnly()
|
||||
&& !v3Global.opt.dpiHdrOnly())) {
|
||||
V3EmitXml::emitxml();
|
||||
}
|
||||
|
||||
@ -549,7 +554,8 @@ void process() {
|
||||
}
|
||||
|
||||
if (!v3Global.opt.lintOnly()
|
||||
&& !v3Global.opt.xmlOnly()) {
|
||||
&& !v3Global.opt.xmlOnly()
|
||||
&& !v3Global.opt.dpiHdrOnly()) {
|
||||
// Makefile must be after all other emitters
|
||||
V3EmitMk::emitmk(v3Global.rootp());
|
||||
}
|
||||
@ -633,10 +639,11 @@ int main(int argc, char** argv, char** env) {
|
||||
V3Error::abortIfWarnings();
|
||||
|
||||
if (!v3Global.opt.lintOnly() && !v3Global.opt.cdc()
|
||||
&& v3Global.opt.makeDepend()) {
|
||||
&& !v3Global.opt.dpiHdrOnly() && v3Global.opt.makeDepend()) {
|
||||
V3File::writeDepend(v3Global.opt.makeDir()+"/"+v3Global.opt.prefix()+"__ver.d");
|
||||
}
|
||||
if (!v3Global.opt.lintOnly() && !v3Global.opt.cdc()
|
||||
&& !v3Global.opt.dpiHdrOnly()
|
||||
&& (v3Global.opt.skipIdentical() || v3Global.opt.makeDepend())) {
|
||||
V3File::writeTimes(v3Global.opt.makeDir()+"/"+v3Global.opt.prefix()
|
||||
+"__verFiles.dat", argString);
|
||||
|
@ -1201,6 +1201,11 @@ sub trace_filename {
|
||||
return "$self->{obj_dir}/simx.vcd";
|
||||
}
|
||||
|
||||
sub obj_dir {
|
||||
my $self = shift;
|
||||
return $self->{obj_dir};
|
||||
}
|
||||
|
||||
sub get_default_vltmt_threads {
|
||||
return $Vltmt_threads;
|
||||
}
|
||||
|
45
test_regress/t/t_dpi_import_hdr_only.pl
Executable file
45
test_regress/t/t_dpi_import_hdr_only.pl
Executable file
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/perl
|
||||
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2019 by Todd Strader. 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.
|
||||
|
||||
use File::Temp;
|
||||
use File::Compare;
|
||||
|
||||
scenarios(simulator => 1);
|
||||
|
||||
top_filename("t/t_dpi_import.v");
|
||||
|
||||
my $tmp_dir = File::Temp->newdir();
|
||||
|
||||
compile(
|
||||
verilator_flags2 => ["-Wall -Wno-DECLFILENAME -Mdir " . $tmp_dir . " --dpi-hdr-only"],
|
||||
verilator_make_gcc => 0,
|
||||
);
|
||||
|
||||
my @files = glob($tmp_dir . "/*");
|
||||
|
||||
die "Did not produce DPI header" if scalar(@files) == 0;
|
||||
die "Too many files created" if scalar(@files) > 1;
|
||||
my $tmp_header = $files[0];
|
||||
print("============".$tmp_header."\n");
|
||||
die "Unexpected file $tmp_header" unless $tmp_header =~ /__Dpi\.h$/;
|
||||
|
||||
compile(
|
||||
verilator_flags2 => ["-Wall -Wno-DECLFILENAME"],
|
||||
verilator_make_gcc => 0,
|
||||
);
|
||||
|
||||
@files = glob($Self->obj_dir . "/*__Dpi.h");
|
||||
my $header = @files[0];
|
||||
|
||||
if (compare($tmp_header, $header) != 0) {
|
||||
die "DPI header files are not the same";
|
||||
}
|
||||
|
||||
ok(1);
|
||||
1;
|
Loading…
Reference in New Issue
Block a user