Debug and Trace Facilities in System C Part
Debug and Trace Facilities in System. C Part of HW/SW Codesign of Embedded Systems Course (CE 40 -226) 08/02/42 Winter. Spring 2001 Codesign of Embedded Systems 1
Today programme n n Some System. C examples Simulation and Debugging in System. C Winter-Spring 2001 Codesign of Embedded Systems 2
DFF Example d DFF q display Input_gen clock_gen Winter-Spring 2001 Codesign of Embedded Systems 3
DFF Example (cont’d) void update(); Winter-Spring 2001 d DFF q clock_gen SC_CTOR(DFF){ SC_METHOD(update); sensitive_pos(clk); } }; Input_gen display SC_MODULE(DFF) { sc_in<bool> d, clk; sc_out<bool> q; void DFF: : update() { q = d; cout <<"Time: “<< sc_time_stamp()<<". DFF: output updated to “<< q << endl; } Codesign of Embedded Systems 4
DFF Example (cont’d) void gen() { input_to_dff = val; val = !val; cout<<"Time: ” <<sc_time_stamp() << ". input_gen: generating ” << input_to_dff<<" for next clock. n"<<val; } Winter-Spring 2001 Input_gen d DFF q display SC_MODULE(input_gen){ sc_in<bool> clk; sc_out<bool> input_to_dff; sc_logic val; clock_gen SC_CTOR(input_gen} ( SC_METHOD(gen; ( sensitive_pos(clk; ( val = 0; { Codesign of Embedded Systems 5
DFF Example (cont’d) void show() { cout<<"Time: "<< sc_time_stamp()<<". display: showing "<< output_of_dff<< endl; } SC_CTOR(display) { SC_METHOD(show); sensitive<<output_of_dff; } Input_gen d DFF q display SC_MODULE(display) { sc_in<bool> output_of_dff; clock_gen }; Winter-Spring 2001 Codesign of Embedded Systems 6
DFF Example (cont’d) Input_gen Winter-Spring 2001 DFF q clock_gen display disp("Disp; (" disp. output_of_dff(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); d display int sc_main(int , char*argv[]) { sc_clock_gen("CLK_GEN", 10, 0. 5); sc_signal<bool> d, q; sc_start(50; ( return 0; { Codesign of Embedded Systems 7
Simulation and Debugging Using System. C n Simulation Control n n Advanced Simulation Control Techniques Tracing Waveforms n n 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 Systems 8
Simulation and … (cont’d) n Simulation Control n n sc_start(double simulation_duration) sc_stop() sc_time_stamp() Debugging aid n n 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 Systems 9
Simulation and … (cont’d) n Simulation Control n Advanced Simulation control techniques n Instead of sc_start: sc_initialize(); // init System. C 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 Systems 10
Simulation and … (cont’d) n Tracing Waveforms n Supported waveformats n n VCD (Value Change Dump) ASCII WIF (Wave Intermediate Format) ISDB (Integrated Signal Data. Base) Notes n n 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 Systems 11
Simulation and … (cont’d) n Tracing wave forms n Creating the trace file: sc_trace_file *tf; tf = sc_create_vcd_trace_file(“trace_file”); n For other trace file formats n n n sc_create_wif_trace_file(<filename>); sc_create_isdb_trace_file(<filename>); To close the trace file n n n 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 Systems 12
Simulation and … (cont’d) n Tracing scalar variable and signals sc_trace(<trace-file pointer>, <traced variable>, <string>); n Example sc_signal<int> a; float b; sc_trace(trace_file, a, “My. A”); sc_trace(trace_file, b, “B”); Winter-Spring 2001 Codesign of Embedded Systems 13
Simulation and … (cont’d) n Tracing variable and signals of aggregate type n n Solution 1: trace each element separately Solution 2: define a special trace function for the type n Will be covered later Winter-Spring 2001 Codesign of Embedded Systems 14
Simulation and … (cont’d) n Tracing variable and signal arrays n Solution 1: trace each element separately n Solution 2: define a special trace function for the array n Will be covered later Winter-Spring 2001 Codesign of Embedded Systems 15
What we learned today n n More System. C Examples Simulation and Debugging using System. C Winter-Spring 2001 Codesign of Embedded Systems 16
- Slides: 16