test02.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 test02.cpp -- 23 24 Original Author: Andy Goodrich, Forte Design Systems, 2003-01-17 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 r-value and l-value concatenation -- use concat() 39 40#include "systemc.h" 41 42int 43sc_main( int, char*[] ) 44{ 45 sc_bv<2> bv2a; 46 sc_bv<2> bv2b; 47 const sc_bv<2> bv2c( "10" ); 48 const sc_bv<2> bv2d( "01" ); 49 sc_bv<4> bv4a; 50 sc_bv<4> bv4b( "1111" ); 51 52 concat( bv2a, bv2b ) = "0110"; 53 cout << "bv2a = " << bv2a << endl; 54 cout << "bv2b = " << bv2b << endl; 55 56 bv4a = concat( bv2a, bv2b ); 57 cout << "bv4a = " << bv4a << endl; 58 59 bv4a = concat( bv2c, bv2d ); 60 cout << "bv4a = " << bv4a << endl; 61 62 concat( bv4a.range( 2, 1 ), bv2a ) = "0110"; 63 cout << "bv4a = " << bv4a << endl; 64 cout << "bv2a = " << bv2a << endl; 65 66 concat( bv2a, bv4a.range( 1, 2 ) ) = "0101"; 67 cout << "bv4a = " << bv4a << endl; 68 cout << "bv2a = " << bv2a << endl; 69 70 concat( bv4a.range( 2, 1 ), bv4b.range( 2, 1 ) ) = "1100"; 71 cout << "bv4a = " << bv4a << endl; 72 cout << "bv4b = " << bv4b << endl; 73 74 concat( concat( bv2a, bv2b ), bv4a ) = "00110011"; 75 cout << "bv2a = " << bv2a << endl; 76 cout << "bv2b = " << bv2b << endl; 77 cout << "bv4a = " << bv4a << endl; 78 79 concat( bv4a, concat( bv2a, bv2b ) ) = "11001100"; 80 cout << "bv4a = " << bv4a << endl; 81 cout << "bv2a = " << bv2a << endl; 82 cout << "bv2b = " << bv2b << endl; 83 84 concat( concat( bv2a, bv2b ), concat( bv4a, bv4b ) ) = "011000001111"; 85 cout << "bv2a = " << bv2a << endl; 86 cout << "bv2b = " << bv2b << endl; 87 cout << "bv4a = " << bv4a << endl; 88 cout << "bv4b = " << bv4b << endl; 89 90 concat( concat( bv2a, bv2b ), bv4a.range( 2, 1 ) ) = "001111"; 91 cout << "bv2a = " << bv2a << endl; 92 cout << "bv2b = " << bv2b << endl; 93 cout << "bv4a = " << bv4a << endl; 94 95 concat( bv4a.range( 2, 1 ), concat( bv2a, bv2b ) ) = "001100"; 96 cout << "bv4a = " << bv4a << endl; 97 cout << "bv2a = " << bv2a << endl; 98 cout << "bv2b = " << bv2b << endl; 99 100 const char* s = "1010"; 101 sc_logic l = SC_LOGIC_1; 102 bool b = true; 103 104 cout << concat( bv4b, s ) << endl; 105 cout << concat( s, bv4b ) << endl; 106 cout << concat( bv4a, l ) << endl; 107 cout << concat( l, bv4a ) << endl; 108 cout << concat( bv4a, b ) << endl; 109 cout << concat( b, bv4a ) << endl; 110 111 return 0; 112} 113