112109SRekai.GonzalezAlberquilla@arm.com/***************************************************************************** 212109SRekai.GonzalezAlberquilla@arm.com 312109SRekai.GonzalezAlberquilla@arm.com Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 412109SRekai.GonzalezAlberquilla@arm.com more contributor license agreements. See the NOTICE file distributed 512109SRekai.GonzalezAlberquilla@arm.com with this work for additional information regarding copyright ownership. 612109SRekai.GonzalezAlberquilla@arm.com Accellera licenses this file to you under the Apache License, Version 2.0 712109SRekai.GonzalezAlberquilla@arm.com (the "License"); you may not use this file except in compliance with the 812109SRekai.GonzalezAlberquilla@arm.com License. You may obtain a copy of the License at 912109SRekai.GonzalezAlberquilla@arm.com 1012109SRekai.GonzalezAlberquilla@arm.com http://www.apache.org/licenses/LICENSE-2.0 1112109SRekai.GonzalezAlberquilla@arm.com 1212109SRekai.GonzalezAlberquilla@arm.com Unless required by applicable law or agreed to in writing, software 139024Sgblack@eecs.umich.edu distributed under the License is distributed on an "AS IS" BASIS, 149024Sgblack@eecs.umich.edu WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 159024Sgblack@eecs.umich.edu implied. See the License for the specific language governing 169024Sgblack@eecs.umich.edu permissions and limitations under the License. 179024Sgblack@eecs.umich.edu 189024Sgblack@eecs.umich.edu *****************************************************************************/ 199024Sgblack@eecs.umich.edu 209024Sgblack@eecs.umich.edu/***************************************************************************** 219024Sgblack@eecs.umich.edu 229024Sgblack@eecs.umich.edu test01.cpp -- 239024Sgblack@eecs.umich.edu 249024Sgblack@eecs.umich.edu Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 259024Sgblack@eecs.umich.edu 269024Sgblack@eecs.umich.edu *****************************************************************************/ 279024Sgblack@eecs.umich.edu 289024Sgblack@eecs.umich.edu/***************************************************************************** 299024Sgblack@eecs.umich.edu 309024Sgblack@eecs.umich.edu MODIFICATION LOG - modifiers, enter your name, affiliation, date and 319024Sgblack@eecs.umich.edu changes you are making here. 329024Sgblack@eecs.umich.edu 339024Sgblack@eecs.umich.edu Name, Affiliation, Date: 349024Sgblack@eecs.umich.edu Description of Modification: 359024Sgblack@eecs.umich.edu 369024Sgblack@eecs.umich.edu *****************************************************************************/ 379024Sgblack@eecs.umich.edu 389024Sgblack@eecs.umich.edu// test of sc_int's concat operators -- basic functionality, operator , () 399024Sgblack@eecs.umich.edu 409024Sgblack@eecs.umich.edu#include "systemc.h" 419024Sgblack@eecs.umich.edu 429024Sgblack@eecs.umich.eduvoid 439850Sandreas.hansson@arm.comtest_concat( const sc_int<8>& a ) 449850Sandreas.hansson@arm.com{ 459850Sandreas.hansson@arm.com sc_int<8> b; 469024Sgblack@eecs.umich.edu sc_int<4> c; 479897Sandreas@sandberg.pp.se sc_int<4> d; 4810687SAndreas.Sandberg@ARM.com 4910687SAndreas.Sandberg@ARM.com cout << a << endl; 5010687SAndreas.Sandberg@ARM.com 5112109SRekai.GonzalezAlberquilla@arm.com cout << "*** sc_int_base" << endl; 5210687SAndreas.Sandberg@ARM.com 5310687SAndreas.Sandberg@ARM.com ( c, d ) = a; 5410553Salexandru.dutu@amd.com cout << c << endl; 55 cout << d << endl; 56 57 b = ( d, c ); 58 cout << b << endl; 59 60 cout << "---" << endl; 61 62 ( c, d[1] ) = a.range( 4, 0 ); 63 cout << c << endl; 64 cout << d << endl; 65 66 b.range( 4, 0 ) = ( c, d[1] ); 67 cout << b << endl; 68 69 cout << "---" << endl; 70 71 ( c, d.range( 1, 0 ) ) = a.range( 5, 0 ); 72 cout << c << endl; 73 cout << d << endl; 74 75 b.range( 5, 0 ) = ( c, d.range( 1, 0 ) ); 76 cout << b << endl; 77 78 cout << "---" << endl; 79 80 ( c, ( d[0], d[1] ) ) = a.range( 5, 0 ); 81 cout << c << endl; 82 cout << d << endl; 83 84 b.range( 5, 0 ) = ( c, ( d[0], d[1] ) ); 85 cout << b << endl; 86 87 cout << "*** sc_int_bitref" << endl; 88 89 ( d[1], c ) = a.range( 4, 0 ); 90 cout << c << endl; 91 cout << d << endl; 92 93 b.range( 4, 0 ) = ( d[1], c ); 94 cout << b << endl; 95 96 cout << "---" << endl; 97 98 ( d[0], d[1] ) = a.range( 1,0 ); 99 cout << d << endl; 100 101 b.range( 1, 0 ) = ( d[1], d[0] ); 102 cout << b << endl; 103 104 cout << "---" << endl; 105 106 ( d[0], c.range( 3, 0 ) ) = a.range( 4, 0 ); 107 cout << c << endl; 108 cout << d << endl; 109 110 b.range( 4, 0 ) = ( d[0], c.range( 3, 0 ) ); 111 cout << b << endl; 112 113 cout << "---" << endl; 114 115 ( d[0], ( d[1], d[2], d[3] ) ) = a.range( 3, 0 ); 116 cout << d << endl; 117 118 b.range( 3, 0 ) = ( d[3], ( d[2], d[1], d[0] ) ); 119 cout << b << endl; 120 121 cout << "*** sc_int_subref" << endl; 122 123 ( c.range( 3, 0 ), d ) = a; 124 cout << c << endl; 125 cout << d << endl; 126 127 b = ( c.range( 3, 0 ), d ); 128 cout << b << endl; 129 130 cout << "---" << endl; 131 132 ( c.range( 3, 0 ), d[1] ) = a.range( 4, 0 ); 133 cout << c << endl; 134 cout << d << endl; 135 136 b.range( 4, 0 ) = ( c.range( 3, 0 ), d[1] ); 137 cout << b << endl; 138 139 cout << "---" << endl; 140 141 ( c.range( 3, 0 ), d.range( 3, 0 ) ) = a; 142 cout << c << endl; 143 cout << d << endl; 144 145 b = ( d.range( 3, 0 ), c.range( 3, 0 ) ); 146 cout << b << endl; 147 148 cout << "---" << endl; 149 150 ( c.range( 3, 0 ), ( d[0], d[1] ) ) = a.range( 5, 0 ); 151 cout << c << endl; 152 cout << d << endl; 153 154 b.range( 5, 0 ) = ( c.range( 3, 0 ), ( d[1], d[0] ) ); 155 cout << b << endl; 156 157 cout << "*** sc_int_concat" << endl; 158 159 ( ( c[1], c[0] ), d ) = a.range( 5, 0 ); 160 cout << c << endl; 161 cout << d << endl; 162 163 b.range( 5, 0 ) = ( ( c[0], c[1] ), d ); 164 cout << b << endl; 165 166 cout << "---" << endl; 167 168 ( ( c[1], c[0] ), d[0] ) = a.range( 2, 0 ); 169 cout << c << endl; 170 cout << d << endl; 171 172 b.range( 2, 0 ) = ( ( c[0], c[1] ), d[0] ); 173 cout << b << endl; 174 175 cout << "---" << endl; 176 177 ( ( c[1], c[0] ), d.range( 3, 0 ) ) = a.range( 5, 0 ); 178 cout << c << endl; 179 cout << d << endl; 180 181 b.range( 5, 0 ) = ( ( c[0], c[1] ), d.range( 3, 0 ) ); 182 cout << b << endl; 183 184 cout << "---" << endl; 185 186 ( ( c[0], c[1] ), ( c[2], c[3] ) ) = a.range( 3, 0 ); 187 cout << c << endl; 188 189 b.range( 3, 0 ) = ( ( c[3], c[2] ), ( c[1], c[0] ) ); 190 cout << b << endl; 191} 192 193int 194sc_main( int, char*[] ) 195{ 196 sc_int<8> a( 33 ); 197 198 test_concat( a ); 199 200 return 0; 201} 202