1 / 16

Debug and Trace Facilities in SystemC

Debug and Trace Facilities in SystemC. Part of HW/SW Codesign of Embedded Systems Course (CE 40-226). Today programme. Some SystemC examples Simulation and Debugging in SystemC. display. DFF. d. q. Input_gen. clock_gen. DFF Example. DFF Example (cont’d). SC_MODULE(DFF) {

pascal
Download Presentation

Debug and Trace Facilities in SystemC

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Today programme • Some SystemC examples • Simulation and Debugging in SystemC Codesign of Embedded Systems

  3. display DFF d q Input_gen clock_gen DFF Example Codesign of Embedded Systems

  4. DFF Example (cont’d) SC_MODULE(DFF) { sc_in<bool> d, clk; sc_out<bool> q; void update(); SC_CTOR(DFF){ SC_METHOD(update); sensitive_pos(clk); } }; display DFF d q Input_gen clock_gen void DFF::update() { q = d; cout <<"Time: “<< sc_time_stamp()<<". DFF: output updated to “<< q << endl; } Codesign of Embedded Systems

  5. DFF Example (cont’d) SC_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;} display DFF d q Input_gen clock_gen SC_CTOR(input_gen) { SC_METHOD(gen); sensitive_pos(clk); val = 0; } }; Codesign of Embedded Systems

  6. DFF Example (cont’d) SC_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; } }; display DFF d q Input_gen clock_gen Codesign of Embedded Systems

  7. 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 DFF d q Input_gen clock_gen display disp("Disp"); disp.output_of_dff(q); sc_start(50); return 0; } Codesign of Embedded Systems

  8. 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 Codesign of Embedded Systems

  9. 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 Codesign of Embedded Systems

  10. 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 Codesign of Embedded Systems

  11. 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 Codesign of Embedded Systems

  12. 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>); Codesign of Embedded Systems

  13. Simulation and … (cont’d) • Tracing scalar variable and signals sc_trace(<trace-file pointer>, <traced variable>, <string>); • Example sc_signal<int> a; float b; sc_trace(trace_file, a, “MyA”); sc_trace(trace_file, b, “B”); Codesign of Embedded Systems

  14. 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 Codesign of Embedded Systems

  15. 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 Codesign of Embedded Systems

  16. What we learned today • More SystemC Examples • Simulation and Debugging using SystemC Codesign of Embedded Systems

More Related