quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../images/main/bulllet_4dots_orange.gif sc_int

sc_int is signed integer, and it is fixed precision integer of size 64 bits. The underlying operations use 64 bits, but the result size is determined at object declaration. In sc_int the values is stored in 2's compliment. Since it is signed integer, the sign bit for a N bit wide sc_int is stored at N-1 bit position.

   

space.gif

Integer types have a very rich set of operators that work with them.

   

space.gif

Basic Operators

   

space.gif

Operator

Description

Usage

&

Bitwise AND

expr1 & expr2

1

Bitwise OR

expr1 | expr2

^

Bitwise XOR

expr1 ^ expr2

~

Bitwise NOT

~expr

+

Addition

expr1 + expr2

-

Minus

expr1 - expr2

*

Multiply

expr1 * expr2

/

Divide

expr1 / expr2

%

Modulus

expr1 % expr2

>>

Arithmetic right shift

expr >> constant

<<

Arithmetic left shift

expr << constant

   

space.gif

Compound Assignment

   

space.gif

Operator

Description

Usage

+=

+ assignment

variable += expr

-=

- assignment

variable -= expr

*=

* assignment

variable *= expr

\=

\ assignment

variable \= expr

%=

% assignment

variable %= expr

&=

AND assignment

variable &= expr

|=

OR assignment

variable |= expr

^=

XOR assignment

variable ^= expr

   

space.gif

Logic Operators

   

space.gif

Operator

Description

Usage

=

Equality

expr1 = expr2

!=

Inequality

expr1 != expr2

<

Less than

expr1 < expr2

<=

Less than or equal to

expr1 <= expr2

>

Greater than

expr1 > expr2

>=

Greater than or equal to

expr1 >= expr2

++

AutoIncrement

variable ++

--

AutoDecrement

variable --

   

space.gif

Bit Operators

   

space.gif

Operator

Description

Usage

[]

Bit selection

variable [index ]

(,)

Concatenation

(expr1, expr2,... )

range()

Range Selection

variable.range(index1,index2)

   

space.gif

Bitwise operators work on operands . The not(~) operator will invert all bits, and the shift operators will shift left(<<) or right(>>) an operand by the specified number of bits.

   

space.gif

Type sc_int can be used with C++ integer types without restriction.

   

space.gif

   

space.gif

  ../images/main/bullet_star_pink.gif Example sc_int
   

space.gif


  1 #include <systemc.h>
  2 
  3 int sc_main (int argc, char* argv[]) {
  4   sc_int<1>  bit_size    = 0;
  5   sc_int<4>  nibble_size = 1;
  6   sc_int<8>  byte_size   = 2;
  7   sc_int<32> dword_size  = 3;
  8   //sc_int<128> addr; sc_int can not be more then 64
  9   // Perform auto increment
 10   dword_size ++;
 11   cout <<"Value of dword_size : " << dword_size << endl;
 12   // Terse method addition
 13   byte_size += nibble_size;
 14   cout <<"Value of byte_size  : " << byte_size << endl;
 15   // Bit selection
 16   bit_size = dword_size[2];
 17   cout <<"Value of bit_size   : " << bit_size << endl;
 18   // Range selection
 19   nibble_size = dword_size.range(4,1); // Can not assign out of range
 20   cout <<"Value of nibble_size: " << nibble_size << endl;
 21   // Concatenated
 22   dword_size = (byte_size,byte_size,byte_size,byte_size);
 23   cout <<"Value of dword_size : " << dword_size << endl;
 24 
 25   return 1;
 26 }
You could download file sc_int.cpp here
   

space.gif

  ../images/main/bullet_star_pink.gif Simulator Output: sc_int
   

space.gif

              SystemC 2.0.1 --- Oct  6 2006 19:17:37
         Copyright (c) 1996-2002 by all Contributors
                     ALL RIGHTS RESERVED
 Value of dword_size : 4
 Value of byte_size  : 3
 Value of bit_size   : -1
 Value of nibble_size: 2
 Value of dword_size : 50529027
   

space.gif

   

space.gif

   

space.gif

   

space.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

  

Copyright © 1998-2014

Deepak Kumar Tala - All rights reserved

Do you have any Comment? mail me at:deepak@asic-world.com