summaryrefslogtreecommitdiff
path: root/src/systemc/tests/systemc/communication/sc_port_policy
diff options
context:
space:
mode:
Diffstat (limited to 'src/systemc/tests/systemc/communication/sc_port_policy')
-rw-r--r--src/systemc/tests/systemc/communication/sc_port_policy/test01/golden/test01.log13
-rw-r--r--src/systemc/tests/systemc/communication/sc_port_policy/test01/test01.cpp100
-rw-r--r--src/systemc/tests/systemc/communication/sc_port_policy/test02/golden/test02.log16
-rw-r--r--src/systemc/tests/systemc/communication/sc_port_policy/test02/test02.cpp100
-rw-r--r--src/systemc/tests/systemc/communication/sc_port_policy/test03/golden/test03.log4
-rw-r--r--src/systemc/tests/systemc/communication/sc_port_policy/test03/test03.cpp100
-rw-r--r--src/systemc/tests/systemc/communication/sc_port_policy/test04/golden/test04.log4
-rw-r--r--src/systemc/tests/systemc/communication/sc_port_policy/test04/test04.cpp100
-rw-r--r--src/systemc/tests/systemc/communication/sc_port_policy/test05/golden/test05.log6
-rw-r--r--src/systemc/tests/systemc/communication/sc_port_policy/test05/test05.cpp101
10 files changed, 544 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/communication/sc_port_policy/test01/golden/test01.log b/src/systemc/tests/systemc/communication/sc_port_policy/test01/golden/test01.log
new file mode 100644
index 000000000..b5ba39034
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_port_policy/test01/golden/test01.log
@@ -0,0 +1,13 @@
+SystemC Simulation
+1 ns:
+ all[0] = 1
+ all[1] = 0
+ one = 1
+2 ns:
+ all[0] = 1
+ all[1] = 1
+ one = 1
+3 ns:
+ all[0] = 0
+ all[1] = 0
+ one = 0
diff --git a/src/systemc/tests/systemc/communication/sc_port_policy/test01/test01.cpp b/src/systemc/tests/systemc/communication/sc_port_policy/test01/test01.cpp
new file mode 100644
index 000000000..30afd975e
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_port_policy/test01/test01.cpp
@@ -0,0 +1,100 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ test01.cpp -- Test bind policy: unbound port.
+
+ Original Author: Andy Goodrich, Forte Design Systems, 02 September 2005
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+#include <systemc.h>
+
+// #define ALL_ERROR // Force error on all bound port.
+// #define BIND_NONE // Bind port with zero or more bound.
+// #define ONE_ERROR // Force error on one or more bound port.
+
+SC_MODULE(TB)
+{
+ SC_CTOR(TB) : m_all("all"), m_none("none"), m_one("one")
+ {
+ SC_CTHREAD(thread, m_clk.pos());
+ }
+ void thread()
+ {
+ for (;;)
+ {
+ wait();
+ cout << sc_time_stamp() << ":" << endl;
+ cout << " all[0] = " << m_all[0]->read() << endl;
+ cout << " all[1] = " << m_all[1]->read() << endl;
+ cout << " one = " << m_one->read() << endl;
+# if defined(BIND_NONE)
+ cout << " none = " << m_none->read() << endl;
+# endif
+ }
+ }
+ sc_port<sc_signal_in_if<bool>,2,SC_ALL_BOUND> m_all;
+ sc_in<bool> m_clk;
+ sc_port<sc_signal_in_if<bool>,2,SC_ZERO_OR_MORE_BOUND> m_none;
+ sc_port<sc_signal_in_if<bool>,2,SC_ONE_OR_MORE_BOUND> m_one;
+};
+
+int sc_main (int argc , char *argv[]) {
+ sc_clock clock;
+ sc_signal<bool> sig1;
+ sc_signal<bool> sig2;
+
+ TB tb("tb");
+
+ tb.m_clk(clock);
+
+# if !defined(ONE_ERROR)
+ tb.m_one(sig1);
+# endif
+# if defined(BIND_NONE)
+ tb.m_none(sig2);
+# endif
+ tb.m_all(sig1);
+# if !defined(ALL_ERROR)
+ tb.m_all(sig2);
+# endif
+
+ sc_start(1, SC_NS);
+ sig1 = true;
+ sc_start(1, SC_NS);
+ sig2 = true;
+ sc_start(1, SC_NS);
+ sig1 = false;
+ sig2 = false;
+ sc_start(1, SC_NS);
+ return 0;
+}
+
diff --git a/src/systemc/tests/systemc/communication/sc_port_policy/test02/golden/test02.log b/src/systemc/tests/systemc/communication/sc_port_policy/test02/golden/test02.log
new file mode 100644
index 000000000..53354e74d
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_port_policy/test02/golden/test02.log
@@ -0,0 +1,16 @@
+SystemC Simulation
+1 ns:
+ all[0] = 1
+ all[1] = 0
+ one = 1
+ none = 0
+2 ns:
+ all[0] = 1
+ all[1] = 1
+ one = 1
+ none = 1
+3 ns:
+ all[0] = 0
+ all[1] = 0
+ one = 0
+ none = 0
diff --git a/src/systemc/tests/systemc/communication/sc_port_policy/test02/test02.cpp b/src/systemc/tests/systemc/communication/sc_port_policy/test02/test02.cpp
new file mode 100644
index 000000000..4a7ef1e38
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_port_policy/test02/test02.cpp
@@ -0,0 +1,100 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ test02.cpp -- Test bind policy: none port bound.
+
+ Original Author: Andy Goodrich, Forte Design Systems, 02 September 2005
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+#include <systemc.h>
+
+// #define ALL_ERROR // Force error on all bound port.
+#define BIND_NONE // Bind port with zero or more bound.
+// #define ONE_ERROR // Force error on one or more bound port.
+
+SC_MODULE(TB)
+{
+ SC_CTOR(TB) : m_all("all"), m_none("none"), m_one("one")
+ {
+ SC_CTHREAD(thread, m_clk.pos());
+ }
+ void thread()
+ {
+ for (;;)
+ {
+ wait();
+ cout << sc_time_stamp() << ":" << endl;
+ cout << " all[0] = " << m_all[0]->read() << endl;
+ cout << " all[1] = " << m_all[1]->read() << endl;
+ cout << " one = " << m_one->read() << endl;
+# if defined(BIND_NONE)
+ cout << " none = " << m_none->read() << endl;
+# endif
+ }
+ }
+ sc_port<sc_signal_in_if<bool>,2,SC_ALL_BOUND> m_all;
+ sc_in<bool> m_clk;
+ sc_port<sc_signal_in_if<bool>,2,SC_ZERO_OR_MORE_BOUND> m_none;
+ sc_port<sc_signal_in_if<bool>,2,SC_ONE_OR_MORE_BOUND> m_one;
+};
+
+int sc_main (int argc , char *argv[]) {
+ sc_clock clock;
+ sc_signal<bool> sig1;
+ sc_signal<bool> sig2;
+
+ TB tb("tb");
+
+ tb.m_clk(clock);
+
+# if !defined(ONE_ERROR)
+ tb.m_one(sig1);
+# endif
+# if defined(BIND_NONE)
+ tb.m_none(sig2);
+# endif
+ tb.m_all(sig1);
+# if !defined(ALL_ERROR)
+ tb.m_all(sig2);
+# endif
+
+ sc_start(1, SC_NS);
+ sig1 = true;
+ sc_start(1, SC_NS);
+ sig2 = true;
+ sc_start(1, SC_NS);
+ sig1 = false;
+ sig2 = false;
+ sc_start(1, SC_NS);
+ return 0;
+}
+
diff --git a/src/systemc/tests/systemc/communication/sc_port_policy/test03/golden/test03.log b/src/systemc/tests/systemc/communication/sc_port_policy/test03/golden/test03.log
new file mode 100644
index 000000000..2119b4e08
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_port_policy/test03/golden/test03.log
@@ -0,0 +1,4 @@
+SystemC Simulation
+
+Error: (E109) complete binding failed: port not bound: port 'tb.one' (sc_port)
+In file: <removed by verify.pl>
diff --git a/src/systemc/tests/systemc/communication/sc_port_policy/test03/test03.cpp b/src/systemc/tests/systemc/communication/sc_port_policy/test03/test03.cpp
new file mode 100644
index 000000000..8200ead5d
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_port_policy/test03/test03.cpp
@@ -0,0 +1,100 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ test03.cpp -- Test bind policy: one required not bound.
+
+ Original Author: Andy Goodrich, Forte Design Systems, 02 September 2005
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+#include <systemc.h>
+
+// #define ALL_ERROR // Force error on all bound port.
+// #define BIND_NONE // Bind port with zero or more bound.
+#define ONE_ERROR // Force error on one or more bound port.
+
+SC_MODULE(TB)
+{
+ SC_CTOR(TB) : m_all("all"), m_none("none"), m_one("one")
+ {
+ SC_CTHREAD(thread, m_clk.pos());
+ }
+ void thread()
+ {
+ for (;;)
+ {
+ wait();
+ cout << sc_time_stamp() << ":" << endl;
+ cout << " all[0] = " << m_all[0]->read() << endl;
+ cout << " all[1] = " << m_all[1]->read() << endl;
+ cout << " one = " << m_one->read() << endl;
+# if defined(BIND_NONE)
+ cout << " none = " << m_none->read() << endl;
+# endif
+ }
+ }
+ sc_port<sc_signal_in_if<bool>,2,SC_ALL_BOUND> m_all;
+ sc_in<bool> m_clk;
+ sc_port<sc_signal_in_if<bool>,2,SC_ZERO_OR_MORE_BOUND> m_none;
+ sc_port<sc_signal_in_if<bool>,2,SC_ONE_OR_MORE_BOUND> m_one;
+};
+
+int sc_main (int argc , char *argv[]) {
+ sc_clock clock;
+ sc_signal<bool> sig1;
+ sc_signal<bool> sig2;
+
+ TB tb("tb");
+
+ tb.m_clk(clock);
+
+# if !defined(ONE_ERROR)
+ tb.m_one(sig1);
+# endif
+# if defined(BIND_NONE)
+ tb.m_none(sig2);
+# endif
+ tb.m_all(sig1);
+# if !defined(ALL_ERROR)
+ tb.m_all(sig2);
+# endif
+
+ sc_start(1, SC_NS);
+ sig1 = true;
+ sc_start(1, SC_NS);
+ sig2 = true;
+ sc_start(1, SC_NS);
+ sig1 = false;
+ sig2 = false;
+ sc_start(1, SC_NS);
+ return 0;
+}
+
diff --git a/src/systemc/tests/systemc/communication/sc_port_policy/test04/golden/test04.log b/src/systemc/tests/systemc/communication/sc_port_policy/test04/golden/test04.log
new file mode 100644
index 000000000..ee4a4baaf
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_port_policy/test04/golden/test04.log
@@ -0,0 +1,4 @@
+SystemC Simulation
+
+Error: (E109) complete binding failed: 1 actual binds is less than required 2: port 'tb.all' (sc_port)
+In file: <removed by verify.pl>
diff --git a/src/systemc/tests/systemc/communication/sc_port_policy/test04/test04.cpp b/src/systemc/tests/systemc/communication/sc_port_policy/test04/test04.cpp
new file mode 100644
index 000000000..8f202dc11
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_port_policy/test04/test04.cpp
@@ -0,0 +1,100 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ test04.cpp -- Test bind policy: all required not bound.
+
+ Original Author: Andy Goodrich, Forte Design Systems, 02 September 2005
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+#include <systemc.h>
+
+#define ALL_ERROR // Force error on all bound port.
+// #define BIND_NONE // Bind port with zero or more bound.
+// #define ONE_ERROR // Force error on one or more bound port.
+
+SC_MODULE(TB)
+{
+ SC_CTOR(TB) : m_all("all"), m_none("none"), m_one("one")
+ {
+ SC_CTHREAD(thread, m_clk.pos());
+ }
+ void thread()
+ {
+ for (;;)
+ {
+ wait();
+ cout << sc_time_stamp() << ":" << endl;
+ cout << " all[0] = " << m_all[0]->read() << endl;
+ cout << " all[1] = " << m_all[1]->read() << endl;
+ cout << " one = " << m_one->read() << endl;
+# if defined(BIND_NONE)
+ cout << " none = " << m_none->read() << endl;
+# endif
+ }
+ }
+ sc_port<sc_signal_in_if<bool>,2,SC_ALL_BOUND> m_all;
+ sc_in<bool> m_clk;
+ sc_port<sc_signal_in_if<bool>,2,SC_ZERO_OR_MORE_BOUND> m_none;
+ sc_port<sc_signal_in_if<bool>,2,SC_ONE_OR_MORE_BOUND> m_one;
+};
+
+int sc_main (int argc , char *argv[]) {
+ sc_clock clock;
+ sc_signal<bool> sig1;
+ sc_signal<bool> sig2;
+
+ TB tb("tb");
+
+ tb.m_clk(clock);
+
+# if !defined(ONE_ERROR)
+ tb.m_one(sig1);
+# endif
+# if defined(BIND_NONE)
+ tb.m_none(sig2);
+# endif
+ tb.m_all(sig1);
+# if !defined(ALL_ERROR)
+ tb.m_all(sig2);
+# endif
+
+ sc_start(1, SC_NS);
+ sig1 = true;
+ sc_start(1, SC_NS);
+ sig2 = true;
+ sc_start(1, SC_NS);
+ sig1 = false;
+ sig2 = false;
+ sc_start(1, SC_NS);
+ return 0;
+}
+
diff --git a/src/systemc/tests/systemc/communication/sc_port_policy/test05/golden/test05.log b/src/systemc/tests/systemc/communication/sc_port_policy/test05/golden/test05.log
new file mode 100644
index 000000000..833e3177e
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_port_policy/test05/golden/test05.log
@@ -0,0 +1,6 @@
+SystemC Simulation
+m_all_bound_4[0] = 0
+m_all_bound_4[1] = 1
+m_all_bound_4[2] = 2
+m_all_bound_4[3] = 3
+Program completed
diff --git a/src/systemc/tests/systemc/communication/sc_port_policy/test05/test05.cpp b/src/systemc/tests/systemc/communication/sc_port_policy/test05/test05.cpp
new file mode 100644
index 000000000..c50ee616b
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_port_policy/test05/test05.cpp
@@ -0,0 +1,101 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ test05.cpp -- test of binding w/zero bound port and binding after the fact.
+
+ Original Author: Andy Goodrich, Forte Design Systems, 2005-09-12
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// test of binding with zero bound port and binding after the fact.
+
+
+#include "systemc.h"
+
+SC_MODULE(DUT)
+{
+ SC_CTOR(DUT) :
+ m_all_bound_0("all_bound_0"),
+ m_all_bound_4("all_bound_4"),
+ m_one_or_more_2("one_or_more_2"),
+ m_zero_or_more_2("zero_or_more_2")
+ {
+ SC_CTHREAD(thread,m_clk.pos());
+
+ m_all_bound_0(m_signal_0); // 1
+
+ m_all_bound_4(m_all_bound_0); // 1
+ m_all_bound_4(m_one_or_more_2); // 2 and 3
+ m_all_bound_4(m_zero_or_more_2);
+ m_all_bound_4(m_signal_3); // 4
+ m_all_bound_4(m_zero_or_more_2);
+
+ m_one_or_more_2(m_signal_1); // 1
+ m_one_or_more_2(m_signal_2); // 2
+ }
+ void thread()
+ {
+ m_signal_0 = 0;
+ m_signal_1 = 1;
+ m_signal_2 = 2;
+ m_signal_3 = 3;
+ for (;;)
+ {
+ wait();
+ cout << "m_all_bound_4[0] = " << m_all_bound_4[0]->read() << endl;
+ cout << "m_all_bound_4[1] = " << m_all_bound_4[1]->read() << endl;
+ cout << "m_all_bound_4[2] = " << m_all_bound_4[2]->read() << endl;
+ cout << "m_all_bound_4[3] = " << m_all_bound_4[3]->read() << endl;
+ }
+ }
+ sc_in<bool> m_clk;
+
+ sc_port<sc_signal_in_if<int>,0,SC_ALL_BOUND> m_all_bound_0;
+ sc_port<sc_signal_in_if<int>,4,SC_ALL_BOUND> m_all_bound_4;
+ sc_port<sc_signal_in_if<int>,2,SC_ONE_OR_MORE_BOUND> m_one_or_more_2;
+ sc_signal<int> m_signal_0;
+ sc_signal<int> m_signal_1;
+ sc_signal<int> m_signal_2;
+ sc_signal<int> m_signal_3;
+ sc_port<sc_signal_in_if<int>,2,SC_ZERO_OR_MORE_BOUND> m_zero_or_more_2;
+};
+int sc_main(int argc, char* argv[])
+{
+ sc_clock clock;
+ DUT dut("dut");
+
+ dut.m_clk(clock);
+
+ sc_start(2, SC_NS);
+
+ cout << "Program completed" << endl;
+ return 0;
+}