Jump to content

Recommended Posts

Posted

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;
}

 

  • skander turki changed the title to (W170) Object cannot be traced Warning
Posted

The simple answer is that SystemC does not know how to trace std::string, and much less and array of std::string.

First, std::string is a dynamically variable array of characters, which will perplex waveform viewing because you need a fixed number of signals to display.

Changing to a fixed std::array<char,10> would help. You would still need to write an overload something like:

template<int depth>
void sc_trace( sc_trace_file* tf, const std::array<char,depth>& A, const std::string& name )
{
  // Code to trace individual char's
  for(int i=0; i<depth; ++i) {
    string elt_name = name + "["s + to_string(i) + "]s"; //< using modern C++14
    sc_trace( tf, A[i], elt_name );
  }
}

Even a simple array of int would need an overload.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...