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 --- .../tests/systemc/misc/stars/star102573/COMPILE | 0 .../tests/systemc/misc/stars/star102573/for_nest.h | 70 ++++++++++++++++ .../systemc/misc/stars/star102573/star102573.cpp | 96 ++++++++++++++++++++++ 3 files changed, 166 insertions(+) create mode 100644 src/systemc/tests/systemc/misc/stars/star102573/COMPILE create mode 100644 src/systemc/tests/systemc/misc/stars/star102573/for_nest.h create mode 100644 src/systemc/tests/systemc/misc/stars/star102573/star102573.cpp (limited to 'src/systemc/tests/systemc/misc/stars/star102573') diff --git a/src/systemc/tests/systemc/misc/stars/star102573/COMPILE b/src/systemc/tests/systemc/misc/stars/star102573/COMPILE new file mode 100644 index 000000000..e69de29bb diff --git a/src/systemc/tests/systemc/misc/stars/star102573/for_nest.h b/src/systemc/tests/systemc/misc/stars/star102573/for_nest.h new file mode 100644 index 000000000..aa5ee10b8 --- /dev/null +++ b/src/systemc/tests/systemc/misc/stars/star102573/for_nest.h @@ -0,0 +1,70 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + for_nest.h -- + + Original Author: Preeti Panda, Janssen, Synopsys, Inc., 2000-08-09 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +SC_MODULE( for_nest ) +{ + SC_HAS_PROCESS( for_nest ); + + sc_in_clk clk; + + const sc_signal& reset; + const sc_signal& in_valid; + const sc_signal& in_value; + sc_signal& out_valid; + sc_signal& result; + + for_nest( + sc_module_name NAME, // referense name + sc_clock& CLOCK, // clock + const sc_signal& RESET, + const sc_signal& IN_VALID, + const sc_signal& IN_VALUE, + sc_signal& OUT_VALID, + sc_signal& RESULT + ) + : clk (CLOCK), // connection definition + reset (RESET), + in_valid (IN_VALID), + in_value (IN_VALUE), + out_valid (OUT_VALID), + result (RESULT) + { + SC_CTHREAD( entry, clk.pos() ); + reset_signal_is(reset,true); + }; + void entry (); +}; diff --git a/src/systemc/tests/systemc/misc/stars/star102573/star102573.cpp b/src/systemc/tests/systemc/misc/stars/star102573/star102573.cpp new file mode 100644 index 000000000..60385dc6f --- /dev/null +++ b/src/systemc/tests/systemc/misc/stars/star102573/star102573.cpp @@ -0,0 +1,96 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + star102573.cpp -- + + Original Author: Preeti Panda, Synopsys, Inc., 2000-08-09 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +#include +#include "for_nest.h" + +#define max 5 +#define max1 4 +#define max2 3 +#define max3 2 + +void for_nest::entry() +{ + + sc_signed tmp2(2); + sc_signed tmp4(4); + sc_signed tmp8(8); + sc_signed tmp6(6); + + int i, j, inp_tmp; + + result.write(0); + out_valid.write(false); + wait(); + + main_loop:while(1) { + + while (in_valid.read()==false) wait(); + out_valid.write(true); + wait(); + /* unrolled loop inside rolled loop */ + loop1:for (i=1; i<=max; i++) { + tmp2 = in_value.read(); + inp_tmp = tmp2.to_int() + i ; + loop2:for (j=1; j<=max1; j++) + inp_tmp = inp_tmp - tmp2.to_int() ; + result.write(inp_tmp); + wait(); + }; + out_valid.write(false); + wait(); + out_valid.write(true); + wait(); + + inp_tmp = in_value.read(); + wait(); + /* unrolled loop inside unrolled loop */ + loop3:for (i=1; i<=max2; i++) { + inp_tmp += i ; + loop4:for (j=1; j<=max3; j++) { + inp_tmp -= j ; + } + }; + result.write(inp_tmp); + out_valid.write(false); + wait(); + out_valid.write(true); + wait(); + + } +} + -- cgit v1.2.3