Jump to content

anna

Members
  • Posts

    9
  • Joined

  • Last visited

Everything posted by anna

  1. hello everyone, In my module code, when I detect the simulation is complete, I call > sc_stop(). Is there a better way to stop simulation witout getting the > following error:>> SystemC: simulation stopped by user.>> Error: (E546) sc_start called after sc_stop has been called> In file: ../../../../src/sysc/kernel/sc_simcontext.cpp:1315>> Thank you,
  2. hello everyone, i have the same error , i dont know how i resolve it , i want do summation of 4 pixels in each line and display the sum , Error: (E109) complete binding failed: port not bound: port 'i_adder_10.port_2' (sc_in) adder.h #include <iostream> #include <fstream> #include <stdlib.h> #include "systemc-ams.h" #include "systemc.h" SC_MODULE(adder) { sc_in<double> in[4]; sc_out<double> out; void somme (){ double sum=0; while(true) { for (int j=0; j<4 ; j++){ sum +=in[j].read(); out.write(sum); sum_finished.notify(SC_ZERO_TIME); cout<< "sum = " << sum<< endl; }}} SC_CTOR(adder){ SC_THREAD(somme); for ( int i=0; i<4;i++){ sensitive<<in[i];} } }; main.cpp int sc_main(int argc, char *argv[]) { sc_set_time_resolution(1, SC_FS); int NB_elements_trans = 4; int N =3; sc_signal<double>sig_data[N][NB_elements_trans]; sc_signal<double>sig_add; donnee <3,4> *i_donnee = new donnee <3,4>( "i_donnee" ); for ( int i=0; i<N ; i++){ for ( int j=0; j<NB_elements_trans ; j++){ i_donnee-> out[i][j] (sig_data[i][j]); i_donnee -> initialize(sim_rate*fs) ;}} adder *i_adder; for ( int i=0; i<N ; i++){ for ( int j=0; j<NB_elements_trans ; j++){ i_adder = new adder("i_adder"); i_adder->in[j](sig_data[i][j]);} i_adder->out(sig_add); }
  3. hi @AmeyaVS , thanks for your reply, i want to synchronize many incoming delayed data with fifo ( each delayed data with one fifo) , so i need to implement a constant delay for each data with a fifo ) my problem is how to introduce the delay in fifo designing. this is the code of the fifo bloc: #include "systemc.h" #include <iostream> #include <fstream> #include <stdlib.h> template<class T > SC_MODULE(fifo) { sc_in<bool> clk; sc_in<T> data_in; sc_in<bool> valid_in; sc_in<bool> ready_in; sc_out<bool> ready_out; sc_out<T> data_out; sc_out<bool> valid_out; unsigned _size, _first, _items; T* _data; //int sampling_rate; void initialize(){ assert (_size > 0); _first = _items = 0; ready_out.initialize(true); valid_out.initialize(false);} void hw_fifo_method() { _data = new T [_size]; if (valid_in.read() && ready_out.read()) { // store new data item into fifo _data[(_first + _items) % _size] = data_in; ++_items; } if (ready_in.read() && valid_out.read()) { // discard data item that was just read from fifo -- _items; _first = (_first + 1) % _size ; } //Update all output signals. //Valid on next delta-cycle ready_out = (_items < _size); valid_out = (_items >0); data_out = _data[_first]; } fifo(sc_module_name name, unsigned size){ SC_HAS_PROCESS(fifo); SC_METHOD(hw_fifo_method); sensitive << clk.pos();} };
  4. hi Ameya , thanks for your reply, i want to synchronize many incoming delayed data with fifo ( each delayed data with one fifo) , so i need to implement a constant delay for each data with a fifo ) my problem is how to introduce the delay in fifo designing. this is the code of the fifo bloc: #include "systemc.h" #include <iostream> #include <fstream> #include <stdlib.h> template<class T > SC_MODULE(fifo) { sc_in<bool> clk; sc_in<T> data_in; sc_in<bool> valid_in; sc_in<bool> ready_in; sc_out<bool> ready_out; sc_out<T> data_out; sc_out<bool> valid_out; unsigned _size, _first, _items; T* _data; //int sampling_rate; void initialize(){ assert (_size > 0); _first = _items = 0; ready_out.initialize(true); valid_out.initialize(false);} void hw_fifo_method() { _data = new T [_size]; if (valid_in.read() && ready_out.read()) { // store new data item into fifo _data[(_first + _items) % _size] = data_in; ++_items; } if (ready_in.read() && valid_out.read()) { // discard data item that was just read from fifo -- _items; _first = (_first + 1) % _size ; } //Update all output signals. //Valid on next delta-cycle ready_out = (_items < _size); valid_out = (_items >0); data_out = _data[_first]; } fifo(sc_module_name name, unsigned size){ SC_HAS_PROCESS(fifo); SC_METHOD(hw_fifo_method); sensitive << clk.pos();} };
  5. hello; i need your help thank you; Error: (E109) complete binding failed: 4 binds exceeds maximum of 1 allowed: port 'adc_sub_1.sca_tdf_in_0' (sca_tdf::sca_in) In file: ../../../../source/src/sysc/communication/sc_port.cpp:231 my code is here : this is the first bloc : image.h #include <iostream> #include <fstream> #include <stdlib.h> #include <stdio.h> #include "systemc-ams.h" #include "systemc.h" template< int n , int m > SCA_TDF_MODULE( image) { sca_tdf::sca_out<double> out[n][m] ; double data[n][m]; double fsimu; void initialize(double _fsimu){ fsimu=_fsimu;} void set_attributes(){ out.set_timestep(1/fsimu,SC_SEC); } void processing(){ std::ifstream fichier("MatrixFile/log0.txt" , "r"); if (fichier != NULL){ for ( int i=0; i<n; i++){ for ( int j=0; j<m; j++){ fichier >> data[i][j]; out.write(data[i][j]);}}} } SCA_CTOR(image){} }; the second bloc (it's a ADC to digitize the image) , each line from the image will processed by one ADC . main.cpp #include <iostream> #include <fstream> #include <stdlib.h> #include "systemc-ams.h" #include "systemc.h" #include "image.h" #include "sigmadelta.h" //#include "transducteur.h" int sc_main(int argc, char *argv[]) { sc_set_time_resolution(1, SC_FS); const int OSR = 32; double BW = 50e3; double fs = 2.0 * BW*OSR ; const int sim_rate=10; int N_line = 4; int NB_elements_trans = 3; sca_tdf::sca_signal<double>sig_data[NB_elements_trans][N_LINE]; sca_tdf::sca_signal<double>sig_adc[NB_elements_trans]; sc_clock my_clk ("my_clk", 0.0020, SC_MS, 0.5, 0.0010, SC_MS, true); adc* adc_sub[NB_elements_trans]; donnee <3,4> *i_donnee = new donnee <3,4>( "i_donnee" ); for ( int i=0; i<NB_elements_trans ; i++){ for ( int j=0; j<N_LINE ; j++){ i_donnee-> out[i][j] (sig_data[i][j]); } i_donnee -> initialize(sim_rate*fs) ;} for ( int i=0; i<NB_elements_trans ; i++){ for ( int j=0; j<N_LINE ; j++){ adc_sub[i] = new adc("adc_sub"); adc_sub[i]->in(sig_data[i][j]); } adc_sub[i]->out(sig_adc[i]); adc_sub[i]->clock(my_clk); adc_sub[i]->initialize(fs,sim_rate);} fs= 2*fs ; // TRACE sca_util::sca_trace_file *tf1 = sca_util::sca_create_tabular_trace_file( "wave.dat" ); for ( int i=0; i<NB_elements_trans; i++){ for ( int j=0; j<N_LINE; j++){ sca_util::sca_trace(tf1,sig_data[i][j],"sig_data"); } } for ( int i=0; i<NB_elements_trans ; i++){ sca_util::sca_trace(tf1,sig_adc[i],"sig_adc"); } sc_start( N/fs , SC_SEC); sca_util::sca_close_tabular_trace_file(tf1); //sca_util::sca_close_tabular_trace_file(tf2); cout<< endl<< sc_time_stamp() << " sc_main finished" << endl; return 0; }
×
×
  • Create New...