Created
September 14, 2022 18:41
-
-
Save rahulbhadani/638191679b9f227b2eab86c69e37e0a2 to your computer and use it in GitHub Desktop.
Active low-pass filter implementation using sinusoidal input
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
#include "electric_low_pass.h" | |
#include "data_sources.h" | |
int sc_main(int argc, char **argv) | |
{ | |
/* Inter-module signal channel */ | |
sca_tdf::sca_signal<double> sig0; | |
sca_tdf::sca_signal<double> sig1; | |
double amplitude, frequency; | |
if(argc < 3) | |
{ | |
cout <<" In sufficient input params. \n usage: ./sim <amplitude> <frequency>" << endl; | |
exit(0); | |
} | |
amplitude = strtod(argv[1], NULL); | |
frequency = strtod(argv[2], NULL); | |
sin_source sine("Sine"); | |
sine.out(sig0); | |
sine.amplitude = amplitude; | |
sine.frequency = frequency; | |
lowpass LP("low-pass-fifth-order"); | |
/*Connect module ports and channels and assign parameters*/ | |
LP.input(sig0); | |
LP.output(sig1); | |
//tracing | |
sca_trace_file* atf = sca_create_tabular_trace_file("Electrical_LP"); | |
sca_trace(atf, sig0, "Input"); | |
sca_trace(atf, sig1, "Output"); | |
cout << "Simulation started..." << endl; | |
sc_start(100.0, SC_MS); | |
sc_stop(); | |
cout << "Simulation finished." << endl; | |
sca_close_tabular_trace_file(atf); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment