simulationsystemc

SystemC-AMS: Initialization for tracing of: v_supercap failed set wave to 0


I receive the error in the title when I simulate my supercapacitor class with systemC. More precisely, the whole error message is as follows:

Warning: SystemC-AMS: Initialization for tracing of: v_supercap failed set wave to 0

In file: ../../../../../../src/scams/impl/util/tracing/sca_trace_object_data.cpp:174 In process: sca_implementation_0.cluster_process_0 @ 0 s

Warning: SystemC-AMS: Initialization for tracing of: e_supercap failed set wave to 0

In file: ../../../../../../src/scams/impl/util/tracing/sca_trace_object_data.cpp:174 In process: sca_implementation_0.cluster_process_0 @ 0 s

Warning: SystemC-AMS: Initialization for tracing of: soc_supercap failed set wave to 0

In file: ../../../../../../src/scams/impl/util/tracing/sca_trace_object_data.cpp:174 In process: sca_implementation_0.cluster_process_0 @ 0 s

My supercapacitor class consists of a parent class, supercap that instantiates and connects the two child classes, supercap_tdf and supercap_eln . The problem only occurs when I use the supercap class, when I use only the supercap_eln alone I do not get this error. For this reason, I think the problem is related to the other two classes but I couldn't figure out what causes it.

This is not the behaviour I expect as there is a current flowing to the input of the supercapacitor (proven when I use the supercap_eln alone). I would expect the supercap class to output relevant v_supercap, e_supercap, soc_supercap not only 0s at the beginning and then nothing.

I have included the files for the classes mentioned above for reference.

=========================================================================

supercap_eln.h

#ifndef SUPERCAP_ELN_H
#define SUPERCAP_ELN_H

#include <systemc-ams.h>

SC_MODULE(supercap_eln)
{
    public:
        // Interface and internal components declaration
        sca_tdf::sca_in<double> pI_in; // Requested supercapacitor current
        sca_tdf::sca_out<double> pV_out; // Provided supercapacitor voltage

        // transformers bw ELN and TDF
        sca_eln::sca_tdf::sca_isource iin;
        sca_eln::sca_tdf::sca_vsink vout;

        // ELN components
        sca_eln::sca_c C_sc; // Capacitance (for supercap)
        sca_eln::sca_r R_l; // Leakage resistance
        sca_eln::sca_r R_s; // Series resistance

        // Constructor
        supercap_eln( sc_core::sc_module_name nm, double c_par, double r_l_par, double r_s_par):
            pI_in("pI_in"),
            pV_out("pV_out"),
            iin("iin"),
            vout("vout"),
            C_sc("C_sc", c_par),
            R_l("R_l", r_l_par),
            R_s("R_s", r_s_par),
            node_top("node_top"),
            node_mid("node_mid"),
            gnd("gnd")
        {
            iin.inp(pI_in);
            iin.p(node_top);
            iin.n(gnd);

            vout.p(node_top);
            vout.n(gnd);
            vout.outp(pV_out);

            C_sc.p(node_top);
            C_sc.n(node_mid);

            R_l.p(node_top);
            R_l.n(node_mid);

            R_s.p(node_mid);
            R_s.n(gnd);

            cout << "Supercapacitor created, C:" << C_sc.value << ", R_l:" << R_l.value << ", R_s:" << R_s.value << endl;
        }

    private:
    
        // internal node and ref node
        sca_eln::sca_node node_top, node_mid;
        sca_eln::sca_node_ref gnd;
};

#endif

supercap_tdf.h:

#ifndef SUPERCAP_TDF_H
#define SUPERCAP_TDF_H

#include <systemc-ams.h>
#include "config.h"

SC_MODULE(supercap_tdf)
{
    public:
        // Ports
        sca_tdf::sca_in<double> pV_in; //incoming voltage

        sca_tdf::sca_out<double> pV_out; //forwarded voltage
        sca_tdf::sca_out<double> pE_out; //current energy
        sca_tdf::sca_out<double> pSoC_out; //state of charge

        supercap_tdf( sc_core::sc_module_name nm, double c_par): 
                                pV_in("pV_in"),
                                pV_out("pV_out"), 
                                pE_out("pE_out"),
                                pSoC_out("pSoC_out"),
                                C(c_par),
                                MAX_E(0.5 * C * VREF_BUS * VREF_BUS),
                                SoC_val(SOC_INIT),
                                E_val(SoC_val * MAX_E) 
        {
            cout << "Supercapacitor TDF created, C:"<< C << ", MAX_E:" << MAX_E << ", SoC:" << SoC_val << ", E:" << E_val << endl;

        }

        void set_attributes();
        void initialize();
        void processing();

    private:
        const double C;
        const double MAX_E;
        double SoC_val;
        double E_val;
};

#endif

supercap_tdf.cpp

#include "supercap_tdf.h"

void supercap_tdf::set_attributes()
{
    pE_out.set_timestep(SIM_STEP, sc_core::SC_SEC);
    pSoC_out.set_timestep(SIM_STEP, sc_core::SC_SEC);
    pV_out.set_timestep(SIM_STEP, sc_core::SC_SEC);

    pE_out.set_delay(1);
    pSoC_out.set_delay(1);
    pV_out.set_delay(1);
}

void supercap_tdf::initialize(){}

void supercap_tdf::processing()
{

    double tmp_v;

    tmp_v = pV_in.read();
    cout << "Voltage value: " << tmp_v << " @" << sc_time_stamp() << endl;

    if(tmp_v <= 0)
    {
        cout << "ERROR: 0 or less voltage value" << " @" << sc_time_stamp() << "Value V=" << tmp_v << endl;
        sc_stop();
    }
    if(tmp_v > VREF_BUS)
    {
        cout << "Voltage is greatar than VREF_BUS" << " @" << sc_time_stamp() << "Value V=" << tmp_v << endl;
        tmp_v = VREF_BUS;
    }

    pV_out.write(tmp_v);

    E_val = 0.5 * C * tmp_v * tmp_v;
    
    pE_out.write(E_val);

    SoC_val = E_val / MAX_E;
    
    if(SoC_val <= 0.01)
    {
        cout << "SC SOC is less than or equal to 1%:" << " @" << sc_time_stamp() << endl;
        sc_stop();
    }

    pSoC_out.write(SoC_val);

}

supercap.h:

#ifndef SUPERCAP_H
#define SUPERCAP_H

#include <systemc-ams.h>
#include "supercap_eln.h"
#include "supercap_tdf.h"
#include "config.h"

SC_MODULE(supercap)
{
    public:
        sca_tdf::sca_in<double> pI_in; // Battery current
        sca_tdf::sca_out<double> pV_out; // Voltage
        sca_tdf::sca_out<double> pE_out; // Energy
        sca_tdf::sca_out<double> pSoC_out; // State of Charge

        // connecting signals
        sca_tdf::sca_signal<double> sVoltage;

        supercap_eln eln_module;
        supercap_tdf tdf_module;

        supercap( sc_core::sc_module_name nm, double c_par = 3.0, double r_l_par = 500000.0, double r_s_par = 0.08): 
                                pI_in("pI_in"),
                                pV_out("pV_out"),
                                pE_out("pE_out"),
                                pSoC_out("pSoC_out"),
                                eln_module("eln_module", c_par, r_l_par, r_s_par),
                                tdf_module("tdf_module", c_par)
        {

            eln_module.pI_in(pI_in);
            eln_module.pV_out(sVoltage);

            tdf_module.pV_in(sVoltage);
            tdf_module.pV_out(pV_out);
            tdf_module.pE_out(pE_out);
            tdf_module.pSoC_out(pSoC_out);
        }

};

#endif

Solution

  • SC_MODULE(supercap_tdf) {}

    must be

    SCA_TDF_MODULE(supercap_tdf)

    for explanation see:

    https://www.accellera.org/images/downloads/standards/systemc/Accellera_SystemC_AMS_Users_Guide_January_2020.pdf