Verilator and Systemperl: Wilson Snyder
Verilator and Systemperl: Wilson Snyder
SystemPerl
Wilson Snyder,
wsnyder@wsnyder.org
http://www.veripool.com
Agenda
• Introduction
• Design Goals
• Benefits
Verilator Environment, NASCUG June 2004. Copyright 2004 by Wilson Snyder; redistribution allowed as complete presentation. 2
Introduction
• In 2000, we were starting a all new project and could
choose all new tools
– Wanted Verilog, for easy synthesis and related tools
– Wanted C++, to share code with our embedded application
– Wanted object oriented language, for test benches
– Wanted behavioral modeling
Verilator Environment, NASCUG June 2004. Copyright 2004 by Wilson Snyder; redistribution allowed as complete presentation. 3
Benefits
• Faster Architectural Development
– SystemC allows rapid behavioral model development
– C++ allows tie-ins with embedded software
Verilator Environment, NASCUG June 2004. Copyright 2004 by Wilson Snyder; redistribution allowed as complete presentation. 4
CAD Flowchart
Embedded
Architecture RTL Verification
Software Verilog
Team Team Team
Team
Executable
Verilator Environment, NASCUG June 2004. Copyright 2004 by Wilson Snyder; redistribution allowed as complete presentation. 5
What Verilator Does
• Verilator converts Synthesizable Verilog into C++
– Always statements, wires, etc
– No time delays ( a <= #{n} b;)
– Only two state simulation (no tri-state busses)
– Unknowns are randomized (even better then having Xs)
Verilator Environment, NASCUG June 2004. Copyright 2004 by Wilson Snyder; redistribution allowed as complete presentation. 6
Example Translation
• Inputs and outputs map directly to bool, uint32_t or
sc_bv's:
#include "systemperl.h"
#include "verilated.h"
SC_MODULE(Convert) {
module Convert; sc_in_clk clk;
input clk sc_in<uint32_t> data;
input [31:0] data; sc_out<uint32_t> out;
output [31:0] out;
void eval();
always @ (posedge clk) }
out <= data;
endmodule SP_CTOR_IMP(Convert) {
SP_CELL(v,VConvert);
SC_METHOD(eval);
sensitive(clk);
}
…
Verilator Environment, NASCUG June 2004. Copyright 2004 by Wilson Snyder; redistribution allowed as complete presentation. 7
Talking C++ inside Verilog
• Verilator allows C++ code to be embedded directly in
Verilog
`systemc_include
#include "MDebug.h" Place at the top of the generated header file.
`systemc_header
public:
int debug(); Place inside the class definition of the
generated header file.
`systemc_ctor
__message = MDebug::debug(); Place in the constructor of the
generated C++ file.
`systemc_implementation
int debug() {
return __message; Place in the generated C++ file.
}
Verilator Environment, NASCUG June 2004. Copyright 2004 by Wilson Snyder; redistribution allowed as complete presentation. 9
SystemPerl
• Verilator outputs a dialect of SystemC, SystemPerl.
(Though Verilator also has option to output straight C++.)
Verilator Environment, NASCUG June 2004. Copyright 2004 by Wilson Snyder; redistribution allowed as complete presentation. 10
Faster SystemC Compiles
• Our model has 1,200 SystemC Modules
– Compile time would be >> 4 hours on 2GHz system
Verilator Environment, NASCUG June 2004. Copyright 2004 by Wilson Snyder; redistribution allowed as complete presentation. 11
Avoid Includes!
• SystemC documentation suggests the bad practice of
putting SC_CTOR implementation in the header file.
– If a low level module changes, you need to recompile EVERYTHING!
// FileName.h // FileName.cpp
class SubModule; #include "SubModule.h"
SC_MODULE(Foo) { SP_CTOR_IMP(Foo) {
… …
SubModule* subcell; }
…
SC_CTOR(Foo);
};
Verilator Environment, NASCUG June 2004. Copyright 2004 by Wilson Snyder; redistribution allowed as complete presentation. 12
Conclusions
• With the SystemPerl and Verilator methodology we
– Enable high level SystemC modeling
– Write standard Verilog RTL
– Can interchange Verilog <-> SystemC on major modules
– Run as fast as major simulators.
– Have a license-free environment.
Verilator Environment, NASCUG June 2004. Copyright 2004 by Wilson Snyder; redistribution allowed as complete presentation. 13
Download Verilator from
Veripool.com
• Downloading Verilator and SystemPerl:
– GNU Licensed
– C++ and Perl Based
– http://www.veripool.com
Verilator Environment, NASCUG June 2004. Copyright 2004 by Wilson Snyder; redistribution allowed as complete presentation. 14