omaima Posted March 28, 2021 Report Share Posted March 28, 2021 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; } Quote Link to comment Share on other sites More sharing options...
maehne Posted April 6, 2021 Report Share Posted April 6, 2021 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: Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.