test11.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 test11.cpp -- Test that sign extension and bit inversion works for the 23 ~ operator when used in sc_XXsigned::concat_get_data() 24 25 Original Author: Andy Goodrich, Forte Design Systems, 29 April 2008 26 27 *****************************************************************************/ 28 29/***************************************************************************** 30 31 MODIFICATION LOG - modifiers, enter your name, affiliation, date and 32 changes you are making here. 33 34 Name, Affiliation, Date: 35 Description of Modification: 36 37 *****************************************************************************/ 38 39 40#include "systemc.h" 41 42int sc_main(int argc, char* argv[]) 43{ 44 sc_bigint<20> w; 45 sc_biguint<20> x; 46 sc_biguint<30> y; 47 48 w = 1; 49 x = 1; 50 y = (sc_bigint<21>)(sc_uint<1>(1),~w); 51 cout << "sc_signed 1 " << hex << y << endl; 52 y = (sc_bigint<21>)(sc_uint<1>(1),~x); 53 cout << "sc_unsigned 1 " << hex << y << endl; 54 55 w = -1; 56 x = -1; 57 y = (sc_bigint<21>)(sc_uint<1>(1),~w); 58 cout << "sc_signed -1 " << hex << y << endl; 59 y = (sc_bigint<21>)(sc_uint<1>(1),~x); 60 cout << "sc_unsigned -1 " << hex << y << endl; 61 62 w = 0x80000; 63 x = 0x80000; 64 y = (sc_bigint<21>)(sc_uint<1>(1),~w); 65 cout << "sc_signed 0x800000 " << hex << y << endl; 66 y = (sc_bigint<21>)(sc_uint<1>(1),~x); 67 cout << "sc_unsigned 0x800000 " << hex << y << endl; 68 69 w = 0; 70 x = 0; 71 y = (sc_bigint<21>)(sc_uint<1>(1),~w); 72 cout << "sc_signed 0 " << hex << y << endl; 73 y = (sc_bigint<21>)(sc_uint<1>(1),~x); 74 cout << "sc_unsigned 0 " << hex << y << endl; 75 76 cout << "Program completed" << endl; 77 return 0; 78} 79