From 16fa8d7cc8c92f5ab879e4cf9c6c0bbb3567860f Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 24 May 2018 01:37:55 -0700 Subject: systemc: Import tests from the Accellera systemc distribution. Change-Id: Iad76b398949a55d768a34d027a2d8e3739953da6 Reviewed-on: https://gem5-review.googlesource.com/10845 Reviewed-by: Giacomo Travaglini Maintainer: Gabe Black --- .../sc_prim_channel/test01/golden/test01.log | 3 + .../sc_prim_channel/test01/test01.cpp | 139 ++++++++++++++++++ .../sc_prim_channel/test02/golden/test02.log | 21 +++ .../sc_prim_channel/test02/test02.cpp | 144 +++++++++++++++++++ .../sc_prim_channel/test03/golden/test03.log | 15 ++ .../sc_prim_channel/test03/test03.cpp | 140 ++++++++++++++++++ .../sc_prim_channel/test04/golden/test04.log | 22 +++ .../sc_prim_channel/test04/test04.cpp | 148 +++++++++++++++++++ .../sc_prim_channel/test05/golden/test05.log | 26 ++++ .../sc_prim_channel/test05/test05.cpp | 152 ++++++++++++++++++++ .../sc_prim_channel/test06/golden/test06.log | 27 ++++ .../sc_prim_channel/test06/test06.cpp | 151 ++++++++++++++++++++ .../sc_prim_channel/test07/golden/test07.log | 22 +++ .../sc_prim_channel/test07/test07.cpp | 149 +++++++++++++++++++ .../sc_prim_channel/test08/golden/test08.log | 26 ++++ .../sc_prim_channel/test08/test08.cpp | 154 ++++++++++++++++++++ .../sc_prim_channel/test09/golden/test09.log | 27 ++++ .../sc_prim_channel/test09/test09.cpp | 153 ++++++++++++++++++++ .../sc_prim_channel/test10/golden/test10.log | 14 ++ .../sc_prim_channel/test10/test10.cpp | 145 +++++++++++++++++++ .../sc_prim_channel/test11/golden/test11.log | 22 +++ .../sc_prim_channel/test11/test11.cpp | 152 ++++++++++++++++++++ .../sc_prim_channel/test12/golden/test12.log | 19 +++ .../sc_prim_channel/test12/test12.cpp | 144 +++++++++++++++++++ .../sc_prim_channel/test13/golden/test13.log | 20 +++ .../sc_prim_channel/test13/test13.cpp | 155 ++++++++++++++++++++ .../sc_prim_channel/test14/golden/test14.log | 20 +++ .../sc_prim_channel/test14/test14.cpp | 154 ++++++++++++++++++++ .../sc_prim_channel/test15/golden/test15.log | 24 ++++ .../sc_prim_channel/test15/test15.cpp | 156 ++++++++++++++++++++ .../sc_prim_channel/test16/golden/test16.log | 24 ++++ .../sc_prim_channel/test16/test16.cpp | 157 +++++++++++++++++++++ .../sc_prim_channel/test17/golden/test17.log | 25 ++++ .../sc_prim_channel/test17/test17.cpp | 156 ++++++++++++++++++++ .../sc_prim_channel/test18/golden/test18.log | 25 ++++ .../sc_prim_channel/test18/test18.cpp | 157 +++++++++++++++++++++ .../sc_prim_channel/test19/golden/test19.log | 11 ++ .../sc_prim_channel/test19/test19.cpp | 149 +++++++++++++++++++ .../sc_prim_channel/test20/golden/test20.log | 19 +++ .../sc_prim_channel/test20/test20.cpp | 156 ++++++++++++++++++++ 40 files changed, 3423 insertions(+) create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test01/golden/test01.log create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test01/test01.cpp create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test02/golden/test02.log create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test02/test02.cpp create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test03/golden/test03.log create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test03/test03.cpp create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test04/golden/test04.log create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test04/test04.cpp create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test05/golden/test05.log create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test05/test05.cpp create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test06/golden/test06.log create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test06/test06.cpp create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test07/golden/test07.log create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test07/test07.cpp create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test08/golden/test08.log create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test08/test08.cpp create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test09/golden/test09.log create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test09/test09.cpp create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test10/golden/test10.log create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test10/test10.cpp create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test11/golden/test11.log create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test11/test11.cpp create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test12/golden/test12.log create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test12/test12.cpp create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test13/golden/test13.log create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test13/test13.cpp create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test14/golden/test14.log create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test14/test14.cpp create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test15/golden/test15.log create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test15/test15.cpp create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test16/golden/test16.log create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test16/test16.cpp create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test17/golden/test17.log create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test17/test17.cpp create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test18/golden/test18.log create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test18/test18.cpp create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test19/golden/test19.log create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test19/test19.cpp create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test20/golden/test20.log create mode 100644 src/systemc/tests/systemc/communication/sc_prim_channel/test20/test20.cpp (limited to 'src/systemc/tests/systemc/communication/sc_prim_channel') diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test01/golden/test01.log b/src/systemc/tests/systemc/communication/sc_prim_channel/test01/golden/test01.log new file mode 100644 index 000000000..510988bc1 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test01/golden/test01.log @@ -0,0 +1,3 @@ +SystemC Simulation +simulation time:0 s writting 0 to channel +simulation time:0 s reading 0 from channel diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test01/test01.cpp b/src/systemc/tests/systemc/communication/sc_prim_channel/test01/test01.cpp new file mode 100644 index 000000000..87fb28e29 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test01/test01.cpp @@ -0,0 +1,139 @@ +/***************************************************************************** + + 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 -- + + Original Author: Ucar Aziz, Synopsys, Inc., 2002-02-15 + Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +//test of sc_prim_channel::next_trigger() + +#include + +//write and read interfaces +class write_if : virtual public +sc_interface + { + public: + virtual void write() = 0; +}; + +class read_if : virtual public +sc_interface +{ + public: + virtual void read( ) = 0; +}; + +// channel implements write_if and read_if interfaces +class channel : + public sc_channel, + public write_if, + public read_if +{ + + public : + + //constructor + channel(sc_module_name name):sc_channel(name), data(0) + { } + + //write to channel + void write(){ + static int i = 0; + next_trigger(); + data = i; + cout <<"simulation time" << ":" << sc_time_stamp()<<" "; + cout<<"writting "<< data <<" to channel" << endl; + i++; + } + + //read from channel + void read( ){ + int j; + next_trigger(); + j = data; + cout <<"simulation time" << ":" << sc_time_stamp(); + cout<<" reading "< out; + + void write( ) + { + out->write(); + } + + SC_CTOR( mod_a ){ + + SC_METHOD(write); + } +}; + +//sink module +SC_MODULE(mod_b) +{ + sc_port input; + int i; + + void read( ) + { + input->read(); + } + + SC_CTOR( mod_b ){ + + SC_METHOD(read); + } +}; + + +int sc_main(int, char*[] ) +{ + channel a("a"); + mod_a modul_a("modul_a"); + mod_b modul_b("modul_b"); + modul_a.out(a); + modul_b.input(a); + + sc_start(10, SC_NS); + return 0 ; +} diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test02/golden/test02.log b/src/systemc/tests/systemc/communication/sc_prim_channel/test02/golden/test02.log new file mode 100644 index 000000000..531039f15 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test02/golden/test02.log @@ -0,0 +1,21 @@ +SystemC Simulation +writting 0 to channel and notifying write_event +reading 0 from channel and notifying read_event +writting 1 to channel and notifying write_event +reading 1 from channel and notifying read_event +writting 2 to channel and notifying write_event +reading 2 from channel and notifying read_event +writting 3 to channel and notifying write_event +reading 3 from channel and notifying read_event +writting 4 to channel and notifying write_event +reading 4 from channel and notifying read_event +writting 5 to channel and notifying write_event +reading 5 from channel and notifying read_event +writting 6 to channel and notifying write_event +reading 6 from channel and notifying read_event +writting 7 to channel and notifying write_event +reading 7 from channel and notifying read_event +writting 8 to channel and notifying write_event +reading 8 from channel and notifying read_event +writting 9 to channel and notifying write_event +reading 9 from channel and notifying read_event diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test02/test02.cpp b/src/systemc/tests/systemc/communication/sc_prim_channel/test02/test02.cpp new file mode 100644 index 000000000..c0c0c2a7a --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test02/test02.cpp @@ -0,0 +1,144 @@ +/***************************************************************************** + + 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 -- + + Original Author: Ucar Aziz, Synopsys, Inc., 2002-02-15 + Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +//test of sc_prim_channel::next_trigger(const sc_event&) + +#include + +//write and read interfaces +class write_if : virtual public +sc_interface + { + public: + virtual void write() = 0; +}; + +class read_if : virtual public +sc_interface +{ + public: + virtual void read( ) = 0; +}; + +// channel implements write_if and read_if interfaces +class channel : + public sc_channel, + public write_if, + public read_if +{ + + public : + + //constructor + channel(sc_module_name name):sc_channel(name) , data(0) + { } + + //write to channel + void write(){ + static int i = 0; + if(i < 10){ + next_trigger(read_event); + data = i; + cout<<"writting "<< data <<" to channel"; + i++; + cout<<" and notifying write_event" << endl; + write_event.notify(); + } + } + + //read from channel + void read( ){ + int j; + next_trigger(write_event); + j = data; + cout<<"reading "< out; + + void write( ) + { + out->write(); + } + + SC_CTOR( mod_a ){ + + SC_METHOD(write); + } +}; + +//sink module +SC_MODULE(mod_b) +{ + sc_port input; + int i; + + void read( ) + { + input->read(); + } + + SC_CTOR( mod_b ){ + + SC_METHOD(read); + } +}; + + +int sc_main(int, char*[] ) +{ + channel a("a"); + mod_a modul_a("modul_a"); + mod_b modul_b("modul_b"); + modul_a.out(a); + modul_b.input(a); + + sc_start(10, SC_NS); + return 0 ; +} diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test03/golden/test03.log b/src/systemc/tests/systemc/communication/sc_prim_channel/test03/golden/test03.log new file mode 100644 index 000000000..f783e1cb6 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test03/golden/test03.log @@ -0,0 +1,15 @@ +SystemC Simulation +simulation time:0 s writting 0 to channel +simulation time:0 s reading 0 from channel +simulation time:10 ns writting 1 to channel +simulation time:10 ns reading 1 from channel +simulation time:20 ns writting 2 to channel +simulation time:20 ns reading 2 from channel +simulation time:30 ns writting 3 to channel +simulation time:30 ns reading 3 from channel +simulation time:40 ns writting 4 to channel +simulation time:40 ns reading 4 from channel +simulation time:50 ns writting 5 to channel +simulation time:50 ns reading 5 from channel +simulation time:60 ns writting 6 to channel +simulation time:60 ns reading 6 from channel diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test03/test03.cpp b/src/systemc/tests/systemc/communication/sc_prim_channel/test03/test03.cpp new file mode 100644 index 000000000..07554c293 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test03/test03.cpp @@ -0,0 +1,140 @@ +/***************************************************************************** + + 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 -- + + Original Author: Ucar Aziz, Synopsys, Inc., 2002-02-15 + Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +//test of sc_prim_channel::next_trigger(const sc_time&) + +#include + +//write and read interfaces +class write_if : virtual public +sc_interface + { + public: + virtual void write() = 0; +}; + +class read_if : virtual public +sc_interface +{ + public: + virtual void read( ) = 0; +}; + +// channel implements write_if and read_if interfaces +class channel : + public sc_channel, + public write_if, + public read_if +{ + + public : + + //constructor + channel(sc_module_name name):sc_channel(name) , data(0) + { } + + //write to channel + void write(){ + static int i = 0; + next_trigger(10, SC_NS); + data = i; + cout <<"simulation time" << ":" << sc_time_stamp()<<" "; + cout<<"writting "<< data <<" to channel" << endl; + i++; + } + + //read from channel + void read( ){ + int j; + sc_time t(10, SC_NS); + next_trigger(t); + j = data; + cout <<"simulation time" << ":" << sc_time_stamp(); + cout<<" reading "< out; + + void write( ) + { + out->write(); + } + + SC_CTOR( mod_a ){ + + SC_METHOD(write); + } +}; + +//sink module +SC_MODULE(mod_b) +{ + sc_port input; + int i; + + void read( ) + { + input->read(); + } + + SC_CTOR( mod_b ){ + + SC_METHOD(read); + } +}; + + +int sc_main(int, char*[] ) +{ + channel a("a"); + mod_a modul_a("modul_a"); + mod_b modul_b("modul_b"); + modul_a.out(a); + modul_b.input(a); + + sc_start(70, SC_NS); + return 0 ; +} diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test04/golden/test04.log b/src/systemc/tests/systemc/communication/sc_prim_channel/test04/golden/test04.log new file mode 100644 index 000000000..da6325102 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test04/golden/test04.log @@ -0,0 +1,22 @@ +SystemC Simulation +simulation time:0 s writting 0 to channel +simulation time:0 s reading 0 from channel +simulation time:10 ns writting 1 to channel +simulation time:10 ns reading 1 from channel +simulation time:20 ns reading 1 from channel +simulation time:20 ns writting 2 to channel +simulation time:30 ns reading 2 from channel +simulation time:30 ns writting 3 to channel +simulation time:40 ns reading 3 from channel +simulation time:40 ns writting 4 to channel +simulation time:50 ns reading 4 from channel +simulation time:50 ns writting 5 to channel +simulation time:55 ns reading 5 from channel +simulation time:60 ns writting 6 to channel +simulation time:65 ns reading 6 from channel +simulation time:70 ns writting 7 to channel +simulation time:75 ns reading 7 from channel +simulation time:80 ns writting 8 to channel +simulation time:85 ns reading 8 from channel +simulation time:90 ns writting 9 to channel +simulation time:95 ns reading 9 from channel diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test04/test04.cpp b/src/systemc/tests/systemc/communication/sc_prim_channel/test04/test04.cpp new file mode 100644 index 000000000..395186f17 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test04/test04.cpp @@ -0,0 +1,148 @@ +/***************************************************************************** + + 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 -- + + Original Author: Ucar Aziz, Synopsys, Inc., 2002-02-15 + Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +//test of sc_prim_channel::next_trigger(double, sc_time_unit, sc_event&) + +#include + +//write and read interfaces +class write_if : virtual public +sc_interface + { + public: + virtual void write() = 0; +}; + +class read_if : virtual public +sc_interface +{ + public: + virtual void read( ) = 0; +}; + +// channel implements write_if and read_if interfaces +class channel : + public sc_channel, + public write_if, + public read_if +{ + + public : + + //constructor + channel(sc_module_name name):sc_channel(name) , data(0) + { } + + //write to channel + void write(){ + static int i = 0; + next_trigger(10, SC_NS); + data = i; + cout <<"simulation time" << ":" << sc_time_stamp()<<" "; + cout<<"writting "<< data <<" to channel" << endl; + + if(i < 5){ + write_event.notify(20, SC_NS); + } + else { + write_event.notify(5, SC_NS); + } + + i++; + } + + //read from channel + void read( ){ + int j; + next_trigger(10, SC_NS, write_event); + j = data; + cout <<"simulation time" << ":" << sc_time_stamp(); + cout<<" reading "< out; + + void write( ) + { + out->write(); + } + + SC_CTOR( mod_a ){ + + SC_METHOD(write); + } +}; + +//sink module +SC_MODULE(mod_b) +{ + sc_port input; + int i; + + void read( ) + { + input->read(); + } + + SC_CTOR( mod_b ){ + + SC_METHOD(read); + } +}; + + +int sc_main(int, char*[] ) +{ + channel a("a"); + mod_a modul_a("modul_a"); + mod_b modul_b("modul_b"); + modul_a.out(a); + modul_b.input(a); + + sc_start(100, SC_NS); + return 0 ; +} diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test05/golden/test05.log b/src/systemc/tests/systemc/communication/sc_prim_channel/test05/golden/test05.log new file mode 100644 index 000000000..8988b3192 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test05/golden/test05.log @@ -0,0 +1,26 @@ +SystemC Simulation +simulation time:0 s writing 0 to channel +simulation time:0 s reading 0 from channel +simulation time:10 ns writing 1 to channel +simulation time:10 ns reading 1 from channel +simulation time:20 ns reading 1 from channel +simulation time:20 ns writing 2 to channel +simulation time:30 ns reading 2 from channel +simulation time:30 ns writing 3 to channel +simulation time:40 ns reading 3 from channel +simulation time:40 ns writing 4 to channel +simulation time:50 ns reading 4 from channel +simulation time:50 ns writing 5 to channel +simulation time:60 ns reading 5 from channel +simulation time:60 ns writing 6 to channel +simulation time:65 ns reading 6 from channel +simulation time:70 ns writing 7 to channel +simulation time:75 ns reading 7 from channel +simulation time:80 ns writing 8 to channel +simulation time:85 ns reading 8 from channel +simulation time:90 ns writing 9 to channel +simulation time:95 ns reading 9 from channel +simulation time:100 ns writing 10 to channel +simulation time:105 ns reading 10 from channel +simulation time:110 ns writing 11 to channel +simulation time:115 ns reading 11 from channel diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test05/test05.cpp b/src/systemc/tests/systemc/communication/sc_prim_channel/test05/test05.cpp new file mode 100644 index 000000000..60c7624c6 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test05/test05.cpp @@ -0,0 +1,152 @@ +/***************************************************************************** + + 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 -- + + Original Author: Ucar Aziz, Synopsys, Inc., 2002-02-15 + Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +//test of sc_prim_channel::next_trigger(double, sc_time_unit, sc_event_and_list&) + +#include + +//write and read interfaces +class write_if : virtual public +sc_interface + { + public: + virtual void write() = 0; +}; + +class read_if : virtual public +sc_interface +{ + public: + virtual void read( ) = 0; +}; + +// channel implements write_if and read_if interfaces +class channel : + public sc_channel, + public write_if, + public read_if +{ + + public : + + //constructor + channel(sc_module_name name):sc_channel(name) , data(0) + { } + + //write to channel + void write(){ + static int i = 0; + next_trigger(10, SC_NS); + data = i; + cout <<"simulation time" << ":" << sc_time_stamp()<<" "; + cout<<"writing "<< data <<" to channel" << endl; + + if(i < 3){ + write_event_1.notify(20, SC_NS); + } + else if(3 <= i && i < 6) { + write_event_2.notify(5, SC_NS); + } + else{ + write_event_2.notify(5, SC_NS); + write_event_1.notify(5, SC_NS); + } + + i++; + } + + //read from channel + void read( ){ + int j; + next_trigger(10, SC_NS, write_event_1 & write_event_2); + j = data; + cout <<"simulation time" << ":" << sc_time_stamp(); + cout<<" reading "< out; + + void write( ) + { + out->write(); + } + + SC_CTOR( mod_a ){ + + SC_METHOD(write); + } +}; + +//sink module +SC_MODULE(mod_b) +{ + sc_port input; + int i; + + void read( ) + { + input->read(); + } + + SC_CTOR( mod_b ){ + + SC_METHOD(read); + } +}; + + +int sc_main(int, char*[] ) +{ + channel a("a"); + mod_a modul_a("modul_a"); + mod_b modul_b("modul_b"); + modul_a.out(a); + modul_b.input(a); + + sc_start(120, SC_NS); + return 0 ; +} diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test06/golden/test06.log b/src/systemc/tests/systemc/communication/sc_prim_channel/test06/golden/test06.log new file mode 100644 index 000000000..50d5bb719 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test06/golden/test06.log @@ -0,0 +1,27 @@ +SystemC Simulation +simulation time:0 s writting 0 to channel +simulation time:0 s reading 0 from channel +simulation time:10 ns writting 1 to channel +simulation time:10 ns reading 1 from channel +simulation time:20 ns reading 1 from channel +simulation time:20 ns writting 2 to channel +simulation time:30 ns reading 2 from channel +simulation time:30 ns writting 3 to channel +simulation time:35 ns reading 3 from channel +simulation time:40 ns writting 4 to channel +simulation time:45 ns reading 4 from channel +simulation time:50 ns writting 5 to channel +simulation time:55 ns reading 5 from channel +simulation time:60 ns writting 6 to channel +simulation time:65 ns reading 6 from channel +simulation time:66 ns reading 6 from channel +simulation time:70 ns writting 7 to channel +simulation time:76 ns reading 7 from channel +simulation time:80 ns writting 8 to channel +simulation time:86 ns reading 8 from channel +simulation time:90 ns writting 9 to channel +simulation time:96 ns reading 9 from channel +simulation time:100 ns writting 10 to channel +simulation time:106 ns reading 10 from channel +simulation time:110 ns writting 11 to channel +simulation time:116 ns reading 11 from channel diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test06/test06.cpp b/src/systemc/tests/systemc/communication/sc_prim_channel/test06/test06.cpp new file mode 100644 index 000000000..ddfbd5c2a --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test06/test06.cpp @@ -0,0 +1,151 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test06.cpp -- + + Original Author: Ucar Aziz, Synopsys, Inc., 2002-02-15 + Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +//test of sc_prim_channel::next_trigger(double, sc_time_unit, sc_event_or_list&) + +#include + +//write and read interfaces +class write_if : virtual public +sc_interface + { + public: + virtual void write() = 0; +}; + +class read_if : virtual public +sc_interface +{ + public: + virtual void read( ) = 0; +}; + +// channel implements write_if and read_if interfaces +class channel : + public sc_channel, + public write_if, + public read_if +{ + + public : + + //constructor + channel(sc_module_name name):sc_channel(name) , data(0) + { } + + //write to channel + void write(){ + static int i = 0; + next_trigger(10, SC_NS); + data = i; + cout <<"simulation time" << ":" << sc_time_stamp()<<" "; + cout<<"writting "<< data <<" to channel" << endl; + + if(i < 3){ + write_event_1.notify(20, SC_NS); + } + else if(3 <= i && i < 6) { + write_event_1.notify(5, SC_NS); + } + else{ + write_event_2.notify(6, SC_NS); + } + + i++; + } + + //read from channel + void read( ){ + int j; + next_trigger(10, SC_NS, write_event_1 | write_event_2); + j = data; + cout <<"simulation time" << ":" << sc_time_stamp(); + cout<<" reading "< out; + + void write( ) + { + out->write(); + } + + SC_CTOR( mod_a ){ + + SC_METHOD(write); + } +}; + +//sink module +SC_MODULE(mod_b) +{ + sc_port input; + int i; + + void read( ) + { + input->read(); + } + + SC_CTOR( mod_b ){ + + SC_METHOD(read); + } +}; + + +int sc_main(int, char*[] ) +{ + channel a("a"); + mod_a modul_a("modul_a"); + mod_b modul_b("modul_b"); + modul_a.out(a); + modul_b.input(a); + + sc_start(120, SC_NS); + return 0 ; +} diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test07/golden/test07.log b/src/systemc/tests/systemc/communication/sc_prim_channel/test07/golden/test07.log new file mode 100644 index 000000000..da6325102 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test07/golden/test07.log @@ -0,0 +1,22 @@ +SystemC Simulation +simulation time:0 s writting 0 to channel +simulation time:0 s reading 0 from channel +simulation time:10 ns writting 1 to channel +simulation time:10 ns reading 1 from channel +simulation time:20 ns reading 1 from channel +simulation time:20 ns writting 2 to channel +simulation time:30 ns reading 2 from channel +simulation time:30 ns writting 3 to channel +simulation time:40 ns reading 3 from channel +simulation time:40 ns writting 4 to channel +simulation time:50 ns reading 4 from channel +simulation time:50 ns writting 5 to channel +simulation time:55 ns reading 5 from channel +simulation time:60 ns writting 6 to channel +simulation time:65 ns reading 6 from channel +simulation time:70 ns writting 7 to channel +simulation time:75 ns reading 7 from channel +simulation time:80 ns writting 8 to channel +simulation time:85 ns reading 8 from channel +simulation time:90 ns writting 9 to channel +simulation time:95 ns reading 9 from channel diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test07/test07.cpp b/src/systemc/tests/systemc/communication/sc_prim_channel/test07/test07.cpp new file mode 100644 index 000000000..b1b18185c --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test07/test07.cpp @@ -0,0 +1,149 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test07.cpp -- + + Original Author: Ucar Aziz, Synopsys, Inc., 2002-02-15 + Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// test of sc_prim_channel::next_trigger(const sc_time&, sc_event&) + +#include + +//write and read interfaces +class write_if : virtual public +sc_interface + { + public: + virtual void write() = 0; +}; + +class read_if : virtual public +sc_interface +{ + public: + virtual void read( ) = 0; +}; + +// channel implements write_if and read_if interfaces +class channel : + public sc_channel, + public write_if, + public read_if +{ + + public : + + //constructor + channel(sc_module_name name):sc_channel(name) , data(0) + { } + + //write to channel + void write(){ + static int i = 0; + next_trigger(10, SC_NS); + data = i; + cout <<"simulation time" << ":" << sc_time_stamp()<<" "; + cout<<"writting "<< data <<" to channel" << endl; + + if(i < 5){ + write_event.notify(20, SC_NS); + } + else { + write_event.notify(5, SC_NS); + } + + i++; + } + + //read from channel + void read( ){ + int j; + const sc_time t(10, SC_NS); + next_trigger(t, write_event); + j = data; + cout <<"simulation time" << ":" << sc_time_stamp(); + cout<<" reading "< out; + + void write( ) + { + out->write(); + } + + SC_CTOR( mod_a ){ + + SC_METHOD(write); + } +}; + +//sink module +SC_MODULE(mod_b) +{ + sc_port input; + int i; + + void read( ) + { + input->read(); + } + + SC_CTOR( mod_b ){ + + SC_METHOD(read); + } +}; + + +int sc_main(int, char*[] ) +{ + channel a("a"); + mod_a modul_a("modul_a"); + mod_b modul_b("modul_b"); + modul_a.out(a); + modul_b.input(a); + + sc_start(100, SC_NS); + return 0 ; +} diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test08/golden/test08.log b/src/systemc/tests/systemc/communication/sc_prim_channel/test08/golden/test08.log new file mode 100644 index 000000000..8988b3192 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test08/golden/test08.log @@ -0,0 +1,26 @@ +SystemC Simulation +simulation time:0 s writing 0 to channel +simulation time:0 s reading 0 from channel +simulation time:10 ns writing 1 to channel +simulation time:10 ns reading 1 from channel +simulation time:20 ns reading 1 from channel +simulation time:20 ns writing 2 to channel +simulation time:30 ns reading 2 from channel +simulation time:30 ns writing 3 to channel +simulation time:40 ns reading 3 from channel +simulation time:40 ns writing 4 to channel +simulation time:50 ns reading 4 from channel +simulation time:50 ns writing 5 to channel +simulation time:60 ns reading 5 from channel +simulation time:60 ns writing 6 to channel +simulation time:65 ns reading 6 from channel +simulation time:70 ns writing 7 to channel +simulation time:75 ns reading 7 from channel +simulation time:80 ns writing 8 to channel +simulation time:85 ns reading 8 from channel +simulation time:90 ns writing 9 to channel +simulation time:95 ns reading 9 from channel +simulation time:100 ns writing 10 to channel +simulation time:105 ns reading 10 from channel +simulation time:110 ns writing 11 to channel +simulation time:115 ns reading 11 from channel diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test08/test08.cpp b/src/systemc/tests/systemc/communication/sc_prim_channel/test08/test08.cpp new file mode 100644 index 000000000..9f8ae16fa --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test08/test08.cpp @@ -0,0 +1,154 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test08.cpp -- + + Original Author: Ucar Aziz, Synopsys, Inc., 2002-02-15 + Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// test of sc_prim_channel::next_trigger(sc_time&, sc_event_and_list&) + +#include + +//write and read interfaces +class write_if : virtual public +sc_interface + { + public: + virtual void write() = 0; +}; + +class read_if : virtual public +sc_interface +{ + public: + virtual void read( ) = 0; +}; + +// channel implements write_if and read_if interfaces +class channel : + public sc_channel, + public write_if, + public read_if +{ + + public : + + //constructor + channel(sc_module_name name):sc_channel(name) , data(0) + { } + + //write to channel + void write(){ + static int i = 0; + next_trigger(10, SC_NS); + data = i; + + cout <<"simulation time" << ":" << sc_time_stamp()<<" "; + cout<<"writing "<< data <<" to channel" << endl; + + if(i < 3){ + write_event_1.notify(20, SC_NS); + } + else if(3 <= i && i < 6) { + write_event_2.notify(5, SC_NS); + } + else{ + write_event_2.notify(5, SC_NS); + write_event_1.notify(5, SC_NS); + } + + i++; + } + + //read from channel + void read( ){ + int j; + const sc_time t(10, SC_NS); + next_trigger(t, write_event_1 & write_event_2); + j = data; + cout <<"simulation time" << ":" << sc_time_stamp(); + cout<<" reading "< out; + + void write( ) + { + out->write(); + } + + SC_CTOR( mod_a ){ + + SC_METHOD(write); + } +}; + +//sink module +SC_MODULE(mod_b) +{ + sc_port input; + int i; + + void read( ) + { + input->read(); + } + + SC_CTOR( mod_b ){ + + SC_METHOD(read); + } +}; + + +int sc_main(int, char*[] ) +{ + channel a("a"); + mod_a modul_a("modul_a"); + mod_b modul_b("modul_b"); + modul_a.out(a); + modul_b.input(a); + + sc_start(120, SC_NS); + return 0 ; +} diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test09/golden/test09.log b/src/systemc/tests/systemc/communication/sc_prim_channel/test09/golden/test09.log new file mode 100644 index 000000000..0886c231e --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test09/golden/test09.log @@ -0,0 +1,27 @@ +SystemC Simulation +simulation time:0 s writing 0 to channel +simulation time:0 s reading 0 from channel +simulation time:10 ns writing 1 to channel +simulation time:10 ns reading 1 from channel +simulation time:20 ns reading 1 from channel +simulation time:20 ns writing 2 to channel +simulation time:30 ns reading 2 from channel +simulation time:30 ns writing 3 to channel +simulation time:35 ns reading 3 from channel +simulation time:40 ns writing 4 to channel +simulation time:45 ns reading 4 from channel +simulation time:50 ns writing 5 to channel +simulation time:55 ns reading 5 from channel +simulation time:60 ns writing 6 to channel +simulation time:65 ns reading 6 from channel +simulation time:66 ns reading 6 from channel +simulation time:70 ns writing 7 to channel +simulation time:76 ns reading 7 from channel +simulation time:80 ns writing 8 to channel +simulation time:86 ns reading 8 from channel +simulation time:90 ns writing 9 to channel +simulation time:96 ns reading 9 from channel +simulation time:100 ns writing 10 to channel +simulation time:106 ns reading 10 from channel +simulation time:110 ns writing 11 to channel +simulation time:116 ns reading 11 from channel diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test09/test09.cpp b/src/systemc/tests/systemc/communication/sc_prim_channel/test09/test09.cpp new file mode 100644 index 000000000..d474a086d --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test09/test09.cpp @@ -0,0 +1,153 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test09.cpp -- + + Original Author: Ucar Aziz, Synopsys, Inc., 2002-02-15 + Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// test of sc_prim_channel::next_trigger(const sc_time&, sc_event_or_list&) + +#include + +//write and read interfaces +class write_if : virtual public +sc_interface + { + public: + virtual void write() = 0; +}; + +class read_if : virtual public +sc_interface +{ + public: + virtual void read( ) = 0; +}; + +// channel implements write_if and read_if interfaces +class channel : + public sc_channel, + public write_if, + public read_if +{ + + public : + + //constructor + channel(sc_module_name name):sc_channel(name) , data(0) + { } + + //write to channel + void write(){ + static int i = 0; + sc_time t1(10, SC_NS); + next_trigger(t1); + data = i; + cout <<"simulation time" << ":" << sc_time_stamp()<<" "; + cout<<"writing "<< data <<" to channel" << endl; + + if(i < 3){ + write_event_1.notify(20, SC_NS); + } + else if(3 <= i & i < 6) { + write_event_1.notify(5, SC_NS); + } + else{ + write_event_2.notify(6, SC_NS); + } + + i++; + } + + //read from channel + void read( ){ + int j; + sc_time t2(10, SC_NS); + next_trigger(t2, write_event_1 | write_event_2); + j = data; + cout <<"simulation time" << ":" << sc_time_stamp(); + cout<<" reading "< out; + + void write( ) + { + out->write(); + } + + SC_CTOR( mod_a ){ + + SC_METHOD(write); + } +}; + +//sink module +SC_MODULE(mod_b) +{ + sc_port input; + int i; + + void read( ) + { + input->read(); + } + + SC_CTOR( mod_b ){ + + SC_METHOD(read); + } +}; + + +int sc_main(int, char*[] ) +{ + channel a("a"); + mod_a modul_a("modul_a"); + mod_b modul_b("modul_b"); + modul_a.out(a); + modul_b.input(a); + + sc_start(120, SC_NS); + return 0 ; +} diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test10/golden/test10.log b/src/systemc/tests/systemc/communication/sc_prim_channel/test10/golden/test10.log new file mode 100644 index 000000000..0385702b3 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test10/golden/test10.log @@ -0,0 +1,14 @@ +SystemC Simulation +simulation time:0 s writting 0 to channel +simulation time:0 s reading 0 from channel +simulation time:5 ns reading 0 from channel +simulation time:10 ns writting 1 to channel +simulation time:15 ns reading 1 from channel +simulation time:20 ns writting 2 to channel +simulation time:25 ns reading 2 from channel +simulation time:30 ns writting 3 to channel +simulation time:35 ns reading 3 from channel +simulation time:40 ns writting 4 to channel +simulation time:45 ns reading 4 from channel +simulation time:50 ns writting 5 to channel +simulation time:55 ns reading 5 from channel diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test10/test10.cpp b/src/systemc/tests/systemc/communication/sc_prim_channel/test10/test10.cpp new file mode 100644 index 000000000..e28fd2a6f --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test10/test10.cpp @@ -0,0 +1,145 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test10.cpp -- + + Original Author: Ucar Aziz, Synopsys, Inc., 2002-02-15 + Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// test of sc_prim_channel::next_trigger(sc_event_and_list&) + +#include + +//write and read interfaces +class write_if : virtual public +sc_interface + { + public: + virtual void write() = 0; +}; + +class read_if : virtual public +sc_interface +{ + public: + virtual void read( ) = 0; +}; + +// channel implements write_if and read_if interfaces +class channel : + public sc_channel, + public write_if, + public read_if +{ + + public : + + //constructor + channel(sc_module_name name):sc_channel(name) , data(0) + { } + + //write to channel + void write(){ + static int i = 0; + next_trigger(10, SC_NS); + data = i; + cout <<"simulation time" << ":" << sc_time_stamp()<<" "; + cout<<"writting "<< data <<" to channel" << endl; + + write_event_2.notify(5, SC_NS); + write_event_1.notify(5, SC_NS); + + + i++; + } + + //read from channel + void read( ){ + int j; + next_trigger(write_event_1 & write_event_2); + j = data; + cout <<"simulation time" << ":" << sc_time_stamp(); + cout<<" reading "< out; + + void write( ) + { + out->write(); + } + + SC_CTOR( mod_a ){ + + SC_METHOD(write); + } +}; + +//sink module +SC_MODULE(mod_b) +{ + sc_port input; + int i; + + void read( ) + { + input->read(); + } + + SC_CTOR( mod_b ){ + + SC_METHOD(read); + } +}; + + +int sc_main(int, char*[] ) +{ + channel a("a"); + mod_a modul_a("modul_a"); + mod_b modul_b("modul_b"); + modul_a.out(a); + modul_b.input(a); + + sc_start(60, SC_NS); + return 0 ; +} diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test11/golden/test11.log b/src/systemc/tests/systemc/communication/sc_prim_channel/test11/golden/test11.log new file mode 100644 index 000000000..e48baf7c5 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test11/golden/test11.log @@ -0,0 +1,22 @@ +SystemC Simulation +simulation time:0 s writting 0 to channel +simulation time:0 s reading 0 from channel +simulation time:5 ns reading 0 from channel +simulation time:20 ns writting 1 to channel +simulation time:25 ns reading 1 from channel +simulation time:40 ns writting 2 to channel +simulation time:45 ns reading 2 from channel +simulation time:60 ns writting 3 to channel +simulation time:70 ns reading 3 from channel +simulation time:80 ns writting 4 to channel +simulation time:90 ns reading 4 from channel +simulation time:100 ns writting 5 to channel +simulation time:110 ns reading 5 from channel +simulation time:120 ns writting 6 to channel +simulation time:135 ns reading 6 from channel +simulation time:140 ns writting 7 to channel +simulation time:155 ns reading 7 from channel +simulation time:160 ns writting 8 to channel +simulation time:175 ns reading 8 from channel +simulation time:180 ns writting 9 to channel +simulation time:195 ns reading 9 from channel diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test11/test11.cpp b/src/systemc/tests/systemc/communication/sc_prim_channel/test11/test11.cpp new file mode 100644 index 000000000..e85090b16 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test11/test11.cpp @@ -0,0 +1,152 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test11.cpp -- + + Original Author: Ucar Aziz, Synopsys, Inc., 2002-02-15 + Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// test of sc_prim_channel::next_trigger(sc_event_or_list&) + +#include + +//write and read interfaces +class write_if : virtual public +sc_interface + { + public: + virtual void write() = 0; +}; + +class read_if : virtual public +sc_interface +{ + public: + virtual void read( ) = 0; +}; + +// channel implements write_if and read_if interfaces +class channel : + public sc_channel, + public write_if, + public read_if +{ + + public : + + //constructor + channel(sc_module_name name):sc_channel(name), data(0) + { } + + //write to channel + void write(){ + static int i = 0; + next_trigger(20, SC_NS); + data = i; + cout <<"simulation time" << ":" << sc_time_stamp()<<" "; + cout<<"writting "<< data <<" to channel" << endl; + + if(i < 3){ + write_event_1.notify(5, SC_NS); + write_event_1.notify(5, SC_NS); + } + else if(3 <= i & i < 6) { + write_event_1.notify(10, SC_NS); + } + else{ + write_event_2.notify(15, SC_NS); + } + + i++; + } + + //read from channel + void read( ){ + int j; + next_trigger(write_event_1 | write_event_2); + j = data; + cout <<"simulation time" << ":" << sc_time_stamp(); + cout<<" reading "< out; + + void write( ) + { + out->write(); + } + + SC_CTOR( mod_a ){ + + SC_METHOD(write); + } +}; + +//sink module +SC_MODULE(mod_b) +{ + sc_port input; + int i; + + void read( ) + { + input->read(); + } + + SC_CTOR( mod_b ){ + + SC_METHOD(read); + } +}; + + +int sc_main(int, char*[] ) +{ + channel a("a"); + mod_a modul_a("modul_a"); + mod_b modul_b("modul_b"); + modul_a.out(a); + modul_b.input(a); + + sc_start(200, SC_NS); + return 0; +} diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test12/golden/test12.log b/src/systemc/tests/systemc/communication/sc_prim_channel/test12/golden/test12.log new file mode 100644 index 000000000..43e07ec75 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test12/golden/test12.log @@ -0,0 +1,19 @@ +SystemC Simulation +simulation time:10 ns writting 0 to channel +simulation time:10 ns reading 0 from channel +simulation time:20 ns writting 1 to channel +simulation time:20 ns reading 1 from channel +simulation time:30 ns writting 2 to channel +simulation time:30 ns reading 2 from channel +simulation time:40 ns writting 3 to channel +simulation time:40 ns reading 3 from channel +simulation time:50 ns writting 4 to channel +simulation time:50 ns reading 4 from channel +simulation time:60 ns writting 5 to channel +simulation time:60 ns reading 5 from channel +simulation time:70 ns writting 6 to channel +simulation time:70 ns reading 6 from channel +simulation time:80 ns writting 7 to channel +simulation time:80 ns reading 7 from channel +simulation time:90 ns writting 8 to channel +simulation time:90 ns reading 8 from channel diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test12/test12.cpp b/src/systemc/tests/systemc/communication/sc_prim_channel/test12/test12.cpp new file mode 100644 index 000000000..6af1bbd22 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test12/test12.cpp @@ -0,0 +1,144 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test12.cpp -- + + Original Author: Ucar Aziz, Synopsys, Inc., 2002-02-15 + Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// test of sc_prim_channel::wait(const sc_time&) + +#include + +//write and read interfaces +class write_if : virtual public +sc_interface + { + public: + virtual void write() = 0; +}; + +class read_if : virtual public +sc_interface +{ + public: + virtual void read( ) = 0; +}; + +// channel implements write_if and read_if interfaces +class channel : + public sc_channel, + public write_if, + public read_if +{ + + public : + + //constructor + channel(sc_module_name name):sc_channel(name) , data(0) + { } + + //write to channel + void write(){ + int i = 0; + sc_time t1(10, SC_NS); + + while(1){ + wait(t1); + data = i; + cout<<"simulation time"<<":"< out; + + void write( ) + { + out->write(); + } + + SC_CTOR( mod_a ){ + + SC_THREAD(write); + } +}; + +//sink module +SC_MODULE(mod_b) +{ + sc_port input; + int i; + + void read( ) + { + input->read(); + } + + SC_CTOR( mod_b ){ + + SC_THREAD(read); + } +}; + + +int sc_main(int, char*[] ) +{ + channel a("a"); + mod_a modul_a("modul_a"); + mod_b modul_b("modul_b"); + modul_a.out(a); + modul_b.input(a); + + sc_start(100, SC_NS); + return 0; +} diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test13/golden/test13.log b/src/systemc/tests/systemc/communication/sc_prim_channel/test13/golden/test13.log new file mode 100644 index 000000000..b5b5202e5 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test13/golden/test13.log @@ -0,0 +1,20 @@ +SystemC Simulation +simulation time:10 ns writting 0 to channel +simulation time:10 ns reading 0 from channel +simulation time:20 ns writting 1 to channel +simulation time:20 ns reading 1 from channel +simulation time:30 ns reading 1 from channel +simulation time:30 ns writting 2 to channel +simulation time:40 ns reading 2 from channel +simulation time:40 ns writting 3 to channel +simulation time:50 ns reading 3 from channel +simulation time:50 ns writting 4 to channel +simulation time:60 ns reading 4 from channel +simulation time:60 ns writting 5 to channel +simulation time:65 ns reading 5 from channel +simulation time:70 ns writting 6 to channel +simulation time:75 ns reading 6 from channel +simulation time:80 ns writting 7 to channel +simulation time:85 ns reading 7 from channel +simulation time:90 ns writting 8 to channel +simulation time:95 ns reading 8 from channel diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test13/test13.cpp b/src/systemc/tests/systemc/communication/sc_prim_channel/test13/test13.cpp new file mode 100644 index 000000000..b26ceafc1 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test13/test13.cpp @@ -0,0 +1,155 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test13.cpp -- + + Original Author: Ucar Aziz, Synopsys, Inc., 2002-02-15 + Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// test of sc_prim_channel::wait(sc_time&, sc_event&) + +#include + +//write and read interfaces +class write_if : virtual public +sc_interface + { + public: + virtual void write() = 0; +}; + +class read_if : virtual public +sc_interface +{ + public: + virtual void read( ) = 0; +}; + +// channel implements write_if and read_if interfaces +class channel : + public sc_channel, + public write_if, + public read_if +{ + + public : + + //constructor + channel(sc_module_name name):sc_channel(name) , data(0) + { } + + //write to channel + void write(){ + int i = 0; + sc_time t(10, SC_NS); + + while(1){ + wait(t); + data = i; + cout <<"simulation time" << ":" << sc_time_stamp()<<" "; + cout<<"writting "<< data <<" to channel" << endl; + + if(i < 5){ + write_event.notify(20, SC_NS); + } + else { + write_event.notify(5, SC_NS); + } + i++; + } + } + + //read from channel + void read( ){ + int j; + sc_time t1(10, SC_NS); + + while(1){ + wait(t1, write_event); + j = data; + cout <<"simulation time" << ":" << sc_time_stamp(); + cout<<" reading "< out; + + void write( ) + { + out->write(); + } + + SC_CTOR( mod_a ){ + + SC_THREAD(write); + } +}; + +//sink module +SC_MODULE(mod_b) +{ + sc_port input; + int i; + + void read( ) + { + input->read(); + } + + SC_CTOR( mod_b ){ + + SC_THREAD(read); + } +}; + + +int sc_main(int, char*[] ) +{ + channel a("a"); + mod_a modul_a("modul_a"); + mod_b modul_b("modul_b"); + modul_a.out(a); + modul_b.input(a); + + sc_start(100, SC_NS); + return 0; +} diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test14/golden/test14.log b/src/systemc/tests/systemc/communication/sc_prim_channel/test14/golden/test14.log new file mode 100644 index 000000000..b5b5202e5 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test14/golden/test14.log @@ -0,0 +1,20 @@ +SystemC Simulation +simulation time:10 ns writting 0 to channel +simulation time:10 ns reading 0 from channel +simulation time:20 ns writting 1 to channel +simulation time:20 ns reading 1 from channel +simulation time:30 ns reading 1 from channel +simulation time:30 ns writting 2 to channel +simulation time:40 ns reading 2 from channel +simulation time:40 ns writting 3 to channel +simulation time:50 ns reading 3 from channel +simulation time:50 ns writting 4 to channel +simulation time:60 ns reading 4 from channel +simulation time:60 ns writting 5 to channel +simulation time:65 ns reading 5 from channel +simulation time:70 ns writting 6 to channel +simulation time:75 ns reading 6 from channel +simulation time:80 ns writting 7 to channel +simulation time:85 ns reading 7 from channel +simulation time:90 ns writting 8 to channel +simulation time:95 ns reading 8 from channel diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test14/test14.cpp b/src/systemc/tests/systemc/communication/sc_prim_channel/test14/test14.cpp new file mode 100644 index 000000000..e93ef3fa6 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test14/test14.cpp @@ -0,0 +1,154 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test14.cpp -- + + Original Author: Ucar Aziz, Synopsys, Inc., 2002-02-15 + Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// test of sc_prim_channel::wait(double, sc_time_unit, sc_event&) + +#include + +//write and read interfaces +class write_if : virtual public +sc_interface + { + public: + virtual void write() = 0; +}; + +class read_if : virtual public +sc_interface +{ + public: + virtual void read( ) = 0; +}; + +// channel implements write_if and read_if interfaces +class channel : + public sc_channel, + public write_if, + public read_if +{ + + public : + + //constructor + channel(sc_module_name name):sc_channel(name) , data(0) + { } + + //write to channel + void write(){ + int i = 0; + sc_time t(10, SC_NS); + + while(1){ + wait(t); + data = i; + cout <<"simulation time" << ":" << sc_time_stamp()<<" "; + cout<<"writting "<< data <<" to channel" << endl; + + if(i < 5){ + write_event.notify(20, SC_NS); + } + else { + write_event.notify(5, SC_NS); + } + i++; + } + } + + //read from channel + void read( ){ + int j; + + while(1){ + wait(10, SC_NS, write_event); + j = data; + cout <<"simulation time" << ":" << sc_time_stamp(); + cout<<" reading "< out; + + void write( ) + { + out->write(); + } + + SC_CTOR( mod_a ){ + + SC_THREAD(write); + } +}; + +//sink module +SC_MODULE(mod_b) +{ + sc_port input; + int i; + + void read( ) + { + input->read(); + } + + SC_CTOR( mod_b ){ + + SC_THREAD(read); + } +}; + + +int sc_main(int, char*[] ) +{ + channel a("a"); + mod_a modul_a("modul_a"); + mod_b modul_b("modul_b"); + modul_a.out(a); + modul_b.input(a); + + sc_start(100, SC_NS); + return 0; +} diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test15/golden/test15.log b/src/systemc/tests/systemc/communication/sc_prim_channel/test15/golden/test15.log new file mode 100644 index 000000000..9f6958921 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test15/golden/test15.log @@ -0,0 +1,24 @@ +SystemC Simulation +simulation time:10 ns writing 0 to channel +simulation time:10 ns reading 0 from channel +simulation time:20 ns writing 1 to channel +simulation time:20 ns reading 1 from channel +simulation time:30 ns reading 1 from channel +simulation time:30 ns writing 2 to channel +simulation time:40 ns reading 2 from channel +simulation time:40 ns writing 3 to channel +simulation time:50 ns writing 4 to channel +simulation time:50 ns reading 4 from channel +simulation time:60 ns reading 4 from channel +simulation time:60 ns writing 5 to channel +simulation time:70 ns writing 6 to channel +simulation time:70 ns reading 6 from channel +simulation time:75 ns reading 6 from channel +simulation time:80 ns writing 7 to channel +simulation time:85 ns reading 7 from channel +simulation time:90 ns writing 8 to channel +simulation time:95 ns reading 8 from channel +simulation time:100 ns writing 9 to channel +simulation time:105 ns reading 9 from channel +simulation time:110 ns writing 10 to channel +simulation time:115 ns reading 10 from channel diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test15/test15.cpp b/src/systemc/tests/systemc/communication/sc_prim_channel/test15/test15.cpp new file mode 100644 index 000000000..28781776d --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test15/test15.cpp @@ -0,0 +1,156 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test15.cpp -- + + Original Author: Ucar Aziz, Synopsys, Inc., 2002-02-15 + Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// test of sc_prim_channel::wait(double, sc_time_unit, sc_event_and_list&) + +#include + +//write and read interfaces +class write_if : virtual public +sc_interface + { + public: + virtual void write() = 0; +}; + +class read_if : virtual public +sc_interface +{ + public: + virtual void read( ) = 0; +}; + +// channel implements write_if and read_if interfaces +class channel : + public sc_channel, + public write_if, + public read_if +{ + + public : + + //constructor + channel(sc_module_name name):sc_channel(name) , data(0) + { } + + //write to channel + void write(){ + int i = 0; + + while(1){ + wait(10, SC_NS); + data = i; + cout <<"simulation time" << ":" << sc_time_stamp()<<" "; + cout<<"writing "<< data <<" to channel" << endl; + + if(i < 3){ + write_event_1.notify(20, SC_NS); + } + else if(3 <= i && i < 6) { + write_event_2.notify(5, SC_NS); + } + else{ + write_event_2.notify(5, SC_NS); + write_event_1.notify(5, SC_NS); + } + i++; + } + } + //read from channel + void read( ){ + int j; + + while(1){ + wait(10, SC_NS, write_event_1 & write_event_2); + j = data; + cout <<"simulation time" << ":" << sc_time_stamp(); + cout<<" reading "< out; + + void write( ) + { + out->write(); + } + + SC_CTOR( mod_a ){ + + SC_THREAD(write); + } +}; + +//sink module +SC_MODULE(mod_b) +{ + sc_port input; + int i; + + void read( ) + { + input->read(); + } + + SC_CTOR( mod_b ){ + + SC_THREAD(read); + } +}; + + +int sc_main(int, char*[] ) +{ + channel a("a"); + mod_a modul_a("modul_a"); + mod_b modul_b("modul_b"); + modul_a.out(a); + modul_b.input(a); + + sc_start(120, SC_NS); + return 0; +} diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test16/golden/test16.log b/src/systemc/tests/systemc/communication/sc_prim_channel/test16/golden/test16.log new file mode 100644 index 000000000..2c73a9072 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test16/golden/test16.log @@ -0,0 +1,24 @@ +SystemC Simulation +simulation time:10 ns writting 0 to channel +simulation time:10 ns reading 0 from channel +simulation time:20 ns writting 1 to channel +simulation time:20 ns reading 1 from channel +simulation time:30 ns reading 1 from channel +simulation time:30 ns writting 2 to channel +simulation time:40 ns reading 2 from channel +simulation time:40 ns writting 3 to channel +simulation time:50 ns writting 4 to channel +simulation time:50 ns reading 4 from channel +simulation time:60 ns reading 4 from channel +simulation time:60 ns writting 5 to channel +simulation time:70 ns writting 6 to channel +simulation time:70 ns reading 6 from channel +simulation time:75 ns reading 6 from channel +simulation time:80 ns writting 7 to channel +simulation time:85 ns reading 7 from channel +simulation time:90 ns writting 8 to channel +simulation time:95 ns reading 8 from channel +simulation time:100 ns writting 9 to channel +simulation time:105 ns reading 9 from channel +simulation time:110 ns writting 10 to channel +simulation time:115 ns reading 10 from channel diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test16/test16.cpp b/src/systemc/tests/systemc/communication/sc_prim_channel/test16/test16.cpp new file mode 100644 index 000000000..c82ec5d06 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test16/test16.cpp @@ -0,0 +1,157 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test16.cpp -- + + Original Author: Ucar Aziz, Synopsys, Inc., 2002-02-15 + Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// test of sc_prim_channel::wait(sc_time, sc_event_and_list&) + +#include + +//write and read interfaces +class write_if : virtual public +sc_interface + { + public: + virtual void write() = 0; +}; + +class read_if : virtual public +sc_interface +{ + public: + virtual void read( ) = 0; +}; + +// channel implements write_if and read_if interfaces +class channel : + public sc_channel, + public write_if, + public read_if +{ + + public : + + //constructor + channel(sc_module_name name):sc_channel(name) , data(0) + { } + + //write to channel + void write(){ + int i = 0; + + while(1){ + wait(10, SC_NS); + data = i; + cout <<"simulation time" << ":" << sc_time_stamp()<<" "; + cout<<"writting "<< data <<" to channel" << endl; + + if(i < 3){ + write_event_1.notify(20, SC_NS); + } + else if(3 <= i && i < 6) { + write_event_2.notify(5, SC_NS); + } + else{ + write_event_2.notify(5, SC_NS); + write_event_1.notify(5, SC_NS); + } + i++; + } + } + //read from channel + void read( ){ + int j; + sc_time t(10, SC_NS); + + while(1){ + wait(t, write_event_1 & write_event_2); + j = data; + cout <<"simulation time" << ":" << sc_time_stamp(); + cout<<" reading "< out; + + void write( ) + { + out->write(); + } + + SC_CTOR( mod_a ){ + + SC_THREAD(write); + } +}; + +//sink module +SC_MODULE(mod_b) +{ + sc_port input; + int i; + + void read( ) + { + input->read(); + } + + SC_CTOR( mod_b ){ + + SC_THREAD(read); + } +}; + + +int sc_main(int, char*[] ) +{ + channel a("a"); + mod_a modul_a("modul_a"); + mod_b modul_b("modul_b"); + modul_a.out(a); + modul_b.input(a); + + sc_start(120, SC_NS); + return 0; +} diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test17/golden/test17.log b/src/systemc/tests/systemc/communication/sc_prim_channel/test17/golden/test17.log new file mode 100644 index 000000000..6d9eb24d9 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test17/golden/test17.log @@ -0,0 +1,25 @@ +SystemC Simulation +simulation time:10 ns writting 0 to channel +simulation time:10 ns reading 0 from channel +simulation time:20 ns writting 1 to channel +simulation time:20 ns reading 1 from channel +simulation time:30 ns reading 1 from channel +simulation time:30 ns writting 2 to channel +simulation time:40 ns reading 2 from channel +simulation time:40 ns writting 3 to channel +simulation time:45 ns reading 3 from channel +simulation time:50 ns writting 4 to channel +simulation time:55 ns reading 4 from channel +simulation time:60 ns writting 5 to channel +simulation time:65 ns reading 5 from channel +simulation time:70 ns writting 6 to channel +simulation time:75 ns reading 6 from channel +simulation time:76 ns reading 6 from channel +simulation time:80 ns writting 7 to channel +simulation time:86 ns reading 7 from channel +simulation time:90 ns writting 8 to channel +simulation time:96 ns reading 8 from channel +simulation time:100 ns writting 9 to channel +simulation time:106 ns reading 9 from channel +simulation time:110 ns writting 10 to channel +simulation time:116 ns reading 10 from channel diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test17/test17.cpp b/src/systemc/tests/systemc/communication/sc_prim_channel/test17/test17.cpp new file mode 100644 index 000000000..3ed584ea6 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test17/test17.cpp @@ -0,0 +1,156 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test17.cpp -- + + Original Author: Ucar Aziz, Synopsys, Inc., 2002-02-15 + Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// test of sc_prim_channel::wait(double, sc_time_unit, sc_event_or_list&) + +#include + +//write and read interfaces +class write_if : virtual public +sc_interface + { + public: + virtual void write() = 0; +}; + +class read_if : virtual public +sc_interface +{ + public: + virtual void read( ) = 0; +}; + +// channel implements write_if and read_if interfaces +class channel : + public sc_channel, + public write_if, + public read_if +{ + + public : + + //constructor + channel(sc_module_name name):sc_channel(name) , data(0) + { } + + //write to channel + void write(){ + int i = 0; + + while(1){ + wait(10, SC_NS); + data = i; + cout <<"simulation time" << ":" << sc_time_stamp()<<" "; + cout<<"writting "<< data <<" to channel" << endl; + + if(i < 3){ + write_event_1.notify(20, SC_NS); + } + else if(3 <= i && i < 6) { + write_event_1.notify(5, SC_NS); + } + else{ + write_event_2.notify(6, SC_NS); + } + i++; + } + } + + //read from channel + void read( ){ + int j; + + while(1){ + wait(10, SC_NS, write_event_1 | write_event_2); + j = data; + cout <<"simulation time" << ":" << sc_time_stamp(); + cout<<" reading "< out; + + void write( ) + { + out->write(); + } + + SC_CTOR( mod_a ){ + + SC_THREAD(write); + } +}; + +//sink module +SC_MODULE(mod_b) +{ + sc_port input; + int i; + + void read( ) + { + input->read(); + } + + SC_CTOR( mod_b ){ + + SC_THREAD(read); + } +}; + + +int sc_main(int, char*[] ) +{ + channel a("a"); + mod_a modul_a("modul_a"); + mod_b modul_b("modul_b"); + modul_a.out(a); + modul_b.input(a); + + sc_start(120, SC_NS); + return 0; +} diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test18/golden/test18.log b/src/systemc/tests/systemc/communication/sc_prim_channel/test18/golden/test18.log new file mode 100644 index 000000000..6d9eb24d9 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test18/golden/test18.log @@ -0,0 +1,25 @@ +SystemC Simulation +simulation time:10 ns writting 0 to channel +simulation time:10 ns reading 0 from channel +simulation time:20 ns writting 1 to channel +simulation time:20 ns reading 1 from channel +simulation time:30 ns reading 1 from channel +simulation time:30 ns writting 2 to channel +simulation time:40 ns reading 2 from channel +simulation time:40 ns writting 3 to channel +simulation time:45 ns reading 3 from channel +simulation time:50 ns writting 4 to channel +simulation time:55 ns reading 4 from channel +simulation time:60 ns writting 5 to channel +simulation time:65 ns reading 5 from channel +simulation time:70 ns writting 6 to channel +simulation time:75 ns reading 6 from channel +simulation time:76 ns reading 6 from channel +simulation time:80 ns writting 7 to channel +simulation time:86 ns reading 7 from channel +simulation time:90 ns writting 8 to channel +simulation time:96 ns reading 8 from channel +simulation time:100 ns writting 9 to channel +simulation time:106 ns reading 9 from channel +simulation time:110 ns writting 10 to channel +simulation time:116 ns reading 10 from channel diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test18/test18.cpp b/src/systemc/tests/systemc/communication/sc_prim_channel/test18/test18.cpp new file mode 100644 index 000000000..e57ce7097 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test18/test18.cpp @@ -0,0 +1,157 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test18.cpp -- + + Original Author: Ucar Aziz, Synopsys, Inc., 2002-02-15 + Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// test of sc_prim_channel::wait(sc_time, sc_event_or_list&) + +#include + +//write and read interfaces +class write_if : virtual public +sc_interface + { + public: + virtual void write() = 0; +}; + +class read_if : virtual public +sc_interface +{ + public: + virtual void read( ) = 0; +}; + +// channel implements write_if and read_if interfaces +class channel : + public sc_channel, + public write_if, + public read_if +{ + + public : + + //constructor + channel(sc_module_name name):sc_channel(name) , data(0) + { } + + //write to channel + void write(){ + int i = 0; + + while(1){ + wait(10, SC_NS); + data = i; + cout <<"simulation time" << ":" << sc_time_stamp()<<" "; + cout<<"writting "<< data <<" to channel" << endl; + + if(i < 3){ + write_event_1.notify(20, SC_NS); + } + else if(3 <= i && i < 6) { + write_event_1.notify(5, SC_NS); + } + else{ + write_event_2.notify(6, SC_NS); + } + i++; + } + } + + //read from channel + void read( ){ + int j; + sc_time t(10, SC_NS); + + while(1){ + wait(t, write_event_1 | write_event_2); + j = data; + cout <<"simulation time" << ":" << sc_time_stamp(); + cout<<" reading "< out; + + void write( ) + { + out->write(); + } + + SC_CTOR( mod_a ){ + + SC_THREAD(write); + } +}; + +//sink module +SC_MODULE(mod_b) +{ + sc_port input; + int i; + + void read( ) + { + input->read(); + } + + SC_CTOR( mod_b ){ + + SC_THREAD(read); + } +}; + + +int sc_main(int, char*[] ) +{ + channel a("a"); + mod_a modul_a("modul_a"); + mod_b modul_b("modul_b"); + modul_a.out(a); + modul_b.input(a); + + sc_start(120, SC_NS); + return 0; +} diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test19/golden/test19.log b/src/systemc/tests/systemc/communication/sc_prim_channel/test19/golden/test19.log new file mode 100644 index 000000000..f1e6af3b0 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test19/golden/test19.log @@ -0,0 +1,11 @@ +SystemC Simulation +simulation time:10 ns writting 0 to channel +simulation time:15 ns reading 0 from channel +simulation time:20 ns writting 1 to channel +simulation time:25 ns reading 1 from channel +simulation time:30 ns writting 2 to channel +simulation time:35 ns reading 2 from channel +simulation time:40 ns writting 3 to channel +simulation time:45 ns reading 3 from channel +simulation time:50 ns writting 4 to channel +simulation time:55 ns reading 4 from channel diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test19/test19.cpp b/src/systemc/tests/systemc/communication/sc_prim_channel/test19/test19.cpp new file mode 100644 index 000000000..a0a6c4330 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test19/test19.cpp @@ -0,0 +1,149 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test19.cpp -- + + Original Author: Ucar Aziz, Synopsys, Inc., 2002-02-15 + Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// test of sc_prim_channel::wait(sc_event_and_list&) + +#include + +//write and read interfaces +class write_if : virtual public +sc_interface + { + public: + virtual void write() = 0; +}; + +class read_if : virtual public +sc_interface +{ + public: + virtual void read( ) = 0; +}; + +// channel implements write_if and read_if interfaces +class channel : + public sc_channel, + public write_if, + public read_if +{ + + public : + + //constructor + channel(sc_module_name name):sc_channel(name) , data(0) + { } + + //write to channel + void write(){ + int i = 0; + + while(1){ + wait(10, SC_NS); + data = i; + cout <<"simulation time" << ":" << sc_time_stamp()<<" "; + cout<<"writting "<< data <<" to channel" << endl; + + write_event_2.notify(5, SC_NS); + write_event_1.notify(5, SC_NS); + i++; + } + } + + //read from channel + void read( ){ + int j; + + while(1){ + wait(write_event_1 & write_event_2); + j = data; + cout <<"simulation time" << ":" << sc_time_stamp(); + cout<<" reading "< out; + + void write( ) + { + out->write(); + } + + SC_CTOR( mod_a ){ + + SC_THREAD(write); + } +}; + +//sink module +SC_MODULE(mod_b) +{ + sc_port input; + int i; + + void read( ) + { + input->read(); + } + + SC_CTOR( mod_b ){ + + SC_THREAD(read); + } +}; + + +int sc_main(int, char*[] ) +{ + channel a("a"); + mod_a modul_a("modul_a"); + mod_b modul_b("modul_b"); + modul_a.out(a); + modul_b.input(a); + + sc_start(60, SC_NS); + return 0; +} diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test20/golden/test20.log b/src/systemc/tests/systemc/communication/sc_prim_channel/test20/golden/test20.log new file mode 100644 index 000000000..2a867ec5a --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test20/golden/test20.log @@ -0,0 +1,19 @@ +SystemC Simulation +simulation time:20 ns writting 0 to channel +simulation time:25 ns reading 0 from channel +simulation time:40 ns writting 1 to channel +simulation time:45 ns reading 1 from channel +simulation time:60 ns writting 2 to channel +simulation time:65 ns reading 2 from channel +simulation time:80 ns writting 3 to channel +simulation time:90 ns reading 3 from channel +simulation time:100 ns writting 4 to channel +simulation time:110 ns reading 4 from channel +simulation time:120 ns writting 5 to channel +simulation time:130 ns reading 5 from channel +simulation time:140 ns writting 6 to channel +simulation time:155 ns reading 6 from channel +simulation time:160 ns writting 7 to channel +simulation time:175 ns reading 7 from channel +simulation time:180 ns writting 8 to channel +simulation time:195 ns reading 8 from channel diff --git a/src/systemc/tests/systemc/communication/sc_prim_channel/test20/test20.cpp b/src/systemc/tests/systemc/communication/sc_prim_channel/test20/test20.cpp new file mode 100644 index 000000000..a92b1a0e5 --- /dev/null +++ b/src/systemc/tests/systemc/communication/sc_prim_channel/test20/test20.cpp @@ -0,0 +1,156 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test20.cpp -- + + Original Author: Ucar Aziz, Synopsys, Inc., 2002-02-15 + Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// test of sc_prim_channel::wait(sc_event_or_list&) + +#include + +//write and read interfaces +class write_if : virtual public +sc_interface + { + public: + virtual void write() = 0; +}; + +class read_if : virtual public +sc_interface +{ + public: + virtual void read( ) = 0; +}; + +// channel implements write_if and read_if interfaces +class channel : + public sc_channel, + public write_if, + public read_if +{ + + public : + + //constructor + channel(sc_module_name name):sc_channel(name) , data(0) + { } + + //write to channel + void write(){ + int i = 0; + + while(1){ + wait(20, SC_NS); + data = i; + cout <<"simulation time" << ":" << sc_time_stamp()<<" "; + cout<<"writting "<< data <<" to channel" << endl; + + if(i < 3){ + write_event_1.notify(5, SC_NS); + write_event_1.notify(5, SC_NS); + } + else if(3 <= i && i < 6) { + write_event_1.notify(10, SC_NS); + } + else{ + write_event_2.notify(15, SC_NS); + } + i++; + } + } + //read from channel + void read( ){ + int j; + + while(1){ + wait(write_event_1 | write_event_2); + j = data; + cout <<"simulation time" << ":" << sc_time_stamp(); + cout<<" reading "< out; + + void write( ) + { + out->write(); + } + + SC_CTOR( mod_a ){ + + SC_THREAD(write); + } +}; + +//sink module +SC_MODULE(mod_b) +{ + sc_port input; + int i; + + void read( ) + { + input->read(); + } + + SC_CTOR( mod_b ){ + + SC_THREAD(read); + } +}; + + +int sc_main(int, char*[] ) +{ + channel a("a"); + mod_a modul_a("modul_a"); + mod_b modul_b("modul_b"); + modul_a.out(a); + modul_b.input(a); + + sc_start(200, SC_NS); + return 0; +} -- cgit v1.2.3