112855Sgabeblack@google.com/*****************************************************************************
212855Sgabeblack@google.com
312855Sgabeblack@google.com  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
412855Sgabeblack@google.com  more contributor license agreements.  See the NOTICE file distributed
512855Sgabeblack@google.com  with this work for additional information regarding copyright ownership.
612855Sgabeblack@google.com  Accellera licenses this file to you under the Apache License, Version 2.0
712855Sgabeblack@google.com  (the "License"); you may not use this file except in compliance with the
812855Sgabeblack@google.com  License.  You may obtain a copy of the License at
912855Sgabeblack@google.com
1012855Sgabeblack@google.com    http://www.apache.org/licenses/LICENSE-2.0
1112855Sgabeblack@google.com
1212855Sgabeblack@google.com  Unless required by applicable law or agreed to in writing, software
1312855Sgabeblack@google.com  distributed under the License is distributed on an "AS IS" BASIS,
1412855Sgabeblack@google.com  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
1512855Sgabeblack@google.com  implied.  See the License for the specific language governing
1612855Sgabeblack@google.com  permissions and limitations under the License.
1712855Sgabeblack@google.com
1812855Sgabeblack@google.com *****************************************************************************/
1912855Sgabeblack@google.com
2012855Sgabeblack@google.com/*****************************************************************************
2112855Sgabeblack@google.com
2212855Sgabeblack@google.com  int_datatype.cpp --
2312855Sgabeblack@google.com
2412855Sgabeblack@google.com  Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15
2512855Sgabeblack@google.com
2612855Sgabeblack@google.com *****************************************************************************/
2712855Sgabeblack@google.com
2812855Sgabeblack@google.com/*****************************************************************************
2912855Sgabeblack@google.com
3012855Sgabeblack@google.com  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
3112855Sgabeblack@google.com  changes you are making here.
3212855Sgabeblack@google.com
3312855Sgabeblack@google.com      Name, Affiliation, Date:
3412855Sgabeblack@google.com  Description of Modification:
3512855Sgabeblack@google.com
3612855Sgabeblack@google.com *****************************************************************************/
3712855Sgabeblack@google.com
3812855Sgabeblack@google.com/* Main file for "int" data type */
3912855Sgabeblack@google.com
4012855Sgabeblack@google.com#include "systemc.h"
4112855Sgabeblack@google.com
4212855Sgabeblack@google.comint sc_main(int ac, char *av[])
4312855Sgabeblack@google.com{
4412855Sgabeblack@google.com
4512855Sgabeblack@google.com// 1. DECLARATION SYNTAX
4612855Sgabeblack@google.com  int	a;
4712855Sgabeblack@google.com  int	b;
4812855Sgabeblack@google.com
4912855Sgabeblack@google.com// 2. TYPE CONVERSION
5012855Sgabeblack@google.com
5112855Sgabeblack@google.com  // int <- int
5212855Sgabeblack@google.com  a = 5;
5312855Sgabeblack@google.com  b = -12;
5412855Sgabeblack@google.com
5512855Sgabeblack@google.com  cout 	<< "int \t<=\t int"
5612855Sgabeblack@google.com	<< "\n---------------------"
5712855Sgabeblack@google.com	<< "\nA = " << a << "\t\t 5"
5812855Sgabeblack@google.com	<< "\nB = " << b << "\t\t -12"
5912855Sgabeblack@google.com	<< "\n" << endl;
6012855Sgabeblack@google.com
6112855Sgabeblack@google.com  // **** ADD MORE TYPE CONVERSIONS *****
6212855Sgabeblack@google.com
6312855Sgabeblack@google.com// 3. OPERATORS
6412855Sgabeblack@google.com//    Supported operators:      ! && || ~ & ^ | + - * / % << >>
6512855Sgabeblack@google.com//                              &= ^= |= += -= *= /= %= <<= >>=
6612855Sgabeblack@google.com//                              = == != < <= > >= << >>
6712855Sgabeblack@google.com//                              ()++ ++() ()-- --() ?: ,
6812855Sgabeblack@google.com
6912855Sgabeblack@google.com#define VAL1	13
7012855Sgabeblack@google.com#define VAL2	 3
7112855Sgabeblack@google.com
7212855Sgabeblack@google.com  unsigned int 	op1 = VAL1;
7312855Sgabeblack@google.com  unsigned int  op2 = VAL2;
7412855Sgabeblack@google.com  unsigned int 	r1, r2, r3, r4, r5, r6, r7, r8, r9;
7512855Sgabeblack@google.com  unsigned int 	r10, r11, r12, r13, r14, r15, r16, r17, r18, r19;
7612855Sgabeblack@google.com  unsigned int 	r20, r21, r22, r23, r24, r25, r26, r27, r28, r29;
7712855Sgabeblack@google.com  unsigned int 	r30, r31, r32, r33, r34, r35;
7812855Sgabeblack@google.com
7912855Sgabeblack@google.com  r1 = op1 * op2;			// Multiplication
8012855Sgabeblack@google.com
8112855Sgabeblack@google.com  r2 = op1 / op2;			// Division
8212855Sgabeblack@google.com
8312855Sgabeblack@google.com  r3 = op1 % op2;			// Modulus
8412855Sgabeblack@google.com
8512855Sgabeblack@google.com  r4 = op1 + op2;			// Addition
8612855Sgabeblack@google.com
8712855Sgabeblack@google.com  r5 = op1 - op2;			// Subtraction
8812855Sgabeblack@google.com
8912855Sgabeblack@google.com  r6 = !op1;				// Logical NOT
9012855Sgabeblack@google.com
9112855Sgabeblack@google.com  r7 = op1 && op2;			// Logical AND
9212855Sgabeblack@google.com
9312855Sgabeblack@google.com  r8 = op1 || op2;			// Logical OR
9412855Sgabeblack@google.com
9512855Sgabeblack@google.com  r9 = op1 < op2;			// Less than
9612855Sgabeblack@google.com
9712855Sgabeblack@google.com  r10 = op1 <= op2;			// Less than or equal
9812855Sgabeblack@google.com
9912855Sgabeblack@google.com  r11 = op1 > op2;			// Greater than
10012855Sgabeblack@google.com
10112855Sgabeblack@google.com  r12 = op1 >= op2;			// Greater than or equal
10212855Sgabeblack@google.com
10312855Sgabeblack@google.com  r13 = op1 += op2;			// Compound addition
10412855Sgabeblack@google.com    op1 = VAL1; op2 = VAL2;
10512855Sgabeblack@google.com
10612855Sgabeblack@google.com  r14 = op1 -= op2;			// Compound subtraction
10712855Sgabeblack@google.com    op1 = VAL1; op2 = VAL2;
10812855Sgabeblack@google.com
10912855Sgabeblack@google.com  r15 = op1 *= op2;			// Compound multiplication
11012855Sgabeblack@google.com    op1 = VAL1; op2 = VAL2;
11112855Sgabeblack@google.com
11212855Sgabeblack@google.com  r16 = op1 /= op2;			// Compound division
11312855Sgabeblack@google.com    op1 = VAL1; op2 = VAL2;
11412855Sgabeblack@google.com
11512855Sgabeblack@google.com  r17 = op1 %= op2;			// Compound modulus
11612855Sgabeblack@google.com    op1 = VAL1; op2 = VAL2;
11712855Sgabeblack@google.com
11812855Sgabeblack@google.com  r18 = op1 <<= op2;			// Compound shift left
11912855Sgabeblack@google.com    op1 = VAL1; op2 = VAL2;
12012855Sgabeblack@google.com
12112855Sgabeblack@google.com  r19 = op1 >>= op2;			// Compound shift right
12212855Sgabeblack@google.com    op1 = VAL1; op2 = VAL2;
12312855Sgabeblack@google.com
12412855Sgabeblack@google.com  r20 = op1 &= op2;			// Compound bitwise AND
12512855Sgabeblack@google.com    op1 = VAL1; op2 = VAL2;
12612855Sgabeblack@google.com
12712855Sgabeblack@google.com  r21 = op1 ^= op2;			// Compound bitwise XOR
12812855Sgabeblack@google.com    op1 = VAL1; op2 = VAL2;
12912855Sgabeblack@google.com
13012855Sgabeblack@google.com  r22 = op1 |= op2;			// Compound bitwise OR
13112855Sgabeblack@google.com    op1 = VAL1; op2 = VAL2;
13212855Sgabeblack@google.com
13312855Sgabeblack@google.com  r23 = op2++;				// Postfix increment
13412855Sgabeblack@google.com    op1 = VAL1; op2 = VAL2;
13512855Sgabeblack@google.com
13612855Sgabeblack@google.com  r24 = ++op2;				// Prefix increment
13712855Sgabeblack@google.com    op1 = VAL1; op2 = VAL2;
13812855Sgabeblack@google.com
13912855Sgabeblack@google.com  r25 = op2--;				// Postfix decrement
14012855Sgabeblack@google.com    op1 = VAL1; op2 = VAL2;
14112855Sgabeblack@google.com
14212855Sgabeblack@google.com  r26 = --op2;				// Prefix decrement
14312855Sgabeblack@google.com    op1 = VAL1; op2 = VAL2;
14412855Sgabeblack@google.com
14512855Sgabeblack@google.com  r27 = (op1 > op2) ? true : false;	// Arithmetic if
14612855Sgabeblack@google.com  r28 = (op1 < op2) ? true : false;	// Arithmetic if
14712855Sgabeblack@google.com
14812855Sgabeblack@google.com  r29 = op1, r29 = op2;		 	// Comma
14912855Sgabeblack@google.com
15012855Sgabeblack@google.com  r30 = ~op1;				// Bitwise NOT
15112855Sgabeblack@google.com
15212855Sgabeblack@google.com  r31 = op1 << op2;			// Left shift
15312855Sgabeblack@google.com    op1 = VAL1; op2 = VAL2;
15412855Sgabeblack@google.com
15512855Sgabeblack@google.com  r32 = op1 >> op2;			// Right shift
15612855Sgabeblack@google.com    op1 = VAL1; op2 = VAL2;
15712855Sgabeblack@google.com
15812855Sgabeblack@google.com  r33 = op1 & op2;			// Bitwise AND
15912855Sgabeblack@google.com
16012855Sgabeblack@google.com  r34 = op1 ^ op2;			// Bitwise XOR
16112855Sgabeblack@google.com
16212855Sgabeblack@google.com  r35 = op1 | op2;			// Bitwise OR
16312855Sgabeblack@google.com
16412855Sgabeblack@google.com  cout 	<< "op1 \t operator \t op2 \t result  [All operands are int]"
16512855Sgabeblack@google.com	<< "\n----------------------------------------------------------------"
16612855Sgabeblack@google.com  	<< "\n" << op1 << "\t    * \t\t " << op2 << "\t = " << r1
16712855Sgabeblack@google.com  	<< "\n" << op1 << "\t    / \t\t " << op2 << "\t = " << r2
16812855Sgabeblack@google.com  	<< "\n" << op1 << "\t    % \t\t " << op2 << "\t = " << r3
16912855Sgabeblack@google.com  	<< "\n" << op1 << "\t    + \t\t " << op2 << "\t = " << r4
17012855Sgabeblack@google.com  	<< "\n" << op1 << "\t    - \t\t " << op2 << "\t = " << r5
17112855Sgabeblack@google.com  	<< "\n!(" << op1 << ") \t\t\t\t = " << r6
17212855Sgabeblack@google.com  	<< "\n" << op1 << "\t    && \t\t " << op2 << "\t = " << r7
17312855Sgabeblack@google.com  	<< "\n" << op1 << "\t    || \t\t " << op2 << "\t = " << r8
17412855Sgabeblack@google.com  	<< "\n" << op1 << "\t    < \t\t "  << op2 << "\t = " << r9
17512855Sgabeblack@google.com  	<< "\n" << op1 << "\t    <= \t\t " << op2 << "\t = " << r10
17612855Sgabeblack@google.com  	<< "\n" << op1 << "\t    > \t\t "  << op2 << "\t = " << r11
17712855Sgabeblack@google.com  	<< "\n" << op1 << "\t    >= \t\t " << op2 << "\t = " << r12
17812855Sgabeblack@google.com  	<< "\n" << op1 << "\t    += \t\t " << op2 << "\t = " << r13
17912855Sgabeblack@google.com  	<< "\n" << op1 << "\t    -= \t\t " << op2 << "\t = " << r14
18012855Sgabeblack@google.com  	<< "\n" << op1 << "\t    *= \t\t " << op2 << "\t = " << r15
18112855Sgabeblack@google.com  	<< "\n" << op1 << "\t    /= \t\t " << op2 << "\t = " << r16
18212855Sgabeblack@google.com  	<< "\n" << op1 << "\t    %= \t\t " << op2 << "\t = " << r17
18312855Sgabeblack@google.com  	<< "\n" << op1 << "\t    <<=\t\t " << op2 << "\t = " << r18
18412855Sgabeblack@google.com  	<< "\n" << op1 << "\t    >>=\t\t " << op2 << "\t = " << r19
18512855Sgabeblack@google.com  	<< "\n" << op1 << "\t    &= \t\t " << op2 << "\t = " << r20
18612855Sgabeblack@google.com  	<< "\n" << op1 << "\t    ^= \t\t " << op2 << "\t = " << r21
18712855Sgabeblack@google.com  	<< "\n" << op1 << "\t    |= \t\t " << op2 << "\t = " << r22
18812855Sgabeblack@google.com  	<< "\n" << "\t    ()++ \t " << op2 << "\t = " << r23
18912855Sgabeblack@google.com  	<< "\n" << "\t    ++() \t " << op2 << "\t = " << r24
19012855Sgabeblack@google.com  	<< "\n" << "\t    ()-- \t " << op2 << "\t = " << r25
19112855Sgabeblack@google.com  	<< "\n" << "\t    --() \t " << op2 << "\t = " << r26
19212855Sgabeblack@google.com  	<< "\n" << op1 << "\t    > ?: \t " << op2 << "\t = " << r27
19312855Sgabeblack@google.com  	<< "\n" << op1 << "\t    < ?: \t " << op2 << "\t = " << r28
19412855Sgabeblack@google.com  	<< "\n" << op1 << "\t    , \t\t " << op2 << "\t = " << r29
19512855Sgabeblack@google.com  	<< "\n~(" << op1 << ") \t\t\t\t = " << r30
19612855Sgabeblack@google.com  	<< "\n" << op1 << "\t    << \t\t " << op2 << "\t = " << r31
19712855Sgabeblack@google.com  	<< "\n" << op1 << "\t    >> \t\t " << op2 << "\t = " << r32
19812855Sgabeblack@google.com  	<< "\n" << op1 << "\t    & \t\t " << op2 << "\t = " << r33
19912855Sgabeblack@google.com  	<< "\n" << op1 << "\t    ^ \t\t " << op2 << "\t = " << r34
20012855Sgabeblack@google.com  	<< "\n" << op1 << "\t    | \t\t " << op2 << "\t = " << r35
20112855Sgabeblack@google.com 	<< endl;
20212855Sgabeblack@google.com
20312855Sgabeblack@google.com  if (op1 == op2)			// Equality
20412855Sgabeblack@google.com   cout << op1 << "\t    == \t\t " << op2 << "\t -> true" << endl;
20512855Sgabeblack@google.com  else
20612855Sgabeblack@google.com   cout << op1 << "\t    == \t\t " << op2 << "\t -> false" << endl;
20712855Sgabeblack@google.com
20812855Sgabeblack@google.com  if (op1 != op2)			// Inequality
20912855Sgabeblack@google.com   cout << op1 << "\t    != \t\t " << op2 << "\t -> true" << endl;
21012855Sgabeblack@google.com  else
21112855Sgabeblack@google.com   cout << op1 << "\t    != \t\t " << op2 << "\t -> false" << endl;
21212855Sgabeblack@google.com
21312855Sgabeblack@google.com  op1 = op2 = 0;			// Assignment operator concatenation
21412855Sgabeblack@google.com   cout << op1 << "\t    = \t\t " << op2 << endl;
21512855Sgabeblack@google.com  sc_start(0, SC_NS);
21612855Sgabeblack@google.com  return 0;
21712855Sgabeblack@google.com}
218