c_array_datatype.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  c_array_datatype.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/* Main file for "C array" data type */
39
40#include "systemc.h"
41
42int sc_main(int ac, char *av[])
43{
44
45// 1. DECLARATION SYNTAX
46  int			a[4] = { 0, 23, -534, 23423 };
47  long			b[4] = { 0, 23, -534, 23423 };
48  short			c[4] = { 0, 23, -534, 23423 };
49  char			d[9] = { 'U', 'X', '0', '1', 'Z', 'W', 'L', 'H', '-' };
50
51  unsigned int		e[4] = { 0, 23, 534, 23423 };
52  unsigned long		f[4] = { 0, 23, 534, 23423 };
53  unsigned short	g[4] = { 0, 23, 534, 23423 };
54  unsigned char		h[9] = { 'U', 'X', '0', '1', 'Z', 'W', 'L', 'H', '-' };
55
56  float			i[4] = { 0, 4.89, -345.6778, 543222.898394322 };
57  double		j[4] = { 0, 4.89, -345.6778, 543222.898394322 };
58//  type 'long double' is non-portable
59//  long double		k[4] = { 0, 4.89, -345.6778, 543222.898394322 };
60
61  bool			l[4] = { 0, 1, true, false };
62
63  sc_logic m[9] = { sc_logic('U'), sc_logic('X'), sc_logic('0'), sc_logic('1'),
64    sc_logic('Z'), sc_logic('W'), sc_logic('L'), sc_logic('H'), sc_logic('-') };
65
66
67// 2. TYPE CONVERSION
68
69  // No type conversion because assignment of arrays is illegal
70
71// 3. OPERATORS
72//    Supported operators:      []
73
74  cout.precision(15);
75  cout	<< "\nINT \t\t"
76		<< a[0] << "\t" << a[1] << "\t" << a[2] << "\t" << a[3]
77      	<< "\nLONG \t\t"
78		<< b[0] << "\t" << b[1] << "\t" << b[2] << "\t" << b[3]
79      	<< "\nSHORT \t\t"
80		<< c[0] << "\t" << c[1] << "\t" << c[2] << "\t" << c[3]
81      	<< "\nCHAR \t\t"
82		<< d[0] << "\t" << d[1] << "\t" << d[2] << "\t"
83		<< d[3] << "\t" << d[4] << "\t" << d[5] << "\t"
84		<< d[6] << "\t" << d[7] << "\t" << d[8]
85      	<< "\n\nUNSIGNED INT \t"
86		<< e[0] << "\t" << e[1] << "\t" << e[2] << "\t" << e[3]
87      	<< "\nUNSIGNED LONG \t"
88		<< f[0] << "\t" << f[1] << "\t" << f[2] << "\t" << f[3]
89      	<< "\nUNSIGNED SHORT \t"
90		<< g[0] << "\t" << g[1] << "\t" << g[2] << "\t" << g[3]
91      	<< "\nUNSIGNED CHAR \t"
92		<< h[0] << "\t" << h[1] << "\t" << h[2] << "\t"
93		<< h[3] << "\t" << h[4] << "\t" << h[5] << "\t"
94		<< h[6] << "\t" << h[7] << "\t" << h[8]
95      	<< "\n\nFLOAT \t\t"
96		<< i[0] << "\t" << i[1] << "\t" << i[2] << "\t" << i[3]
97      	<< "\nDOUBLE \t\t"
98		<< j[0] << "\t" << j[1] << "\t" << j[2] << "\t" << j[3]
99//  type 'long double' is non-portable
100//      	<< "\nLONG DOUBLE \t"
101//		<< k[0] << "\t" << k[1] << "\t" << k[2] << "\t" << k[3]
102      	<< "\n\nBOOL \t\t"
103		<< l[0] << "\t" << l[1] << "\t" << l[2] << "\t" << l[3]
104      	<< "\nSTD_ULOGIC \t"
105		<< m[0] << "\t" << m[1] << "\t" << m[2] << "\t"
106		<< m[3] << "\t" << m[4] << "\t" << m[5] << "\t"
107		<< m[6] << "\t" << m[7] << "\t" << m[8]
108      	<< endl;
109   return 0;
110}
111