test01.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 test01.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// test of checks in the sc_[u]int classes 39 40#include "systemc.h" 41 42int 43sc_main( int, char*[] ) 44{ 45 // check_length for sc_int_base 46 47 try { 48 sc_int<-3> a; 49 } 50 catch( sc_report ) { 51 cout << "caught exception for sc_int<-3>\n"; 52 } 53 54 try { 55 sc_int<0> a; 56 } 57 catch( sc_report ) { 58 cout << "caught exception for sc_int<0>\n"; 59 } 60 61 try { 62 sc_int<100> a; 63 } 64 catch( sc_report ) { 65 cout << "caught exception for sc_int<100>\n"; 66 } 67 68 69 // check_index for sc_int_base 70 71 try { 72 sc_int<8> a = 42; 73 cout << a[-1] << "\n"; 74 } 75 catch( sc_report ) { 76 cout << "caught exception for sc_int<8>[-1]\n"; 77 } 78 79 try { 80 sc_int<8> a = 42; 81 cout << a[8] << "\n"; 82 } 83 catch( sc_report ) { 84 cout << "caught exception for sc_int<8>[8]\n"; 85 } 86 87 88 // check_range for sc_int_base 89 90 try { 91 sc_int<8> a = 42; 92 cout << a( 3, -1 ) << "\n"; 93 } 94 catch( sc_report ) { 95 cout << "caught exception for sc_int<8>( 3, -1 )\n"; 96 } 97 98 try { 99 sc_int<8> a = 42; 100 cout << a( 8, 4 ) << "\n"; 101 } 102 catch( sc_report ) { 103 cout << "caught exception for sc_int<8>( 8, 4 )\n"; 104 } 105 106 try { 107 sc_int<8> a = 42; 108 cout << a( 0, 3 ) << endl; 109 } 110 catch( sc_report ) { 111 cout << "caught exception for sc_int<8>( 0, 3 )\n"; 112 } 113 114 115 // check_length for sc_int_concref<T1,T2> 116 117 try { 118 sc_int<42> a; 119 cout << ( a, a ) << "\n"; 120 } 121 catch( sc_report ) { 122 cout << "caught exception for ( sc_int<42>, sc_int<42> )\n"; 123 } 124 125 126 // check_length for sc_uint_base 127 128 try { 129 sc_uint<-3> a; 130 } 131 catch( sc_report ) { 132 cout << "caught exception for sc_uint<-3>\n"; 133 } 134 135 try { 136 sc_uint<0> a; 137 } 138 catch( sc_report ) { 139 cout << "caught exception for sc_uint<0>\n"; 140 } 141 142 try { 143 sc_uint<100> a; 144 } 145 catch( sc_report ) { 146 cout << "caught exception for sc_uint<100>\n"; 147 } 148 149 150 // check_index for sc_uint_base 151 152 try { 153 sc_uint<8> a = 42; 154 cout << a[-1] << "\n"; 155 } 156 catch( sc_report ) { 157 cout << "caught exception for sc_uint<8>[-1]\n"; 158 } 159 160 try { 161 sc_uint<8> a = 42; 162 cout << a[8] << "\n"; 163 } 164 catch( sc_report ) { 165 cout << "caught exception for sc_uint<8>[8]\n"; 166 } 167 168 169 // check_range for sc_uint_base 170 171 try { 172 sc_uint<8> a = 42; 173 cout << a( 3, -1 ) << "\n"; 174 } 175 catch( sc_report ) { 176 cout << "caught exception for sc_uint<8>( 3, -1 )\n"; 177 } 178 179 try { 180 sc_uint<8> a = 42; 181 cout << a( 8, 4 ) << "\n"; 182 } 183 catch( sc_report ) { 184 cout << "caught exception for sc_uint<8>( 8, 4 )\n"; 185 } 186 187 try { 188 sc_uint<8> a = 42; 189 cout << a( 0, 3 ) << endl; 190 } 191 catch( sc_report ) { 192 cout << "caught exception for sc_uint<8>( 0, 3 )\n"; 193 } 194 195 196 // check_length for sc_uint_concref<T1,T2> 197 198 try { 199 sc_uint<42> a; 200 cout << ( a, a ) << "\n"; 201 } 202 catch( sc_report ) { 203 cout << "caught exception for ( sc_uint<42>, sc_uint<42> )\n"; 204 } 205 206 return 0; 207} 208