winter-spring 2001codesign of embedded systems1 debug and trace facilities in systemc part of hw/sw...
TRANSCRIPT
Winter-Spring 2001 Codesign of Embedded Syste
ms1
Debug and Trace Facilities in SystemC
Part ofHW/SW Codesign of
Embedded Systems Course (CE 40-226)
Winter-Spring 2001 Codesign of Embedded Syste
ms2
Today programme Some SystemC examples Simulation and Debugging in
SystemC
Winter-Spring 2001 Codesign of Embedded Syste
ms3
DFF Example
DFFInput_gen
disp
lay
clock_gen
d q
Winter-Spring 2001 Codesign of Embedded Syste
ms4
DFF Example (cont’d)
DFFInput_gen
disp
lay
clock_gen
d qSC_MODULE(DFF) {
sc_in<bool> d, clk;
sc_out<bool> q;
void update();
SC_CTOR(DFF){
SC_METHOD(update);
sensitive_pos(clk);
}
};
void DFF::update()
{
q = d;
cout <<"Time: “<< sc_time_stamp()<<". DFF: output updated to “<< q << endl;
}
Winter-Spring 2001 Codesign of Embedded Syste
ms5
DFF Example (cont’d)
DFFInput_gen
disp
lay
clock_gen
d qSC_MODULE(input_gen){
sc_in<bool> clk;
sc_out<bool> input_to_dff;
sc_logic val;
void gen()
{
input_to_dff = val;
val = !val;
cout<<"Time: ” <<sc_time_stamp() << ". input_gen: generating ” << input_to_dff<<" for next clock.\n"<<val;}
SC_CTOR(input_gen) {
SC_METHOD(gen);
sensitive_pos(clk);
val = 0;
}
};
Winter-Spring 2001 Codesign of Embedded Syste
ms6
DFF Example (cont’d)
DFFInput_gen
disp
lay
clock_gen
d qSC_MODULE(display) {
sc_in<bool> output_of_dff;
void show() {
cout<<"Time: "<< sc_time_stamp()<<". display: showing "<< output_of_dff<< endl;
}
SC_CTOR(display) {
SC_METHOD(show);
sensitive<<output_of_dff;
}
};
Winter-Spring 2001 Codesign of Embedded Syste
ms7
DFF Example (cont’d)int sc_main(int , char*argv[])
{
sc_clock clock_gen("CLK_GEN", 10, 0.5);
sc_signal<bool> d, q;
input_gen gen("Gen");
gen.clk(clock_gen.signal());
gen.input_to_dff(d);
DFF ff("Flip Flop");
ff.clk(clock_gen);
ff.d(d);
ff.q(q);
display disp("Disp");
disp.output_of_dff(q);
sc_start(50);
return 0;
}
DFFInput_gen
disp
lay
clock_gen
d q
Winter-Spring 2001 Codesign of Embedded Syste
ms8
Simulation and Debugging Using SystemC Simulation Control
Advanced Simulation Control Techniques Tracing Waveforms
Creating The Trace File Tracing Scalar Variable and Signals Tracing Variables and Signals of Aggregate
Types Tracing Variable and Signal Arrays
Winter-Spring 2001 Codesign of Embedded Syste
ms9
Simulation and … (cont’d) Simulation Control
sc_start(double simulation_duration) sc_stop() sc_time_stamp() Debugging aid
read/print signal, port, and variable values For ports and signals: The printed value is the
current value, not the value just written to it
Winter-Spring 2001 Codesign of Embedded Syste
ms10
Simulation and … (cont’d) Simulation Control
Advanced Simulation control techniques
Instead of sc_start:sc_initialize();// init SystemC scheduler
// set signals by writing values to them
sc_cycle(double); // simulates signal writes, then advances simulation time by its argument value
Winter-Spring 2001 Codesign of Embedded Syste
ms11
Simulation and … (cont’d) Tracing Waveforms
Supported waveform formats VCD (Value Change Dump) ASCII WIF (Wave Intermediate Format) ISDB (Integrated Signal DataBase)
Notes Variables local to a function cannot be traced scalar, array, and aggregate types can be traced Different types of trace files can be created during the
same simulation run A signal or variable can be traced any number of times
in different trace formats
Winter-Spring 2001 Codesign of Embedded Syste
ms12
Simulation and … (cont’d) Tracing wave forms
Creating the trace file:sc_trace_file *tf;tf = sc_create_vcd_trace_file(“trace_file”);
For other trace file formats sc_create_wif_trace_file(<filename>); sc_create_isdb_trace_file(<filename>);
To close the trace file sc_close_vcd_trace_file(<trace-file pointer>); sc_close_wif_trace_file(<trace-file pointer>); sc_close_isdb_trace_file(<trace-file pointer>);
Winter-Spring 2001 Codesign of Embedded Syste
ms13
Simulation and … (cont’d) Tracing scalar variable and signals
sc_trace(<trace-file pointer>, <traced variable>, <string>);
Examplesc_signal<int> a;
float b;
sc_trace(trace_file, a, “MyA”);
sc_trace(trace_file, b, “B”);
Winter-Spring 2001 Codesign of Embedded Syste
ms14
Simulation and … (cont’d) Tracing variable and signals of
aggregate type Solution 1: trace each element
separately Solution 2: define a special trace
function for the type Will be covered later
Winter-Spring 2001 Codesign of Embedded Syste
ms15
Simulation and … (cont’d) Tracing variable and signal arrays
Solution 1: trace each element separately
Solution 2: define a special trace function for the array
Will be covered later
Winter-Spring 2001 Codesign of Embedded Syste
ms16
What we learned today More SystemC Examples Simulation and Debugging using
SystemC