Jump to content

Issues with tracing using get_typed_trace_value()

Recommended Posts

Hey everyone,

I'm experiencing an issue with version 2.3.4 of systemC and systemC-AMS libraries when trying to read currents passing through ELN elements using the get_typed_trace_value() method.

Here I identified two potential issues:

  1. The first time the method is called, the returned value is 0, regardless of the timestamp. For all the subsequent calls, the returned value is correct.
  2. In particular, for elements of type sca_eln::sc_vsource, the current is always zero for any timestamp.

An interesting observation is that this issue does not seem to appear when the values are written on a sca_util::sca_trace_file.

I worked on a minimal reproducible example to demonstrate the problem:

#include <systemc-ams>

int sc_main (int argc, char* argv[])
    sca_eln::sca_vsource src("src", 0, 10);
    sca_eln::sca_r r("r",1);
    sca_eln::sca_node node1;
    sca_eln::sca_node_ref gnd;

    src.set_timestep(1, sc_core::SC_MS);


    sca_util::sca_trace_file* tf = sca_util::sca_create_tabular_trace_file("trace_error.dat");
    sca_util::sca_trace(tf, src, "current_SRC");
    sca_util::sca_trace(tf, r, "current_R");

    std::cout << "%time current_SRC current_R" << std::endl;
    for(size_t i = 0; i < 10; ++i)
        sc_start(1, sc_core::SC_MS);

        std::cout << sc_core::sc_time_stamp().to_seconds() << " " <<
                     src.get_typed_trace_value() << " " <<
                     r.get_typed_trace_value() << std::endl;


    return 0;


The output of this program is a trace_error.dat with the correct values:

%time current_SRC current_R
0 -10 -10
0.001 -10 -10
0.002 -10 -10
0.003 -10 -10
0.004 -10 -10
0.005 -10 -10
0.006 -10 -10
0.007 -10 -10
0.008 -10 -10
0.009 -10 -10

and the output to the standard outptut:

%time current_SRC current_R
0.001 0 0
0.002 0 -10
0.003 0 -10
0.004 0 -10
0.005 0 -10
0.006 0 -10
0.007 0 -10
0.008 0 -10
0.009 0 -10
0.01 0 -10

Note how the values for timestamp 0.001 is zero for the current passing through the resistor and how the current through the voltage source is zero for any timestemp.

Please let me know if you can reproduce this or if I'm missing something. Also, please let me know if there's a better place to report this.

Link to comment
Share on other sites

Hello Diego,

get_typed_trace_value() is not a documented/standardized method, thus you should not use this method. 

This are only experimental methods to prepare the next standard update and this non-standardized methods will be definitely changed or removed from version to version in dependency of the discussions in the Acellera AMSWG.

Guaranteed is only the IEEE P1666.1 standardized functionality. 


Best regards 


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.

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