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 --- .../bitselect/32bit/signed/golden/select.log | 33 +++ .../int/sc_int/bitselect/32bit/signed/select.cpp | 64 ++++++ .../bitselect/32bit/unsigned/golden/select.log | 33 +++ .../int/sc_int/bitselect/32bit/unsigned/select.cpp | 64 ++++++ .../bitselect/64bit/signed/golden/select.log | 49 +++++ .../int/sc_int/bitselect/64bit/signed/select.cpp | 65 ++++++ .../bitselect/64bit/unsigned/golden/select.log | 65 ++++++ .../int/sc_int/bitselect/64bit/unsigned/select.cpp | 65 ++++++ .../int/sc_int/concat/signed/32bit/concat.cpp | 56 +++++ .../sc_int/concat/signed/32bit/golden/concat.log | 32 +++ .../int/sc_int/concat/signed/64bit/concat.cpp | 56 +++++ .../sc_int/concat/signed/64bit/golden/concat.log | 64 ++++++ .../int/sc_int/concat/unsigned/32bit/concat.cpp | 55 +++++ .../sc_int/concat/unsigned/32bit/golden/concat.log | 32 +++ .../int/sc_int/concat/unsigned/64bit/concat.cpp | 56 +++++ .../sc_int/concat/unsigned/64bit/golden/concat.log | 64 ++++++ .../datatypes/int/sc_int/mixed/golden/test_int.log | 38 ++++ .../datatypes/int/sc_int/mixed/test_int.cpp | 235 +++++++++++++++++++++ .../partselect/32bit/signed/golden/select.log | 33 +++ .../int/sc_int/partselect/32bit/signed/select.cpp | 64 ++++++ .../partselect/32bit/unsigned/golden/select.log | 33 +++ .../sc_int/partselect/32bit/unsigned/select.cpp | 64 ++++++ .../partselect/64bit/signed/golden/select.log | 65 ++++++ .../int/sc_int/partselect/64bit/signed/select.cpp | 64 ++++++ .../partselect/64bit/unsigned/golden/select.log | 65 ++++++ .../sc_int/partselect/64bit/unsigned/select.cpp | 64 ++++++ 26 files changed, 1578 insertions(+) create mode 100644 src/systemc/tests/systemc/datatypes/int/sc_int/bitselect/32bit/signed/golden/select.log create mode 100644 src/systemc/tests/systemc/datatypes/int/sc_int/bitselect/32bit/signed/select.cpp create mode 100644 src/systemc/tests/systemc/datatypes/int/sc_int/bitselect/32bit/unsigned/golden/select.log create mode 100644 src/systemc/tests/systemc/datatypes/int/sc_int/bitselect/32bit/unsigned/select.cpp create mode 100644 src/systemc/tests/systemc/datatypes/int/sc_int/bitselect/64bit/signed/golden/select.log create mode 100644 src/systemc/tests/systemc/datatypes/int/sc_int/bitselect/64bit/signed/select.cpp create mode 100644 src/systemc/tests/systemc/datatypes/int/sc_int/bitselect/64bit/unsigned/golden/select.log create mode 100644 src/systemc/tests/systemc/datatypes/int/sc_int/bitselect/64bit/unsigned/select.cpp create mode 100644 src/systemc/tests/systemc/datatypes/int/sc_int/concat/signed/32bit/concat.cpp create mode 100644 src/systemc/tests/systemc/datatypes/int/sc_int/concat/signed/32bit/golden/concat.log create mode 100644 src/systemc/tests/systemc/datatypes/int/sc_int/concat/signed/64bit/concat.cpp create mode 100644 src/systemc/tests/systemc/datatypes/int/sc_int/concat/signed/64bit/golden/concat.log create mode 100644 src/systemc/tests/systemc/datatypes/int/sc_int/concat/unsigned/32bit/concat.cpp create mode 100644 src/systemc/tests/systemc/datatypes/int/sc_int/concat/unsigned/32bit/golden/concat.log create mode 100644 src/systemc/tests/systemc/datatypes/int/sc_int/concat/unsigned/64bit/concat.cpp create mode 100644 src/systemc/tests/systemc/datatypes/int/sc_int/concat/unsigned/64bit/golden/concat.log create mode 100644 src/systemc/tests/systemc/datatypes/int/sc_int/mixed/golden/test_int.log create mode 100644 src/systemc/tests/systemc/datatypes/int/sc_int/mixed/test_int.cpp create mode 100644 src/systemc/tests/systemc/datatypes/int/sc_int/partselect/32bit/signed/golden/select.log create mode 100644 src/systemc/tests/systemc/datatypes/int/sc_int/partselect/32bit/signed/select.cpp create mode 100644 src/systemc/tests/systemc/datatypes/int/sc_int/partselect/32bit/unsigned/golden/select.log create mode 100644 src/systemc/tests/systemc/datatypes/int/sc_int/partselect/32bit/unsigned/select.cpp create mode 100644 src/systemc/tests/systemc/datatypes/int/sc_int/partselect/64bit/signed/golden/select.log create mode 100644 src/systemc/tests/systemc/datatypes/int/sc_int/partselect/64bit/signed/select.cpp create mode 100644 src/systemc/tests/systemc/datatypes/int/sc_int/partselect/64bit/unsigned/golden/select.log create mode 100644 src/systemc/tests/systemc/datatypes/int/sc_int/partselect/64bit/unsigned/select.cpp (limited to 'src/systemc/tests/systemc/datatypes/int/sc_int') diff --git a/src/systemc/tests/systemc/datatypes/int/sc_int/bitselect/32bit/signed/golden/select.log b/src/systemc/tests/systemc/datatypes/int/sc_int/bitselect/32bit/signed/golden/select.log new file mode 100644 index 000000000..c81b8ffe9 --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/sc_int/bitselect/32bit/signed/golden/select.log @@ -0,0 +1,33 @@ +SystemC Simulation +i = 0 +i = 1 +i = 2 +i = 3 +i = 4 +i = 5 +i = 6 +i = 7 +i = 8 +i = 9 +i = 10 +i = 11 +i = 12 +i = 13 +i = 14 +i = 15 +i = 16 +i = 17 +i = 18 +i = 19 +i = 20 +i = 21 +i = 22 +i = 23 +i = 24 +i = 25 +i = 26 +i = 27 +i = 28 +i = 29 +i = 30 +i = 31 diff --git a/src/systemc/tests/systemc/datatypes/int/sc_int/bitselect/32bit/signed/select.cpp b/src/systemc/tests/systemc/datatypes/int/sc_int/bitselect/32bit/signed/select.cpp new file mode 100644 index 000000000..cb9ee2e68 --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/sc_int/bitselect/32bit/signed/select.cpp @@ -0,0 +1,64 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + select.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" + +#define WIDTH 32 +#define COUNT 100000 + +int sc_main( int ac, char* av[] ) +{ + sc_int Bx, By; + + for(unsigned int i = 0; i < WIDTH; i++){ + cout << "i = " << i << endl; + for(unsigned int j=0; j < COUNT; j++ ){ + + /* ( By.range(WIDTH-1, i+1), By.range(i,0) ) = Bx; + sc_assert( By == Bx ); + */ + + Bx = j; + sc_assert( (bool) Bx[i] == (j & (1< Bx, By; + + for(unsigned int i = 0; i < WIDTH; i++){ + cout << "i = " << i << endl; + for(unsigned int j=0; j < COUNT; j++ ){ + + /* ( By.range(WIDTH-1, i+1), By.range(i,0) ) = Bx; + sc_assert( By == Bx ); + */ + + Bx = j; + sc_assert( (bool) Bx[i] == (j & (1< Bx,By; + + for(unsigned int i = 0; i < WIDTH; i++){ + cout << "i = " << i << endl; + for(uint64 j=0; j < COUNT; j++ ){ + + /* ( By.range(WIDTH-1, i+1), By.range(i,0) ) = Bx; + sc_assert( By == Bx ); + */ + + Bx = j; + sc_assert( (bool) Bx[i] == (j & (uint64(1)< Bx,By; + + for(unsigned int i = 0; i < WIDTH; i++){ + cout << "i = " << i << endl; + for(uint64 j=0; j < COUNT; j++ ){ + + /* ( By.range(WIDTH-1, i+1), By.range(i,0) ) = Bx; + sc_assert( By == Bx ); + */ + + Bx = j; + sc_assert( (bool) Bx[i] == (j & (uint64(1)< a_si32, b_si32; + + for(int i=0; i < WIDTH-1; i++ ){ + cout << "i = " << i << endl; + a_si32 = i; + b_si32 = (a_si32.range(WIDTH-1,i+1), a_si32.range(i,0)); + sc_assert( a_si32 == b_si32 ); + } + + return 0; +} + diff --git a/src/systemc/tests/systemc/datatypes/int/sc_int/concat/signed/32bit/golden/concat.log b/src/systemc/tests/systemc/datatypes/int/sc_int/concat/signed/32bit/golden/concat.log new file mode 100644 index 000000000..31bb32fc5 --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/sc_int/concat/signed/32bit/golden/concat.log @@ -0,0 +1,32 @@ +SystemC Simulation +i = 0 +i = 1 +i = 2 +i = 3 +i = 4 +i = 5 +i = 6 +i = 7 +i = 8 +i = 9 +i = 10 +i = 11 +i = 12 +i = 13 +i = 14 +i = 15 +i = 16 +i = 17 +i = 18 +i = 19 +i = 20 +i = 21 +i = 22 +i = 23 +i = 24 +i = 25 +i = 26 +i = 27 +i = 28 +i = 29 +i = 30 diff --git a/src/systemc/tests/systemc/datatypes/int/sc_int/concat/signed/64bit/concat.cpp b/src/systemc/tests/systemc/datatypes/int/sc_int/concat/signed/64bit/concat.cpp new file mode 100644 index 000000000..a2a7acd1f --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/sc_int/concat/signed/64bit/concat.cpp @@ -0,0 +1,56 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + concat.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" + +#define WIDTH 64 + +int sc_main(int ac, char* av[] ) +{ + + sc_int a_si64, b_si64; + + for(int i=0; i < WIDTH-1; i++ ){ + cout << "i = " << i << endl; + a_si64 = i; + b_si64 = (a_si64.range(WIDTH-1,i+1), a_si64.range(i,0)); + sc_assert( a_si64 == b_si64 ); + } + + return 0; +} + diff --git a/src/systemc/tests/systemc/datatypes/int/sc_int/concat/signed/64bit/golden/concat.log b/src/systemc/tests/systemc/datatypes/int/sc_int/concat/signed/64bit/golden/concat.log new file mode 100644 index 000000000..e47f7871b --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/sc_int/concat/signed/64bit/golden/concat.log @@ -0,0 +1,64 @@ +SystemC Simulation +i = 0 +i = 1 +i = 2 +i = 3 +i = 4 +i = 5 +i = 6 +i = 7 +i = 8 +i = 9 +i = 10 +i = 11 +i = 12 +i = 13 +i = 14 +i = 15 +i = 16 +i = 17 +i = 18 +i = 19 +i = 20 +i = 21 +i = 22 +i = 23 +i = 24 +i = 25 +i = 26 +i = 27 +i = 28 +i = 29 +i = 30 +i = 31 +i = 32 +i = 33 +i = 34 +i = 35 +i = 36 +i = 37 +i = 38 +i = 39 +i = 40 +i = 41 +i = 42 +i = 43 +i = 44 +i = 45 +i = 46 +i = 47 +i = 48 +i = 49 +i = 50 +i = 51 +i = 52 +i = 53 +i = 54 +i = 55 +i = 56 +i = 57 +i = 58 +i = 59 +i = 60 +i = 61 +i = 62 diff --git a/src/systemc/tests/systemc/datatypes/int/sc_int/concat/unsigned/32bit/concat.cpp b/src/systemc/tests/systemc/datatypes/int/sc_int/concat/unsigned/32bit/concat.cpp new file mode 100644 index 000000000..2c2a1964b --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/sc_int/concat/unsigned/32bit/concat.cpp @@ -0,0 +1,55 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + concat.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" + +#define WIDTH 32 + +int sc_main(int ac, char* av[] ) +{ + + sc_uint a_su32, b_su32; + + for(int i=0; i < WIDTH-1; i++ ){ + cout << "i = " << i << endl; + a_su32 = i; + b_su32 = (a_su32.range(WIDTH-1,i+1), a_su32.range(i,0)); + sc_assert( a_su32 == b_su32 ); + } + + return 0; +} diff --git a/src/systemc/tests/systemc/datatypes/int/sc_int/concat/unsigned/32bit/golden/concat.log b/src/systemc/tests/systemc/datatypes/int/sc_int/concat/unsigned/32bit/golden/concat.log new file mode 100644 index 000000000..31bb32fc5 --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/sc_int/concat/unsigned/32bit/golden/concat.log @@ -0,0 +1,32 @@ +SystemC Simulation +i = 0 +i = 1 +i = 2 +i = 3 +i = 4 +i = 5 +i = 6 +i = 7 +i = 8 +i = 9 +i = 10 +i = 11 +i = 12 +i = 13 +i = 14 +i = 15 +i = 16 +i = 17 +i = 18 +i = 19 +i = 20 +i = 21 +i = 22 +i = 23 +i = 24 +i = 25 +i = 26 +i = 27 +i = 28 +i = 29 +i = 30 diff --git a/src/systemc/tests/systemc/datatypes/int/sc_int/concat/unsigned/64bit/concat.cpp b/src/systemc/tests/systemc/datatypes/int/sc_int/concat/unsigned/64bit/concat.cpp new file mode 100644 index 000000000..5bd3abe5e --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/sc_int/concat/unsigned/64bit/concat.cpp @@ -0,0 +1,56 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + concat.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" + +#define WIDTH 64 + +int sc_main(int ac, char* av[] ) +{ + + sc_uint a_su64, b_su64; + + for(int i=0; i < WIDTH-1; i++ ){ + cout << "i = " << i << endl; + a_su64 = i; + b_su64 = (a_su64.range(WIDTH-1,i+1), a_su64.range(i,0)); + sc_assert( a_su64 == b_su64 ); + } + + return 0; +} + diff --git a/src/systemc/tests/systemc/datatypes/int/sc_int/concat/unsigned/64bit/golden/concat.log b/src/systemc/tests/systemc/datatypes/int/sc_int/concat/unsigned/64bit/golden/concat.log new file mode 100644 index 000000000..e47f7871b --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/sc_int/concat/unsigned/64bit/golden/concat.log @@ -0,0 +1,64 @@ +SystemC Simulation +i = 0 +i = 1 +i = 2 +i = 3 +i = 4 +i = 5 +i = 6 +i = 7 +i = 8 +i = 9 +i = 10 +i = 11 +i = 12 +i = 13 +i = 14 +i = 15 +i = 16 +i = 17 +i = 18 +i = 19 +i = 20 +i = 21 +i = 22 +i = 23 +i = 24 +i = 25 +i = 26 +i = 27 +i = 28 +i = 29 +i = 30 +i = 31 +i = 32 +i = 33 +i = 34 +i = 35 +i = 36 +i = 37 +i = 38 +i = 39 +i = 40 +i = 41 +i = 42 +i = 43 +i = 44 +i = 45 +i = 46 +i = 47 +i = 48 +i = 49 +i = 50 +i = 51 +i = 52 +i = 53 +i = 54 +i = 55 +i = 56 +i = 57 +i = 58 +i = 59 +i = 60 +i = 61 +i = 62 diff --git a/src/systemc/tests/systemc/datatypes/int/sc_int/mixed/golden/test_int.log b/src/systemc/tests/systemc/datatypes/int/sc_int/mixed/golden/test_int.log new file mode 100644 index 000000000..6237a8ce1 --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/sc_int/mixed/golden/test_int.log @@ -0,0 +1,38 @@ +SystemC Simulation +x + a = 16 +++a = 9 +a-- = 9 +a = 9 +a[3] = 1 +a.range(4,0) = 9 +a = 9 +c = 9 +a = 15 +a = 23 +a = -121 +a = 19 +sb = 19 +sx = 1 +sy = 1 +sx = 1 +sy = 3 +s5 = 3 +s5 = -15 +sc8 = 16 +sc4 = 1 +u4 = 1 +u4 = 9 +sx = 6 +b = 0 +b = 1 +bva = 00000001 +lva = 00000001 +bva = 00000001 +ss8 = 1 +ss8 = 9 +b = 9 +b = 1 +ei8 = -118 +ei10 = -470 +bs4 = -8 +ds4 = -8 diff --git a/src/systemc/tests/systemc/datatypes/int/sc_int/mixed/test_int.cpp b/src/systemc/tests/systemc/datatypes/int/sc_int/mixed/test_int.cpp new file mode 100644 index 000000000..ba4cfd254 --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/sc_int/mixed/test_int.cpp @@ -0,0 +1,235 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + test_int.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" + +int sc_main( int ac, char *av[] ) +{ + sc_int<8> a,b; + int x; + + + + x = 8; + a = 8; + sc_assert( x == a); + + cout << "x + a = " << x + a << endl; + cout << "++a = " << ++a << endl; + cout << "a-- = " << a-- << endl; + + // bit-select on L.H.S. + a[0] = 1; + cout << "a = " << a << endl; + + // bitselect on R.H.S. + cout << "a[3] = " << a[3] << endl; + + + // part-select on R.H.S + cout << "a.range(4,0) = " << a.range(4,0) << endl; + cout << "a = " << a << endl; + + sc_int<5> c = a.range(4,0); + cout << "c = " << c << endl; + + // part-select on L.H.S. + a.range(2,0) = 7; + cout << "a = " << a << endl; + + a.range(4,2) = 5; + cout << "a = " << a << endl; + + a.range(7,4) = 8; + cout << "a = " << a << endl; + + // concat on R.H.S. + sc_int<4> sx = 1; + sc_int<4> sy = 3; + a = ( sx, sy ); + + cout << "a = " << a << endl; + + sc_int<8> sb; + // concat of part-selects + sb = ( a.range(7,4), a.range(3,0) ); + + cout << "sb = " << sb << endl; + + ( sx, sy ) = 17; + + cout << "sx = " << sx << endl; + cout << "sy = " << sy << endl; + + // concat and part-selects + ( sx, sy ) = ( a.range(7,4), a.range(3,0) ); + + cout << "sx = " << sx << endl; + cout << "sy = " << sy << endl; + + sc_int<5> s5; + + s5 = ( sx , a[4] ); + + cout << "s5 = " << s5 << endl; + + s5 = (a[4],sx); + cout << "s5 = " << s5 << endl; + + sc_bv<8> sc8; + sc_bv<4> sc4; + + // ( sc8.range(7,4), sc4 ) = 17; + ( sc8.range(7,4), sc4 ) = "00010001"; + + cout << "sc8 = " << sc8.to_int() << endl; + cout << "sc4 = " << sc4.to_int() << endl; + + sc_int_base sia(8); + + + sc_uint<4> u4; + + // part-select on sc_uint + u4 = sx.range(3,0); + + cout << "u4 = " << u4 << endl; + + u4[3] = sx[0]; + + cout << "u4 = " << u4 << endl; + + sx = (u4.range(1,0), u4.range(3,2)); + + cout << "sx = " << sx << endl; + + sc_bv<8> bva; + sc_lv<8> lva; + + // Mixing bv, lv on the RHS + + bva = "10000000"; + lva = "10000001"; + +// #if ! defined( __GNUC__ ) + b = bva & "1010"; + cout << "b = " << b << endl; +// #endif + + // b = lva ^ bva; + b = sc_lv<8>( lva ^ bva ); + cout << "b = " << b << endl; + + //Mixing bv, lv on the LHS + + bva = b; + lva = b; + + cout << "bva = " << bva << endl; + cout << "lva = " << lva << endl; + + bva = b & lva.to_int(); + + cout << "bva = " << bva << endl; + + + //Mixing sc_signed on LHS + + sc_signed ss8(8); + ss8 = b; + cout << "ss8 = " << ss8 << endl; + + ss8 = u4; + cout << "ss8 = " << ss8 << endl; + + // Mixing sc_signed/sc_unsigned on RHS + sc_unsigned su8(8); + + su8 = 8; + b = su8 + 1; + + cout << "b = " << b << endl; + + b = ss8 * su8; + b = ss8 ^ su8; + su8 = bva.to_int() | ss8; + + cout << "b = " << b << endl; + + // Having more than two concats + + sc_int<2> ai2; + sc_int<4> bi4; + sc_int<2> ci2; + sc_int<2> di2; + sc_int<8> ei8; + sc_int<10> ei10; + + ai2 = 2; + bi4 = 2; + ci2 = 2; + di2 = 2; + + ei8 = (ai2, bi4, ci2 ); + + cout << "ei8 = " << ei8 << endl; + + ei10 = (ai2, bi4, ci2 , di2); + + cout << "ei10 = " << ei10 << endl; + + // bit-true behavior + sc_int<4> bs4; + sc_signed ds4(4); + + bs4[3] = 1; + bs4[2] = 0; + bs4[1] = 0; + bs4[0] = 0; + + ds4[3] = 1; + ds4[2] = 0; + ds4[1] = 0; + ds4[0] = 0; + + + cout << "bs4 = " << bs4 << endl; + cout << "ds4 = " << ds4 << endl; + + return 0; + +} diff --git a/src/systemc/tests/systemc/datatypes/int/sc_int/partselect/32bit/signed/golden/select.log b/src/systemc/tests/systemc/datatypes/int/sc_int/partselect/32bit/signed/golden/select.log new file mode 100644 index 000000000..c81b8ffe9 --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/sc_int/partselect/32bit/signed/golden/select.log @@ -0,0 +1,33 @@ +SystemC Simulation +i = 0 +i = 1 +i = 2 +i = 3 +i = 4 +i = 5 +i = 6 +i = 7 +i = 8 +i = 9 +i = 10 +i = 11 +i = 12 +i = 13 +i = 14 +i = 15 +i = 16 +i = 17 +i = 18 +i = 19 +i = 20 +i = 21 +i = 22 +i = 23 +i = 24 +i = 25 +i = 26 +i = 27 +i = 28 +i = 29 +i = 30 +i = 31 diff --git a/src/systemc/tests/systemc/datatypes/int/sc_int/partselect/32bit/signed/select.cpp b/src/systemc/tests/systemc/datatypes/int/sc_int/partselect/32bit/signed/select.cpp new file mode 100644 index 000000000..27534579b --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/sc_int/partselect/32bit/signed/select.cpp @@ -0,0 +1,64 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + select.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" + +#define WIDTH 32 +#define COUNT 10000 + +int sc_main( int ac, char* av[] ) +{ + sc_int Bx,By; + + for(unsigned int i = 0; i < WIDTH; i++){ + cout << "i = " << i << endl; + for(unsigned int j=0; j < COUNT; j++ ){ + + /* ( By.range(WIDTH-1, i+1), By.range(i,0) ) = Bx; + sc_assert( By == Bx ); + */ + + Bx = j; + By.range(WIDTH-1,i) = Bx.range(WIDTH-1,i); + if(i >= 1) + By.range(i-1,0) = Bx.range(i-1,0); + sc_assert( Bx == By ); + } + } + + return 0; +} diff --git a/src/systemc/tests/systemc/datatypes/int/sc_int/partselect/32bit/unsigned/golden/select.log b/src/systemc/tests/systemc/datatypes/int/sc_int/partselect/32bit/unsigned/golden/select.log new file mode 100644 index 000000000..c81b8ffe9 --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/sc_int/partselect/32bit/unsigned/golden/select.log @@ -0,0 +1,33 @@ +SystemC Simulation +i = 0 +i = 1 +i = 2 +i = 3 +i = 4 +i = 5 +i = 6 +i = 7 +i = 8 +i = 9 +i = 10 +i = 11 +i = 12 +i = 13 +i = 14 +i = 15 +i = 16 +i = 17 +i = 18 +i = 19 +i = 20 +i = 21 +i = 22 +i = 23 +i = 24 +i = 25 +i = 26 +i = 27 +i = 28 +i = 29 +i = 30 +i = 31 diff --git a/src/systemc/tests/systemc/datatypes/int/sc_int/partselect/32bit/unsigned/select.cpp b/src/systemc/tests/systemc/datatypes/int/sc_int/partselect/32bit/unsigned/select.cpp new file mode 100644 index 000000000..9631a020d --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/sc_int/partselect/32bit/unsigned/select.cpp @@ -0,0 +1,64 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + select.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" + +#define WIDTH 32 +#define COUNT 100000 + +int sc_main( int ac, char* av[] ) +{ + sc_uint Bx,By; + + for(unsigned int i = 0; i < WIDTH; i++){ + cout << "i = " << i << endl; + for(unsigned int j=0; j < COUNT; j++ ){ + + /* ( By.range(WIDTH-1, i+1), By.range(i,0) ) = Bx; + sc_assert( By == Bx ); + */ + + Bx = j; + By.range(WIDTH-1,i) = Bx.range(WIDTH-1,i); + if(i >= 1) + By.range(i-1,0) = Bx.range(i-1,0); + sc_assert( Bx == By ); + } + } + + return 0; +} diff --git a/src/systemc/tests/systemc/datatypes/int/sc_int/partselect/64bit/signed/golden/select.log b/src/systemc/tests/systemc/datatypes/int/sc_int/partselect/64bit/signed/golden/select.log new file mode 100644 index 000000000..c4375f21c --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/sc_int/partselect/64bit/signed/golden/select.log @@ -0,0 +1,65 @@ +SystemC Simulation +i = 0 +i = 1 +i = 2 +i = 3 +i = 4 +i = 5 +i = 6 +i = 7 +i = 8 +i = 9 +i = 10 +i = 11 +i = 12 +i = 13 +i = 14 +i = 15 +i = 16 +i = 17 +i = 18 +i = 19 +i = 20 +i = 21 +i = 22 +i = 23 +i = 24 +i = 25 +i = 26 +i = 27 +i = 28 +i = 29 +i = 30 +i = 31 +i = 32 +i = 33 +i = 34 +i = 35 +i = 36 +i = 37 +i = 38 +i = 39 +i = 40 +i = 41 +i = 42 +i = 43 +i = 44 +i = 45 +i = 46 +i = 47 +i = 48 +i = 49 +i = 50 +i = 51 +i = 52 +i = 53 +i = 54 +i = 55 +i = 56 +i = 57 +i = 58 +i = 59 +i = 60 +i = 61 +i = 62 +i = 63 diff --git a/src/systemc/tests/systemc/datatypes/int/sc_int/partselect/64bit/signed/select.cpp b/src/systemc/tests/systemc/datatypes/int/sc_int/partselect/64bit/signed/select.cpp new file mode 100644 index 000000000..e13202d32 --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/sc_int/partselect/64bit/signed/select.cpp @@ -0,0 +1,64 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + select.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" + +#define WIDTH 64 +#define COUNT 10000 + +int sc_main( int ac, char* av[] ) +{ + sc_int Bx,By; + + for(unsigned int i = 0; i < WIDTH; i++){ + cout << "i = " << i << endl; + for(unsigned int j=0; j < COUNT; j++ ){ + + /* ( By.range(WIDTH-1, i+1), By.range(i,0) ) = Bx; + sc_assert( By == Bx ); + */ + + Bx = j; + By.range(WIDTH-1,i) = Bx.range(WIDTH-1,i); + if(i >= 1) + By.range(i-1,0) = Bx.range(i-1,0); + sc_assert( Bx == By ); + } + } + + return 0; +} diff --git a/src/systemc/tests/systemc/datatypes/int/sc_int/partselect/64bit/unsigned/golden/select.log b/src/systemc/tests/systemc/datatypes/int/sc_int/partselect/64bit/unsigned/golden/select.log new file mode 100644 index 000000000..c4375f21c --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/sc_int/partselect/64bit/unsigned/golden/select.log @@ -0,0 +1,65 @@ +SystemC Simulation +i = 0 +i = 1 +i = 2 +i = 3 +i = 4 +i = 5 +i = 6 +i = 7 +i = 8 +i = 9 +i = 10 +i = 11 +i = 12 +i = 13 +i = 14 +i = 15 +i = 16 +i = 17 +i = 18 +i = 19 +i = 20 +i = 21 +i = 22 +i = 23 +i = 24 +i = 25 +i = 26 +i = 27 +i = 28 +i = 29 +i = 30 +i = 31 +i = 32 +i = 33 +i = 34 +i = 35 +i = 36 +i = 37 +i = 38 +i = 39 +i = 40 +i = 41 +i = 42 +i = 43 +i = 44 +i = 45 +i = 46 +i = 47 +i = 48 +i = 49 +i = 50 +i = 51 +i = 52 +i = 53 +i = 54 +i = 55 +i = 56 +i = 57 +i = 58 +i = 59 +i = 60 +i = 61 +i = 62 +i = 63 diff --git a/src/systemc/tests/systemc/datatypes/int/sc_int/partselect/64bit/unsigned/select.cpp b/src/systemc/tests/systemc/datatypes/int/sc_int/partselect/64bit/unsigned/select.cpp new file mode 100644 index 000000000..16701d45c --- /dev/null +++ b/src/systemc/tests/systemc/datatypes/int/sc_int/partselect/64bit/unsigned/select.cpp @@ -0,0 +1,64 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + select.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" + +#define WIDTH 64 +#define COUNT 10000 + +int sc_main( int ac, char* av[] ) +{ + sc_uint Bx,By; + + for(unsigned int i = 0; i < WIDTH; i++){ + cout << "i = " << i << endl; + for(unsigned int j=0; j < COUNT; j++ ){ + + /* ( By.range(WIDTH-1, i+1), By.range(i,0) ) = Bx; + sc_assert( By == Bx ); + */ + + Bx = j; + By.range(WIDTH-1,i) = Bx.range(WIDTH-1,i); + if(i >= 1) + By.range(i-1,0) = Bx.range(i-1,0); + sc_assert( Bx == By ); + } + } + + return 0; +} -- cgit v1.2.3