Jump to content

Recommended Posts

I found vcf file empty I don't know what the main problem is. Is there an error in the code, or there is a problem of  installing systemc-ams

Code:

#ifndef SRC_INC_SIN_SRC_HPP_
#define SRC_INC_SIN_SRC_HPP_


#include <systemc-ams>

SCA_TDF_MODULE (sin_src) {
    sca_tdf::sca_out<double> out; // output port

    sin_src( sc_core::sc_module_name nm, double ampl_= 1.0, double freq_ = 1.0e3,
             sca_core::sca_time Tm_ = sca_core::sca_time(0.125, sc_core::SC_MS))
        : out("out"), ampl(ampl_), freq(freq_), Tm(Tm_) {}
    void set_attributes() {
        set_timestep(Tm);
    }
    void processing() {
        double t = get_time().to_seconds(); // actual time
        out.write( ampl * std::sin( 2.0 * M_PI * freq * t ) );
    }
private:
    double ampl; // amplitude
    double freq; // frequency
    sca_core::sca_time Tm; // module time step
};

#endif /* SRC_INC_SIN_SRC_HPP_ */
//////////////////////////////////////////////////////////////////////////////////////

#ifndef SRC_INC_COMPARATOR_HPP_
#define SRC_INC_COMPARATOR_HPP_


#include <systemc-ams>


SCA_TDF_MODULE( comparator ) {
    sca_tdf::sca_in<double> vplus;
    sca_tdf::sca_in<double> vminus;

    sca_tdf::sca_de::sca_out<bool> comp;


    void set_attributes() {};

    void initialize() {

    };

    void processing() {
        if(vplus.read() > vminus.read()) {
            comp.write(1);
        } else {
            comp.write(0);
        }

    }


    void ac_processing() {};


    SCA_CTOR( comparator) : vplus("vplus"), vminus("vminus"){}

};

#endif /* SRC_INC_COMPARATOR_HPP_ */
//////////////////////////////////////////////////////////////////////////////////////////

 

#ifndef SRC_INC_CONSTANT_VOLTAGE_TDF_HPP_
#define SRC_INC_CONSTANT_VOLTAGE_TDF_HPP_


#include <systemc-ams>

SCA_TDF_MODULE (constant_voltage_tdf) {
    sca_tdf::sca_out<double> out; // output port

    constant_voltage_tdf( sc_core::sc_module_name nm, double ampl_= 1.0)
        : out("out"), ampl(ampl_) {}
    void set_attributes() {

    }
    void processing() {
        out.write( ampl);
    }
private:
    double ampl; // amplitude

};

#endif /* SRC_INC_CONSTANT_VOLTAGE_TDF_HPP_ */
 

///////////////////////////////////////////////////////////////////////////////////////////////////////

#include <systemc-ams>
#include "inc/comparator.hpp"
#include "inc/sin_src.hpp"
#include "inc/constant_voltage_tdf.hpp"

int sc_main (int argc, char* argv[])

{
    uint32_t i;
    sca_tdf::sca_signal<double> vp;
    sca_tdf::sca_signal<double> vn;
    sc_core::sc_signal<bool> z;
    sc_core::sc_time time_step(10.0, sc_core::SC_NS);

    comparator comp0("comp0");
    comp0.vplus(vp);
    comp0.vminus(vn);
    comp0.comp(z);


    sin_src sin0("sin0",3.3,10000,time_step);
    sin0.out(vp);
    constant_voltage_tdf ref("ref",1.2);
    ref.out(vn);


    sca_util::sca_trace_file *vcdfile= sca_util::sca_create_vcd_trace_file("comparator-tdf.vcd");
    sca_util::sca_trace(vcdfile, vp, "v_p");
    sca_util::sca_trace(vcdfile, vn, "v_n");
   sca_util:: sca_trace(vcdfile, z, "z");

    sc_start(5, sc_core::SC_MS);

    sca_util::sca_close_vcd_trace_file(vcdfile);

    return 0;
}

Link to post
Share on other sites
  • 2 weeks later...

I cannot reproduce your problem. I copied your source code to files and build it. The comparator-pdf.vcd file generated by the executable contained the following three traces for v_p, v_n, and z, which match my expectations from inspecting your code:

image.thumb.png.b755e74f0bc3014904151fedd78728c8.png

Link to post
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...