diff --git a/SysCAMSGenerationCode/generated_CPP/sin_source_sink.cpp b/SysCAMSGenerationCode/generated_CPP/sin_source_sink.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b23af42ee703a348973b884d3862c20cbdc1bdc5 --- /dev/null +++ b/SysCAMSGenerationCode/generated_CPP/sin_source_sink.cpp @@ -0,0 +1,34 @@ +#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; +} + diff --git a/SysCAMSGenerationCode/generated_H/sin_source.h b/SysCAMSGenerationCode/generated_H/sin_source.h new file mode 100644 index 0000000000000000000000000000000000000000..20097c71c27482f1af10ad767b0e82bda9db943c --- /dev/null +++ b/SysCAMSGenerationCode/generated_H/sin_source.h @@ -0,0 +1,29 @@ +#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 diff --git a/SysCAMSGenerationCode/generated_H/sink.h b/SysCAMSGenerationCode/generated_H/sink.h new file mode 100644 index 0000000000000000000000000000000000000000..bcf8081484bce60d8e87d0ca2e367497da7e86f5 --- /dev/null +++ b/SysCAMSGenerationCode/generated_H/sink.h @@ -0,0 +1,29 @@ +#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 diff --git a/modeling/sin_source_sink.xml b/modeling/sin_source_sink.xml index b13a136ee93a8c2ed5387e55755c40f28d2ef951..23c7962060d240d457586831048d42b279f8be61 100644 --- a/modeling/sin_source_sink.xml +++ b/modeling/sin_source_sink.xml @@ -1,118 +1,113 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> +<?xml version="1.0" encoding="UTF-8"?> <TURTLEGMODELING version="1.0beta"> <Modeling type="SystemC-AMS" nameTab="SystemC_AMS" > <SysCAMSComponentTaskDiagramPanel name="SystemC-AMS Component Diagram" minX="10" maxX="2500" minY="10" maxY="1500" TDF="true" DE="true" zoom="1.0" > -<CONNECTOR type="1601" id="49" > +<CONNECTOR type="1601" id="1" > <cdparam x="400" y="247" /> <sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <infoparam name="connector" value="Connector between ports" /> -<P1 x="400" y="247" id="1" /> -<P2 x="483" y="247" id="40" /> +<P1 x="400" y="247" id="21" /> +<P2 x="483" y="247" id="2" /> <AutomaticDrawing data="true" /> </CONNECTOR> -<COMPONENT type="1607" id="37" > +<COMPONENT type="1607" id="48" > <cdparam x="123" y="94" /> <sizeparam width="674" height="332" minWidth="1" minHeight="1" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <hidden value="false" /> <cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> -<infoparam name="Composite component" value="Cluster" /> -<TGConnectingPoint num="0" id="29" /> -<TGConnectingPoint num="1" id="30" /> -<TGConnectingPoint num="2" id="31" /> -<TGConnectingPoint num="3" id="32" /> -<TGConnectingPoint num="4" id="33" /> -<TGConnectingPoint num="5" id="34" /> -<TGConnectingPoint num="6" id="35" /> -<TGConnectingPoint num="7" id="36" /> +<infoparam name="Composite component" value="sin_source_sink" /> +<TGConnectingPoint num="0" id="40" /> +<TGConnectingPoint num="1" id="41" /> +<TGConnectingPoint num="2" id="42" /> +<TGConnectingPoint num="3" id="43" /> +<TGConnectingPoint num="4" id="44" /> +<TGConnectingPoint num="5" id="45" /> +<TGConnectingPoint num="6" id="46" /> +<TGConnectingPoint num="7" id="47" /> <extraparam> <info hiddeni="false" /> </extraparam> </COMPONENT> -<SUBCOMPONENT type="1602" id="19" > -<father id="37" num="0" /> -<cdparam x="187" y="177" /> +<SUBCOMPONENT type="1602" id="20" > +<father id="48" num="0" /> +<cdparam x="496" y="175" /> <sizeparam width="200" height="150" minWidth="1" minHeight="1" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <hidden value="false" /> <cdrectangleparam minX="0" maxX="474" minY="0" maxY="182" /> -<infoparam name="Primitive component" value="sin_source" /> -<TGConnectingPoint num="0" id="11" /> -<TGConnectingPoint num="1" id="12" /> -<TGConnectingPoint num="2" id="13" /> -<TGConnectingPoint num="3" id="14" /> -<TGConnectingPoint num="4" id="15" /> -<TGConnectingPoint num="5" id="16" /> -<TGConnectingPoint num="6" id="17" /> -<TGConnectingPoint num="7" id="18" /> +<infoparam name="Primitive component" value="sink" /> +<TGConnectingPoint num="0" id="12" /> +<TGConnectingPoint num="1" id="13" /> +<TGConnectingPoint num="2" id="14" /> +<TGConnectingPoint num="3" id="15" /> +<TGConnectingPoint num="4" id="16" /> +<TGConnectingPoint num="5" id="17" /> +<TGConnectingPoint num="6" id="18" /> +<TGConnectingPoint num="7" id="19" /> <extraparam> <Data isAttacker="No" /> -<Attribute period="0" processCode="void processing() { double t = out.get_time().to_seconds(); double x = 1.5 * sin(2.0 * M_PI * 50.0 * t); out.write(x); }" /> +<Attribute period="0" processCode="void processing() { using namespace std; cout << this->name() << " @ " << this->get_time() << ": " << in.read() << endl; } " /> </extraparam> </SUBCOMPONENT> -<SUBCOMPONENT type="1604" id="10" > -<father id="19" num="0" /> -<cdparam x="374" y="234" /> +<SUBCOMPONENT type="1604" id="11" > +<father id="20" num="0" /> +<cdparam x="483" y="234" /> <sizeparam width="26" height="26" minWidth="1" minHeight="1" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <hidden value="false" /> <cdrectangleparam minX="-13" maxX="187" minY="-13" maxY="137" /> -<infoparam name="Primitive port" value="Port TDF port" /> -<TGConnectingPoint num="0" id="1" /> -<TGConnectingPoint num="1" id="2" /> -<TGConnectingPoint num="2" id="3" /> -<TGConnectingPoint num="3" id="4" /> -<TGConnectingPoint num="4" id="5" /> -<TGConnectingPoint num="5" id="6" /> -<TGConnectingPoint num="6" id="7" /> -<TGConnectingPoint num="7" id="8" /> -<TGConnectingPoint num="8" id="9" /> +<infoparam name="Primitive port" value="Port TDF in" /> +<TGConnectingPoint num="0" id="2" /> +<TGConnectingPoint num="1" id="3" /> +<TGConnectingPoint num="2" id="4" /> +<TGConnectingPoint num="3" id="5" /> +<TGConnectingPoint num="4" id="6" /> +<TGConnectingPoint num="5" id="7" /> +<TGConnectingPoint num="6" id="8" /> +<TGConnectingPoint num="7" id="9" /> +<TGConnectingPoint num="8" id="10" /> <extraparam> -<Prop commName="out" commType="0" origin="1" period="1" time="us" rate="0" delay="0" type="double" /> +<Prop commName="in" commType="0" origin="0" period="0" time="us" rate="0" delay="0" type="double" /> </extraparam> </SUBCOMPONENT> -<SUBCOMPONENT type="1602" id="28" > -<father id="37" num="1" /> -<cdparam x="496" y="175" /> +<SUBCOMPONENT type="1602" id="39" > +<father id="48" num="1" /> +<cdparam x="187" y="177" /> <sizeparam width="200" height="150" minWidth="1" minHeight="1" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <hidden value="false" /> <cdrectangleparam minX="0" maxX="474" minY="0" maxY="182" /> -<infoparam name="Primitive component" value="sink" /> -<TGConnectingPoint num="0" id="20" /> -<TGConnectingPoint num="1" id="21" /> -<TGConnectingPoint num="2" id="22" /> -<TGConnectingPoint num="3" id="23" /> -<TGConnectingPoint num="4" id="24" /> -<TGConnectingPoint num="5" id="25" /> -<TGConnectingPoint num="6" id="26" /> -<TGConnectingPoint num="7" id="27" /> +<infoparam name="Primitive component" value="sin_source" /> +<TGConnectingPoint num="0" id="31" /> +<TGConnectingPoint num="1" id="32" /> +<TGConnectingPoint num="2" id="33" /> +<TGConnectingPoint num="3" id="34" /> +<TGConnectingPoint num="4" id="35" /> +<TGConnectingPoint num="5" id="36" /> +<TGConnectingPoint num="6" id="37" /> +<TGConnectingPoint num="7" id="38" /> <extraparam> <Data isAttacker="No" /> -<Attribute period="0" processCode="void processing() { - using namespace std; - cout << this->name() << " @ " << this->get_time() << ": " - << in.read() << endl; -} -" /> +<Attribute period="0" processCode="void processing() { double t = out.get_time().to_seconds(); double x = 1.5 * sin(2.0 * M_PI * 50.0 * t); out.write(x); }" /> </extraparam> </SUBCOMPONENT> -<SUBCOMPONENT type="1604" id="39" > -<father id="28" num="0" /> -<cdparam x="483" y="234" /> +<SUBCOMPONENT type="1604" id="30" > +<father id="39" num="0" /> +<cdparam x="374" y="234" /> <sizeparam width="26" height="26" minWidth="1" minHeight="1" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> <hidden value="false" /> <cdrectangleparam minX="-13" maxX="187" minY="-13" maxY="137" /> -<infoparam name="Primitive port" value="Port TDF port" /> -<TGConnectingPoint num="0" id="40" /> -<TGConnectingPoint num="1" id="41" /> -<TGConnectingPoint num="2" id="42" /> -<TGConnectingPoint num="3" id="43" /> -<TGConnectingPoint num="4" id="44" /> -<TGConnectingPoint num="5" id="45" /> -<TGConnectingPoint num="6" id="46" /> -<TGConnectingPoint num="7" id="47" /> -<TGConnectingPoint num="8" id="48" /> +<infoparam name="Primitive port" value="Port TDF out" /> +<TGConnectingPoint num="0" id="21" /> +<TGConnectingPoint num="1" id="22" /> +<TGConnectingPoint num="2" id="23" /> +<TGConnectingPoint num="3" id="24" /> +<TGConnectingPoint num="4" id="25" /> +<TGConnectingPoint num="5" id="26" /> +<TGConnectingPoint num="6" id="27" /> +<TGConnectingPoint num="7" id="28" /> +<TGConnectingPoint num="8" id="29" /> <extraparam> -<Prop commName="in" commType="0" origin="0" period="0" time="us" rate="0" delay="0" type="double" /> +<Prop commName="out" commType="0" origin="1" period="1" time="us" rate="0" delay="0" type="double" /> </extraparam> </SUBCOMPONENT>