summaryrefslogtreecommitdiff
path: root/src/systemc/tests/systemc/kernel/sc_event/test02
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/kernel/sc_event/test02
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/kernel/sc_event/test02')
-rw-r--r--src/systemc/tests/systemc/kernel/sc_event/test02/golden/test02.log140
-rw-r--r--src/systemc/tests/systemc/kernel/sc_event/test02/test02.cpp127
2 files changed, 267 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/kernel/sc_event/test02/golden/test02.log b/src/systemc/tests/systemc/kernel/sc_event/test02/golden/test02.log
new file mode 100644
index 000000000..4608d4fd4
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/sc_event/test02/golden/test02.log
@@ -0,0 +1,140 @@
+SystemC Simulation
+1 -- 0
+1 AA 0
+4 -- 0
+4 BB 0
+7 -- 1
+10 -- 2
+13 -- 3
+13 CC 3
+16 -- 4
+19 -- 5
+22 -- 6
+22 DD 6
+25 -- 7
+28 -- 8
+31 -- 9
+31 EE 9
+34 -- 10
+37 -- 11
+40 -- 12
+40 FF 12
+42 GG 13
+44 -- 13
+47 -- 14
+50 -- 15
+50 AA 15
+53 -- 16
+56 -- 17
+59 -- 18
+59 BB 18
+62 -- 19
+65 -- 20
+68 -- 21
+68 CC 21
+71 -- 22
+74 -- 23
+77 -- 24
+77 DD 24
+80 -- 25
+83 -- 26
+86 -- 27
+86 EE 27
+89 -- 28
+92 -- 29
+95 -- 30
+95 FF 30
+97 GG 31
+99 -- 31
+102 -- 32
+105 -- 33
+105 AA 33
+108 -- 34
+111 -- 35
+114 -- 36
+114 BB 36
+117 -- 37
+120 -- 38
+123 -- 39
+123 CC 39
+126 -- 40
+129 -- 41
+132 -- 42
+132 DD 42
+135 -- 43
+138 -- 44
+141 -- 45
+141 EE 45
+144 -- 46
+147 -- 47
+150 -- 48
+150 FF 48
+152 GG 49
+154 -- 49
+157 -- 50
+160 -- 51
+160 AA 51
+163 -- 52
+166 -- 53
+169 -- 54
+169 BB 54
+172 -- 55
+175 -- 56
+178 -- 57
+178 CC 57
+181 -- 58
+184 -- 59
+187 -- 60
+187 DD 60
+190 -- 61
+193 -- 62
+196 -- 63
+196 EE 63
+199 -- 64
+202 -- 65
+205 -- 66
+205 FF 66
+207 GG 67
+209 -- 67
+212 -- 68
+215 -- 69
+215 AA 69
+218 -- 70
+221 -- 71
+224 -- 72
+224 BB 72
+227 -- 73
+230 -- 74
+233 -- 75
+233 CC 75
+236 -- 76
+239 -- 77
+242 -- 78
+242 DD 78
+245 -- 79
+248 -- 80
+251 -- 81
+251 EE 81
+254 -- 82
+257 -- 83
+260 -- 84
+260 FF 84
+262 GG 85
+264 -- 85
+267 -- 86
+270 -- 87
+270 AA 87
+273 -- 88
+276 -- 89
+279 -- 90
+279 BB 90
+282 -- 91
+285 -- 92
+288 -- 93
+288 CC 93
+291 -- 94
+294 -- 95
+297 -- 96
+297 DD 96
+300 -- 97
+303 -- 98
diff --git a/src/systemc/tests/systemc/kernel/sc_event/test02/test02.cpp b/src/systemc/tests/systemc/kernel/sc_event/test02/test02.cpp
new file mode 100644
index 000000000..0137a0012
--- /dev/null
+++ b/src/systemc/tests/systemc/kernel/sc_event/test02/test02.cpp
@@ -0,0 +1,127 @@
+/*****************************************************************************
+
+ 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 immediate event notification
+
+#include "systemc.h"
+
+SC_MODULE( source )
+{
+ sc_in_clk clk;
+ sc_out<int> out;
+
+ void main_action()
+ {
+ int a = 0;
+ while( true ) {
+ wait();
+ out = a ++;
+ }
+ }
+
+ SC_CTOR( source )
+ {
+ SC_THREAD( main_action );
+ sensitive << clk.pos();
+ }
+};
+
+SC_MODULE( sink )
+{
+ sc_in_clk clk;
+ sc_in<int> in;
+
+ sc_event e;
+
+ void main_action()
+ {
+ int a;
+ while( true ) {
+ wait();
+ cout << sc_delta_count() << " -- " << in.read() << endl;
+ a = in.read();
+ if( ( a % 3 ) == 0 ) {
+ e.notify();
+ }
+ }
+ }
+
+ void other_action()
+ {
+ while( true ) {
+ wait( e );
+ cout << sc_delta_count() << " AA " << in.read() << endl;
+ wait( e | e ); // same as wait( e )
+ cout << sc_delta_count() << " BB " << in.read() << endl;
+ wait( e & e ); // same as wait( e )
+ cout << sc_delta_count() << " CC " << in.read() << endl;
+ wait( e | e | e ); // same as wait( e )
+ cout << sc_delta_count() << " DD " << in.read() << endl;
+ wait( e & e & e ); // same as wait( e )
+ cout << sc_delta_count() << " EE " << in.read() << endl;
+ wait( e & clk->negedge_event() );
+ cout << sc_delta_count() << " FF " << in.read() << endl;
+ wait( e | clk->negedge_event() );
+ cout << sc_delta_count() << " GG " << in.read() << endl;
+ }
+ }
+
+ SC_CTOR( sink )
+ {
+ SC_THREAD( main_action );
+ sensitive << clk.pos();
+ SC_THREAD( other_action );
+ }
+};
+
+int sc_main( int, char** )
+{
+ sc_clock clk;
+
+ sc_signal<int> sig;
+ source src( "src" );
+ sink snk( "snk" );
+
+ src.clk( clk );
+ src.out( sig );
+ snk.clk( clk );
+ snk.in( sig );
+
+ sc_start( 100, SC_NS );
+
+ return 0;
+}