![]() |
![]() |
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. | |
~CVector () | |
Destroy vector freeing storage if possible. | |
unsigned | Hash () |
Calculate a hash for vector value. | |
int | HasXZ () |
Determine if any bit is either x or z. | |
int | HasZ (void) |
Determine if any bit is a z. | |
int | HasX (void) |
Determine if any bit is a x. | |
int | IsNegative () |
Determine if value is negative. | |
void | SetPreferredBase (int base) |
Set preferred base for printing value. | |
int | GetPreferredBase () |
Get preferred base for printing value. | |
int | Sized () |
Get sized attribute. | |
void | Sized (int sized) |
Set sized attribute. | |
int | Based () |
Get based attribute. | |
void | Based (int based) |
Set based attribute. | |
int | Unbased () |
Get unbased attribute. | |
void | Unbased (int unbased) |
Set unbased attribute. | |
int | Signed () const |
Get signed attribute. | |
void | Signed (int _signed) |
set signed attribute. | |
int | Overflowed () |
Determine if conversion from ascii overflowed the give vector width. | |
INT32 | GetWidth (void) |
Get vector bit width. | |
void | SetWidth (INT32 newWidth) |
Set width of vector in bits. | |
void | SetToX () |
Set vector value to X. | |
const CVector & | operator= (const CVector &v) |
Assignment operator. | |
UINT32 | operator= (UINT32 v) |
Assignment operator. | |
int | LoadDecimal (const char *string) |
Load decimal value from string. | |
int | LoadBinary (const char *string) |
Load binary value from string. | |
int | LoadOctal (const char *string) |
Load octal value from string. | |
int | LoadHex (const char *string) |
Load hex value from string. | |
int | LoadString (const char *string) |
Load string value from string. | |
char * | GetVString (void) |
Convert vector to string using preferred base. | |
char * | GetDecimal (void) |
Convert vector to decimal string. | |
char * | GetBinary (void) |
Convert vector to binary string. | |
char * | GetOctal (void) |
Convert vector to octal string. | |
char * | GetHex (void) |
Convert vector to hex string. | |
char * | GetString (void) |
Convert vector to ascii string. | |
int | operator== (CVector &v) |
Equality operator. | |
int | operator== (UINT32 i) |
Equality operator. | |
int | operator!= (CVector &v) |
Inequality operator. | |
int | operator!= (UINT32 i) |
Inequality operator. | |
INT32 | GetINT32 (void) |
Get value as a 32 bit integer. | |
INT64 | GetINT64 (void) |
Get value as a 64 bit integer. | |
void | LoadINT32 (INT32 v) |
Load vector with integer value. | |
void | LoadReal (double d) |
Load vector with integer part of real value. | |
double | GetReal () |
Get vector value as a real. | |
const CUInt & | Aval () |
return aval part of this vector. | |
const CUInt & | Bval () |
return bval part of this vector. | |
void | Aval (const CUInt &v) |
set aval part of this vector. | |
void | Bval (const CUInt &v) |
set bval part of this vector. | |
Static Public Member Functions | |
static CVector * | AllocFromHeap (CObstack *aHeap, int width) |
Create vector allocating all storage from given heap. |
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:
CVector::CVector | ( | INT32 | aWidth | ) |
Create bit vector of given width.
aWidth | width of vector in bits. |
Destroy vector freeing storage if possible.
static CVector* CVector::AllocFromHeap | ( | CObstack * | aHeap, |
int | width | ||
) | [inline, static] |
Create vector allocating all storage from given heap.
aHeap | obstack to allocate storage from. |
width | width of vector in bits. |
const CUInt& CVector::Aval | ( | ) | [inline] |
return aval part of this vector.
void CVector::Aval | ( | const CUInt & | v | ) | [inline] |
set aval part of this vector.
v | value to assign to aval |
int CVector::Based | ( | ) | [inline] |
Get based attribute.
void CVector::Based | ( | int | based | ) | [inline] |
Set based attribute.
based | non-zero if constant was specified with a base specification. |
const CUInt& CVector::Bval | ( | ) | [inline] |
return bval part of this vector.
void CVector::Bval | ( | const CUInt & | v | ) | [inline] |
set bval part of this vector.
v | value to assign to bval |
char* CVector::GetBinary | ( | void | ) |
Convert vector to binary string.
char* CVector::GetDecimal | ( | void | ) |
Convert vector to decimal string.
char* CVector::GetHex | ( | void | ) |
Convert vector to hex string.
INT32 CVector::GetINT32 | ( | void | ) | [inline] |
Get value as a 32 bit integer.
Value is truncated if it is larger than 32 bits.
INT64 CVector::GetINT64 | ( | void | ) | [inline] |
Get value as a 64 bit integer.
Value is truncated if it is larger than 64 bits.
char* CVector::GetOctal | ( | void | ) |
Convert vector to octal string.
int CVector::GetPreferredBase | ( | ) | [inline] |
Get preferred base for printing value.
double CVector::GetReal | ( | ) |
Get vector value as a real.
char* CVector::GetString | ( | void | ) |
Convert vector to ascii string.
Conversion includes leading and trailing quote.
char* CVector::GetVString | ( | void | ) |
Convert vector to string using preferred base.
INT32 CVector::GetWidth | ( | void | ) |
Get vector bit width.
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()
int CVector::HasX | ( | void | ) | [inline] |
Determine if any bit is a x.
int CVector::HasXZ | ( | ) | [inline] |
Determine if any bit is either x or z.
int CVector::HasZ | ( | void | ) | [inline] |
Determine if any bit is a z.
int CVector::IsNegative | ( | ) | [inline] |
Determine if value is negative.
int CVector::LoadBinary | ( | const char * | string | ) |
Load binary value from string.
string | string to convert. |
int CVector::LoadDecimal | ( | const char * | string | ) |
Load decimal value from string.
string | string to convert. |
int CVector::LoadHex | ( | const char * | string | ) |
Load hex value from string.
string | string to convert. |
void CVector::LoadINT32 | ( | INT32 | v | ) | [inline] |
Load vector with integer value.
v | integer to load. |
int CVector::LoadOctal | ( | const char * | string | ) |
Load octal value from string.
string | string to convert. |
void CVector::LoadReal | ( | double | d | ) |
Load vector with integer part of real value.
d | real value to load. |
int CVector::LoadString | ( | const char * | string | ) |
Load string value from string.
string | string to convert. |
int CVector::operator!= | ( | CVector & | v | ) | [inline] |
Inequality operator.
v | vector to compare. |
int CVector::operator!= | ( | UINT32 | i | ) | [inline] |
Inequality operator.
i | integer to compare. |
Assignment operator.
v | vector to assign from. |
Assignment operator.
v | integer to assign to vector. |
int CVector::operator== | ( | CVector & | v | ) |
Equality operator.
v | vector to compare. |
int CVector::operator== | ( | UINT32 | i | ) |
Equality operator.
i | integer to compare. |
int CVector::Overflowed | ( | ) | [inline] |
Determine if conversion from ascii overflowed the give vector width.
void CVector::SetPreferredBase | ( | int | base | ) | [inline] |
Set preferred base for printing value.
base | base for printing: 2, 8, 10, 16 or 0 for string. |
void CVector::SetToX | ( | ) |
Set vector value to X.
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.
newWidth | new vector width. |
int CVector::Signed | ( | ) | const [inline] |
Get signed attribute.
void CVector::Signed | ( | int | _signed | ) | [inline] |
set signed attribute.
_signed | non-zero if constant is signed. |
int CVector::Sized | ( | ) | [inline] |
Get sized attribute.
void CVector::Sized | ( | int | sized | ) | [inline] |
Set sized attribute.
sized | non-zero if constant was specified with a size specification. |
int CVector::Unbased | ( | ) | [inline] |
Get unbased attribute.
void CVector::Unbased | ( | int | unbased | ) | [inline] |
Set unbased attribute.
unbased | non-zero if constant was specified with a unbased specification. |