test04.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  test04.cpp --
23
24  Original Author: Andy Goodrich, Forte Design Systems, 7 Apr 2005
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 l-value concatenation
39
40#include "systemc.h"
41
42int
43sc_main( int, char*[] )
44{
45    sc_bv<2> bv2a;
46    sc_lv<2> lv2b;
47    const sc_bv<2> bv2c( "10" );
48    const sc_bv<2> bv2d( "01" );
49    sc_bv<4> bv4a;
50
51    ( bv2a, lv2b ) = "0110";
52    cout << "bv2a = " << bv2a << endl;
53    cout << "lv2b = " << lv2b << endl;
54
55    bv4a = ( bv2a, lv2b );
56    cout << "bv4a = " << bv4a << endl;
57
58    bv4a = ( bv2c, bv2d );
59    cout << "bv4a = " << bv4a << endl;
60
61    ( bv4a.range( 2, 1 ), bv2a ) = "0110";
62    cout << "bv4a = " << bv4a << endl;
63    cout << "bv2a = " << bv2a << endl;
64
65    ( bv2a, bv4a.range( 1, 2 ) ) = "0101";
66    cout << "bv4a = " << bv4a << endl;
67    cout << "bv2a = " << bv2a << endl;
68
69    ( ( bv2a, lv2b ), bv4a ) = "00110011";
70    cout << "bv2a = " << bv2a << endl;
71    cout << "lv2b = " << lv2b << endl;
72    cout << "bv4a = " << bv4a << endl;
73
74    ( bv4a, ( bv2a, lv2b ) ) = "11001100";
75    cout << "bv4a = " << bv4a << endl;
76    cout << "bv2a = " << bv2a << endl;
77    cout << "lv2b = " << lv2b << endl;
78
79    ( ( bv2a, lv2b ), bv4a.range( 2, 1 ) ) = "001111";
80    cout << "bv2a = " << bv2a << endl;
81    cout << "lv2b = " << lv2b << endl;
82    cout << "bv4a = " << bv4a << endl;
83
84    ( bv4a.range( 2, 1 ), ( bv2a, lv2b ) ) = "001100";
85    cout << "bv4a = " << bv4a << endl;
86    cout << "bv2a = " << bv2a << endl;
87    cout << "lv2b = " << lv2b << endl;
88
89    return 0;
90}
91