Learning BSV‎ > ‎Data Types‎ > ‎

Integer

Overview

The Integer type is a non-synthesizable data type used for integer values and functions.  Because Integer is not part of the Bits typeclass, the Integer type is used for static elaboration only; all values must be resolved at compile time.  Integer is distinctly different from UInt and Int, both of which are part of the Bits typeclass and therefore synthesizable.

Integer Functions

div  Element x is divided by element y and the result is rounded toward negative infinity. Division by 0 is undefined.

 function Integer div(Integer x, Integer y);


mod
Element x is divided by element y using the div function and the remainder is returned as an Integer value. div and mod satisfy the identity div(x,y) * y) + mod(x,y) == x. Division by 0 is undefined.

 function Integer mod(Integer x, Integer y);

quot  Element x is divided by element y and the result  is truncated (rounded towards 0). Division by 0 is undefined.

 function Integer quot(Integer x, Integer y);

rem  Element x is divided by element y using the quot function and the remainder is returned as an Integer value.  quot and rem satisfy the identity quot(x,y) * y) + rem(x,y) == x.  Division by 0 is undefined.

 function Integer rem(Integer x, Integer y);

exp The element base is raised to the pwr power and the exponential value exp is returned as type Integer.

 function Integer exp(Integer base, Integer pwr);
Comments