Mixing SystemC and VHDL
Mixing SystemC and VHDL
Martin Radetzki
[email protected]
www.edacentrum.de
Definition of Terms
electronic design automation centrum
Co-Simulation
SystemC
VHDL
SystemC
.o .so .lib
.o .so .lib
work
SystemC
Kernel
VHDL
Simulator
VHDL
work
Mixed-Language
Single Kernel
Simulator
SystemC in VHDL
VHDL in SystemC
SystemC Module
VHDL
SystemC Module
Entity / Architecture
Configuration
Typical case
SystemC testbench
VHDL design under test
SystemC model
VHDL RTL not yet avail.
Higher level in VHDL
Mixed-Language Fundamentals
electronic design automation centrum
SystemC in VHDL
(in)out ports
Parameters
VHDL signals
SystemC Module
in ports
Generic map
comparator.h
comparator.cpp
SC_MODULE(Comparator)
{
// ports
sc_in<int>
in1, in2;
sc_out<bool> out1;
#include "comparator.h"
// process declaration
void action();
SC_CTOR(Comparator) {
SC_METHOD(action);
sensitive << in1
<< in2;
}
};
Competence for EDA
void Comparator::action()
{
out1 = false;
if (in1 > in2) {
out1 = true;
}
}
SC_MODULE_EXPORT(Comparator);
Instantiation in VHDL
electronic design automation centrum
vgencomp Comparator
component Comparator
VHDL stub / socket
port(
in1 : in std_logic_vector(31 downto 0);
in2 : in std_logic_vector(31 downto 0);
out1 : out std_logic
);
end component;
... - instantiation to be written by user
c1 : comparator port map(a, b, a_gt_b);
component
c2 : comparator port map(
instantiation
in1 => b,
in2 => c,
out1 => b_gt_c
);
c3 : comparator port map(c, a, out1 => c_gt_a);
Binding by Name
electronic design automation centrum
generic names as in
VHDL stub entity
10
VHDL in SystemC
(in)out ports
Generics
SystemC signals
VHDL Entity
in ports
SystemC Module
Constructor call
11
entity sorter is
port(
a : in std_logic_vector(31 downto
b : in std_logic_vector(31 downto
c : in std_logic_vector(31 downto
biggest : out std_logic_vector(31
end;
scgenmod sorter
simulator command
SystemC stub
12
#include "sorter.h"
SystemC stub
...
SC_MODULE( testbench )
{
// signals to wire up the device under test
sc_signal<sc_lv<32> > asig, bsig, csig, fsig;
...
instantiation
Sorter dut;
...
SC_CTOR( testbench ) : ...,
initialization with
dut( "dut", "sorter" )
additional parameter
{
...
dut.a(asig);
port / signal
dut.b(bsig);
dut.c(csig);
connection
dut.biggest(fsig);
...
13
Additional stub
constructor parameters
to pass generic values
Pass values on to
SystemC foreign
module class
14
SystemC port
VHDL port
sc_in<T>
sc_out<T>
sc_inout<T>
in
out / buffer
inout
sc_in_resolved
sc_out_resolved
sc_inout_resolved
sc_in_rv<N>
sc_out_rv<N>
sc_inout_rv<N>
sc_in_clk
sc_out_clk
sc_inout_clk
in std_logic
out std_logic
inout std_logic
in std_logic_vector(N-1 downto 0)
out std_logic_vector(N-1 downto 0)
inout std_logic_vector( ... )
in boolean / bit / std_[u]logic
out boolean / bit / std_[u]logic
inout boolean / bit / std_[u]logic
15
SystemC type T
VHDL type
bool / sc_bit
sc_logic
sc_bv<N>
sc_lv<N>
bit_vector(N-1 downto 0)
std_[u]logic_vector(N-1
downto 0)
sc_[u]int<N>
[unsigned] char
[unsigned] int
[unsigned] long
bit_vector(N-1 downto 0)
std_[u]logic_vector(N-1
downto 0)
16
std_logic
sc_logic
sc_bit
bool
0
L
0
0
0
0
false
false
1
H
1
1
1
1
true
true
false
U
W
X
-
X
X
X
X
0
0
0
0
false
false
false
false
17
Conclusion
electronic design automation centrum
works
uses mechanisms similar to mixed VHDL / Verilog simulation
is fairly simple as long as no generics / parameters involved
employs some mechanisms that are not standardized
18