summaryrefslogtreecommitdiff
path: root/src/systemc/tests/systemc/datatypes/fx/copy_ctors/copy_ctors.cpp
blob: 4cdd0e0874d189785873bc5536fddac536697156 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*****************************************************************************

  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
  more contributor license agreements.  See the NOTICE file distributed
  with this work for additional information regarding copyright ownership.
  Accellera licenses this file to you under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with the
  License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  implied.  See the License for the specific language governing
  permissions and limitations under the License.

 *****************************************************************************/

/*****************************************************************************

  copy_ctors.cpp -- 

  Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15

 *****************************************************************************/

/*****************************************************************************

  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
  changes you are making here.

      Name, Affiliation, Date:
  Description of Modification:

 *****************************************************************************/

// test of sc_[u]fix constructors with fixed-point type argument

#define SC_INCLUDE_FX
#include "systemc.h"

#define WRITE(a) \
    cout << a.type_params() << endl

int
sc_main( int, char*[] )
{
    sc_fixed<1,2,SC_RND,SC_SAT> fxd;
    sc_fixed_fast<3,4,SC_RND_ZERO,SC_SAT_ZERO> fxdf;
    sc_ufixed<5,6,SC_RND_MIN_INF,SC_SAT_SYM> ufxd;
    sc_ufixed_fast<7,8,SC_RND_INF,SC_WRAP> ufxdf;

    sc_fix fx( 9, 10, SC_RND_CONV, SC_SAT );
    sc_fix_fast fxf( 11, 12, SC_TRN, SC_SAT_ZERO );
    sc_ufix ufx( 13, 14, SC_TRN_ZERO, SC_SAT_SYM );
    sc_ufix_fast ufxf( 15, 16, SC_RND, SC_WRAP );

    WRITE(  fxd );
    WRITE(  fxdf );
    WRITE( ufxd );
    WRITE( ufxdf );

    WRITE(  fx );
    WRITE(  fxf );
    WRITE( ufx );
    WRITE( ufxf );

    // sc_fix
    sc_fix fx01(  fxd );
    sc_fix fx02(  fxdf );
    sc_fix fx03( ufxd );
    sc_fix fx04( ufxdf );
    sc_fix fx05(  fx );
    sc_fix fx06(  fxf );
    sc_fix fx07( ufx );
    sc_fix fx08( ufxf );

    cout << endl;
    WRITE( fx01 );
    WRITE( fx02 );
    WRITE( fx03 );
    WRITE( fx04 );
    WRITE( fx05 );
    WRITE( fx06 );
    WRITE( fx07 );
    WRITE( fx08 );

    // sc_fix_fast
    sc_fix_fast fxf01(  fxd );
    sc_fix_fast fxf02(  fxdf );
    sc_fix_fast fxf03( ufxd );
    sc_fix_fast fxf04( ufxdf );
    sc_fix_fast fxf05(  fx );
    sc_fix_fast fxf06(  fxf );
    sc_fix_fast fxf07( ufx );
    sc_fix_fast fxf08( ufxf );

    cout << endl;
    WRITE( fxf01 );
    WRITE( fxf02 );
    WRITE( fxf03 );
    WRITE( fxf04 );
    WRITE( fxf05 );
    WRITE( fxf06 );
    WRITE( fxf07 );
    WRITE( fxf08 );

    // sc_ufix
    sc_ufix ufx01(  fxd );
    sc_ufix ufx02(  fxdf );
    sc_ufix ufx03( ufxd );
    sc_ufix ufx04( ufxdf );
    sc_ufix ufx05(  fx );
    sc_ufix ufx06(  fxf );
    sc_ufix ufx07( ufx );
    sc_ufix ufx08( ufxf );

    cout << endl;
    WRITE( ufx01 );
    WRITE( ufx02 );
    WRITE( ufx03 );
    WRITE( ufx04 );
    WRITE( ufx05 );
    WRITE( ufx06 );
    WRITE( ufx07 );
    WRITE( ufx08 );

    // sc_ufix_fast
    sc_ufix_fast ufxf01(  fxd );
    sc_ufix_fast ufxf02(  fxdf );
    sc_ufix_fast ufxf03( ufxd );
    sc_ufix_fast ufxf04( ufxdf );
    sc_ufix_fast ufxf05(  fx );
    sc_ufix_fast ufxf06(  fxf );
    sc_ufix_fast ufxf07( ufx );
    sc_ufix_fast ufxf08( ufxf );

    cout << endl;
    WRITE( ufxf01 );
    WRITE( ufxf02 );
    WRITE( ufxf03 );
    WRITE( ufxf04 );
    WRITE( ufxf05 );
    WRITE( ufxf06 );
    WRITE( ufxf07 );
    WRITE( ufxf08 );

    // misc
    sc_fix fx09( fx, 123, 456 );
    sc_fix_fast fxf09( fxf, SC_RND, SC_SAT );
    sc_ufix ufx09( ufx, 456, 123 );
    sc_ufix_fast ufxf09( ufxf, SC_TRN, SC_WRAP );

    cout << endl;
    WRITE(  fx09 );
    WRITE(  fxf09 );
    WRITE( ufx09 );
    WRITE( ufxf09 );

    return 0;
}