From 8174c1ad02b732c85f266330f0794c741b9e7916 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Tue, 7 Jul 2009 17:51:00 -0400 Subject: [PATCH] Patching SystemC is no longer required to trace sc_bvs. --- Changes | 4 +++- Makefile.in | 3 +-- bin/verilator | 6 ----- include/verilatedsc.h | 51 +++++++++++++++++++++++++++++++++++++++++++ readme.texi | 3 +-- src/V3EmitC.cpp | 4 ++-- src/V3EmitCBase.h | 10 +++++++-- 7 files changed, 66 insertions(+), 15 deletions(-) create mode 100644 include/verilatedsc.h diff --git a/Changes b/Changes index 93a1e1700..5693a1764 100644 --- a/Changes +++ b/Changes @@ -3,7 +3,9 @@ Revision history for Verilator The contributors that suggested a given feature are shown in []. [by ...] indicates the contributor was also the author of the fix; Thanks! -* Verilator 3.711 2009/** +* Verilator 3.712 2009/** + +** Patching SystemC is no longer required to trace sc_bvs. *** Support zero-width constants in concatenations. [Jeff Winston] diff --git a/Makefile.in b/Makefile.in index 0622509e5..57c7c2bae 100644 --- a/Makefile.in +++ b/Makefile.in @@ -109,8 +109,7 @@ DISTFILES_INC = $(INFOS) .gitignore Artistic COPYING *.in *.ac \ MANIFEST.SKIP \ bin/* \ install-sh configure mkinstalldirs *.texi \ - include/verilated.[chv]* \ - include/verilatedos.[chv]* \ + include/verilated*.[chv]* \ include/*.in \ include/.*ignore \ .*attributes */.*attributes */*/.*attributes \ diff --git a/bin/verilator b/bin/verilator index c41c4e8da..16039b768 100755 --- a/bin/verilator +++ b/bin/verilator @@ -2337,12 +2337,6 @@ Call Verilated::assertOn(false) before you first call the model, then turn it back on after reset. It defaults to true. When false, all assertions controlled by --assert are disabled. -=item Why do I get "undefined reference to `get_datap()'"? - -You need to apply the SystemC patches that are provided with the SystemPerl -kit. These enable fast tracing of SystemC sc_bv<> signals. Recompiling -SystemC is not needed, it's just a header change. - =item Why do I get "undefined reference to `sc_time_stamp()'"? In C++ (non SystemC) code you need to define this function so that the diff --git a/include/verilatedsc.h b/include/verilatedsc.h new file mode 100644 index 000000000..3120f636a --- /dev/null +++ b/include/verilatedsc.h @@ -0,0 +1,51 @@ +// -*- C++ -*- +//************************************************************************* +// +// Copyright 2009-2009 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. +// +// Verilator is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +//************************************************************************* +/// +/// \file +/// \brief Verilator: Common include for all Verilated SystemC files +/// +/// This file is included automatically by Verilator at the top of +/// all SystemC files it generates. +/// +/// Code available from: http://www.veripool.org/verilator +/// +//************************************************************************* + + +#ifndef _VERILATEDSC_H_ +#define _VERILATEDSC_H_ 1 ///< Header Guard + +#include "verilatedos.h" +#include "systemc.h" + +//============================================================================= +// VL_SC_BV_DATAP +// We want to get a pointer to m_data in the sc_bv_base class, +// but it is protected. So make an exposing class, then use +// cast magic to get at it. Saves patching get_datap in SystemC. + +#define VL_SC_BV_DATAP(bv) (VlScBvExposer::sp_datap(bv)) +class VlScBvExposer : public sc_bv_base { +public: + static uint32_t* sp_datap(const sc_bv_base& base) { + return static_cast(&base)->sp_datatp(); } + uint32_t* sp_datatp() const { return (uint32_t*)(m_data); } + // Above reads this protected element in sc_bv_base: + // sc_digit* m_data; // data array +}; + +//========================================================================= + +#endif // guard diff --git a/readme.texi b/readme.texi index 56887b9b1..8ccf4fff0 100644 --- a/readme.texi +++ b/readme.texi @@ -121,8 +121,7 @@ If you will be using SystemC, download and install System-Perl, @url{http://search.cpan.org/search?module=SystemC::Netlist}. Note you'll need to set a @samp{SYSTEMPERL} environment variable to point to the downloaded kit. Optionally also set @samp{SYSTEMPERL_INCLUDE} -to point to the installed headers. Also, make sure to do a @code{make -sc_patch}. +to point to the installed headers. @item @code{cd} to the Verilator directory containing this README. diff --git a/src/V3EmitC.cpp b/src/V3EmitC.cpp index 209fd3693..5726f1001 100644 --- a/src/V3EmitC.cpp +++ b/src/V3EmitC.cpp @@ -1885,8 +1885,8 @@ class EmitCTrace : EmitCStmts { if (nodep->valuep()->castVarRef()) { AstVarRef* varrefp = nodep->valuep()->castVarRef(); AstVar* varp = varrefp->varp(); - if (emitTraceIsScBv(nodep)) puts("(uint32_t*)"); puts("("); + if (emitTraceIsScBv(nodep)) puts("VL_SC_BV_DATAP("); varrefp->iterate(*this); // Put var name out if (varp->arraysp()) { if (arrayindex==-2) puts("[i]"); @@ -1894,7 +1894,7 @@ class EmitCTrace : EmitCStmts { else puts("["+cvtToStr(arrayindex)+"]"); } if (varp->isSc()) puts(".read()"); - if (emitTraceIsScBv(nodep)) puts(".get_datap()"); + if (emitTraceIsScBv(nodep)) puts(")"); puts(")"); } else { puts("("); diff --git a/src/V3EmitCBase.h b/src/V3EmitCBase.h index 2cd45a8c9..68f1e395f 100644 --- a/src/V3EmitCBase.h +++ b/src/V3EmitCBase.h @@ -68,7 +68,10 @@ public: V3OutScFile(const string& filename) : V3OutCFile(filename) {} virtual ~V3OutScFile() {}; virtual void putsHeader() { puts("// Verilated -*- SystemC -*-\n"); } - virtual void putsIntTopInclude() { puts("#include \"systemc.h\"\n"); } + virtual void putsIntTopInclude() { + puts("#include \"systemc.h\"\n"); + puts("#include \"verilatedsc.h\"\n"); + } }; class V3OutSpFile : public V3OutCFile { @@ -76,7 +79,10 @@ public: V3OutSpFile(const string& filename) : V3OutCFile(filename) {} virtual ~V3OutSpFile() {}; virtual void putsHeader() { puts("// Verilated -*- SystemC -*-\n"); } - virtual void putsIntTopInclude() { puts("#include \"systemperl.h\"\n"); } + virtual void putsIntTopInclude() { + puts("#include \"systemperl.h\"\n"); + puts("#include \"verilatedsc.h\"\n"); + } }; class V3OutVFile : public V3OutFile {