summaryrefslogtreecommitdiff
path: root/src/systemc/tests/systemc/datatypes/misc/concat/test07/test07.cpp
blob: e4ff7e279b2fa04bc1799472e7df6eaa519f6284 (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
/*****************************************************************************

  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.

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

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

  test07.cpp --

  Original Author: Andy Goodrich, Forte Design Systems, 29 October 2007

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

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

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

      Name, Affiliation, Date:
  Description of Modification:

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

// test various width concatenations for each major base type.

#include "systemc.h"

void checkout( const sc_unsigned* actual_p, const sc_unsigned* expected_p )
{
    cout << *actual_p <<" " << *expected_p << endl;
	cout <<"another line" << endl;
}

#define TEST(LEFT,RIGHT) \
{ \
    const sc_unsigned* actual_p = &(LEFT,RIGHT).value(); \
    const sc_unsigned* expected_p = &(high_int,low_int).value(); \
	if ( *actual_p != *expected_p ) \
	{ \
	    checkout(actual_p, expected_p); \
		cout << "!!! ERROR (" << #LEFT << "," << #RIGHT << "):" << endl; \
		cout << "    expected:  " << hex << *expected_p  << endl; \
		cout << "    actual:    " << hex << *actual_p << endl; \
		cout << "    diff mask: " << hex << ((high_int,low_int) ^ (LEFT,RIGHT))  << endl; \
	} \
}

int sc_main(int argc, char* argv[])
{
    for ( int cycle_i = 0; cycle_i < 3; cycle_i++ )
	{
		for ( int high_i = 64; high_i > 0; high_i-- )
		{
			for ( int low_i = 64; low_i > 0; --low_i )
			{
				sc_int_base  high_int(high_i);
				sc_int_base  low_int(low_i);
				sc_signed    high_signed(high_i);
				sc_signed    low_signed(low_i);
				sc_uint_base high_uint(high_i);
				sc_uint_base low_uint(low_i);
				sc_unsigned  high_unsigned(high_i);
				sc_unsigned  low_unsigned(low_i);

				switch ( cycle_i )
				{
				  case 0:
					low_int =       "0xaaaaaaaa55555555";
					low_signed =    "0xaaaaaaaa55555555";
					low_uint =      "0xaaaaaaaa55555555";
					low_unsigned =  "0xaaaaaaaa55555555";
					high_int =      "0xfedcba9876543210";
					high_signed =   "0xfedcba9876543210";
					high_uint =     "0xfedcba9876543210";
					high_unsigned = "0xfedcba9876543210";
				    break;
			      case 1:	
					low_int =       "0x0000000000000000";
					low_signed =    "0x0000000000000000";
					low_uint =      "0x0000000000000000";
					low_unsigned =  "0x0000000000000000";
					high_int =      "0xffffffffffffffff";
					high_signed =   "0xffffffffffffffff";
					high_uint =     "0xffffffffffffffff";
					high_unsigned = "0xffffffffffffffff";
					break;
			      case 2:	
					low_int =       "0xffffffffffffffff";
					low_signed =    "0xffffffffffffffff";
					low_uint =      "0xffffffffffffffff";
					low_unsigned =  "0xffffffffffffffff";
					high_int =      "0x0000000000000000";
					high_signed =   "0x0000000000000000";
					high_uint =     "0x0000000000000000";
					high_unsigned = "0x0000000000000000";
					break;
				}

				cout << endl << dec << "[" << high_i << "," << low_i << "]:" 
					 << endl;

				cout << hex << "  int      " << (high_int,low_int) << " <- (  " 
							<< high_int  << " , " << low_int << " )" << endl;

				TEST(high_int,low_signed);
				TEST(high_int,low_uint);
				TEST(high_int,low_unsigned);

				TEST(high_signed,low_int);
				TEST(high_signed,low_signed);
				TEST(high_signed,low_uint);
				TEST(high_signed,low_unsigned);

				TEST(high_uint,low_int);
				TEST(high_uint,low_signed);
				TEST(high_uint,low_uint);
				TEST(high_uint,low_unsigned);

				TEST(high_unsigned,low_int);
				TEST(high_unsigned,low_signed);
				TEST(high_unsigned,low_uint);
				TEST(high_unsigned,low_unsigned);
			}
		}
    }

	cout << "Program completed" << endl;
	return 0;
}