Presentation is loading. Please wait.

Presentation is loading. Please wait.

Winter-Spring 2001Codesign of Embedded Systems1 Debug and Trace Facilities in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE 40-226)

Similar presentations


Presentation on theme: "Winter-Spring 2001Codesign of Embedded Systems1 Debug and Trace Facilities in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE 40-226)"— Presentation transcript:

1 Winter-Spring 2001Codesign of Embedded Systems1 Debug and Trace Facilities in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE 40-226)

2 Winter-Spring 2001Codesign of Embedded Systems2 Today programme Some SystemC examples Simulation and Debugging in SystemC

3 Winter-Spring 2001Codesign of Embedded Systems3 DFF Example DFF Input_gen display clock_gen dq

4 Winter-Spring 2001Codesign of Embedded Systems4 DFF Example (cont’d) DFF Input_gen display clock_gen dq SC_MODULE(DFF) { sc_in d, clk; sc_out 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; }

5 Winter-Spring 2001Codesign of Embedded Systems5 DFF Example (cont’d) DFF Input_gen display clock_gen dq SC_MODULE(input_gen){ sc_in clk; sc_out 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; } };

6 Winter-Spring 2001Codesign of Embedded Systems6 DFF Example (cont’d) DFF Input_gen display clock_gen dq SC_MODULE(display) { sc_in 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; } };

7 Winter-Spring 2001Codesign of Embedded Systems7 DFF Example (cont’d) int sc_main(int, char*argv[]) { sc_clock clock_gen("CLK_GEN", 10, 0.5); sc_signal 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; } DFF Input_gen display clock_gen dq

8 Winter-Spring 2001Codesign of Embedded Systems8 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

9 Winter-Spring 2001Codesign of Embedded Systems9 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

10 Winter-Spring 2001Codesign of Embedded Systems10 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

11 Winter-Spring 2001Codesign of Embedded Systems11 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

12 Winter-Spring 2001Codesign of Embedded Systems12 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( ); sc_create_isdb_trace_file( ); To close the trace file sc_close_vcd_trace_file( ); sc_close_wif_trace_file( ); sc_close_isdb_trace_file( );

13 Winter-Spring 2001Codesign of Embedded Systems13 Simulation and … (cont’d) Tracing scalar variable and signals sc_trace(,, ); Example sc_signal a; float b; sc_trace(trace_file, a, “MyA”); sc_trace(trace_file, b, “B”);

14 Winter-Spring 2001Codesign of Embedded Systems14 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

15 Winter-Spring 2001Codesign of Embedded Systems15 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

16 Winter-Spring 2001Codesign of Embedded Systems16 What we learned today More SystemC Examples Simulation and Debugging using SystemC


Download ppt "Winter-Spring 2001Codesign of Embedded Systems1 Debug and Trace Facilities in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE 40-226)"

Similar presentations


Ads by Google