![]() |
![]() |
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 CVector & | operator= (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 CUInt & | Aval () |
return aval part of this vector. More... | |
const CUInt & | Bval () |
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 CVector * | AllocFromHeap (CObstack *aHeap, int width) |
Create vector allocating all storage from given heap. More... | |
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. |
CVector::~CVector | ( | ) |
Destroy vector freeing storage if possible.
Create vector allocating all storage from given heap.
aHeap | obstack to allocate storage from. |
width | width of vector in bits. |
|
inline |
return aval part of this vector.
|
inline |
set aval part of this vector.
v | value to assign to aval |
|
inline |
Get based attribute.
|
inline |
Set based attribute.
based | non-zero if constant was specified with a base specification. |
|
inline |
return bval part of this vector.
|
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.
|
inline |
Get value as a 32 bit integer.
Value is truncated if it is larger than 32 bits.
|
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.
|
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()
|
inline |
Determine if any bit is a x.
|
inline |
Determine if any bit is either x or z.
|
inline |
Determine if any bit is a z.
|
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. |
|
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. |
|
inline |
Inequality operator.
v | vector to compare. |
|
inline |
Inequality operator.
i | integer to compare. |
Assignment operator.
v | vector to assign from. |
int CVector::operator== | ( | CVector & | v | ) |
Equality operator.
v | vector to compare. |
int CVector::operator== | ( | UINT32 | i | ) |
Equality operator.
i | integer to compare. |
|
inline |
Determine if conversion from ascii overflowed the give vector width.
|
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. |
|
inline |
Get signed attribute.
|
inline |
set signed attribute.
_signed | non-zero if constant is signed. |
|
inline |
Get sized attribute.
|
inline |
Set sized attribute.
sized | non-zero if constant was specified with a size specification. |
|
inline |
Get unbased attribute.
|
inline |
Set unbased attribute.
unbased | non-zero if constant was specified with a unbased specification. |