Jump to content

Alveena

Members
  • Posts

    2
  • Joined

  • Last visited

Alveena's Achievements

Member

Member (1/2)

0

Reputation

  1. I have two TDF modules param_gen and func. The function of param_gen is to write combination of amplitude and frequency values to its output port and func module reads those values and generate sine wave according to the characteristics read. My goal is to generate sine waves from the combination of amplitude and frequency values inserted. But the problem I'm facing is signal generated are no longer sine waves because of changing amplitude and frequency values. I tried capturing those signals using longer timestep so that they atleast look sine waves but that does not help. I'm pasting the code below. All kind of suggestions would be helpful. I have an array initilised with amplitude and frequency values in the param_gen.h file. double combi[4][2]= //combi(amp,freq) { {1,1e12}, {1.5,5e12}, {2,10e12}, {2.5,15e12}, }; Now in param_gen.cpp file, in function processing(), I write new values to the output port output_amp after a considerable amount of time step void param_gen::processing() { double current_time=get_time().to_seconds(); double time_difference=get_timestep().to_seconds()-last_timestep; if (time_difference==5e-6) { std::cout<<counter<<" "<<"counter"<<endl; output_amp.write(combi[index1+1][0]); //update new values output_freq.write(combi[index1+1][1]); index1++; if(index1==3) { index1=0; // reset the index so that combi values repeat again for remaining cycles } } else { output_amp.write(combi[index1][0]); // otherwise write the old values output_freq.write(combi[index1][1]); last_timestep=current_time; } } void param_gen::set_attributes_cpp() { output_amp.set_timestep(sca_core::sca_time(1,sc_core::SC_FS)); output_freq.set_timestep(sca_core::sca_time(1,sc_core::SC_FS)); } The func module simply read those values and generate sine singlas. void func::processing() { double t = single_sine_src_out.get_time().to_seconds(); double t1 = double_sine_src_out.get_time().to_seconds(); double t2 = triple_sine_src_out.get_time().to_seconds(); std::cout<<amp_in.read()<<" "<<" amp value "<<endl; std::cout<<freq_in.read()<<" "<<"freq value"<<endl; double x=amp_in.read()* sin ((2 * M_PI * freq_in.read() * t)+ p.phase1); double x1 = x + (amp_in.read() * sin ((2 * M_PI *freq_in.read()+100 * t1) + p.phase2)); double x2 = x1 + (amp_in.read() * sin ((2 * M_PI * freq_in.read()+200 * t2) + p.phase3));// ! 100,200 replace with variables single_sine_src_out.write(x); double_sine_src_out.write(x1); triple_sine_src_out.write(x2); } void func::set_attributes_cpp() { amp_in.set_timestep(sca_core::sca_time(1,sc_core::SC_FS)); freq_in.set_timestep(sca_core::sca_time(1,sc_core::SC_FS)); } I'm attaching my schematic below for a clear image of the problem.
  2. Hi, I'm new to systemC AMS and I want to implement statistics_config class in my project. Where can I learn more about its member functions? Couldn't find it in the user guide or elsewhere.
×
×
  • Create New...