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 --- .../unit/data/general/array_range/array_range.cpp | 77 ++++++++++++++++++++ .../unit/data/general/array_range/array_range.f | 3 + .../unit/data/general/array_range/array_range.h | 83 ++++++++++++++++++++++ .../misc/unit/data/general/array_range/common.h | 49 +++++++++++++ .../general/array_range/golden/array_range.log | 8 +++ .../misc/unit/data/general/array_range/main.cpp | 67 +++++++++++++++++ .../misc/unit/data/general/array_range/stimgen.cpp | 61 ++++++++++++++++ .../misc/unit/data/general/array_range/stimgen.h | 83 ++++++++++++++++++++++ 8 files changed, 431 insertions(+) create mode 100644 src/systemc/tests/systemc/misc/unit/data/general/array_range/array_range.cpp create mode 100644 src/systemc/tests/systemc/misc/unit/data/general/array_range/array_range.f create mode 100644 src/systemc/tests/systemc/misc/unit/data/general/array_range/array_range.h create mode 100644 src/systemc/tests/systemc/misc/unit/data/general/array_range/common.h create mode 100644 src/systemc/tests/systemc/misc/unit/data/general/array_range/golden/array_range.log create mode 100644 src/systemc/tests/systemc/misc/unit/data/general/array_range/main.cpp create mode 100644 src/systemc/tests/systemc/misc/unit/data/general/array_range/stimgen.cpp create mode 100644 src/systemc/tests/systemc/misc/unit/data/general/array_range/stimgen.h (limited to 'src/systemc/tests/systemc/misc/unit/data/general/array_range') diff --git a/src/systemc/tests/systemc/misc/unit/data/general/array_range/array_range.cpp b/src/systemc/tests/systemc/misc/unit/data/general/array_range/array_range.cpp new file mode 100644 index 000000000..b8ea63ebc --- /dev/null +++ b/src/systemc/tests/systemc/misc/unit/data/general/array_range/array_range.cpp @@ -0,0 +1,77 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + array_range.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: + + *****************************************************************************/ + + /*******************************************/ + /* Implementation Filename: array_range.cc */ + /*******************************************/ + +#include "array_range.h" + +void +array_range::entry() +{ + bool_vector8 a; + bool_vector4 b; + bool_vector4 c; + bool_vector8 d; + bool_vector8 e; + bool_vector8 f; + // bool_vector0 nullbv; // Null vector to make scalar concat work + + wait(); + + a = in1.read(); + + b = a.range(7,4); c = a.range(3,0); // sub vectors + + d = a.range(0,7); // bit reverse + + // e = (nullbv, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7]); + e = (a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7]); + // bit reverse concat + + f = (a.range(3,1), a.range(7,6), a[0], a.range(4,5)); // shuffle + + o1.write(b); + o2.write(c); + o3.write(d); + o4.write(e); + o5.write(f); + + wait(); + +} diff --git a/src/systemc/tests/systemc/misc/unit/data/general/array_range/array_range.f b/src/systemc/tests/systemc/misc/unit/data/general/array_range/array_range.f new file mode 100644 index 000000000..4eb297dac --- /dev/null +++ b/src/systemc/tests/systemc/misc/unit/data/general/array_range/array_range.f @@ -0,0 +1,3 @@ +array_range/array_range.cpp +array_range/stimgen.cpp +array_range/main.cpp diff --git a/src/systemc/tests/systemc/misc/unit/data/general/array_range/array_range.h b/src/systemc/tests/systemc/misc/unit/data/general/array_range/array_range.h new file mode 100644 index 000000000..e4916ca3e --- /dev/null +++ b/src/systemc/tests/systemc/misc/unit/data/general/array_range/array_range.h @@ -0,0 +1,83 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + array_range.h -- + + 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: + + *****************************************************************************/ + + /**************************************/ + /* Interface Filename: array_range.h */ + /**************************************/ + +#include "common.h" + +SC_MODULE( array_range ) +{ + SC_HAS_PROCESS( array_range ); + + sc_in_clk clk; + + // Inputs + const signal_bool_vector8& in1; + // Outputs + signal_bool_vector4& o1; + signal_bool_vector4& o2; + signal_bool_vector8& o3; + signal_bool_vector8& o4; + signal_bool_vector8& o5; + + // Constructor + array_range (sc_module_name NAME, + sc_clock& TICK, + const signal_bool_vector8& IN1, + signal_bool_vector4& O1, + signal_bool_vector4& O2, + signal_bool_vector8& O3, + signal_bool_vector8& O4, + signal_bool_vector8& O5 ) + + : + in1 (IN1), + o1 (O1), + o2 (O2), + o3 (O3), + o4 (O4), + o5 (O5) + + { + clk (TICK); + SC_CTHREAD( entry, clk.pos() ); + } + + void entry(); +}; diff --git a/src/systemc/tests/systemc/misc/unit/data/general/array_range/common.h b/src/systemc/tests/systemc/misc/unit/data/general/array_range/common.h new file mode 100644 index 000000000..9e4b1fea5 --- /dev/null +++ b/src/systemc/tests/systemc/misc/unit/data/general/array_range/common.h @@ -0,0 +1,49 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + common.h -- + + 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: + + *****************************************************************************/ + +#ifndef COMMON_H +#define COMMON_H + +#include "systemc.h" + +typedef sc_bv<0> bool_vector0; +typedef sc_bv<4> bool_vector4; +typedef sc_bv<8> bool_vector8; +typedef sc_signal signal_bool_vector4; +typedef sc_signal signal_bool_vector8; + +#endif diff --git a/src/systemc/tests/systemc/misc/unit/data/general/array_range/golden/array_range.log b/src/systemc/tests/systemc/misc/unit/data/general/array_range/golden/array_range.log new file mode 100644 index 000000000..deac0cd85 --- /dev/null +++ b/src/systemc/tests/systemc/misc/unit/data/general/array_range/golden/array_range.log @@ -0,0 +1,8 @@ +SystemC Simulation +IN1 = 01011001 +O1 = 0101 O2 = 1001 +O3 = 10011010 +O4 = 10011010 +O5 = 10001110 + +Info: /OSCI/SystemC: Simulation stopped by user. diff --git a/src/systemc/tests/systemc/misc/unit/data/general/array_range/main.cpp b/src/systemc/tests/systemc/misc/unit/data/general/array_range/main.cpp new file mode 100644 index 000000000..70be37a8c --- /dev/null +++ b/src/systemc/tests/systemc/misc/unit/data/general/array_range/main.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. + + *****************************************************************************/ + +/***************************************************************************** + + main.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: + + *****************************************************************************/ + + /***************************************/ + /* Main Filename: main.cc */ + /***************************************/ + +#include "array_range.h" +#include "stimgen.h" + +int sc_main(int ac, char *av[]) +{ + +// Signal Instantiation + signal_bool_vector8 in1 ("in1"); + signal_bool_vector4 o1 ("o1"); + signal_bool_vector4 o2 ("o2"); + signal_bool_vector8 o3 ("o3"); + signal_bool_vector8 o4 ("o4"); + signal_bool_vector8 o5 ("o5"); + +// Clock Instantiation + sc_clock clk( "clock", 10, SC_NS, 0.5, 0, SC_NS); + +// Process Instantiation + array_range D1 ("D1", clk, in1, o1, o2, o3, o4, o5); + + stimgen T1 ("T1", clk, o1, o2, o3, o4, o5, in1); + +// Simulation Run Control + sc_start(); + return 0; +} diff --git a/src/systemc/tests/systemc/misc/unit/data/general/array_range/stimgen.cpp b/src/systemc/tests/systemc/misc/unit/data/general/array_range/stimgen.cpp new file mode 100644 index 000000000..54c05bc4f --- /dev/null +++ b/src/systemc/tests/systemc/misc/unit/data/general/array_range/stimgen.cpp @@ -0,0 +1,61 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + stimgen.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: + + *****************************************************************************/ + + /*******************************************/ + /* Implementation Filename: stimgen.cc */ + /*******************************************/ + +#include "stimgen.h" + +void +stimgen::entry() +{ + bool_vector8 d; + +// in1.write("0101_1001"); + in1.write("01011001"); + wait(2); + + cout << "IN1 = " << in1.read() << endl; + cout << "O1 = " << o1.read() + << " O2 = " << o2.read() << endl; + cout << "O3 = " << o3.read() << endl; + cout << "O4 = " << o4.read() << endl; + cout << "O5 = " << o5.read() << endl; + + sc_stop(); +} diff --git a/src/systemc/tests/systemc/misc/unit/data/general/array_range/stimgen.h b/src/systemc/tests/systemc/misc/unit/data/general/array_range/stimgen.h new file mode 100644 index 000000000..17244bc5e --- /dev/null +++ b/src/systemc/tests/systemc/misc/unit/data/general/array_range/stimgen.h @@ -0,0 +1,83 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + stimgen.h -- + + 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: + + *****************************************************************************/ + + /**************************************/ + /* Interface Filename: stimgen.h */ + /**************************************/ + +#include "common.h" + +SC_MODULE( stimgen ) +{ + SC_HAS_PROCESS( stimgen ); + + sc_in_clk clk; + + // Inputs + const signal_bool_vector4& o1; + const signal_bool_vector4& o2; + const signal_bool_vector8& o3; + const signal_bool_vector8& o4; + const signal_bool_vector8& o5; + // Outputs + signal_bool_vector8& in1; + + // Constructor + stimgen (sc_module_name NAME, + sc_clock& TICK, + const signal_bool_vector4& O1, + const signal_bool_vector4& O2, + const signal_bool_vector8& O3, + const signal_bool_vector8& O4, + const signal_bool_vector8& O5, + signal_bool_vector8& IN1 ) + + : + o1 (O1), + o2 (O2), + o3 (O3), + o4 (O4), + o5 (O5), + in1 (IN1) + + { + clk (TICK); + SC_CTHREAD( entry, clk.pos() ); + } + + void entry(); +}; -- cgit v1.2.3