omaima Posted March 12, 2021 Report Posted March 12, 2021 Hello I'm traying to creating frontend receiver , when I do Run , I get this Error Error: SystemC-AMS: Error at least one sample period must be assigned per cluster the following modules are included in the current cluster (max. 20 printed): rf_src_1 rffe_1.mxr_1 rffe_1.lpf_1 osc_src_1 In file: ../../../../../src/scams/impl/synchronization/sca_synchronization_alg.cpp:1330 this is my code : sin.h #include <cmath> #include <systemc-ams> class sinsourc : public sca_tdf::sca_module { public: sca_tdf::sca_out<double> out; // Output. // Construct sinusoidal source and name its ports. sinsourc(sc_core::sc_module_name nm, double off = 0.0, double amp = 1.0, double f = 50.0, double phi = 0.0) : out("out"), off_(off), amp_(amp), f_(f), phi_(phi) {} protected: // Generate sine wave and write it to the out port. void processing() { using std::sin; double val = 0.0; double t = out.get_time().to_seconds(); val = off_ + amp_ * sin(2.0 * M_PI * f_ * t + (M_PI / 180.0) * phi_); out.write(val); } private: double off_, amp_, f_, phi_; // Offset, amplitude, frequency / Hz, phase / DEG. }; mixer.h #ifndef SRC_INCLUDE_MIXER_H_ #define SRC_INCLUDE_MIXER_H_ #include<systemc-ams> SCA_TDF_MODULE(mixer) { sca_tdf::sca_in<double> bpf_in, lo_in; sca_tdf::sca_out<double> if_out; void set_attributes() { sc_core::sc_time(1.0, sc_core::SC_US); } void processing() { if_out.write( bpf_in.read() * lo_in.read() ); } mixer( sc_core::sc_module_name Rx) :bpf_in("bpf_in"),lo_in("lo_inn") ,if_out("if_out"){} }; LPF.h #include<systemc-ams> #include<systemc-ams> SCA_TDF_MODULE(LPF) { sca_tdf::sca_in<double> in; sca_tdf::sca_out<double> out; LPF( sc_core::sc_module_name Rx, double fc_, double h0_ ) : fc(fc_), h0(h0_) {} void initialize() { num(0) = 1.0; den(0) = 1.0; den(1) = 1.0 /( 2.0 * M_PI * fc ); } void processing() { out.write( ltf_nd( num, den, in.read(), h0 ) ); } private: sca_tdf::sca_ltf_nd ltf_nd; // Laplace transfer function sca_util::sca_vector<double> num, den; // numerator and denominator coefficients double fc; // 3dB cut-off frequency in Hz double h0; // DC gain }; front.h #include <systemc-ams> #include "../../src/include/LPF.h" #include "../../src/include/mixer.h" // RF front end module with structural description. class rf_front_end : public sc_core::sc_module { public: // Ports. sca_tdf::sca_in<double> rf_in, osc_in; sca_tdf::sca_out<double> dlpf_out; // Internal components. mixer mxr_1; LPF lpf_1; // Internal signals. sca_tdf::sca_signal<double> mxr_sig; // Construct RF front end using the passed parameters for the components. rf_front_end(sc_core::sc_module_name nm, double fc = 200.0e3, double H0 = 1.0) : mxr_1("mxr_1"), lpf_1("lpf_1", fc, H0) { // Specify connectivity using port-to-port and port-to-signal binding. mxr_1.bpf_in(rf_in); mxr_1.lo_in(osc_in); mxr_1.if_out(mxr_sig); // TODO: Connect the LPF to the mixer output. lpf_1.in(mxr_sig); lpf_1.out(lpf_out); // TODO: Connect the ADC to the LPF output. } }; front.cpp #include <iostream> #include <systemc-ams> #include "../src/include/front.h" #include "../src/include/sin.h" int sc_main(int argc, char* argv[]) { using namespace sc_core; using namespace sca_util; using sca_core::sca_time; //////////////////////////////////////////////////////////////////////// // Component and simulation parameters. //////////////////////////////////////////////////////////////////////// const double fosc = 2444.5; // Carrier signal frequency. const double fbb = 2441.5; // Base band signal frequency. const double fc = 2441.5; // Filter cut-off freqency. const double H0 = 5.0; // Filter gain. const sc_core::sc_time t_sim(5.0, SC_NS); // Time to simulate. sca_tdf::sca_signal<double> rf_sig("rf_sig"), osc_sig("osc_sig") ,lpf_sig("lpf_sig"); // RF signal at 10.004 MHz. sinsourc rf_src_1("rf_src_1", 0.0, 1.0 , fosc - fbb, 0.0); rf_src_1.out(rf_sig); // Carrier with 10 MHz. sinsourc osc_src_1("osc_src_1", 0.0, 1.0 , fosc, 0.0); osc_src_1.out(osc_sig); rf_front_end rffe_1("rffe_1",fc, H0); rffe_1.rf_in(rf_sig); rffe_1.osc_in(osc_sig); rffe_1.lpf_out(lpf_sig); // Tracing of RF signals to DAT file. sca_trace_file *tfp_rf = sca_create_tabular_trace_file("01_rf_front_end_rf_tb_rf"); sca_trace(tfp_rf, rf_sig, "rf_sig"); sca_trace(tfp_rf, osc_sig, "osc_sig"); sca_trace(tfp_rf, rffe_1.mxr_sig, "rffe_1.mxr_sig"); // Tracing of base band signals to DAT file. sca_trace_file *tfp_bb = sca_create_tabular_trace_file("01_rf_front_end_rf_tb_bb"); sca_trace(tfp_bb, lpf_sig, "lpf_sig"); // Tracing to VCD file. sca_util::sca_trace_file* tfp_vcd = sca_util::sca_create_vcd_trace_file("01_rf_front_end_rf_tb"); sca_trace(tfp_vcd, rf_sig, "rf_sig"); sca_trace(tfp_vcd, osc_sig, "osc_sig"); sca_trace(tfp_vcd, rffe_1.mxr_sig, "rffe_1.mxr_sig"); sca_trace(tfp_vcd, lpf_sig, "lpf_sig"); // Simulation try { sc_start(t_sim); } catch (const std::exception& e) { std::cerr << e.what() << std::endl; } // Close trace files and stop simulation. sca_close_tabular_trace_file(tfp_rf); sca_close_tabular_trace_file(tfp_bb); sca_close_tabular_trace_file(tfp_vcd); sc_stop(); return sc_core::sc_report_handler::get_count(sc_core::SC_ERROR); } Thanks in advance Quote
Martin Barnasconi Posted March 12, 2021 Report Posted March 12, 2021 You need to specify the timestep to at least one TDF module or TDF port, using method set_timestep. In a TDF module this method should be called in the callback set_attributes. See section 2.3.1 (Discrete-time modeling) and Example 2.11 in the SystemC-AMS User's Guide. omaima 1 Quote
omaima Posted March 12, 2021 Author Report Posted March 12, 2021 7 hours ago, Martin Barnasconi said: You need to specify the timestep to at least one TDF module or TDF port, using method set_timestep. In a TDF module this method should be called in the callback set_attributes. See section 2.3.1 (Discrete-time modeling) and Example 2.11 in the SystemC-AMS User's Guide. Thanks a lot , but when I went to cygwin to open the vcd file I got this message GTKWave Analyzer v3.3.100 (w)1999-2019 BSI No symbols in VCD file..is it malformed Exit Quote
Martin Barnasconi Posted March 12, 2021 Report Posted March 12, 2021 It is recommended not to use VCD trace files for TDF, LSF and ELN signals due to their continuous-time nature. Instead you should use the tabular tracefile format. You can open that it many tools since it is basically a ASCII based file with space-separated columns. Quote
maehne Posted March 17, 2021 Report Posted March 17, 2021 The cause for the empty VCD file is probably due that you call at the end the wrong closing function sca_close_tabular_trace_file(tfp_vcd) instead of the correct one sca_close_vcd_trace_file(tfp_vcd). As Martin Barnasconi wrote, VCD files are not well suited for tracing TDF, LSF, and ELN signals, because these signals tend to change at each time step. VCD is best suited for discrete event signals. omaima 1 Quote
omaima Posted March 23, 2021 Author Report Posted March 23, 2021 What should I use instead VCD file Quote
maehne Posted March 30, 2021 Report Posted March 30, 2021 For analogue signal traces, the tabular trace file format is better suited. Creating them is very similar to VCD trace files. You just need to use sca_util::sca_create_tabular_trace_file() and sca_util::sca_close_tabular_trace_file() to respectively open/close these trace files. The typical file extension is ".dat". These trace files can be easily imported in gnuplot, Octave, MATLAB, Excel, and other mathematical tools for plotting / post-processing. Check out IEEE Std. 1666.1-2016 clause 9.1 for details. Tracing is also discussed in Section 6.2 of the SystemC AMS User's Guide. Quote
omaima Posted April 4, 2021 Author Report Posted April 4, 2021 On 3/30/2021 at 9:33 AM, maehne said: For analogue signal traces, the tabular trace file format is better suited. Creating them is very similar to VCD trace files. You just need to use sca_util::sca_create_tabular_trace_file() and sca_util::sca_close_tabular_trace_file() to respectively open/close these trace files. The typical file extension is ".dat". These trace files can be easily imported in gnuplot, Octave, MATLAB, Excel, and other mathematical tools for plotting / post-processing. Check out IEEE Std. 1666.1-2016 clause 9.1 for details. Tracing is also discussed in Section 6.2 of the SystemC AMS User's Guide. Thanks a lot Quote
omaima Posted April 6, 2021 Author Report Posted April 6, 2021 2 hours ago, maehne said: You are welcome @omaima! mr.maehne I have problem when I'm trying to debug a systemc-ams programe I get this message: 2 hours ago, maehne said: You are welcome @omaima! Error in final launch sequence: Failed to execute MI command: -file-exec-and-symbols C:/Users/ALTQNIA/eclipse-workspace/Td_BBT/src/main.cpp Error message from debugger back end: "C:/Users/ALTQNIA/eclipse-workspace/Td_BBT/src/main.cpp": not in executable format: file format not recognized Failed to execute MI command: -file-exec-and-symbols C:/Users/ALTQNIA/eclipse-workspace/Td_BBT/src/main.cpp Error message from debugger back end: "C:/Users/ALTQNIA/eclipse-workspace/Td_BBT/src/main.cpp": not in executable format: file format not recognized "C:/Users/ALTQNIA/eclipse-workspace/Td_BBT/src/main.cpp": not in executable format: file format not recognized And gdb debug launching stuck at 96% or 94% and when I click run , I get on this message Error Starting process can you help me ,I'm stuck with that for month any tips. Thanks in advance Quote
maehne Posted April 6, 2021 Report Posted April 6, 2021 You are apparently not debugging the compiled executable, but the C++ source file `main.cpp`. Check the manual of Eclipse CDT on how to configure the IDE for debugging a built program. If I remember correctly (haven't used Eclipse) for some time, it should suffice to right-click on the executable in the project navigator pane and select from the context menu "Execute and debug program" or something similar. Quote
omaima Posted April 6, 2021 Author Report Posted April 6, 2021 41 minutes ago, maehne said: You are apparently not debugging the compiled executable, but the C++ source file `main.cpp`. Check the manual of Eclipse CDT on how to configure the IDE for debugging a built program. If I remember correctly (haven't used Eclipse) for some time, it should suffice to right-click on the executable in the project navigator pane and select from the context menu "Execute and debug program" or something similar. Quote
omaima Posted April 6, 2021 Author Report Posted April 6, 2021 43 minutes ago, maehne said: You are apparently not debugging the compiled executable, but the C++ source file `main.cpp`. Check the manual of Eclipse CDT on how to configure the IDE for debugging a built program. If I remember correctly (haven't used Eclipse) for some time, it should suffice to right-click on the executable in the project navigator pane and select from the context menu "Execute and debug program" or something similar. When I build a program with systemc this Error doesn't apppear , but when I build systemc-ams I get this Error, I think this Error from Gdb because I'm using Eclipse under cygwin64 Quote
maehne Posted April 6, 2021 Report Posted April 6, 2021 I suggest to first try launching your SystemC-AMS application under control of `gdb` from the command line to ensure seeing all error messages. My experience with IDEs is, that they sometimes do not show all relevant text of error messages making people look for the source of the problem in the wrong places. Quote
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.