1/***************************************************************************** 2 3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 4 more contributor license agreements. See the NOTICE file distributed 5 with this work for additional information regarding copyright ownership. 6 Accellera licenses this file to you under the Apache License, Version 2.0 7 (the "License"); you may not use this file except in compliance with the 8 License. You may obtain a copy of the License at 9 10 http://www.apache.org/licenses/LICENSE-2.0 11 12 Unless required by applicable law or agreed to in writing, software 13 distributed under the License is distributed on an "AS IS" BASIS, 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 15 implied. See the License for the specific language governing 16 permissions and limitations under the License. 17 18 *****************************************************************************/ 19 20/***************************************************************************** 21 22 test03.cpp -- 23 24 Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 25 26 *****************************************************************************/ 27 28/***************************************************************************** 29 30 MODIFICATION LOG - modifiers, enter your name, affiliation, date and 31 changes you are making here. 32 33 Name, Affiliation, Date: Andy Goodrich, Forte Design Systems 2006-08-17 34 Description of Modification: Converted over to test sc_big types. 35 36 *****************************************************************************/ 37 38// test of the reduce methods in the sc_big[u]int datatypes -- method notation 39 40#include "systemc.h" 41 42int 43sc_main( int, char*[] ) 44{ 45 // 1) check the existence of the reduce methods 46 47 sc_bigint<42> a = 42; 48 49 // sc_signed 50 cout << endl; 51 cout << a.and_reduce() << endl; 52 cout << a.or_reduce() << endl; 53 cout << a.xor_reduce() << endl; 54 cout << a.nand_reduce() << endl; 55 cout << a.nor_reduce() << endl; 56 cout << a.xnor_reduce() << endl; 57 58 // sc_signed_subref 59 cout << endl; 60 cout << a( 7, 0 ).and_reduce() << endl; 61 cout << a( 7, 0 ).or_reduce() << endl; 62 cout << a( 7, 0 ).xor_reduce() << endl; 63 cout << a( 7, 0 ).nand_reduce() << endl; 64 cout << a( 7, 0 ).nor_reduce() << endl; 65 cout << a( 7, 0 ).xnor_reduce() << endl; 66 67 // concatenation 68 cout << endl; 69 cout << ( a( 7, 0 ), a( 15, 8 ) ).and_reduce() << endl; 70 cout << ( a( 7, 0 ), a( 15, 8 ) ).or_reduce() << endl; 71 cout << ( a( 7, 0 ), a( 15, 8 ) ).xor_reduce() << endl; 72 cout << ( a( 7, 0 ), a( 15, 8 ) ).nand_reduce() << endl; 73 cout << ( a( 7, 0 ), a( 15, 8 ) ).nor_reduce() << endl; 74 cout << ( a( 7, 0 ), a( 15, 8 ) ).xnor_reduce() << endl; 75 76 sc_biguint<42> b = 42; 77 78 // sc_unsigned 79 cout << endl; 80 cout << b.and_reduce() << endl; 81 cout << b.or_reduce() << endl; 82 cout << b.xor_reduce() << endl; 83 cout << b.nand_reduce() << endl; 84 cout << b.nor_reduce() << endl; 85 cout << b.xnor_reduce() << endl; 86 87 // sc_unsigned_subref 88 cout << endl; 89 cout << b( 7, 0 ).and_reduce() << endl; 90 cout << b( 7, 0 ).or_reduce() << endl; 91 cout << b( 7, 0 ).xor_reduce() << endl; 92 cout << b( 7, 0 ).nand_reduce() << endl; 93 cout << b( 7, 0 ).nor_reduce() << endl; 94 cout << b( 7, 0 ).xnor_reduce() << endl; 95 96 // concatenation 97 cout << endl; 98 cout << ( b( 7, 0 ), b( 15, 8 ) ).and_reduce() << endl; 99 cout << ( b( 7, 0 ), b( 15, 8 ) ).or_reduce() << endl; 100 cout << ( b( 7, 0 ), b( 15, 8 ) ).xor_reduce() << endl; 101 cout << ( b( 7, 0 ), b( 15, 8 ) ).nand_reduce() << endl; 102 cout << ( b( 7, 0 ), b( 15, 8 ) ).nor_reduce() << endl; 103 cout << ( b( 7, 0 ), b( 15, 8 ) ).xnor_reduce() << endl; 104 105 // 2) check the functionality of the reduce methods 106 107 sc_bigint<2> c2 = -1; 108 cout << endl; 109 cout << c2.and_reduce() << endl; 110 cout << c2.xor_reduce() << endl; 111 112 sc_bigint<3> c3 = -1; 113 cout << endl; 114 cout << c3.and_reduce() << endl; 115 cout << c3.xor_reduce() << endl; 116 117 sc_biguint<2> d2 = sc_dt::uint_type( -1 ); 118 cout << endl; 119 cout << d2.and_reduce() << endl; 120 cout << d2.xor_reduce() << endl; 121 122 sc_biguint<3> d3 = sc_dt::uint_type( -1 ); 123 cout << endl; 124 cout << d3.and_reduce() << endl; 125 cout << d3.xor_reduce() << endl; 126 127 sc_bigint<6> e; 128 sc_biguint<6> f; 129 cout << endl; 130 for( int i = 0; i >= -10; -- i ) { 131 e = i; 132 f = i; 133 cout << e.xor_reduce() << endl; 134 cout << f.xor_reduce() << endl; 135 } 136 137 return 0; 138} 139