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 --- .../channel/hshake1/golden/hshake1.log | 203 +++++++++++++++++++++ .../misc/communication/channel/hshake1/hshake1.cpp | 131 +++++++++++++ 2 files changed, 334 insertions(+) create mode 100644 src/systemc/tests/systemc/misc/communication/channel/hshake1/golden/hshake1.log create mode 100644 src/systemc/tests/systemc/misc/communication/channel/hshake1/hshake1.cpp (limited to 'src/systemc/tests/systemc/misc/communication/channel/hshake1') diff --git a/src/systemc/tests/systemc/misc/communication/channel/hshake1/golden/hshake1.log b/src/systemc/tests/systemc/misc/communication/channel/hshake1/golden/hshake1.log new file mode 100644 index 000000000..a1f8a6efe --- /dev/null +++ b/src/systemc/tests/systemc/misc/communication/channel/hshake1/golden/hshake1.log @@ -0,0 +1,203 @@ +SystemC Simulation +Proc2::Done is 1 +Done is 1 +Input is 0 +Proc2::Input is 0 +Input is 1 +Proc2::Input is 1 +Input is 2 +Proc2::Input is 2 +Input is 3 +Proc2::Input is 3 +Input is 4 +Proc2::Input is 4 +Input is 5 +Proc2::Input is 5 +Input is 6 +Proc2::Input is 6 +Input is 7 +Proc2::Input is 7 +Input is 8 +Proc2::Input is 8 +Input is 9 +Proc2::Input is 9 +Input is 10 +Proc2::Input is 10 +Input is 11 +Proc2::Input is 11 +Input is 12 +Proc2::Input is 12 +Input is 13 +Proc2::Input is 13 +Input is 14 +Proc2::Input is 14 +Input is 15 +Proc2::Input is 15 +Input is 16 +Proc2::Input is 16 +Input is 17 +Proc2::Input is 17 +Input is 18 +Proc2::Input is 18 +Input is 19 +Proc2::Input is 19 +Input is 20 +Proc2::Input is 20 +Input is 21 +Proc2::Input is 21 +Input is 22 +Proc2::Input is 22 +Input is 23 +Proc2::Input is 23 +Input is 24 +Proc2::Input is 24 +Input is 25 +Proc2::Input is 25 +Input is 26 +Proc2::Input is 26 +Input is 27 +Proc2::Input is 27 +Input is 28 +Proc2::Input is 28 +Input is 29 +Proc2::Input is 29 +Input is 30 +Proc2::Input is 30 +Input is 31 +Proc2::Input is 31 +Input is 32 +Proc2::Input is 32 +Input is 33 +Proc2::Input is 33 +Input is 34 +Proc2::Input is 34 +Input is 35 +Proc2::Input is 35 +Input is 36 +Proc2::Input is 36 +Input is 37 +Proc2::Input is 37 +Input is 38 +Proc2::Input is 38 +Input is 39 +Proc2::Input is 39 +Input is 40 +Proc2::Input is 40 +Input is 41 +Proc2::Input is 41 +Input is 42 +Proc2::Input is 42 +Input is 43 +Proc2::Input is 43 +Input is 44 +Proc2::Input is 44 +Input is 45 +Proc2::Input is 45 +Input is 46 +Proc2::Input is 46 +Input is 47 +Proc2::Input is 47 +Input is 48 +Proc2::Input is 48 +Input is 49 +Proc2::Input is 49 +Input is 50 +Proc2::Input is 50 +Input is 51 +Proc2::Input is 51 +Input is 52 +Proc2::Input is 52 +Input is 53 +Proc2::Input is 53 +Input is 54 +Proc2::Input is 54 +Input is 55 +Proc2::Input is 55 +Input is 56 +Proc2::Input is 56 +Input is 57 +Proc2::Input is 57 +Input is 58 +Proc2::Input is 58 +Input is 59 +Proc2::Input is 59 +Input is 60 +Proc2::Input is 60 +Input is 61 +Proc2::Input is 61 +Input is 62 +Proc2::Input is 62 +Input is 63 +Proc2::Input is 63 +Input is 64 +Proc2::Input is 64 +Input is 65 +Proc2::Input is 65 +Input is 66 +Proc2::Input is 66 +Input is 67 +Proc2::Input is 67 +Input is 68 +Proc2::Input is 68 +Input is 69 +Proc2::Input is 69 +Input is 70 +Proc2::Input is 70 +Input is 71 +Proc2::Input is 71 +Input is 72 +Proc2::Input is 72 +Input is 73 +Proc2::Input is 73 +Input is 74 +Proc2::Input is 74 +Input is 75 +Proc2::Input is 75 +Input is 76 +Proc2::Input is 76 +Input is 77 +Proc2::Input is 77 +Input is 78 +Proc2::Input is 78 +Input is 79 +Proc2::Input is 79 +Input is 80 +Proc2::Input is 80 +Input is 81 +Proc2::Input is 81 +Input is 82 +Proc2::Input is 82 +Input is 83 +Proc2::Input is 83 +Input is 84 +Proc2::Input is 84 +Input is 85 +Proc2::Input is 85 +Input is 86 +Proc2::Input is 86 +Input is 87 +Proc2::Input is 87 +Input is 88 +Proc2::Input is 88 +Input is 89 +Proc2::Input is 89 +Input is 90 +Proc2::Input is 90 +Input is 91 +Proc2::Input is 91 +Input is 92 +Proc2::Input is 92 +Input is 93 +Proc2::Input is 93 +Input is 94 +Proc2::Input is 94 +Input is 95 +Proc2::Input is 95 +Input is 96 +Proc2::Input is 96 +Input is 97 +Proc2::Input is 97 +Input is 98 +Proc2::Input is 98 +Input is 99 +Proc2::Input is 99 diff --git a/src/systemc/tests/systemc/misc/communication/channel/hshake1/hshake1.cpp b/src/systemc/tests/systemc/misc/communication/channel/hshake1/hshake1.cpp new file mode 100644 index 000000000..a990b86d3 --- /dev/null +++ b/src/systemc/tests/systemc/misc/communication/channel/hshake1/hshake1.cpp @@ -0,0 +1,131 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + hshake1.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: + + *****************************************************************************/ + +#include "systemc.h" + +SC_MODULE( proc1 ) +{ + SC_HAS_PROCESS( proc1 ); + + sc_in_clk clk; + + sc_fifo& in; + sc_fifo& done; + sc_fifo& out; + sc_fifo& ready; + + // Constructor + proc1 ( sc_module_name NAME, + sc_clock& CLOCK, + sc_fifo& IN_, + sc_fifo& DONE, + sc_fifo& OUT_, + sc_fifo& READY ) + : in(IN_), done(DONE), out(OUT_), ready(READY) + { + clk(CLOCK); + SC_THREAD( entry ); + sensitive << clk.pos(); + } + + void entry() { + ready.write(1); + bool done_ = done.read(); + cout << "Done is " << done_ << endl; + for (int i=0; i < 100; i++) { + out.write(i); + int in_ = in.read(); + cout << "Input is " << in_ << endl; + } + ready.write(0); + } +}; + +SC_MODULE( proc2 ) +{ + SC_HAS_PROCESS( proc2 ); + + sc_in_clk clk; + + sc_fifo& in; + sc_fifo& done; + sc_fifo& out; + sc_fifo& ready; + + // Constructor + proc2 ( sc_module_name NAME, + sc_clock& CLOCK, + sc_fifo& IN_, + sc_fifo& DONE, + sc_fifo& OUT_, + sc_fifo& READY ) + : in(IN_), done(DONE), out(OUT_), ready(READY) + { + clk(CLOCK); + SC_THREAD( entry ); + sensitive << clk.pos(); + } + + void entry() { + bool done_ = done.read(); + cout << "Proc2::Done is " << done_ << endl; + ready.write(1); + for (int i=0; i < 100; i++) { + out.write(i); + int in_ = in.read(); + cout << "Proc2::Input is " << in_ << endl; + } + ready.write(0); + } +}; + +int sc_main(int ac, char *av[]) +{ + sc_fifo a; + sc_fifo b; + sc_fifo c("C", 10); + // sc_fifo d("D", 2); + sc_fifo d("D", 1); + + sc_clock clock("CLK", 20, SC_NS); + + proc1 p1("P1", clock, c, a, d, b); + proc2 p2("P2", clock, d, b, c, a); + + sc_start(1000, SC_NS); + return 0; +} -- cgit v1.2.3