Skip to content
Snippets Groups Projects
Commit ae7061c4 authored by Irina LEE's avatar Irina LEE
Browse files

deleted generate code (syscams)

parent bae2c0a6
No related branches found
No related tags found
1 merge request!72Syscams
#include <systemc-ams>
#include "analog_to_digital.h"
// Simulation entry point.
int sc_main(int argc, char *argv[]) {
using namespace sc_core;
using namespace sca_util;
// Declare signal to interconnect.
// Instantiate source and sink as well as bind their ports to the signal.
analog_to_digital analog_to_digital_1("analog_to_digital_1");
analog_to_digital_1.sensorIn(
// Configure signal tracing.
sca_trace_file* tfp = sca_create_tabular_trace_file("distance_sensor_tb");
// Start simulation.
sc_start(100.0, SC_MS);
// Close trace file and stop simulation to enable clean-up by
// asking SystemC to execute all end_of_simulation() callbacks.
sca_close_tabular_trace_file(tfp);
sc_stop();
return 0;
}
#include <systemc-ams>
#include "sink.h"
#include "sin_source.h"
// Simulation entry point.
int sc_main(int argc, char *argv[]) {
using namespace sc_core;
using namespace sca_util;
// Declare signal to interconnect.
sca_tdf::sca_signal<double> sig_1("sig_1");
// Instantiate source and sink as well as bind their ports to the signal.
sink sink_1("sink_1");
sink_1.in(sig_1);
sin_source sin_source_2("sin_source_2");
sin_source_2.out(sig_1);
// Configure signal tracing.
sca_trace_file* tfp = sca_create_tabular_trace_file("sin_source_sink_tb");
sca_trace(tfp, sig_1, "sig_1");
// Start simulation.
sc_start(100.0, SC_MS);
// Close trace file and stop simulation to enable clean-up by
// asking SystemC to execute all end_of_simulation() callbacks.
sca_close_tabular_trace_file(tfp);
sc_stop();
return 0;
}
#ifndef ANALOG_TO_DIGITAL_H
#define ANALOG_TO_DIGITAL_H
#include <cmath>
#include <iostream>
#include <systemc-ams>
SCA_TDF_MODULE(analog_to_digital) {
// TDF port declarations
sca_tdf::sca_in<double> sensorIn;
// Converter port declarations
sca_tdf::sca_de::sca_out<int> soclibOut;
sca_tdf::sca_de::sca_in<int> soclibIn;
// Constructor
SCA_CTOR(analog_to_digital)
: sensorIn("sensorIn")
, soclibOut("soclibOut")
, soclibIn("soclibIn")
{}
void set_attributes() {
sensorIn.set_rate(1);
sensorIn.set_delay(0);
soclibOut.set_rate(1);
soclibOut.set_delay(0);
soclibIn.set_rate(1);
soclibIn.set_delay(0);
}
void processing() { }
};
#endif // ANALOG_TO_DIGITAL_H
\ No newline at end of file
#ifndef SIN_SOURCE_H
#define SIN_SOURCE_H
#include <cmath>
#include <iostream>
#include <systemc-ams>
SCA_TDF_MODULE(sin_source) {
// TDF port declarations
sca_tdf::sca_out<double> out;
// Constructor
SCA_CTOR(sin_source)
: out("out")
{}
void set_attributes() {
set_timestep(0, sc_core::SC_MS);
out.set_timestep(1, sc_core::SC_US);
out.set_rate(0);
out.set_delay(0);
}
void processing() { double t = out.get_time().to_seconds(); double x = 1.5 * sin(2.0 * M_PI * 50.0 * t); out.write(x); }
};
#endif // SIN_SOURCE_H
\ No newline at end of file
#ifndef SINK_H
#define SINK_H
#include <cmath>
#include <iostream>
#include <systemc-ams>
SCA_TDF_MODULE(sink) {
// TDF port declarations
sca_tdf::sca_in<double> in;
// Constructor
SCA_CTOR(sink)
: in("in")
{}
void set_attributes() {
set_timestep(0, sc_core::SC_MS);
in.set_timestep(0, sc_core::SC_US);
in.set_rate(0);
in.set_delay(0);
}
void processing() { using namespace std; cout << this->name() << " @ " << this->get_time() << ": " << in.read() << endl; }
};
#endif // SINK_H
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment