test.cpp revision 12855:588919e0e4aa
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 test.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: 34 Description of Modification: 35 36 *****************************************************************************/ 37 38/* 39Please add support in form of constructors and assigment operators 40such that assigments between types sc_int, sc_uint, sc_bigint, sc_biguint 41work in all cases. Currently, assigning a sc_int or sc_uint does not 42work in most cases. 43 44The following test case shows were things don't work. I tried it with 45g++ 2.92.5 and Sun SC6.1 on Solaris. 46*/ 47 48#include <systemc.h> 49 50int sc_main( int, char*[] ) 51{ 52 sc_int<8> i8 = 8; 53 sc_uint<9> u9 = 9; 54 sc_bigint<10> bi10 = 10; 55 sc_biguint<11> bu11 = 11; 56 57 sc_int<8> i8_2; 58 sc_uint<9> u9_2; 59 sc_bigint<10> bi10_2; 60 sc_biguint<11> bu11_2; 61 62 i8_2 = sc_int<8>(i8); 63 cout << i8_2 << endl; 64 i8_2 = sc_int<8>(u9); // g++ 2.95.2: ambiguous 65 cout << i8_2 << endl; 66 i8_2 = sc_int<8>(bi10); 67 cout << i8_2 << endl; 68 i8_2 = sc_int<8>(bu11); 69 cout << i8_2 << endl; 70 71 cout << endl; 72 73 u9_2 = sc_uint<9>(i8); // g++ 2.95.2: ambiguous 74 cout << u9_2 << endl; 75 u9_2 = sc_uint<9>(u9); 76 cout << u9_2 << endl; 77 u9_2 = sc_uint<9>(bi10); 78 cout << u9_2 << endl; 79 u9_2 = sc_uint<9>(bu11); 80 cout << u9_2 << endl; 81 82 cout << endl; 83 84 bi10_2 = sc_bigint<10>(i8); 85 cout << bi10_2 << endl; 86 bi10_2 = sc_bigint<10>(u9); 87 cout << bi10_2 << endl; 88 bi10_2 = sc_bigint<10>(bi10); 89 cout << bi10_2 << endl; 90 bi10_2 = sc_bigint<10>(bu11); 91 cout << bi10_2 << endl; 92 93 cout << endl; 94 95 bu11_2 = sc_biguint<11>(i8); // g++ 2.95.2: ambiguous, SC6.1: error 96 cout << bu11_2 << endl; 97 bu11_2 = sc_biguint<11>(u9); // g++ 2.95.2: ambiguous, SC6.1: error 98 cout << bu11_2 << endl; 99 bu11_2 = sc_biguint<11>(bi10); 100 cout << bu11_2 << endl; 101 bu11_2 = sc_biguint<11>(bu11); 102 cout << bu11_2 << endl; 103 104 cout << endl; 105 106 i8_2 = i8; 107 cout << i8_2 << endl; 108 i8_2 = u9; 109 cout << i8_2 << endl; 110 i8_2 = bi10; 111 cout << i8_2 << endl; 112 i8_2 = bu11; 113 cout << i8_2 << endl; 114 115 cout << endl; 116 117 u9_2 = i8; 118 cout << u9_2 << endl; 119 u9_2 = u9; 120 cout << u9_2 << endl; 121 u9_2 = bi10; 122 cout << u9_2 << endl; 123 u9_2 = bu11; 124 cout << u9_2 << endl; 125 126 cout << endl; 127 128 bi10_2 = i8; 129 cout << bi10_2 << endl; 130 bi10_2 = u9; 131 cout << bi10_2 << endl; 132 bi10_2 = bi10; 133 cout << bi10_2 << endl; 134 bi10_2 = bu11; 135 cout << bi10_2 << endl; 136 137 cout << endl; 138 139 bu11_2 = i8; 140 cout << bu11_2 << endl; 141 bu11_2 = u9; 142 cout << bu11_2 << endl; 143 bu11_2 = bi10; 144 cout << bu11_2 << endl; 145 bu11_2 = bu11; 146 cout << bu11_2 << endl; 147 148 return 0; 149} 150