Jump to content

skander turki

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by skander turki

  1. Hi everyone, I am new to SystemC and I am trying to use the tracing functionality but I get the mentioned error, can anyone give some hints? Thankx Here is the message: Info: (I703) tracing timescale unit set: 1 ns (my_trace.vcd) Warning: (W710) object cannot not be traced: Fifo_data In file: tracing/sc_trace.cpp:145 Here is the code: #include <systemc.h> #include <string> using namespace std; #define LENGTH 10 // Declaration de l'objet de tracage sc_trace_file *trace_file; struct write_if : virtual sc_interface { virtual void write(string) = 0; virtual void reset() = 0; }; struct read_if : virtual sc_interface { virtual void read(string &) = 0; virtual int num_available() = 0; }; struct fifo : sc_channel, write_if, read_if { fifo(sc_module_name name) : sc_channel(name), num_elements(0), first(0) { sc_trace(trace_file, data, "Fifo_data"); sc_trace(trace_file, num_elements, "Num_elements"); sc_trace(trace_file, first, "First"); } void write(string s) { if (num_elements == max) wait(read_event); data[(first + num_elements) % max] = s; ++num_elements; write_event.notify(); } void read(string &s) { if (num_elements == 0) wait(write_event); s = data[first]; --num_elements; first = (first + 1) % max; read_event.notify(); } void reset() { num_elements = first = 0; } int num_available() { return num_elements; } void end_of_simulation() { cout << "fifo::end_of_simulation()" << endl; sc_close_vcd_trace_file(trace_file); } protected: enum e { max = 10 }; string data[max]; int num_elements, first; sc_event write_event, read_event; }; struct producer : sc_module { sc_port<write_if> out; SC_HAS_PROCESS(producer); producer(sc_module_name name) : sc_module(name) { SC_THREAD(main); } void main() { while (i < LENGTH) out->write(words[i++]); } void end_of_simulation() { cout << "producer::end_of_simulation()" << endl; sc_close_vcd_trace_file(trace_file); } private: int i = 0; const string words[LENGTH] = { "Visit", "www.accellera.org", "and", "see", "what", "SystemC", "can", "do", "for you", "today!\n" }; }; struct consumer : sc_module { sc_port<read_if> in; SC_HAS_PROCESS(consumer); consumer(sc_module_name name) : sc_module(name) { SC_THREAD(main); } void main() { string s; cout << endl << endl; while (true) { in->read(s); cout << s << flush; if (in->num_available() == 1) cout << "<1>" << flush; if (in->num_available() == 9) cout << "<9>" << flush; } } void end_of_simulation() { cout << "consumer::end_of_simulation()" << endl; sc_close_vcd_trace_file(trace_file); } }; struct top : sc_module { fifo *fifo_inst; producer *prod_inst; consumer *cons_inst; top(sc_module_name name) : sc_module(name) { fifo_inst = new fifo("Fifo1"); prod_inst = new producer("Producer1"); prod_inst->out(*fifo_inst); cons_inst = new consumer("Consumer1"); cons_inst->in(*fifo_inst); } void end_of_simulation() { cout << "top::end_of_simulation()" << endl; sc_close_vcd_trace_file(trace_file); } }; int sc_main(int, char *[]) { trace_file = sc_create_vcd_trace_file("my_trace"); trace_file->set_time_unit(1, SC_NS); top top1("Top1"); sc_start(SC_ZERO_TIME); return 0; }
×
×
  • Create New...