vrq
Public Member Functions | Static Public Member Functions | List of all members
CVector Class Reference

Bit vector class for implementing 4 state verilog signed and unsigned arithmetic. More...

#include <cvector.h>

Public Member Functions

 CVector (INT32 aWidth)
 Create bit vector of given width. More...
 
 ~CVector ()
 Destroy vector freeing storage if possible. More...
 
unsigned Hash ()
 Calculate a hash for vector value. More...
 
int HasXZ ()
 Determine if any bit is either x or z. More...
 
int HasZ (void)
 Determine if any bit is a z. More...
 
int HasX (void)
 Determine if any bit is a x. More...
 
int IsNegative ()
 Determine if value is negative. More...
 
void SetPreferredBase (int base)
 Set preferred base for printing value. More...
 
int GetPreferredBase ()
 Get preferred base for printing value. More...
 
int Sized ()
 Get sized attribute. More...
 
void Sized (int sized)
 Set sized attribute. More...
 
int Based ()
 Get based attribute. More...
 
void Based (int based)
 Set based attribute. More...
 
int Unbased ()
 Get unbased attribute. More...
 
void Unbased (int unbased)
 Set unbased attribute. More...
 
int Signed () const
 Get signed attribute. More...
 
void Signed (int _signed)
 set signed attribute. More...
 
int Overflowed ()
 Determine if conversion from ascii overflowed the give vector width. More...
 
INT32 GetWidth (void)
 Get vector bit width. More...
 
void SetWidth (INT32 newWidth)
 Set width of vector in bits. More...
 
void SetToX ()
 Set vector value to X. More...
 
const CVectoroperator= (const CVector &v)
 Assignment operator. More...
 
UINT32 operator= (UINT32 v)
 Assignment operator. More...
 
int LoadDecimal (const char *string)
 Load decimal value from string. More...
 
int LoadBinary (const char *string)
 Load binary value from string. More...
 
int LoadOctal (const char *string)
 Load octal value from string. More...
 
int LoadHex (const char *string)
 Load hex value from string. More...
 
int LoadString (const char *string)
 Load string value from string. More...
 
char * GetVString (void)
 Convert vector to string using preferred base. More...
 
char * GetDecimal (void)
 Convert vector to decimal string. More...
 
char * GetBinary (void)
 Convert vector to binary string. More...
 
char * GetOctal (void)
 Convert vector to octal string. More...
 
char * GetHex (void)
 Convert vector to hex string. More...
 
char * GetString (void)
 Convert vector to ascii string. More...
 
int operator== (CVector &v)
 Equality operator. More...
 
int operator== (UINT32 i)
 Equality operator. More...
 
int operator!= (CVector &v)
 Inequality operator. More...
 
int operator!= (UINT32 i)
 Inequality operator. More...
 
INT32 GetINT32 (void)
 Get value as a 32 bit integer. More...
 
INT64 GetINT64 (void)
 Get value as a 64 bit integer. More...
 
void LoadINT32 (INT32 v)
 Load vector with integer value. More...
 
void LoadReal (double d)
 Load vector with integer part of real value. More...
 
double GetReal ()
 Get vector value as a real. More...
 
const CUIntAval ()
 return aval part of this vector. More...
 
const CUIntBval ()
 return bval part of this vector. More...
 
void Aval (const CUInt &v)
 set aval part of this vector. More...
 
void Bval (const CUInt &v)
 set bval part of this vector. More...
 

Static Public Member Functions

static CVectorAllocFromHeap (CObstack *aHeap, int width)
 Create vector allocating all storage from given heap. More...
 

Detailed Description

Bit vector class for implementing 4 state verilog signed and unsigned arithmetic.

bits specified by '?' are maintained in representation. Information is also maintained about the constant specification format so it can be faithfully be reproduce later. The class maintains a single char buffer for converions to character strings. The result must be immediatedly be copied otherwise the buffer will be overwritten on the next conversion.

Bit representation:

Constructor & Destructor Documentation

◆ CVector()

CVector::CVector ( INT32  aWidth)

Create bit vector of given width.

Parameters
aWidthwidth of vector in bits.

◆ ~CVector()

CVector::~CVector ( )

Destroy vector freeing storage if possible.

Member Function Documentation

◆ AllocFromHeap()

static CVector* CVector::AllocFromHeap ( CObstack aHeap,
int  width 
)
inlinestatic

Create vector allocating all storage from given heap.

Parameters
aHeapobstack to allocate storage from.
widthwidth of vector in bits.
Returns
pointer to vector object.

◆ Aval() [1/2]

const CUInt& CVector::Aval ( )
inline

return aval part of this vector.

Returns
aval part of vector

◆ Aval() [2/2]

void CVector::Aval ( const CUInt v)
inline

set aval part of this vector.

Parameters
vvalue to assign to aval

◆ Based() [1/2]

int CVector::Based ( )
inline

Get based attribute.

Returns
non-zero if constant was specified with a base specification.

◆ Based() [2/2]

void CVector::Based ( int  based)
inline

Set based attribute.

Parameters
basednon-zero if constant was specified with a base specification.

◆ Bval() [1/2]

const CUInt& CVector::Bval ( )
inline

return bval part of this vector.

Returns
bval part of vector

◆ Bval() [2/2]

void CVector::Bval ( const CUInt v)
inline

set bval part of this vector.

Parameters
vvalue to assign to bval

◆ GetBinary()

char* CVector::GetBinary ( void  )

Convert vector to binary string.

Returns
buffer containing converted value. Buffer is class static storage and should be used or copied before next vector conversion.

◆ GetDecimal()

char* CVector::GetDecimal ( void  )

Convert vector to decimal string.

Returns
buffer containing converted value. Buffer is class static storage and should be used or copied before next vector conversion.

◆ GetHex()

char* CVector::GetHex ( void  )

Convert vector to hex string.

Returns
buffer containing converted value. Buffer is class static storage and should be used or copied before next vector conversion.

◆ GetINT32()

INT32 CVector::GetINT32 ( void  )
inline

Get value as a 32 bit integer.

Value is truncated if it is larger than 32 bits.

Returns
signed 32 bit integer value.

◆ GetINT64()

INT64 CVector::GetINT64 ( void  )
inline

Get value as a 64 bit integer.

Value is truncated if it is larger than 64 bits.

Returns
signed 64 bit integer value.

◆ GetOctal()

char* CVector::GetOctal ( void  )

Convert vector to octal string.

Returns
buffer containing converted value. Buffer is class static storage and should be used or copied before next vector conversion.

◆ GetPreferredBase()

int CVector::GetPreferredBase ( )
inline

Get preferred base for printing value.

Returns
base base for printing: 2, 8, 10, 16 or 0 for string.

◆ GetReal()

double CVector::GetReal ( )

Get vector value as a real.

Returns
real value.

◆ GetString()

char* CVector::GetString ( void  )

Convert vector to ascii string.

Conversion includes leading and trailing quote.

Returns
buffer containing converted value. Buffer is class static storage and should be used or copied before next vector conversion.

◆ GetVString()

char* CVector::GetVString ( void  )

Convert vector to string using preferred base.

Returns
buffer containing converted value. Buffer is class static storage and should be used or copied before next vector conversion.

◆ GetWidth()

INT32 CVector::GetWidth ( void  )

Get vector bit width.

Returns
width of vector in bits.

◆ Hash()

unsigned CVector::Hash ( )

Calculate a hash for vector value.

If a and b are vectors and the value of a == b then a.Hash() == b.Hash()

Returns
hash of vector value.

◆ HasX()

int CVector::HasX ( void  )
inline

Determine if any bit is a x.

Returns
non-zero if any bit is a x.

◆ HasXZ()

int CVector::HasXZ ( )
inline

Determine if any bit is either x or z.

Returns
non-zero if any bit is either z or x.

◆ HasZ()

int CVector::HasZ ( void  )
inline

Determine if any bit is a z.

Returns
non-zero if any bit is a z.

◆ IsNegative()

int CVector::IsNegative ( )
inline

Determine if value is negative.

Returns
non-zero if value is signed and msb is 1.

◆ LoadBinary()

int CVector::LoadBinary ( const char *  string)

Load binary value from string.

Parameters
stringstring to convert.

◆ LoadDecimal()

int CVector::LoadDecimal ( const char *  string)

Load decimal value from string.

Parameters
stringstring to convert.

◆ LoadHex()

int CVector::LoadHex ( const char *  string)

Load hex value from string.

Parameters
stringstring to convert.

◆ LoadINT32()

void CVector::LoadINT32 ( INT32  v)
inline

Load vector with integer value.

Parameters
vinteger to load.

◆ LoadOctal()

int CVector::LoadOctal ( const char *  string)

Load octal value from string.

Parameters
stringstring to convert.

◆ LoadReal()

void CVector::LoadReal ( double  d)

Load vector with integer part of real value.

Parameters
dreal value to load.

◆ LoadString()

int CVector::LoadString ( const char *  string)

Load string value from string.

Parameters
stringstring to convert.

◆ operator!=() [1/2]

int CVector::operator!= ( CVector v)
inline

Inequality operator.

Parameters
vvector to compare.
Returns
non-zero if vectors are not equal.

◆ operator!=() [2/2]

int CVector::operator!= ( UINT32  i)
inline

Inequality operator.

Parameters
iinteger to compare.
Returns
non-zero if integer is not equal to this vector

◆ operator=() [1/2]

const CVector& CVector::operator= ( const CVector v)

Assignment operator.

Parameters
vvector to assign from.

◆ operator=() [2/2]

UINT32 CVector::operator= ( UINT32  v)

Assignment operator.

Parameters
vinteger to assign to vector.

◆ operator==() [1/2]

int CVector::operator== ( CVector v)

Equality operator.

Parameters
vvector to compare.
Returns
non-zero if vectors are equal.

◆ operator==() [2/2]

int CVector::operator== ( UINT32  i)

Equality operator.

Parameters
iinteger to compare.
Returns
non-zero if integer equals this vector

◆ Overflowed()

int CVector::Overflowed ( )
inline

Determine if conversion from ascii overflowed the give vector width.

Returns
non-zero if conversion overflowed.

◆ SetPreferredBase()

void CVector::SetPreferredBase ( int  base)
inline

Set preferred base for printing value.

Parameters
basebase for printing: 2, 8, 10, 16 or 0 for string.

◆ SetToX()

void CVector::SetToX ( )

Set vector value to X.

◆ SetWidth()

void CVector::SetWidth ( INT32  newWidth)

Set width of vector in bits.

If new width is smaller then current width, value is truncated. If new width is larger and vector is signed, value is sign extended.

Parameters
newWidthnew vector width.

◆ Signed() [1/2]

int CVector::Signed ( ) const
inline

Get signed attribute.

Returns
non-zero if constant is signed.

◆ Signed() [2/2]

void CVector::Signed ( int  _signed)
inline

set signed attribute.

Parameters
_signednon-zero if constant is signed.

◆ Sized() [1/2]

int CVector::Sized ( )
inline

Get sized attribute.

Returns
non-zero if constant was specified with a size specification.

◆ Sized() [2/2]

void CVector::Sized ( int  sized)
inline

Set sized attribute.

Parameters
sizednon-zero if constant was specified with a size specification.

◆ Unbased() [1/2]

int CVector::Unbased ( )
inline

Get unbased attribute.

Returns
non-zero if constant was specified with a unbase specification.

◆ Unbased() [2/2]

void CVector::Unbased ( int  unbased)
inline

Set unbased attribute.

Parameters
unbasednon-zero if constant was specified with a unbased specification.

The documentation for this class was generated from the following file: