test06.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  test06.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 sc_[u]int concatenation with type bool, concat()
39
40#include "systemc.h"
41
42#define WRITE(a) \
43    cout << a << endl
44
45int
46sc_main( int, char*[] )
47{
48    bool b;
49
50    // )))  sc_uint  (((
51
52    sc_uint<3> ui3 = 3;
53    sc_uint<4> ui4;
54    sc_uint<2> ui2;
55
56    // sc_uint_base
57
58    b = false;
59    ui4 = concat( ui3, b );
60    WRITE( ui4 );
61    ui4 = concat( b, ui3 );
62    WRITE( ui4 );
63
64    b = true;
65    ui4 = concat( ui3, b );
66    WRITE( ui4 );
67    ui4 = concat( b, ui3 );
68    WRITE( ui4 );
69
70    // sc_uint_bitref
71
72    cout << endl;
73
74    b = false;
75    ui2 = concat( ui3[0], b );
76    WRITE( ui2 );
77    ui2 = concat( b, ui3[0] );
78    WRITE( ui2 );
79
80    b = true;
81    ui2 = concat( ui3[0], b );
82    WRITE( ui2 );
83    ui2 = concat( b, ui3[0] );
84    WRITE( ui2 );
85
86    // sc_uint_subref
87
88    cout << endl;
89
90    b = false;
91    ui2 = concat( ui3.range( 0, 0 ), b );
92    WRITE( ui2 );
93    ui2 = concat( b, ui3.range( 0, 0 ) );
94    WRITE( ui2 );
95
96    b = true;
97    ui2 = concat( ui3.range( 0, 0 ), b );
98    WRITE( ui2 );
99    ui2 = concat( b, ui3.range( 0, 0 ) );
100    WRITE( ui2 );
101
102    // sc_uint_concat
103
104    cout << endl;
105
106    b = false;
107    ui4 = concat( concat( ui3.range( 2, 1 ), ui3[0] ), b );
108    WRITE( ui4 );
109    ui4 = concat( b, concat( ui3.range( 2, 1 ), ui3[0] ) );
110    WRITE( ui4 );
111
112    b = true;
113    ui4 = concat( concat( ui3.range( 2, 1 ), ui3[0] ), b );
114    WRITE( ui4 );
115    ui4 = concat( b, concat( ui3.range( 2, 1 ), ui3[0] ) );
116    WRITE( ui4 );
117
118
119    // )))  sc_int  (((
120
121    sc_int<3> i3 = 3;
122    sc_int<4> i4;
123    sc_int<2> i2;
124
125    // sc_int_base
126
127    cout << endl;
128
129    b = false;
130    i4 = concat( i3, b );
131    WRITE( i4 );
132    i4 = concat( b, i3 );
133    WRITE( i4 );
134
135    b = true;
136    i4 = concat( i3, b );
137    WRITE( i4 );
138    i4 = concat( b, i3 );
139    WRITE( i4 );
140
141    // sc_int_bitref
142
143    cout << endl;
144
145    b = false;
146    i2 = concat( i3[0], b );
147    WRITE( i2 );
148    i2 = concat( b, i3[0] );
149    WRITE( i2 );
150
151    b = true;
152    i2 = concat( i3[0], b );
153    WRITE( i2 );
154    i2 = concat( b, i3[0] );
155    WRITE( i2 );
156
157    // sc_int_subref
158
159    cout << endl;
160
161    b = false;
162    i2 = concat( i3.range( 0, 0 ), b );
163    WRITE( i2 );
164    i2 = concat( b, i3.range( 0, 0 ) );
165    WRITE( i2 );
166
167    b = true;
168    i2 = concat( i3.range( 0, 0 ), b );
169    WRITE( i2 );
170    i2 = concat( b, i3.range( 0, 0 ) );
171    WRITE( i2 );
172
173    // sc_int_concat
174
175    cout << endl;
176
177    b = false;
178    i4 = concat( concat( i3.range( 2, 1 ), i3[0] ), b );
179    WRITE( i4 );
180    i4 = concat( b, concat( i3.range( 2, 1 ), i3[0] ) );
181    WRITE( i4 );
182
183    b = true;
184    i4 = concat( concat( i3.range( 2, 1 ), i3[0] ), b );
185    WRITE( i4 );
186    i4 = concat( b, concat( i3.range( 2, 1 ), i3[0] ) );
187    WRITE( i4 );
188
189    return 0;
190}
191