Created
September 12, 2022 22:56
-
-
Save rahulbhadani/494b83879e337a99eed70f384500e095 to your computer and use it in GitHub Desktop.
Data Sources such sinusoidal wave
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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