Jump to content

Using sc_trace inside SC_THREAD


Nithin

Recommended Posts

Hi,

I am trying to dump internal signals of an SC_MODULE's processes (SC_THREAD process) in a VCD. SC_MODULE has multiple processes and I need to dump signals from each of those processes in the same VCD. 

Currently, I am trying with one SC_THREAD process and I see this error when I add sc_trace inside the while loop:

Error: (E720) sc_trace_file already initialized: sc_trace() failed:
    No traces can be added to 'traces.vcd' once trace recording has started.
    To add tracing of 'A_val', create a new trace file.
In file: ../../../src/sysc/tracing/sc_trace_file_base.cpp:239

 

Here is my code:

SC_MODULE (SUM) {
  sc_in<sc_int<10>> A;
  sc_in<sc_int<10>> B;
  sc_out<sc_int<10>> S;
  sc_trace_file* Tf;

  void do_sum();
  SC_CTOR (SUM) {
      Tf = sc_create_vcd_trace_file("traces");
    SC_THREAD(do_sum);
        sensitive << A << B;
  }
  ~SUM() {
  sc_close_vcd_trace_file(Tf);
  }
};

void SUM::do_sum() {
    int A_val, B_val, S_val;
    while(true) {
    wait();
    A_val = A.read();
    B_val = B.read();
    S.write(A.read()+B.read());
    S_val = A_val + B_val;

    sc_trace(Tf, A_val, "A_val");
    sc_trace(Tf, B_val, "B_val");
    sc_trace(Tf, S_val, "S_val");

    }
  }

 

Can someone please help me with this?

Thanks in advance.

Regards,

Nithin

Link to comment
Share on other sites

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...