summaryrefslogtreecommitdiff
path: root/src/systemc/tests/systemc/communication/sc_export
diff options
context:
space:
mode:
Diffstat (limited to 'src/systemc/tests/systemc/communication/sc_export')
-rw-r--r--src/systemc/tests/systemc/communication/sc_export/test01/golden/test01.log25
-rw-r--r--src/systemc/tests/systemc/communication/sc_export/test01/test01.cpp75
-rw-r--r--src/systemc/tests/systemc/communication/sc_export/test02/golden/test02.log4
-rw-r--r--src/systemc/tests/systemc/communication/sc_export/test02/test02.cpp20
-rw-r--r--src/systemc/tests/systemc/communication/sc_export/test03/golden/test03.log4
-rw-r--r--src/systemc/tests/systemc/communication/sc_export/test03/test03.cpp86
-rw-r--r--src/systemc/tests/systemc/communication/sc_export/test04/golden/test04.log4
-rw-r--r--src/systemc/tests/systemc/communication/sc_export/test04/test04.cpp17
-rw-r--r--src/systemc/tests/systemc/communication/sc_export/test05/golden/test05.log51
-rw-r--r--src/systemc/tests/systemc/communication/sc_export/test05/test05.cpp106
10 files changed, 392 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/communication/sc_export/test01/golden/test01.log b/src/systemc/tests/systemc/communication/sc_export/test01/golden/test01.log
new file mode 100644
index 000000000..19836dbfb
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_export/test01/golden/test01.log
@@ -0,0 +1,25 @@
+SystemC Simulation
+READ_LEAF: change 0
+TOP: change 0
+TOP: change 1
+READ_LEAF: change 1
+TOP: change 2
+READ_LEAF: change 2
+TOP: change 3
+READ_LEAF: change 3
+TOP: change 4
+READ_LEAF: change 4
+TOP: change 5
+READ_LEAF: change 5
+TOP: change 6
+READ_LEAF: change 6
+TOP: change 7
+READ_LEAF: change 7
+TOP: change 8
+READ_LEAF: change 8
+TOP: change 9
+READ_LEAF: change 9
+TOP: change 10
+READ_LEAF: change 10
+TOP: change 11
+READ_LEAF: change 11
diff --git a/src/systemc/tests/systemc/communication/sc_export/test01/test01.cpp b/src/systemc/tests/systemc/communication/sc_export/test01/test01.cpp
new file mode 100644
index 000000000..9b2388421
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_export/test01/test01.cpp
@@ -0,0 +1,75 @@
+#include "systemc.h"
+
+SC_MODULE(READ_LEAF)
+{
+ SC_CTOR(READ_LEAF)
+ {
+ SC_METHOD(delta);
+ sensitive << in;
+ }
+ void delta()
+ {
+ cout << "READ_LEAF: change " << (int)in->read() << endl;
+ }
+ sc_in<sc_uint<8> > in;
+};
+
+SC_MODULE(WRITE_LEAF)
+{
+ SC_CTOR(WRITE_LEAF) : out("out"), clk("clk")
+ {
+ my_export(out);
+ SC_METHOD(sync)
+ sensitive << clk.pos();
+ }
+ void sync()
+ {
+ out = out.read() + 1;
+ }
+ sc_signal<sc_uint<8> > out;
+ sc_export<sc_signal_in_if<sc_uint<8> > > my_export;
+ sc_in_clk clk;
+};
+
+SC_MODULE(MIDDLE)
+{
+ SC_CTOR(MIDDLE) : reader("reader"), writer("writer")
+ {
+ writer.clk(clk); // Bind clk going down the module hierarchy.
+ my_port(writer.my_export); // Bind my_port coming up the module hierarchy.
+ reader.in(my_port); // Bind my_port going down the module hierarchy.
+ }
+ sc_in_clk clk;
+ sc_export<sc_signal_in_if<sc_uint<8> > > my_port;
+ READ_LEAF reader;
+ WRITE_LEAF writer;
+};
+
+SC_MODULE(TOP)
+{
+ SC_CTOR(TOP) : down("down")
+ {
+ down.clk(clk); // Bind clk going down the module hierarchy.
+ in(down.my_port); // Bind in coming up the module hierarchy.
+ SC_METHOD(delta);
+ sensitive << in;
+ }
+ void delta()
+ {
+ cout << "TOP: change " << (int)in.read() << endl;
+ }
+ sc_in_clk clk;
+ sc_in<sc_uint<8> > in;
+ MIDDLE down;
+};
+
+int sc_main(int argc, char* arg[])
+{
+ sc_clock clock;
+ TOP top("top");
+ top.clk(clock);
+
+ sc_start(10, SC_NS);
+ return 0;
+}
+
diff --git a/src/systemc/tests/systemc/communication/sc_export/test02/golden/test02.log b/src/systemc/tests/systemc/communication/sc_export/test02/golden/test02.log
new file mode 100644
index 000000000..b2a9f1c81
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_export/test02/golden/test02.log
@@ -0,0 +1,4 @@
+SystemC Simulation
+
+Error: (E120) sc_export instance has no interface: x.export_1
+In file: <removed by verify.pl>
diff --git a/src/systemc/tests/systemc/communication/sc_export/test02/test02.cpp b/src/systemc/tests/systemc/communication/sc_export/test02/test02.cpp
new file mode 100644
index 000000000..f044fc741
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_export/test02/test02.cpp
@@ -0,0 +1,20 @@
+#include "systemc.h"
+
+SC_MODULE(X)
+{
+ SC_CTOR(X)
+ {
+ a(b);
+ }
+ sc_export<sc_signal_inout_if<int> > a;
+ sc_export<sc_signal_inout_if<int> > b;
+};
+
+int sc_main(int argc, char* argv[])
+{
+ sc_clock clock;
+ X x("x");
+
+ sc_start(1, SC_NS);
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/communication/sc_export/test03/golden/test03.log b/src/systemc/tests/systemc/communication/sc_export/test03/golden/test03.log
new file mode 100644
index 000000000..3de4cda83
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_export/test03/golden/test03.log
@@ -0,0 +1,4 @@
+SystemC Simulation
+10 ns In Channel run()
+17 ns In Channel run()
+20 ns In Channel run()
diff --git a/src/systemc/tests/systemc/communication/sc_export/test03/test03.cpp b/src/systemc/tests/systemc/communication/sc_export/test03/test03.cpp
new file mode 100644
index 000000000..9da2e4934
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_export/test03/test03.cpp
@@ -0,0 +1,86 @@
+#include "systemc.h"
+
+// Interface
+class C_if : virtual public sc_interface
+{
+public:
+ virtual void run() = 0;
+};
+
+// Channel
+class C : public C_if, public sc_channel
+{
+public:
+ SC_CTOR(C) { }
+ virtual void run()
+ {
+ cout << sc_time_stamp() << " In Channel run() " << endl;
+ }
+};
+
+// --- D: export channel C through IFP --------
+SC_MODULE( D )
+{
+ sc_export<C_if> IFP;
+
+ SC_CTOR( D )
+ : IFP("IFP"), // explicit name
+ m_C("C")
+ {
+ IFP( m_C ); // bind sc_export->interface by name
+ }
+ private:
+ C m_C; // channel
+};
+
+// --- E: module with two interface-ports ---
+SC_MODULE( E )
+{
+ private:
+ C m_C;
+ D m_D;
+
+ public:
+ sc_export<C_if> IFP1;
+ sc_export<C_if> IFP2;
+
+ SC_CTOR( E )
+ : m_C("C"),
+ m_D("D"),
+ IFP1("IFP1")
+ {
+ IFP1( m_C );
+ IFP2( m_D.IFP ); // bind sc_export->sc_export by name
+ IFP1.get_interface(); // just to see whether it compiles
+ }
+};
+
+// Module X connected to the channels through E
+SC_MODULE( X )
+{
+ sc_port<C_if> P1;
+ sc_port<C_if> P2;
+ SC_CTOR(X) {
+ SC_THREAD(run);
+ }
+ void run() {
+ wait(10, SC_NS);
+ P1->run();
+ wait(10, SC_NS);
+ P2->run();
+ }
+};
+
+int sc_main(int argc, char** argv) {
+ E the_E("E");
+ X the_X("X");
+ // port->IFP
+ the_X.P1( the_E.IFP1 );
+ the_X.P2( the_E.IFP2 );
+
+ sc_start(17, SC_NS);
+ the_E.IFP1->run(); // testing the operator-> of sc_export
+ sc_start(50, SC_NS);
+
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/communication/sc_export/test04/golden/test04.log b/src/systemc/tests/systemc/communication/sc_export/test04/golden/test04.log
new file mode 100644
index 000000000..df6df8478
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_export/test04/golden/test04.log
@@ -0,0 +1,4 @@
+SystemC Simulation
+
+Error: (E109) complete binding failed: export not bound: export 'x.a' (sc_export)
+In file: <removed by verify.pl>
diff --git a/src/systemc/tests/systemc/communication/sc_export/test04/test04.cpp b/src/systemc/tests/systemc/communication/sc_export/test04/test04.cpp
new file mode 100644
index 000000000..6a2b21421
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_export/test04/test04.cpp
@@ -0,0 +1,17 @@
+#include "systemc.h"
+
+SC_MODULE(X)
+{
+ SC_CTOR(X) : a("a")
+ {
+ }
+ sc_export<sc_signal_inout_if<int> > a;
+};
+
+int sc_main(int argc, char* argv[])
+{
+ X x("x");
+
+ sc_start(1, SC_NS);
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/communication/sc_export/test05/golden/test05.log b/src/systemc/tests/systemc/communication/sc_export/test05/golden/test05.log
new file mode 100644
index 000000000..a736ca05c
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_export/test05/golden/test05.log
@@ -0,0 +1,51 @@
+SystemC Simulation
+0 s: 0
+1 ns: 0
+2 ns: 0
+3 ns: 0
+4 ns: 1
+5 ns: 2
+6 ns: 3
+7 ns: 4
+8 ns: 5
+9 ns: 6
+10 ns: 7
+11 ns: 8
+12 ns: 9
+13 ns: 10
+14 ns: 11
+15 ns: 12
+16 ns: 13
+17 ns: 14
+18 ns: 15
+19 ns: 16
+20 ns: 17
+21 ns: 18
+22 ns: 19
+23 ns: 20
+24 ns: 21
+25 ns: 22
+26 ns: 23
+27 ns: 24
+28 ns: 25
+29 ns: 26
+30 ns: 27
+31 ns: 28
+32 ns: 29
+33 ns: 30
+34 ns: 31
+35 ns: 32
+36 ns: 33
+37 ns: 34
+38 ns: 35
+39 ns: 36
+40 ns: 37
+41 ns: 38
+42 ns: 39
+43 ns: 40
+44 ns: 41
+45 ns: 42
+46 ns: 43
+47 ns: 44
+48 ns: 45
+49 ns: 46
diff --git a/src/systemc/tests/systemc/communication/sc_export/test05/test05.cpp b/src/systemc/tests/systemc/communication/sc_export/test05/test05.cpp
new file mode 100644
index 000000000..f1e38c862
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_export/test05/test05.cpp
@@ -0,0 +1,106 @@
+#include "systemc.h"
+
+typedef sc_biguint<121> atom; // Value to be pipe delayed.
+
+//==============================================================================
+// esc_dpipe<T,N> - DELAY PIPELINE FOR AN ARBITRARY CLASS:
+//==============================================================================
+template<class T, int N>
+SC_MODULE(esc_dpipe) {
+ public:
+ typedef sc_export<sc_signal_inout_if<T> > in; // To pipe port type.
+ typedef sc_export<sc_signal_in_if<T> > out; // From pipe port type.
+
+ public:
+ SC_CTOR(esc_dpipe)
+ {
+ m_in(m_pipe[0]);
+ m_out(m_pipe[N-1]);
+ SC_METHOD(rachet);
+ sensitive << m_clk.pos();
+ }
+
+ protected:
+ void rachet()
+ {
+ for ( int i = N-1; i > 0; i-- )
+ {
+ m_pipe[i].write(m_pipe[i-1].read());
+ }
+ }
+
+ public:
+ sc_in_clk m_clk; // Pipe synchronization.
+ in m_in; // Input to delay pipe.
+ out m_out; // Output from delay pipe.
+
+ protected:
+ sc_signal<T> m_pipe[N]; // Pipeline stages.
+};
+
+
+// Testbench reader of values from the pipe:
+
+SC_MODULE(Reader)
+{
+ SC_CTOR(Reader)
+ {
+ SC_METHOD(extract)
+ sensitive << m_clk.pos();
+ dont_initialize();
+ }
+
+ void extract()
+ {
+ cout << sc_time_stamp() << ": " << m_from_pipe.read() << endl;
+ }
+
+ sc_in_clk m_clk; // Module synchronization.
+ sc_in<atom > m_from_pipe; // Output from delay pipe.
+};
+
+
+
+// Testbench writer of values to the pipe:
+
+SC_MODULE(Writer)
+{
+ SC_CTOR(Writer)
+ {
+ SC_METHOD(insert)
+ sensitive << m_clk.pos();
+ m_counter = 0;
+ }
+
+ void insert()
+ {
+ m_to_pipe.write(m_counter);
+ m_counter++;
+ }
+
+ sc_in_clk m_clk; // Module synchronization.
+ atom m_counter; // Write value.
+ sc_inout<atom > m_to_pipe; // Input for delay pipe.
+};
+
+// Main program
+
+int sc_main(int argc, char* argv[])
+{
+ sc_clock clock;
+ esc_dpipe<atom,4> delay("pipe");
+ Reader reader("reader");
+ Writer writer("writer");
+
+ delay.m_clk(clock);
+
+ reader.m_clk(clock);
+ reader.m_from_pipe(delay.m_out);
+
+ writer.m_clk(clock);
+ writer.m_to_pipe(delay.m_in);
+
+ sc_start(50, SC_NS);
+
+ return 0;
+}