Skip to content

Instantly share code, notes, and snippets.

@rahulbhadani
Created September 12, 2022 22:56
Show Gist options
  • Save rahulbhadani/494b83879e337a99eed70f384500e095 to your computer and use it in GitHub Desktop.
Save rahulbhadani/494b83879e337a99eed70f384500e095 to your computer and use it in GitHub Desktop.
Data Sources such sinusoidal wave
#ifndef DATA_SOURCES_H
#define DATA_SOURCES_H
#include <systemc-ams.h>
SCA_TDF_MODULE(sin_source)
{
sca_tdf::sca_out<double> out;
double amplitude;
double frequency;
void set_attributes()
{
out.set_timestep(1.0, SC_US);
}
void processing ()
{
double t=out.get_time().to_seconds();
double x = amplitude * std::sin(2.0 * M_PI * frequency * t);
out.write(x);
}
SCA_CTOR(sin_source):
out("out"), amplitude(1.0), frequency(1e3){}
};
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment