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 --- .../datatypes/int/concat/test01/golden/test01.log | 63 +++++++ .../systemc/datatypes/int/concat/test01/test01.cpp | 201 +++++++++++++++++++++ .../datatypes/int/concat/test02/golden/test02.log | 63 +++++++ .../systemc/datatypes/int/concat/test02/test02.cpp | 201 +++++++++++++++++++++ .../datatypes/int/concat/test03/golden/test03.log | 40 ++++ .../systemc/datatypes/int/concat/test03/test03.cpp | 190 +++++++++++++++++++ .../datatypes/int/concat/test04/golden/test04.log | 63 +++++++ .../systemc/datatypes/int/concat/test04/test04.cpp | 201 +++++++++++++++++++++ .../datatypes/int/concat/test05/golden/test05.log | 63 +++++++ .../systemc/datatypes/int/concat/test05/test05.cpp | 201 +++++++++++++++++++++ .../datatypes/int/concat/test06/golden/test06.log | 40 ++++ .../systemc/datatypes/int/concat/test06/test06.cpp | 190 +++++++++++++++++++ 12 files changed, 1516 insertions(+) create mode 100644 src/systemc/tests/systemc/datatypes/int/concat/test01/golden/test01.log create mode 100644 src/systemc/tests/systemc/datatypes/int/concat/test01/test01.cpp create mode 100644 src/systemc/tests/systemc/datatypes/int/concat/test02/golden/test02.log create mode 100644 src/systemc/tests/systemc/datatypes/int/concat/test02/test02.cpp create mode 100644 src/systemc/tests/systemc/datatypes/int/concat/test03/golden/test03.log create mode 100644 src/systemc/tests/systemc/datatypes/int/concat/test03/test03.cpp create mode 100644 src/systemc/tests/systemc/datatypes/int/concat/test04/golden/test04.log create mode 100644 src/systemc/tests/systemc/datatypes/int/concat/test04/test04.cpp create mode 100644 src/systemc/tests/systemc/datatypes/int/concat/test05/golden/test05.log create mode 100644 src/systemc/tests/systemc/datatypes/int/concat/test05/test05.cpp create mode 100644 src/systemc/tests/systemc/datatypes/int/concat/test06/golden/test06.log create mode 100644 src/systemc/tests/systemc/datatypes/int/concat/test06/test06.cpp (limited to 'src/systemc/tests/systemc/datatypes/int/concat') diff --git a/src/systemc/tests/systemc/datatypes/int/concat/test01/golden/test01.log b/src/systemc/tests/systemc/datatypes/int/concat/test01/golden/test01.log new file mode 100644 index 000000000..d2fa0584e --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/concat/test01/golden/test01.log @@ -0,0 +1,63 @@ +SystemC Simulation +33 +*** sc_int_base +2 +1 +18 +--- +0 +3 +1 +--- +-8 +1 +33 +--- +-8 +2 +33 +*** sc_int_bitref +1 +0 +33 +--- +2 +34 +--- +1 +2 +33 +--- +-8 +40 +*** sc_int_subref +2 +1 +33 +--- +0 +3 +33 +--- +2 +1 +18 +--- +-8 +2 +34 +*** sc_int_concat +-6 +1 +17 +--- +-8 +1 +17 +--- +-6 +1 +17 +--- +-8 +24 diff --git a/src/systemc/tests/systemc/datatypes/int/concat/test01/test01.cpp b/src/systemc/tests/systemc/datatypes/int/concat/test01/test01.cpp new file mode 100644 index 000000000..33229ddb3 --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/concat/test01/test01.cpp @@ -0,0 +1,201 @@ +/***************************************************************************** + + 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_int's concat operators -- basic functionality, operator , () + +#include "systemc.h" + +void +test_concat( const sc_int<8>& a ) +{ + sc_int<8> b; + sc_int<4> c; + sc_int<4> d; + + cout << a << endl; + + cout << "*** sc_int_base" << endl; + + ( c, d ) = a; + cout << c << endl; + cout << d << endl; + + b = ( d, c ); + cout << b << endl; + + cout << "---" << endl; + + ( c, d[1] ) = a.range( 4, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 4, 0 ) = ( c, d[1] ); + cout << b << endl; + + cout << "---" << endl; + + ( c, d.range( 1, 0 ) ) = a.range( 5, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 5, 0 ) = ( c, d.range( 1, 0 ) ); + cout << b << endl; + + cout << "---" << endl; + + ( c, ( d[0], d[1] ) ) = a.range( 5, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 5, 0 ) = ( c, ( d[0], d[1] ) ); + cout << b << endl; + + cout << "*** sc_int_bitref" << endl; + + ( d[1], c ) = a.range( 4, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 4, 0 ) = ( d[1], c ); + cout << b << endl; + + cout << "---" << endl; + + ( d[0], d[1] ) = a.range( 1,0 ); + cout << d << endl; + + b.range( 1, 0 ) = ( d[1], d[0] ); + cout << b << endl; + + cout << "---" << endl; + + ( d[0], c.range( 3, 0 ) ) = a.range( 4, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 4, 0 ) = ( d[0], c.range( 3, 0 ) ); + cout << b << endl; + + cout << "---" << endl; + + ( d[0], ( d[1], d[2], d[3] ) ) = a.range( 3, 0 ); + cout << d << endl; + + b.range( 3, 0 ) = ( d[3], ( d[2], d[1], d[0] ) ); + cout << b << endl; + + cout << "*** sc_int_subref" << endl; + + ( c.range( 3, 0 ), d ) = a; + cout << c << endl; + cout << d << endl; + + b = ( c.range( 3, 0 ), d ); + cout << b << endl; + + cout << "---" << endl; + + ( c.range( 3, 0 ), d[1] ) = a.range( 4, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 4, 0 ) = ( c.range( 3, 0 ), d[1] ); + cout << b << endl; + + cout << "---" << endl; + + ( c.range( 3, 0 ), d.range( 3, 0 ) ) = a; + cout << c << endl; + cout << d << endl; + + b = ( d.range( 3, 0 ), c.range( 3, 0 ) ); + cout << b << endl; + + cout << "---" << endl; + + ( c.range( 3, 0 ), ( d[0], d[1] ) ) = a.range( 5, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 5, 0 ) = ( c.range( 3, 0 ), ( d[1], d[0] ) ); + cout << b << endl; + + cout << "*** sc_int_concat" << endl; + + ( ( c[1], c[0] ), d ) = a.range( 5, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 5, 0 ) = ( ( c[0], c[1] ), d ); + cout << b << endl; + + cout << "---" << endl; + + ( ( c[1], c[0] ), d[0] ) = a.range( 2, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 2, 0 ) = ( ( c[0], c[1] ), d[0] ); + cout << b << endl; + + cout << "---" << endl; + + ( ( c[1], c[0] ), d.range( 3, 0 ) ) = a.range( 5, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 5, 0 ) = ( ( c[0], c[1] ), d.range( 3, 0 ) ); + cout << b << endl; + + cout << "---" << endl; + + ( ( c[0], c[1] ), ( c[2], c[3] ) ) = a.range( 3, 0 ); + cout << c << endl; + + b.range( 3, 0 ) = ( ( c[3], c[2] ), ( c[1], c[0] ) ); + cout << b << endl; +} + +int +sc_main( int, char*[] ) +{ + sc_int<8> a( 33 ); + + test_concat( a ); + + return 0; +} diff --git a/src/systemc/tests/systemc/datatypes/int/concat/test02/golden/test02.log b/src/systemc/tests/systemc/datatypes/int/concat/test02/golden/test02.log new file mode 100644 index 000000000..a334a85d4 --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/concat/test02/golden/test02.log @@ -0,0 +1,63 @@ +SystemC Simulation +33 +*** sc_uint_base +2 +1 +18 +--- +0 +3 +1 +--- +8 +1 +33 +--- +8 +2 +33 +*** sc_uint_bitref +1 +0 +33 +--- +2 +34 +--- +1 +2 +33 +--- +8 +40 +*** sc_uint_subref +2 +1 +33 +--- +0 +3 +33 +--- +2 +1 +18 +--- +8 +2 +34 +*** sc_uint_concat +10 +1 +17 +--- +8 +1 +17 +--- +10 +1 +17 +--- +8 +24 diff --git a/src/systemc/tests/systemc/datatypes/int/concat/test02/test02.cpp b/src/systemc/tests/systemc/datatypes/int/concat/test02/test02.cpp new file mode 100644 index 000000000..fa60cb171 --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/concat/test02/test02.cpp @@ -0,0 +1,201 @@ +/***************************************************************************** + + 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_uint's concat operators -- basic functionality, operator , () + +#include "systemc.h" + +void +test_concat( const sc_uint<8>& a ) +{ + sc_uint<8> b; + sc_uint<4> c; + sc_uint<4> d; + + cout << a << endl; + + cout << "*** sc_uint_base" << endl; + + ( c, d ) = a; + cout << c << endl; + cout << d << endl; + + b = ( d, c ); + cout << b << endl; + + cout << "---" << endl; + + ( c, d[1] ) = a.range( 4, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 4, 0 ) = ( c, d[1] ); + cout << b << endl; + + cout << "---" << endl; + + ( c, d.range( 1, 0 ) ) = a.range( 5, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 5, 0 ) = ( c, d.range( 1, 0 ) ); + cout << b << endl; + + cout << "---" << endl; + + ( c, ( d[0], d[1] ) ) = a.range( 5, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 5, 0 ) = ( c, ( d[0], d[1] ) ); + cout << b << endl; + + cout << "*** sc_uint_bitref" << endl; + + ( d[1], c ) = a.range( 4, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 4, 0 ) = ( d[1], c ); + cout << b << endl; + + cout << "---" << endl; + + ( d[0], d[1] ) = a.range( 1,0 ); + cout << d << endl; + + b.range( 1, 0 ) = ( d[1], d[0] ); + cout << b << endl; + + cout << "---" << endl; + + ( d[0], c.range( 3, 0 ) ) = a.range( 4, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 4, 0 ) = ( d[0], c.range( 3, 0 ) ); + cout << b << endl; + + cout << "---" << endl; + + ( d[0], ( d[1], d[2], d[3] ) ) = a.range( 3, 0 ); + cout << d << endl; + + b.range( 3, 0 ) = ( d[3], ( d[2], d[1], d[0] ) ); + cout << b << endl; + + cout << "*** sc_uint_subref" << endl; + + ( c.range( 3, 0 ), d ) = a; + cout << c << endl; + cout << d << endl; + + b = ( c.range( 3, 0 ), d ); + cout << b << endl; + + cout << "---" << endl; + + ( c.range( 3, 0 ), d[1] ) = a.range( 4, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 4, 0 ) = ( c.range( 3, 0 ), d[1] ); + cout << b << endl; + + cout << "---" << endl; + + ( c.range( 3, 0 ), d.range( 3, 0 ) ) = a; + cout << c << endl; + cout << d << endl; + + b = ( d.range( 3, 0 ), c.range( 3, 0 ) ); + cout << b << endl; + + cout << "---" << endl; + + ( c.range( 3, 0 ), ( d[0], d[1] ) ) = a.range( 5, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 5, 0 ) = ( c.range( 3, 0 ), ( d[1], d[0] ) ); + cout << b << endl; + + cout << "*** sc_uint_concat" << endl; + + ( ( c[1], c[0] ), d ) = a.range( 5, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 5, 0 ) = ( ( c[0], c[1] ), d ); + cout << b << endl; + + cout << "---" << endl; + + ( ( c[1], c[0] ), d[0] ) = a.range( 2, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 2, 0 ) = ( ( c[0], c[1] ), d[0] ); + cout << b << endl; + + cout << "---" << endl; + + ( ( c[1], c[0] ), d.range( 3, 0 ) ) = a.range( 5, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 5, 0 ) = ( ( c[0], c[1] ), d.range( 3, 0 ) ); + cout << b << endl; + + cout << "---" << endl; + + ( ( c[0], c[1] ), ( c[2], c[3] ) ) = a.range( 3, 0 ); + cout << c << endl; + + b.range( 3, 0 ) = ( ( c[3], c[2] ), ( c[1], c[0] ) ); + cout << b << endl; +} + +int +sc_main( int, char*[] ) +{ + sc_uint<8> a( 33 ); + + test_concat( a ); + + return 0; +} diff --git a/src/systemc/tests/systemc/datatypes/int/concat/test03/golden/test03.log b/src/systemc/tests/systemc/datatypes/int/concat/test03/golden/test03.log new file mode 100644 index 000000000..4ab7885d8 --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/concat/test03/golden/test03.log @@ -0,0 +1,40 @@ +SystemC Simulation +6 +3 +7 +11 + +2 +1 +3 +3 + +2 +1 +3 +3 + +6 +3 +7 +11 + +6 +3 +7 +-5 + +-2 +1 +-1 +-1 + +-2 +1 +-1 +-1 + +6 +3 +7 +-5 diff --git a/src/systemc/tests/systemc/datatypes/int/concat/test03/test03.cpp b/src/systemc/tests/systemc/datatypes/int/concat/test03/test03.cpp new file mode 100644 index 000000000..c1431f6f7 --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/concat/test03/test03.cpp @@ -0,0 +1,190 @@ +/***************************************************************************** + + 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_[u]int concatenation with type bool, operator , () + +#include "systemc.h" + +#define WRITE(a) \ + cout << a << endl + +int +sc_main( int, char*[] ) +{ + bool b; + + // ))) sc_uint ((( + + sc_uint<3> ui3 = 3; + sc_uint<4> ui4; + sc_uint<2> ui2; + + // sc_uint_base + + b = false; + ui4 = ( ui3, b ); + WRITE( ui4 ); + ui4 = ( b, ui3 ); + WRITE( ui4 ); + + b = true; + ui4 = ( ui3, b ); + WRITE( ui4 ); + ui4 = ( b, ui3 ); + WRITE( ui4 ); + + // sc_uint_bitref + + cout << endl; + + b = false; + ui2 = ( ui3[0], b ); + WRITE( ui2 ); + ui2 = ( b, ui3[0] ); + WRITE( ui2 ); + + b = true; + ui2 = ( ui3[0], b ); + WRITE( ui2 ); + ui2 = ( b, ui3[0] ); + WRITE( ui2 ); + + // sc_uint_subref + + cout << endl; + + b = false; + ui2 = ( ui3.range( 0, 0 ), b ); + WRITE( ui2 ); + ui2 = ( b, ui3.range( 0, 0 ) ); + WRITE( ui2 ); + + b = true; + ui2 = ( ui3.range( 0, 0 ), b ); + WRITE( ui2 ); + ui2 = ( b, ui3.range( 0, 0 ) ); + WRITE( ui2 ); + + // sc_uint_concat + + cout << endl; + + b = false; + ui4 = ( ( ui3.range( 2, 1 ), ui3[0] ), b ); + WRITE( ui4 ); + ui4 = ( b, ( ui3.range( 2, 1 ), ui3[0] ) ); + WRITE( ui4 ); + + b = true; + ui4 = ( ( ui3.range( 2, 1 ), ui3[0] ), b ); + WRITE( ui4 ); + ui4 = ( b, ( ui3.range( 2, 1 ), ui3[0] ) ); + WRITE( ui4 ); + + + // ))) sc_int ((( + + sc_int<3> i3 = 3; + sc_int<4> i4; + sc_int<2> i2; + + // sc_int_base + + cout << endl; + + b = false; + i4 = ( i3, b ); + WRITE( i4 ); + i4 = ( b, i3 ); + WRITE( i4 ); + + b = true; + i4 = ( i3, b ); + WRITE( i4 ); + i4 = ( b, i3 ); + WRITE( i4 ); + + // sc_int_bitref + + cout << endl; + + b = false; + i2 = ( i3[0], b ); + WRITE( i2 ); + i2 = ( b, i3[0] ); + WRITE( i2 ); + + b = true; + i2 = ( i3[0], b ); + WRITE( i2 ); + i2 = ( b, i3[0] ); + WRITE( i2 ); + + // sc_int_subref + + cout << endl; + + b = false; + i2 = ( i3.range( 0, 0 ), b ); + WRITE( i2 ); + i2 = ( b, i3.range( 0, 0 ) ); + WRITE( i2 ); + + b = true; + i2 = ( i3.range( 0, 0 ), b ); + WRITE( i2 ); + i2 = ( b, i3.range( 0, 0 ) ); + WRITE( i2 ); + + // sc_int_concat + + cout << endl; + + b = false; + i4 = ( ( i3.range( 2, 1 ), i3[0] ), b ); + WRITE( i4 ); + i4 = ( b, ( i3.range( 2, 1 ), i3[0] ) ); + WRITE( i4 ); + + b = true; + i4 = ( ( i3.range( 2, 1 ), i3[0] ), b ); + WRITE( i4 ); + i4 = ( b, ( i3.range( 2, 1 ), i3[0] ) ); + WRITE( i4 ); + + return 0; +} diff --git a/src/systemc/tests/systemc/datatypes/int/concat/test04/golden/test04.log b/src/systemc/tests/systemc/datatypes/int/concat/test04/golden/test04.log new file mode 100644 index 000000000..d2fa0584e --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/concat/test04/golden/test04.log @@ -0,0 +1,63 @@ +SystemC Simulation +33 +*** sc_int_base +2 +1 +18 +--- +0 +3 +1 +--- +-8 +1 +33 +--- +-8 +2 +33 +*** sc_int_bitref +1 +0 +33 +--- +2 +34 +--- +1 +2 +33 +--- +-8 +40 +*** sc_int_subref +2 +1 +33 +--- +0 +3 +33 +--- +2 +1 +18 +--- +-8 +2 +34 +*** sc_int_concat +-6 +1 +17 +--- +-8 +1 +17 +--- +-6 +1 +17 +--- +-8 +24 diff --git a/src/systemc/tests/systemc/datatypes/int/concat/test04/test04.cpp b/src/systemc/tests/systemc/datatypes/int/concat/test04/test04.cpp new file mode 100644 index 000000000..e08ecfa43 --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/concat/test04/test04.cpp @@ -0,0 +1,201 @@ +/***************************************************************************** + + 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-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_int's concat operators -- basic functionality, concat() + +#include "systemc.h" + +void +test_concat( const sc_int<8>& a ) +{ + sc_int<8> b; + sc_int<4> c; + sc_int<4> d; + + cout << a << endl; + + cout << "*** sc_int_base" << endl; + + concat( c, d ) = a; + cout << c << endl; + cout << d << endl; + + b = concat( d, c ); + cout << b << endl; + + cout << "---" << endl; + + concat( c, d[1] ) = a.range( 4, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 4, 0 ) = concat( c, d[1] ); + cout << b << endl; + + cout << "---" << endl; + + concat( c, d.range( 1, 0 ) ) = a.range( 5, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 5, 0 ) = concat( c, d.range( 1, 0 ) ); + cout << b << endl; + + cout << "---" << endl; + + concat( c, ( d[0], d[1] ) ) = a.range( 5, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 5, 0 ) = concat( c, ( d[0], d[1] ) ); + cout << b << endl; + + cout << "*** sc_int_bitref" << endl; + + concat( d[1], c ) = a.range( 4, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 4, 0 ) = concat( d[1], c ); + cout << b << endl; + + cout << "---" << endl; + + concat( d[0], d[1] ) = a.range( 1,0 ); + cout << d << endl; + + b.range( 1, 0 ) = concat( d[1], d[0] ); + cout << b << endl; + + cout << "---" << endl; + + concat( d[0], c.range( 3, 0 ) ) = a.range( 4, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 4, 0 ) = concat( d[0], c.range( 3, 0 ) ); + cout << b << endl; + + cout << "---" << endl; + + concat( d[0], concat( concat( d[1], d[2] ), d[3] ) ) = a.range( 3, 0 ); + cout << d << endl; + + b.range( 3, 0 ) = concat( d[3], concat( concat( d[2], d[1] ), d[0] ) ); + cout << b << endl; + + cout << "*** sc_int_subref" << endl; + + concat( c.range( 3, 0 ), d ) = a; + cout << c << endl; + cout << d << endl; + + b = concat( c.range( 3, 0 ), d ); + cout << b << endl; + + cout << "---" << endl; + + concat( c.range( 3, 0 ), d[1] ) = a.range( 4, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 4, 0 ) = concat( c.range( 3, 0 ), d[1] ); + cout << b << endl; + + cout << "---" << endl; + + concat( c.range( 3, 0 ), d.range( 3, 0 ) ) = a; + cout << c << endl; + cout << d << endl; + + b = concat( d.range( 3, 0 ), c.range( 3, 0 ) ); + cout << b << endl; + + cout << "---" << endl; + + concat( c.range( 3, 0 ), concat( d[0], d[1] ) ) = a.range( 5, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 5, 0 ) = concat( c.range( 3, 0 ), concat( d[1], d[0] ) ); + cout << b << endl; + + cout << "*** sc_int_concat" << endl; + + concat( concat( c[1], c[0] ), d ) = a.range( 5, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 5, 0 ) = concat( concat( c[0], c[1] ), d ); + cout << b << endl; + + cout << "---" << endl; + + concat( concat( c[1], c[0] ), d[0] ) = a.range( 2, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 2, 0 ) = concat( concat( c[0], c[1] ), d[0] ); + cout << b << endl; + + cout << "---" << endl; + + concat( concat( c[1], c[0] ), d.range( 3, 0 ) ) = a.range( 5, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 5, 0 ) = concat( concat( c[0], c[1] ), d.range( 3, 0 ) ); + cout << b << endl; + + cout << "---" << endl; + + concat( concat( c[0], c[1] ), concat( c[2], c[3] ) ) = a.range( 3, 0 ); + cout << c << endl; + + b.range( 3, 0 ) = concat( concat( c[3], c[2] ), concat( c[1], c[0] ) ); + cout << b << endl; +} + +int +sc_main( int, char*[] ) +{ + sc_int<8> a( 33 ); + + test_concat( a ); + + return 0; +} diff --git a/src/systemc/tests/systemc/datatypes/int/concat/test05/golden/test05.log b/src/systemc/tests/systemc/datatypes/int/concat/test05/golden/test05.log new file mode 100644 index 000000000..a334a85d4 --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/concat/test05/golden/test05.log @@ -0,0 +1,63 @@ +SystemC Simulation +33 +*** sc_uint_base +2 +1 +18 +--- +0 +3 +1 +--- +8 +1 +33 +--- +8 +2 +33 +*** sc_uint_bitref +1 +0 +33 +--- +2 +34 +--- +1 +2 +33 +--- +8 +40 +*** sc_uint_subref +2 +1 +33 +--- +0 +3 +33 +--- +2 +1 +18 +--- +8 +2 +34 +*** sc_uint_concat +10 +1 +17 +--- +8 +1 +17 +--- +10 +1 +17 +--- +8 +24 diff --git a/src/systemc/tests/systemc/datatypes/int/concat/test05/test05.cpp b/src/systemc/tests/systemc/datatypes/int/concat/test05/test05.cpp new file mode 100644 index 000000000..8d1160f80 --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/concat/test05/test05.cpp @@ -0,0 +1,201 @@ +/***************************************************************************** + + 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-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_uint's concat operators -- basic functionality, concat() + +#include "systemc.h" + +void +test_concat( const sc_uint<8>& a ) +{ + sc_uint<8> b; + sc_uint<4> c; + sc_uint<4> d; + + cout << a << endl; + + cout << "*** sc_uint_base" << endl; + + concat( c, d ) = a; + cout << c << endl; + cout << d << endl; + + b = concat( d, c ); + cout << b << endl; + + cout << "---" << endl; + + concat( c, d[1] ) = a.range( 4, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 4, 0 ) = concat( c, d[1] ); + cout << b << endl; + + cout << "---" << endl; + + concat( c, d.range( 1, 0 ) ) = a.range( 5, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 5, 0 ) = concat( c, d.range( 1, 0 ) ); + cout << b << endl; + + cout << "---" << endl; + + concat( c, concat( d[0], d[1] ) ) = a.range( 5, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 5, 0 ) = concat( c, concat( d[0], d[1] ) ); + cout << b << endl; + + cout << "*** sc_uint_bitref" << endl; + + concat( d[1], c ) = a.range( 4, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 4, 0 ) = concat( d[1], c ); + cout << b << endl; + + cout << "---" << endl; + + concat( d[0], d[1] ) = a.range( 1,0 ); + cout << d << endl; + + b.range( 1, 0 ) = concat( d[1], d[0] ); + cout << b << endl; + + cout << "---" << endl; + + concat( d[0], c.range( 3, 0 ) ) = a.range( 4, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 4, 0 ) = concat( d[0], c.range( 3, 0 ) ); + cout << b << endl; + + cout << "---" << endl; + + concat( d[0], concat( concat( d[1], d[2] ), d[3] ) ) = a.range( 3, 0 ); + cout << d << endl; + + b.range( 3, 0 ) = concat( d[3], concat( concat( d[2], d[1] ), d[0] ) ); + cout << b << endl; + + cout << "*** sc_uint_subref" << endl; + + concat( c.range( 3, 0 ), d ) = a; + cout << c << endl; + cout << d << endl; + + b = concat( c.range( 3, 0 ), d ); + cout << b << endl; + + cout << "---" << endl; + + concat( c.range( 3, 0 ), d[1] ) = a.range( 4, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 4, 0 ) = concat( c.range( 3, 0 ), d[1] ); + cout << b << endl; + + cout << "---" << endl; + + concat( c.range( 3, 0 ), d.range( 3, 0 ) ) = a; + cout << c << endl; + cout << d << endl; + + b = concat( d.range( 3, 0 ), c.range( 3, 0 ) ); + cout << b << endl; + + cout << "---" << endl; + + concat( c.range( 3, 0 ), concat( d[0], d[1] ) ) = a.range( 5, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 5, 0 ) = concat( c.range( 3, 0 ), concat( d[1], d[0] ) ); + cout << b << endl; + + cout << "*** sc_uint_concat" << endl; + + concat( concat( c[1], c[0] ), d ) = a.range( 5, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 5, 0 ) = concat( concat( c[0], c[1] ), d ); + cout << b << endl; + + cout << "---" << endl; + + concat( concat( c[1], c[0] ), d[0] ) = a.range( 2, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 2, 0 ) = concat( concat( c[0], c[1] ), d[0] ); + cout << b << endl; + + cout << "---" << endl; + + concat( concat( c[1], c[0] ), d.range( 3, 0 ) ) = a.range( 5, 0 ); + cout << c << endl; + cout << d << endl; + + b.range( 5, 0 ) = concat( concat( c[0], c[1] ), d.range( 3, 0 ) ); + cout << b << endl; + + cout << "---" << endl; + + concat( concat( c[0], c[1] ), concat( c[2], c[3] ) ) = a.range( 3, 0 ); + cout << c << endl; + + b.range( 3, 0 ) = concat( concat( c[3], c[2] ), concat( c[1], c[0] ) ); + cout << b << endl; +} + +int +sc_main( int, char*[] ) +{ + sc_uint<8> a( 33 ); + + test_concat( a ); + + return 0; +} diff --git a/src/systemc/tests/systemc/datatypes/int/concat/test06/golden/test06.log b/src/systemc/tests/systemc/datatypes/int/concat/test06/golden/test06.log new file mode 100644 index 000000000..4ab7885d8 --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/concat/test06/golden/test06.log @@ -0,0 +1,40 @@ +SystemC Simulation +6 +3 +7 +11 + +2 +1 +3 +3 + +2 +1 +3 +3 + +6 +3 +7 +11 + +6 +3 +7 +-5 + +-2 +1 +-1 +-1 + +-2 +1 +-1 +-1 + +6 +3 +7 +-5 diff --git a/src/systemc/tests/systemc/datatypes/int/concat/test06/test06.cpp b/src/systemc/tests/systemc/datatypes/int/concat/test06/test06.cpp new file mode 100644 index 000000000..ab8f132b7 --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/concat/test06/test06.cpp @@ -0,0 +1,190 @@ +/***************************************************************************** + + 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 -- + + 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_[u]int concatenation with type bool, concat() + +#include "systemc.h" + +#define WRITE(a) \ + cout << a << endl + +int +sc_main( int, char*[] ) +{ + bool b; + + // ))) sc_uint ((( + + sc_uint<3> ui3 = 3; + sc_uint<4> ui4; + sc_uint<2> ui2; + + // sc_uint_base + + b = false; + ui4 = concat( ui3, b ); + WRITE( ui4 ); + ui4 = concat( b, ui3 ); + WRITE( ui4 ); + + b = true; + ui4 = concat( ui3, b ); + WRITE( ui4 ); + ui4 = concat( b, ui3 ); + WRITE( ui4 ); + + // sc_uint_bitref + + cout << endl; + + b = false; + ui2 = concat( ui3[0], b ); + WRITE( ui2 ); + ui2 = concat( b, ui3[0] ); + WRITE( ui2 ); + + b = true; + ui2 = concat( ui3[0], b ); + WRITE( ui2 ); + ui2 = concat( b, ui3[0] ); + WRITE( ui2 ); + + // sc_uint_subref + + cout << endl; + + b = false; + ui2 = concat( ui3.range( 0, 0 ), b ); + WRITE( ui2 ); + ui2 = concat( b, ui3.range( 0, 0 ) ); + WRITE( ui2 ); + + b = true; + ui2 = concat( ui3.range( 0, 0 ), b ); + WRITE( ui2 ); + ui2 = concat( b, ui3.range( 0, 0 ) ); + WRITE( ui2 ); + + // sc_uint_concat + + cout << endl; + + b = false; + ui4 = concat( concat( ui3.range( 2, 1 ), ui3[0] ), b ); + WRITE( ui4 ); + ui4 = concat( b, concat( ui3.range( 2, 1 ), ui3[0] ) ); + WRITE( ui4 ); + + b = true; + ui4 = concat( concat( ui3.range( 2, 1 ), ui3[0] ), b ); + WRITE( ui4 ); + ui4 = concat( b, concat( ui3.range( 2, 1 ), ui3[0] ) ); + WRITE( ui4 ); + + + // ))) sc_int ((( + + sc_int<3> i3 = 3; + sc_int<4> i4; + sc_int<2> i2; + + // sc_int_base + + cout << endl; + + b = false; + i4 = concat( i3, b ); + WRITE( i4 ); + i4 = concat( b, i3 ); + WRITE( i4 ); + + b = true; + i4 = concat( i3, b ); + WRITE( i4 ); + i4 = concat( b, i3 ); + WRITE( i4 ); + + // sc_int_bitref + + cout << endl; + + b = false; + i2 = concat( i3[0], b ); + WRITE( i2 ); + i2 = concat( b, i3[0] ); + WRITE( i2 ); + + b = true; + i2 = concat( i3[0], b ); + WRITE( i2 ); + i2 = concat( b, i3[0] ); + WRITE( i2 ); + + // sc_int_subref + + cout << endl; + + b = false; + i2 = concat( i3.range( 0, 0 ), b ); + WRITE( i2 ); + i2 = concat( b, i3.range( 0, 0 ) ); + WRITE( i2 ); + + b = true; + i2 = concat( i3.range( 0, 0 ), b ); + WRITE( i2 ); + i2 = concat( b, i3.range( 0, 0 ) ); + WRITE( i2 ); + + // sc_int_concat + + cout << endl; + + b = false; + i4 = concat( concat( i3.range( 2, 1 ), i3[0] ), b ); + WRITE( i4 ); + i4 = concat( b, concat( i3.range( 2, 1 ), i3[0] ) ); + WRITE( i4 ); + + b = true; + i4 = concat( concat( i3.range( 2, 1 ), i3[0] ), b ); + WRITE( i4 ); + i4 = concat( b, concat( i3.range( 2, 1 ), i3[0] ) ); + WRITE( i4 ); + + return 0; +} -- cgit v1.2.3