summaryrefslogtreecommitdiff
path: root/src/systemc/tests/systemc/communication/sc_fifo
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-05-24 01:37:55 -0700
committerGabe Black <gabeblack@google.com>2018-08-08 10:09:54 +0000
commit16fa8d7cc8c92f5ab879e4cf9c6c0bbb3567860f (patch)
tree7b6faaacb4574a555e561534aa4a8508c0624c32 /src/systemc/tests/systemc/communication/sc_fifo
parent7235d3b5211d0ba8f528d930a4c1e7ad62eec51a (diff)
downloadgem5-16fa8d7cc8c92f5ab879e4cf9c6c0bbb3567860f.tar.xz
systemc: Import tests from the Accellera systemc distribution.
Change-Id: Iad76b398949a55d768a34d027a2d8e3739953da6 Reviewed-on: https://gem5-review.googlesource.com/10845 Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/tests/systemc/communication/sc_fifo')
-rw-r--r--src/systemc/tests/systemc/communication/sc_fifo/test01/golden/test01.log145
-rw-r--r--src/systemc/tests/systemc/communication/sc_fifo/test01/test01.cpp107
-rw-r--r--src/systemc/tests/systemc/communication/sc_fifo/test02/golden/test02.log18
-rw-r--r--src/systemc/tests/systemc/communication/sc_fifo/test02/test02.cpp67
-rw-r--r--src/systemc/tests/systemc/communication/sc_fifo/test03/golden/test03.log181
-rw-r--r--src/systemc/tests/systemc/communication/sc_fifo/test03/test03.cpp134
-rw-r--r--src/systemc/tests/systemc/communication/sc_fifo/test04/golden/test04.log185
-rw-r--r--src/systemc/tests/systemc/communication/sc_fifo/test04/test04.cpp145
-rw-r--r--src/systemc/tests/systemc/communication/sc_fifo/test05/golden/test05.log185
-rw-r--r--src/systemc/tests/systemc/communication/sc_fifo/test05/test05.cpp147
-rw-r--r--src/systemc/tests/systemc/communication/sc_fifo/test06/golden/test06.log130
-rw-r--r--src/systemc/tests/systemc/communication/sc_fifo/test06/test06.cpp142
12 files changed, 1586 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/communication/sc_fifo/test01/golden/test01.log b/src/systemc/tests/systemc/communication/sc_fifo/test01/golden/test01.log
new file mode 100644
index 000000000..7dbaa863b
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_fifo/test01/golden/test01.log
@@ -0,0 +1,145 @@
+SystemC Simulation
+0
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+Available: 5
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+Available: 0
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+Available: 5
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+Available: 0
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+Available: 5
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+Available: 0
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+100
+101
+102
+103
+104
+Available: 5
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+Available: 0
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+Available: 5
diff --git a/src/systemc/tests/systemc/communication/sc_fifo/test01/test01.cpp b/src/systemc/tests/systemc/communication/sc_fifo/test01/test01.cpp
new file mode 100644
index 000000000..b9e8515d0
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_fifo/test01/test01.cpp
@@ -0,0 +1,107 @@
+/*****************************************************************************
+
+ 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: 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_fifo<T> - general test
+
+#include "systemc.h"
+
+SC_MODULE( writer )
+{
+ // port(s)
+ sc_fifo_out<int> out;
+
+ // process(es)
+ void main_action()
+ {
+ int val = 0;
+ while( true ) {
+ wait( 10, SC_NS ); // wait for 10 ns
+ for( int i = 0; i < 20; i ++ )
+ out->write( val ++ ); // blocking write
+ }
+ }
+
+ SC_CTOR( writer )
+ {
+ SC_THREAD( main_action );
+ }
+};
+
+SC_MODULE( reader )
+{
+ // port(s)
+ sc_fifo_in<int> in;
+
+ // process(es)
+ void main_action()
+ {
+ int val;
+ while( true ) {
+ wait( 10, SC_NS ); // wait for 10 ns
+ for( int i = 0; i < 15; i ++ ) {
+ in->read( val ); // blocking read
+ cout << val << endl;
+ }
+ cout << "Available: " << in->num_available() << endl;
+ }
+ }
+
+ SC_CTOR( reader )
+ {
+ SC_THREAD( main_action );
+ }
+};
+
+int sc_main( int, char*[] )
+{
+ sc_clock c;
+
+ // declare channel(s)
+ sc_fifo<int> fifo( 10 );
+
+ // instantiate block(s) and connect to channel(s)
+ writer w( "writer" );
+ reader r( "reader" );
+
+ w.out( fifo );
+ r.in( fifo );
+
+ // run the simulation
+ sc_start( 100, SC_NS );
+
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/communication/sc_fifo/test02/golden/test02.log b/src/systemc/tests/systemc/communication/sc_fifo/test02/golden/test02.log
new file mode 100644
index 000000000..fc200328a
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_fifo/test02/golden/test02.log
@@ -0,0 +1,18 @@
+SystemC Simulation
+print
+dump
+name = fifo_0
+
+print
+123
+dump
+name = fifo_0
+value[0] = 123
+
+print
+123
+321
+dump
+name = fifo_0
+value[0] = 123
+value[1] = 321
diff --git a/src/systemc/tests/systemc/communication/sc_fifo/test02/test02.cpp b/src/systemc/tests/systemc/communication/sc_fifo/test02/test02.cpp
new file mode 100644
index 000000000..e41bc9a60
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_fifo/test02/test02.cpp
@@ -0,0 +1,67 @@
+/*****************************************************************************
+
+ 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: 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_fifo print() and dump() methods
+
+#include "systemc.h"
+
+int
+sc_main( int, char*[] )
+{
+ sc_fifo<int> a( 2 );
+
+ cout << "print\n";
+ a.print( cout );
+ cout << "dump\n";
+ a.dump( cout );
+
+ cout << endl;
+ a.write( 123 );
+ cout << "print\n";
+ a.print( cout );
+ cout << "dump\n";
+ a.dump( cout );
+
+ cout << endl;
+ a.write( 321 );
+ cout << "print\n";
+ a.print( cout );
+ cout << "dump\n";
+ a.dump( cout );
+
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/communication/sc_fifo/test03/golden/test03.log b/src/systemc/tests/systemc/communication/sc_fifo/test03/golden/test03.log
new file mode 100644
index 000000000..e259c8151
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_fifo/test03/golden/test03.log
@@ -0,0 +1,181 @@
+SystemC Simulation
+writer: blocking write
+reader: blocking read 1
+0
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+writer: 5 free spaces
+writer: non-blocking write
+writer: waiting
+reader: 5 available samples
+reader: blocking read 2
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+writer: waiting
+26
+27
+28
+29
+30
+reader: 10 available samples
+reader: non-blocking read
+31
+32
+33
+34
+35
+37
+38
+39
+40
+41
+reader: waiting
+writer: blocking write
+reader: waiting
+42
+43
+44
+45
+46
+reader: blocking read 1
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+writer: 10 free spaces
+writer: non-blocking write
+writer: waiting
+reader: 0 available samples
+reader: blocking read 2
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+73
+74
+75
+76
+77
+writer: blocking write
+reader: 5 available samples
+reader: non-blocking read
+78
+79
+80
+81
+82
+reader: waiting
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+reader: blocking read 1
+93
+94
+95
+96
+97
+98
+99
+100
+101
+102
+writer: 0 free spaces
+writer: non-blocking write
+writer: waiting
+writer: waiting
+104
+105
+106
+107
+108
+writer: waiting
+writer: waiting
+writer: waiting
+writer: waiting
+writer: waiting
+writer: waiting
+writer: waiting
+writer: waiting
+writer: waiting
+reader: 10 available samples
+reader: blocking read 2
+109
+110
+111
+112
+113
+115
+116
+117
+118
+119
+writer: waiting
+130
+131
+132
+133
+134
+writer: blocking write
+reader: 0 available samples
+reader: non-blocking read
+reader: waiting
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+reader: waiting
+145
+146
+147
+148
+149
diff --git a/src/systemc/tests/systemc/communication/sc_fifo/test03/test03.cpp b/src/systemc/tests/systemc/communication/sc_fifo/test03/test03.cpp
new file mode 100644
index 000000000..da5a8faa0
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_fifo/test03/test03.cpp
@@ -0,0 +1,134 @@
+/*****************************************************************************
+
+ 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: 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_fifo ports - interface access shortcut methods
+
+#include "systemc.h"
+
+SC_MODULE( writer )
+{
+ // port(s)
+ sc_fifo_out<int> out;
+
+ // process(es)
+ void main_action()
+ {
+ int val = 0;
+ while( true ) {
+ wait( 10, SC_NS ); // wait for 10 ns
+ cout << "writer: blocking write\n";
+ for( int i = 0; i < 20; i ++ ) {
+ out.write( val ++ ); // blocking write
+ }
+ wait( 10, SC_NS );
+ cout << "writer: " << out.num_free() << " free spaces\n";
+ cout << "writer: non-blocking write\n";
+ for( int i = 0; i < 20; i ++ ) {
+ while( ! out.nb_write( val ++ ) ) { // non-blocking write
+ cout << "writer: waiting\n";
+ wait( 1, SC_NS );
+ }
+ }
+ }
+ }
+
+ SC_CTOR( writer )
+ {
+ SC_THREAD( main_action );
+ }
+};
+
+SC_MODULE( reader )
+{
+ // port(s)
+ sc_fifo_in<int> in;
+
+ // process(es)
+ void main_action()
+ {
+ int val;
+ while( true ) {
+ wait( 10, SC_NS ); // wait for 10 ns
+ cout << "reader: blocking read 1\n";
+ for( int i = 0; i < 15; i ++ ) {
+ in.read( val ); // blocking read
+ cout << val << endl;
+ }
+ wait( 10, SC_NS );
+ cout << "reader: " << in.num_available() << " available samples\n";
+ cout << "reader: blocking read 2\n";
+ for( int i = 0; i < 15; i ++ ) {
+ cout << in.read() << endl; // blocking read
+ }
+ wait( 10, SC_NS );
+ cout << "reader: " << in.num_available() << " available samples\n";
+ cout << "reader: non-blocking read\n";
+ for( int i = 0; i < 15; i ++ ) {
+ while( ! in.nb_read( val ) ) { // non-blocking read
+ cout << "reader: waiting\n";
+ wait( 1, SC_NS );
+ }
+ cout << val << endl;
+ }
+ }
+ }
+
+ SC_CTOR( reader )
+ {
+ SC_THREAD( main_action );
+ }
+};
+
+int sc_main( int, char*[] )
+{
+ // sc_clock c;
+
+ // declare channel(s)
+ sc_fifo<int> fifo( 10 );
+
+ // instantiate block(s) and connect to channel(s)
+ writer w( "writer" );
+ reader r( "reader" );
+
+ w.out( fifo );
+ r.in( fifo );
+
+ // run the simulation
+ sc_start( 100, SC_NS );
+
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/communication/sc_fifo/test04/golden/test04.log b/src/systemc/tests/systemc/communication/sc_fifo/test04/golden/test04.log
new file mode 100644
index 000000000..4c8333c81
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_fifo/test04/golden/test04.log
@@ -0,0 +1,185 @@
+SystemC Simulation
+10 ns,1: writer: blocking write
+10 ns,1: reader: blocking read 1
+10 ns,2: reader: 0
+10 ns,2: reader: 1
+10 ns,2: reader: 2
+10 ns,2: reader: 3
+10 ns,2: reader: 4
+10 ns,2: reader: 5
+10 ns,2: reader: 6
+10 ns,2: reader: 7
+10 ns,2: reader: 8
+10 ns,2: reader: 9
+10 ns,4: reader: 10
+10 ns,4: reader: 11
+10 ns,4: reader: 12
+10 ns,4: reader: 13
+10 ns,4: reader: 14
+20 ns,5: writer: 5 free spaces
+20 ns,5: writer: non-blocking write
+20 ns,5: writer: waiting
+20 ns,5: reader: 5 available samples
+20 ns,5: reader: blocking read 2
+20 ns,5: reader: 15
+20 ns,5: reader: 16
+20 ns,5: reader: 17
+20 ns,5: reader: 18
+20 ns,5: reader: 19
+20 ns,6: reader: 20
+20 ns,6: reader: 21
+20 ns,6: reader: 22
+20 ns,6: reader: 23
+20 ns,6: reader: 24
+20 ns,6: writer: data read event
+20 ns,6: writer: waiting
+20 ns,7: reader: 26
+20 ns,7: reader: 27
+20 ns,7: reader: 28
+20 ns,7: reader: 29
+20 ns,7: reader: 30
+20 ns,7: writer: data read event
+20 ns,7: writer: waiting
+20 ns,8: writer: data read event
+30 ns,9: reader: 10 available samples
+30 ns,9: reader: non-blocking read
+30 ns,9: reader: 32
+30 ns,9: reader: 33
+30 ns,9: reader: 34
+30 ns,9: reader: 35
+30 ns,9: reader: 36
+30 ns,9: reader: 38
+30 ns,9: reader: 39
+30 ns,9: reader: 40
+30 ns,9: reader: 41
+30 ns,9: reader: 42
+30 ns,9: reader: waiting
+30 ns,9: writer: blocking write
+30 ns,11: reader: data written event
+30 ns,11: reader: 43
+30 ns,11: reader: 44
+30 ns,11: reader: 45
+30 ns,11: reader: 46
+30 ns,11: reader: 47
+40 ns,13: reader: blocking read 1
+40 ns,13: reader: 48
+40 ns,13: reader: 49
+40 ns,13: reader: 50
+40 ns,13: reader: 51
+40 ns,13: reader: 52
+40 ns,13: reader: 53
+40 ns,13: reader: 54
+40 ns,13: reader: 55
+40 ns,13: reader: 56
+40 ns,13: reader: 57
+40 ns,15: reader: 58
+40 ns,15: reader: 59
+40 ns,15: reader: 60
+40 ns,15: reader: 61
+40 ns,15: reader: 62
+50 ns,16: writer: 10 free spaces
+50 ns,16: writer: non-blocking write
+50 ns,16: writer: waiting
+50 ns,16: reader: 0 available samples
+50 ns,16: reader: blocking read 2
+50 ns,17: reader: 63
+50 ns,17: reader: 64
+50 ns,17: reader: 65
+50 ns,17: reader: 66
+50 ns,17: reader: 67
+50 ns,17: reader: 68
+50 ns,17: reader: 69
+50 ns,17: reader: 70
+50 ns,17: reader: 71
+50 ns,17: reader: 72
+50 ns,18: writer: data read event
+50 ns,19: reader: 74
+50 ns,19: reader: 75
+50 ns,19: reader: 76
+50 ns,19: reader: 77
+50 ns,19: reader: 78
+60 ns,20: writer: blocking write
+60 ns,20: reader: 5 available samples
+60 ns,20: reader: non-blocking read
+60 ns,20: reader: 79
+60 ns,20: reader: 80
+60 ns,20: reader: 81
+60 ns,20: reader: 82
+60 ns,20: reader: 83
+60 ns,20: reader: waiting
+60 ns,21: reader: data written event
+60 ns,21: reader: 84
+60 ns,21: reader: 85
+60 ns,21: reader: 86
+60 ns,21: reader: 87
+60 ns,21: reader: 88
+60 ns,21: reader: waiting
+60 ns,22: reader: data written event
+60 ns,22: reader: 89
+60 ns,22: reader: 90
+60 ns,22: reader: 91
+60 ns,22: reader: 92
+60 ns,22: reader: 93
+70 ns,24: reader: blocking read 1
+70 ns,24: reader: 94
+70 ns,24: reader: 95
+70 ns,24: reader: 96
+70 ns,24: reader: 97
+70 ns,24: reader: 98
+70 ns,24: reader: 99
+70 ns,24: reader: 100
+70 ns,24: reader: 101
+70 ns,24: reader: 102
+70 ns,24: reader: 103
+70 ns,24: writer: 0 free spaces
+70 ns,24: writer: non-blocking write
+70 ns,24: writer: waiting
+70 ns,25: writer: data read event
+70 ns,25: writer: waiting
+70 ns,26: reader: 105
+70 ns,26: reader: 106
+70 ns,26: reader: 107
+70 ns,26: reader: 108
+70 ns,26: reader: 109
+70 ns,27: writer: data read event
+70 ns,27: writer: waiting
+80 ns,28: reader: 10 available samples
+80 ns,28: reader: blocking read 2
+80 ns,28: reader: 110
+80 ns,28: reader: 111
+80 ns,28: reader: 112
+80 ns,28: reader: 113
+80 ns,28: reader: 114
+80 ns,28: reader: 116
+80 ns,28: reader: 117
+80 ns,28: reader: 118
+80 ns,28: reader: 119
+80 ns,28: reader: 120
+80 ns,29: writer: data read event
+80 ns,30: reader: 122
+80 ns,30: reader: 123
+80 ns,30: reader: 124
+80 ns,30: reader: 125
+80 ns,30: reader: 126
+90 ns,31: writer: blocking write
+90 ns,31: reader: 0 available samples
+90 ns,31: reader: non-blocking read
+90 ns,31: reader: waiting
+90 ns,32: reader: data written event
+90 ns,32: reader: 127
+90 ns,32: reader: 128
+90 ns,32: reader: 129
+90 ns,32: reader: 130
+90 ns,32: reader: 131
+90 ns,32: reader: 132
+90 ns,32: reader: 133
+90 ns,32: reader: 134
+90 ns,32: reader: 135
+90 ns,32: reader: 136
+90 ns,32: reader: waiting
+90 ns,34: reader: data written event
+90 ns,34: reader: 137
+90 ns,34: reader: 138
+90 ns,34: reader: 139
+90 ns,34: reader: 140
+90 ns,34: reader: 141
diff --git a/src/systemc/tests/systemc/communication/sc_fifo/test04/test04.cpp b/src/systemc/tests/systemc/communication/sc_fifo/test04/test04.cpp
new file mode 100644
index 000000000..be6ee57c5
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_fifo/test04/test04.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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ test04.cpp --
+
+ Original Author: Martin Janssen, Synopsys, Inc., 2002-03-23
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// test of sc_fifo events
+
+#include "systemc.h"
+
+#define W_INFO(msg) \
+ cout << sc_time_stamp() << "," << sc_delta_count() \
+ << ": writer: " << msg << endl;
+
+#define R_INFO(msg) \
+ cout << sc_time_stamp() << "," << sc_delta_count() \
+ << ": reader: " << msg << endl;
+
+SC_MODULE( writer )
+{
+ // port(s)
+ sc_fifo_out<int> out;
+
+ // process(es)
+ void main_action()
+ {
+ int val = 0;
+ while( true ) {
+ wait( 10, SC_NS ); // wait for 10 ns
+ W_INFO( "blocking write" );
+ for( int i = 0; i < 20; i ++ ) {
+ out.write( val ++ ); // blocking write
+ }
+ wait( 10, SC_NS );
+ W_INFO( out.num_free() << " free spaces" );
+ W_INFO( "non-blocking write" );
+ for( int i = 0; i < 20; i ++ ) {
+ while( ! out.nb_write( val ++ ) ) { // non-blocking write
+ W_INFO( "waiting" );
+ wait( out.data_read_event() );
+ W_INFO( "data read event" );
+ }
+ }
+ }
+ }
+
+ SC_CTOR( writer )
+ {
+ SC_THREAD( main_action );
+ }
+};
+
+SC_MODULE( reader )
+{
+ // port(s)
+ sc_fifo_in<int> in;
+
+ // process(es)
+ void main_action()
+ {
+ int val;
+ while( true ) {
+ wait( 10, SC_NS ); // wait for 10 ns
+ R_INFO( "blocking read 1" );
+ for( int i = 0; i < 15; i ++ ) {
+ in.read( val ); // blocking read
+ R_INFO( val );
+ }
+ wait( 10, SC_NS );
+ R_INFO( in.num_available() << " available samples" );
+ R_INFO( "blocking read 2" );
+ for( int i = 0; i < 15; i ++ ) {
+ val = in.read(); // blocking read
+ R_INFO( val );
+ }
+ wait( 10, SC_NS );
+ R_INFO( in.num_available() << " available samples" );
+ R_INFO( "non-blocking read" );
+ for( int i = 0; i < 15; i ++ ) {
+ while( ! in.nb_read( val ) ) { // non-blocking read
+ R_INFO( "waiting" );
+ wait( in.data_written_event() );
+ R_INFO( "data written event" );
+ }
+ R_INFO( val );
+ }
+ }
+ }
+
+ SC_CTOR( reader )
+ {
+ SC_THREAD( main_action );
+ }
+};
+
+int sc_main( int, char*[] )
+{
+ // sc_clock c;
+
+ // declare channel(s)
+ sc_fifo<int> fifo( 10 );
+
+ // instantiate block(s) and connect to channel(s)
+ writer w( "writer" );
+ reader r( "reader" );
+
+ w.out( fifo );
+ r.in( fifo );
+
+ // run the simulation
+ sc_start( 100, SC_NS );
+
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/communication/sc_fifo/test05/golden/test05.log b/src/systemc/tests/systemc/communication/sc_fifo/test05/golden/test05.log
new file mode 100644
index 000000000..4c8333c81
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_fifo/test05/golden/test05.log
@@ -0,0 +1,185 @@
+SystemC Simulation
+10 ns,1: writer: blocking write
+10 ns,1: reader: blocking read 1
+10 ns,2: reader: 0
+10 ns,2: reader: 1
+10 ns,2: reader: 2
+10 ns,2: reader: 3
+10 ns,2: reader: 4
+10 ns,2: reader: 5
+10 ns,2: reader: 6
+10 ns,2: reader: 7
+10 ns,2: reader: 8
+10 ns,2: reader: 9
+10 ns,4: reader: 10
+10 ns,4: reader: 11
+10 ns,4: reader: 12
+10 ns,4: reader: 13
+10 ns,4: reader: 14
+20 ns,5: writer: 5 free spaces
+20 ns,5: writer: non-blocking write
+20 ns,5: writer: waiting
+20 ns,5: reader: 5 available samples
+20 ns,5: reader: blocking read 2
+20 ns,5: reader: 15
+20 ns,5: reader: 16
+20 ns,5: reader: 17
+20 ns,5: reader: 18
+20 ns,5: reader: 19
+20 ns,6: reader: 20
+20 ns,6: reader: 21
+20 ns,6: reader: 22
+20 ns,6: reader: 23
+20 ns,6: reader: 24
+20 ns,6: writer: data read event
+20 ns,6: writer: waiting
+20 ns,7: reader: 26
+20 ns,7: reader: 27
+20 ns,7: reader: 28
+20 ns,7: reader: 29
+20 ns,7: reader: 30
+20 ns,7: writer: data read event
+20 ns,7: writer: waiting
+20 ns,8: writer: data read event
+30 ns,9: reader: 10 available samples
+30 ns,9: reader: non-blocking read
+30 ns,9: reader: 32
+30 ns,9: reader: 33
+30 ns,9: reader: 34
+30 ns,9: reader: 35
+30 ns,9: reader: 36
+30 ns,9: reader: 38
+30 ns,9: reader: 39
+30 ns,9: reader: 40
+30 ns,9: reader: 41
+30 ns,9: reader: 42
+30 ns,9: reader: waiting
+30 ns,9: writer: blocking write
+30 ns,11: reader: data written event
+30 ns,11: reader: 43
+30 ns,11: reader: 44
+30 ns,11: reader: 45
+30 ns,11: reader: 46
+30 ns,11: reader: 47
+40 ns,13: reader: blocking read 1
+40 ns,13: reader: 48
+40 ns,13: reader: 49
+40 ns,13: reader: 50
+40 ns,13: reader: 51
+40 ns,13: reader: 52
+40 ns,13: reader: 53
+40 ns,13: reader: 54
+40 ns,13: reader: 55
+40 ns,13: reader: 56
+40 ns,13: reader: 57
+40 ns,15: reader: 58
+40 ns,15: reader: 59
+40 ns,15: reader: 60
+40 ns,15: reader: 61
+40 ns,15: reader: 62
+50 ns,16: writer: 10 free spaces
+50 ns,16: writer: non-blocking write
+50 ns,16: writer: waiting
+50 ns,16: reader: 0 available samples
+50 ns,16: reader: blocking read 2
+50 ns,17: reader: 63
+50 ns,17: reader: 64
+50 ns,17: reader: 65
+50 ns,17: reader: 66
+50 ns,17: reader: 67
+50 ns,17: reader: 68
+50 ns,17: reader: 69
+50 ns,17: reader: 70
+50 ns,17: reader: 71
+50 ns,17: reader: 72
+50 ns,18: writer: data read event
+50 ns,19: reader: 74
+50 ns,19: reader: 75
+50 ns,19: reader: 76
+50 ns,19: reader: 77
+50 ns,19: reader: 78
+60 ns,20: writer: blocking write
+60 ns,20: reader: 5 available samples
+60 ns,20: reader: non-blocking read
+60 ns,20: reader: 79
+60 ns,20: reader: 80
+60 ns,20: reader: 81
+60 ns,20: reader: 82
+60 ns,20: reader: 83
+60 ns,20: reader: waiting
+60 ns,21: reader: data written event
+60 ns,21: reader: 84
+60 ns,21: reader: 85
+60 ns,21: reader: 86
+60 ns,21: reader: 87
+60 ns,21: reader: 88
+60 ns,21: reader: waiting
+60 ns,22: reader: data written event
+60 ns,22: reader: 89
+60 ns,22: reader: 90
+60 ns,22: reader: 91
+60 ns,22: reader: 92
+60 ns,22: reader: 93
+70 ns,24: reader: blocking read 1
+70 ns,24: reader: 94
+70 ns,24: reader: 95
+70 ns,24: reader: 96
+70 ns,24: reader: 97
+70 ns,24: reader: 98
+70 ns,24: reader: 99
+70 ns,24: reader: 100
+70 ns,24: reader: 101
+70 ns,24: reader: 102
+70 ns,24: reader: 103
+70 ns,24: writer: 0 free spaces
+70 ns,24: writer: non-blocking write
+70 ns,24: writer: waiting
+70 ns,25: writer: data read event
+70 ns,25: writer: waiting
+70 ns,26: reader: 105
+70 ns,26: reader: 106
+70 ns,26: reader: 107
+70 ns,26: reader: 108
+70 ns,26: reader: 109
+70 ns,27: writer: data read event
+70 ns,27: writer: waiting
+80 ns,28: reader: 10 available samples
+80 ns,28: reader: blocking read 2
+80 ns,28: reader: 110
+80 ns,28: reader: 111
+80 ns,28: reader: 112
+80 ns,28: reader: 113
+80 ns,28: reader: 114
+80 ns,28: reader: 116
+80 ns,28: reader: 117
+80 ns,28: reader: 118
+80 ns,28: reader: 119
+80 ns,28: reader: 120
+80 ns,29: writer: data read event
+80 ns,30: reader: 122
+80 ns,30: reader: 123
+80 ns,30: reader: 124
+80 ns,30: reader: 125
+80 ns,30: reader: 126
+90 ns,31: writer: blocking write
+90 ns,31: reader: 0 available samples
+90 ns,31: reader: non-blocking read
+90 ns,31: reader: waiting
+90 ns,32: reader: data written event
+90 ns,32: reader: 127
+90 ns,32: reader: 128
+90 ns,32: reader: 129
+90 ns,32: reader: 130
+90 ns,32: reader: 131
+90 ns,32: reader: 132
+90 ns,32: reader: 133
+90 ns,32: reader: 134
+90 ns,32: reader: 135
+90 ns,32: reader: 136
+90 ns,32: reader: waiting
+90 ns,34: reader: data written event
+90 ns,34: reader: 137
+90 ns,34: reader: 138
+90 ns,34: reader: 139
+90 ns,34: reader: 140
+90 ns,34: reader: 141
diff --git a/src/systemc/tests/systemc/communication/sc_fifo/test05/test05.cpp b/src/systemc/tests/systemc/communication/sc_fifo/test05/test05.cpp
new file mode 100644
index 000000000..cbc5db975
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_fifo/test05/test05.cpp
@@ -0,0 +1,147 @@
+/*****************************************************************************
+
+ 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: Martin Janssen, Synopsys, Inc., 2002-03-23
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// test of sc_fifo event finders
+
+#include "systemc.h"
+
+#define W_INFO(msg) \
+ cout << sc_time_stamp() << "," << sc_delta_count() \
+ << ": writer: " << msg << endl;
+
+#define R_INFO(msg) \
+ cout << sc_time_stamp() << "," << sc_delta_count() \
+ << ": reader: " << msg << endl;
+
+SC_MODULE( writer )
+{
+ // port(s)
+ sc_fifo_out<int> out;
+
+ // process(es)
+ void main_action()
+ {
+ int val = 0;
+ while( true ) {
+ wait( 10, SC_NS ); // wait for 10 ns
+ W_INFO( "blocking write" );
+ for( int i = 0; i < 20; i ++ ) {
+ out.write( val ++ ); // blocking write
+ }
+ wait( 10, SC_NS );
+ W_INFO( out.num_free() << " free spaces" );
+ W_INFO( "non-blocking write" );
+ for( int i = 0; i < 20; i ++ ) {
+ while( ! out.nb_write( val ++ ) ) { // non-blocking write
+ W_INFO( "waiting" );
+ wait();
+ W_INFO( "data read event" );
+ }
+ }
+ }
+ }
+
+ SC_CTOR( writer )
+ {
+ SC_THREAD( main_action );
+ sensitive << out.data_read();
+ }
+};
+
+SC_MODULE( reader )
+{
+ // port(s)
+ sc_fifo_in<int> in;
+
+ // process(es)
+ void main_action()
+ {
+ int val;
+ while( true ) {
+ wait( 10, SC_NS ); // wait for 10 ns
+ R_INFO( "blocking read 1" );
+ for( int i = 0; i < 15; i ++ ) {
+ in.read( val ); // blocking read
+ R_INFO( val );
+ }
+ wait( 10, SC_NS );
+ R_INFO( in.num_available() << " available samples" );
+ R_INFO( "blocking read 2" );
+ for( int i = 0; i < 15; i ++ ) {
+ val = in.read(); // blocking read
+ R_INFO( val );
+ }
+ wait( 10, SC_NS );
+ R_INFO( in.num_available() << " available samples" );
+ R_INFO( "non-blocking read" );
+ for( int i = 0; i < 15; i ++ ) {
+ while( ! in.nb_read( val ) ) { // non-blocking read
+ R_INFO( "waiting" );
+ wait();
+ R_INFO( "data written event" );
+ }
+ R_INFO( val );
+ }
+ }
+ }
+
+ SC_CTOR( reader )
+ {
+ SC_THREAD( main_action );
+ sensitive << in.data_written();
+ }
+};
+
+int sc_main( int, char*[] )
+{
+ // sc_clock c;
+
+ // declare channel(s)
+ sc_fifo<int> fifo( 10 );
+
+ // instantiate block(s) and connect to channel(s)
+ writer w( "writer" );
+ reader r( "reader" );
+
+ w.out( fifo );
+ r.in( fifo );
+
+ // run the simulation
+ sc_start( 100, SC_NS );
+
+ return 0;
+}
diff --git a/src/systemc/tests/systemc/communication/sc_fifo/test06/golden/test06.log b/src/systemc/tests/systemc/communication/sc_fifo/test06/golden/test06.log
new file mode 100644
index 000000000..273d16efc
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_fifo/test06/golden/test06.log
@@ -0,0 +1,130 @@
+SystemC Simulation
+10 ns,1: writer0: blocking write
+10 ns,1: reader0: blocking read 1
+10 ns,2: reader0: 0
+10 ns,2: reader0: 1
+10 ns,2: reader0: 2
+10 ns,2: reader0: 3
+10 ns,2: reader0: 4
+10 ns,2: reader0: 5
+10 ns,2: reader0: 6
+10 ns,2: reader0: 7
+10 ns,2: reader0: 8
+10 ns,2: reader0: 9
+10 ns,3: writer1: blocking write
+10 ns,4: reader0: 10
+10 ns,4: reader0: 11
+10 ns,4: reader0: 12
+10 ns,4: reader0: 13
+10 ns,4: reader0: 14
+10 ns,4: reader1: blocking read 1
+10 ns,4: reader1: 20
+10 ns,4: reader1: 21
+10 ns,4: reader1: 22
+10 ns,4: reader1: 23
+10 ns,4: reader1: 24
+10 ns,4: reader1: 25
+10 ns,4: reader1: 26
+10 ns,4: reader1: 27
+10 ns,4: reader1: 28
+10 ns,4: reader1: 29
+10 ns,5: writer2: blocking write
+10 ns,6: reader1: 30
+10 ns,6: reader1: 31
+10 ns,6: reader1: 32
+10 ns,6: reader1: 33
+10 ns,6: reader1: 34
+10 ns,6: reader2: blocking read 1
+10 ns,6: reader2: 40
+10 ns,6: reader2: 41
+10 ns,6: reader2: 42
+10 ns,6: reader2: 43
+10 ns,6: reader2: 44
+10 ns,6: reader2: 45
+10 ns,6: reader2: 46
+10 ns,6: reader2: 47
+10 ns,6: reader2: 48
+10 ns,6: reader2: 49
+10 ns,8: reader2: 50
+10 ns,8: reader2: 51
+10 ns,8: reader2: 52
+10 ns,8: reader2: 53
+10 ns,8: reader2: 54
+20 ns,9: writer0: blocking write
+20 ns,9: reader3: 5 available samples
+20 ns,9: reader3: blocking read 2
+20 ns,9: reader0: 15
+20 ns,9: reader0: 16
+20 ns,9: reader0: 17
+20 ns,9: reader0: 18
+20 ns,9: reader0: 19
+20 ns,10: reader0: 60
+20 ns,10: reader0: 61
+20 ns,10: reader0: 62
+20 ns,10: reader0: 63
+20 ns,10: reader0: 64
+20 ns,11: reader0: 65
+20 ns,11: reader0: 66
+20 ns,11: reader0: 67
+20 ns,11: reader0: 68
+20 ns,11: reader0: 69
+20 ns,11: reader1: 35
+20 ns,11: reader1: 36
+20 ns,11: reader1: 37
+20 ns,11: reader1: 38
+20 ns,11: reader1: 39
+20 ns,12: writer1: blocking write
+20 ns,13: reader1: 80
+20 ns,13: reader1: 81
+20 ns,13: reader1: 82
+20 ns,13: reader1: 83
+20 ns,13: reader1: 84
+20 ns,13: reader1: 85
+20 ns,13: reader1: 86
+20 ns,13: reader1: 87
+20 ns,13: reader1: 88
+20 ns,13: reader1: 89
+20 ns,13: reader2: 55
+20 ns,13: reader2: 56
+20 ns,13: reader2: 57
+20 ns,13: reader2: 58
+20 ns,13: reader2: 59
+20 ns,14: writer2: blocking write
+20 ns,15: reader2: 100
+20 ns,15: reader2: 101
+20 ns,15: reader2: 102
+20 ns,15: reader2: 103
+20 ns,15: reader2: 104
+20 ns,15: reader2: 105
+20 ns,15: reader2: 106
+20 ns,15: reader2: 107
+20 ns,15: reader2: 108
+20 ns,15: reader2: 109
+30 ns,17: reader0: blocking read 1
+30 ns,17: reader0: 70
+30 ns,17: reader0: 71
+30 ns,17: reader0: 72
+30 ns,17: reader0: 73
+30 ns,17: reader0: 74
+30 ns,17: reader0: 75
+30 ns,17: reader0: 76
+30 ns,17: reader0: 77
+30 ns,17: reader0: 78
+30 ns,17: reader0: 79
+30 ns,17: writer0: blocking write
+30 ns,19: reader0: 120
+30 ns,19: reader0: 121
+30 ns,19: reader0: 122
+30 ns,19: reader0: 123
+30 ns,19: reader0: 124
+30 ns,19: reader1: blocking read 1
+30 ns,19: reader1: 90
+30 ns,19: reader1: 91
+30 ns,19: reader1: 92
+30 ns,19: reader1: 93
+30 ns,19: reader1: 94
+30 ns,19: reader1: 95
+30 ns,19: reader1: 96
+30 ns,19: reader1: 97
+30 ns,19: reader1: 98
+30 ns,19: reader1: 99
diff --git a/src/systemc/tests/systemc/communication/sc_fifo/test06/test06.cpp b/src/systemc/tests/systemc/communication/sc_fifo/test06/test06.cpp
new file mode 100644
index 000000000..bc2c34f89
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/sc_fifo/test06/test06.cpp
@@ -0,0 +1,142 @@
+/*****************************************************************************
+
+ 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 -- test multiple interfaces
+
+ Original Author: Andy Goodrich, Forte Design Systems, 03 April 2007
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// test of multiple interfaces for an sc_fifo
+
+#include "systemc.h"
+
+#define W_INFO(msg,iface) \
+ cout << sc_time_stamp() << "," << sc_delta_count() \
+ << ": writer" << iface << ": " << msg << endl;
+
+#define R_INFO(msg,iface) \
+ cout << sc_time_stamp() << "," << sc_delta_count() \
+ << ": reader" << iface << ": " << msg << endl;
+
+SC_MODULE( writer )
+{
+ // port(s)
+ sc_fifo_out<int> out;
+
+ // process(es)
+ void main_action()
+ {
+ int val = 0;
+ while( true ) {
+ wait( 10, SC_NS ); // wait for 10 ns
+ for ( int iface=0; iface < 3; iface++ )
+ {
+ W_INFO( "blocking write", iface );
+ for( int i = 0; i < 20; i ++ ) {
+ out[iface]->write( val ++ ); // blocking write
+ }
+ }
+ }
+ }
+
+ SC_CTOR( writer )
+ {
+ SC_THREAD( main_action );
+ sensitive << out.data_read();
+ }
+};
+
+SC_MODULE( reader )
+{
+ // port(s)
+ sc_fifo_in<int> in;
+
+ // process(es)
+ void main_action()
+ {
+ int iface;
+ int val;
+ while( true ) {
+ wait( 10, SC_NS ); // wait for 10 ns
+ for ( iface=0; iface < 3; iface++ )
+ {
+ R_INFO( "blocking read 1", iface );
+ for( int i = 0; i < 15; i ++ ) {
+ in[iface]->read( val ); // blocking read
+ R_INFO( val, iface );
+ }
+ }
+ wait( 10, SC_NS );
+ R_INFO( in.num_available() << " available samples", iface );
+ R_INFO( "blocking read 2", iface );
+ for ( iface=0; iface < 3; iface++ )
+ {
+ for( int i = 0; i < 15; i ++ ) {
+ val = in[iface]->read(); // blocking read
+ R_INFO( val, iface );
+ }
+ }
+ }
+ }
+
+ SC_CTOR( reader )
+ {
+ SC_THREAD( main_action );
+ sensitive << in.data_written();
+ }
+};
+
+int sc_main( int, char*[] )
+{
+ // sc_clock c;
+
+ // declare channel(s)
+ sc_fifo<int> fifo( 10 );
+ sc_fifo<int> fifo1( 10 );
+ sc_fifo<int> fifo2( 10 );
+
+ // instantiate block(s) and connect to channel(s)
+ writer w( "writer" );
+ reader r( "reader" );
+
+ w.out( fifo );
+ w.out( fifo1 );
+ w.out( fifo2 );
+ r.in( fifo );
+ r.in( fifo1 );
+ r.in( fifo2 );
+
+ // run the simulation
+ sc_start( 100, SC_NS );
+
+ return 0;
+}