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 assigning sc_bv_base to the integer types 39 40#include "systemc.h" 41 42void 43test_smaller( const sc_bv<4>& bv_one, const sc_bv<4>& bv_two ) 44{ 45 cout << "*** smaller ***" << endl; 46 { 47 sc_int<8> a( bv_one ); 48 sc_int<8> b( bv_two ); 49 sc_int<8> c; 50 sc_int<8> d; 51 c = bv_one; 52 d = bv_two; 53 cout << a << endl; 54 cout << b << endl; 55 cout << c << endl; 56 cout << d << endl; 57 } 58 cout << endl; 59 { 60 sc_uint<8> a( bv_one ); 61 sc_uint<8> b( bv_two ); 62 sc_uint<8> c; 63 sc_uint<8> d; 64 c = bv_one; 65 d = bv_two; 66 cout << a << endl; 67 cout << b << endl; 68 cout << c << endl; 69 cout << d << endl; 70 } 71 cout << endl; 72 { 73 sc_bigint<8> a( bv_one ); 74 sc_bigint<8> b( bv_two ); 75 sc_bigint<8> c; 76 sc_bigint<8> d; 77 c = bv_one; 78 d = bv_two; 79 cout << a << endl; 80 cout << b << endl; 81 cout << c << endl; 82 cout << d << endl; 83 } 84 cout << endl; 85 { 86 sc_biguint<8> a( bv_one ); 87 sc_biguint<8> b( bv_two ); 88 sc_biguint<8> c; 89 sc_biguint<8> d; 90 c = bv_one; 91 d = bv_two; 92 cout << a << endl; 93 cout << b << endl; 94 cout << c << endl; 95 cout << d << endl; 96 } 97} 98 99void 100test_equal( const sc_bv<4>& bv_one, const sc_bv<4>& bv_two ) 101{ 102 cout << "*** equal ***" << endl; 103 { 104 sc_int<4> a( bv_one ); 105 sc_int<4> b( bv_two ); 106 sc_int<4> c; 107 sc_int<4> d; 108 c = bv_one; 109 d = bv_two; 110 cout << a << endl; 111 cout << b << endl; 112 cout << c << endl; 113 cout << d << endl; 114 } 115 cout << endl; 116 { 117 sc_uint<4> a( bv_one ); 118 sc_uint<4> b( bv_two ); 119 sc_uint<4> c; 120 sc_uint<4> d; 121 c = bv_one; 122 d = bv_two; 123 cout << a << endl; 124 cout << b << endl; 125 cout << c << endl; 126 cout << d << endl; 127 } 128 cout << endl; 129 { 130 sc_bigint<4> a( bv_one ); 131 sc_bigint<4> b( bv_two ); 132 sc_bigint<4> c; 133 sc_bigint<4> d; 134 c = bv_one; 135 d = bv_two; 136 cout << a << endl; 137 cout << b << endl; 138 cout << c << endl; 139 cout << d << endl; 140 } 141 cout << endl; 142 { 143 sc_biguint<4> a( bv_one ); 144 sc_biguint<4> b( bv_two ); 145 sc_biguint<4> c; 146 sc_biguint<4> d; 147 c = bv_one; 148 d = bv_two; 149 cout << a << endl; 150 cout << b << endl; 151 cout << c << endl; 152 cout << d << endl; 153 } 154} 155 156void 157test_larger( const sc_bv<4>& bv_one, const sc_bv<4>& bv_two ) 158{ 159 cout << "*** larger ***" << endl; 160 { 161 sc_int<2> a( bv_one ); 162 sc_int<2> b( bv_two ); 163 sc_int<2> c; 164 sc_int<2> d; 165 c = bv_one; 166 d = bv_two; 167 cout << a << endl; 168 cout << b << endl; 169 cout << c << endl; 170 cout << d << endl; 171 } 172 cout << endl; 173 { 174 sc_uint<2> a( bv_one ); 175 sc_uint<2> b( bv_two ); 176 sc_uint<2> c; 177 sc_uint<2> d; 178 c = bv_one; 179 d = bv_two; 180 cout << a << endl; 181 cout << b << endl; 182 cout << c << endl; 183 cout << d << endl; 184 } 185 cout << endl; 186 { 187 sc_bigint<2> a( bv_one ); 188 sc_bigint<2> b( bv_two ); 189 sc_bigint<2> c; 190 sc_bigint<2> d; 191 c = bv_one; 192 d = bv_two; 193 cout << a << endl; 194 cout << b << endl; 195 cout << c << endl; 196 cout << d << endl; 197 } 198 cout << endl; 199 { 200 sc_biguint<2> a( bv_one ); 201 sc_biguint<2> b( bv_two ); 202 sc_biguint<2> c; 203 sc_biguint<2> d; 204 c = bv_one; 205 d = bv_two; 206 cout << a << endl; 207 cout << b << endl; 208 cout << c << endl; 209 cout << d << endl; 210 } 211} 212 213int 214sc_main( int, char*[] ) 215{ 216 sc_bv<4> bv_one( "0101" ); 217 sc_bv<4> bv_two( "1010" ); 218 219 test_smaller( bv_one, bv_two ); 220 test_equal( bv_one, bv_two ); 221 test_larger( bv_one, bv_two ); 222 223 return 0; 224} 225