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#include <systemc.h> 39 40int 41sc_main(int, char**) 42{ 43 { // sc_int works fine 44 sc_int<8> a; 45 sc_int<16> x; 46 a=sc_bigint<8>("0b11101011"); 47 48 x=(a,a); 49 cout << "sc_int (1) " << sc_bigint<16>(x).to_string(SC_BIN) << endl; 50 51 x=(a.range(7,0), a.range(3,0), a.range(3,0)); 52 cout << "sc_int (2) " 53 << sc_bigint<16>(x).to_string(SC_BIN) << endl; 54 } 55 { // sc_uint works fine 56 sc_uint<8> a; 57 sc_uint<16> x; 58 a=sc_biguint<8>("0b11101011"); 59 60 x=(a,a); 61 cout << "sc_uint (1) " << sc_biguint<16>(x).to_string(SC_BIN) << endl; 62 63 x=(a.range(7,0), a.range(3,0), a.range(3,0)); 64 cout << "sc_uint (2) " 65 << sc_biguint<16>(x).to_string(SC_BIN) << endl; 66 } 67 { 68 sc_bigint<8> a; 69 sc_bigint<16> x; 70 a="0b11101011"; 71 72 // compile error (SC6.1): 73 // Error: Overloading ambiguity between "operator,(const sc_uint_base&, const sc_uint_base&)" 74 // and "operator,(const sc_int_base&, const sc_int_base&)". 75 // Error: Overloading ambiguity between "sc_bigint<16>::operator=(const sc_uint_base&)" 76 // and "sc_bigint<16>::operator=(long long)". 77 // ---- 78 // x=(a,a); 79 // cout << "sc_bigint (1) " << x.to_string(SC_BIN) << endl; 80 81 // runtime error: concat yields wrong result 82 // returned value is 1111111111111011 83 // but should be 1110101110111011 84 x=(a.range(7,0), a.range(3,0), a.range(3,0)); 85 cout << "sc_bigint (2) "<< x.to_string(SC_BIN) << endl; 86 } 87 { 88 sc_biguint<8> a; 89 sc_biguint<16> x; 90 a="0b11101011"; 91 92 // compile error (SC6.1): 93 // Error: Overloading ambiguity between "operator,(const sc_uint_base&, const sc_uint_base&)" 94 // and "operator,(const sc_int_base&, const sc_int_base&)". 95 // Error: Overloading ambiguity between "sc_bigint<16>::operator=(const sc_uint_base&)" 96 // and "sc_bigint<16>::operator=(long long)". 97 // ---- 98 // x=(a,a); 99 // cout << "sc_biguint (1) " << x.to_string(SC_BIN) << endl; 100 101 // runtime error: concat yields wrong result 102 // returned value is 0000000000001011 103 // but should be 1110101110111011 104 x=(a.range(7,0), a.range(3,0), a.range(3,0)); 105 cout << "sc_biguint (2) " << x.to_string(SC_BIN) << endl; 106 } 107 { // sc_bv works fine 108 sc_bv<8> a; 109 sc_bv<16> x; 110 a="11101011"; 111 112 x=(a,a); 113 cout << "sc_bv (1) " << x.to_string() << endl; 114 115 x=(a.range(7,0), a.range(3,0), a.range(3,0)); 116 cout << "sc_bv (2) " << x.to_string() << endl; 117 } 118 { // sc_lv works fine 119 sc_lv<8> a; 120 sc_lv<16> x; 121 a="11101011"; 122 123 x=(a,a); 124 cout << "sc_lv (1) " << x.to_string() << endl; 125 126 x=(a.range(7,0), a.range(3,0), a.range(3,0)); 127 cout << "sc_lv (2) " << x.to_string() << endl; 128 } 129 return 0; 130} 131