Bit vector class for implementing 4 state verilog signed and unsigned arithmetic.
More...
#include <cvector.h>
List of all members.
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 | 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.
|
void | GetAval (CVector &v) |
| Set vector to aval part of this vector.
|
void | GetBval (CVector &v) |
| Set vector to bval part of this vector.
|
Static Public Member Functions |
static CVector * | AllocFromHeap (CObstack *aHeap, int width) |
| Create vector allocating all storage from given heap.
|
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:
- aval=0, bval=0, hook=* => 0
- aval=1, bval=0, hook=* => 1
- aval=0, bval=1, hook=0 => z
- aval=0, bval=1, hook=1 => ?
- aval=1, bval=1, hook=* => x
Constructor & Destructor Documentation
CVector::CVector |
( |
INT32 |
aWidth |
) |
|
Create bit vector of given width.
- Parameters:
-
| aWidth | width of vector in bits. |
Destroy vector freeing storage if possible.
Member Function Documentation
static CVector* CVector::AllocFromHeap |
( |
CObstack * |
aHeap, |
|
|
int |
width | |
|
) |
| | [inline, static] |
Create vector allocating all storage from given heap.
- Parameters:
-
| aHeap | obstack to allocate storage from. |
| width | width of vector in bits. |
- Returns:
- pointer to vector object.
int CVector::Based |
( |
|
) |
[inline] |
Get based attribute.
- Returns:
- non-zero if constant was specified with a base specification.
void CVector::Based |
( |
int |
based |
) |
[inline] |
Set based attribute.
- Parameters:
-
| based | non-zero if constant was specified with a base specification. |
void CVector::GetAval |
( |
CVector & |
v |
) |
[inline] |
Set vector to aval part of this vector.
- Parameters:
-
| v | vector to load with aval. |
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.
void CVector::GetBval |
( |
CVector & |
v |
) |
[inline] |
Set vector to bval part of this vector.
- Parameters:
-
| v | vector to load with bval. |
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.
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.
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.
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.
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.
int CVector::GetPreferredBase |
( |
|
) |
[inline] |
Get preferred base for printing value.
- Returns:
- base base for printing: 2, 8, 10, 16 or 0 for string.
double CVector::GetReal |
( |
|
) |
|
Get vector value as a real.
- Returns:
- real value.
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.
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.
INT32 CVector::GetWidth |
( |
void |
|
) |
|
Get vector bit width.
- Returns:
- width of vector in bits.
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.
int CVector::HasXZ |
( |
|
) |
[inline] |
Determine if any bit is either x or z.
- Returns:
- non-zero if any bit is either z or x.
int CVector::HasZ |
( |
void |
|
) |
[inline] |
Determine if any bit is a z.
- Returns:
- non-zero if any bit is a z.
int CVector::IsNegative |
( |
|
) |
[inline] |
Determine if value is negative.
- Returns:
- non-zero if value is signed and msb is 1.
int CVector::LoadBinary |
( |
const char * |
string |
) |
|
Load binary value from string.
- Parameters:
-
| string | string to convert. |
int CVector::LoadDecimal |
( |
const char * |
string |
) |
|
Load decimal value from string.
- Parameters:
-
| string | string to convert. |
int CVector::LoadHex |
( |
const char * |
string |
) |
|
Load hex value from string.
- Parameters:
-
| string | string to convert. |
void CVector::LoadINT32 |
( |
INT32 |
v |
) |
[inline] |
Load vector with integer value.
- Parameters:
-
int CVector::LoadOctal |
( |
const char * |
string |
) |
|
Load octal value from string.
- Parameters:
-
| string | string to convert. |
void CVector::LoadReal |
( |
double |
d |
) |
|
Load vector with integer part of real value.
- Parameters:
-
int CVector::LoadString |
( |
const char * |
string |
) |
|
Load string value from string.
- Parameters:
-
| string | string to convert. |
int CVector::operator!= |
( |
CVector & |
v |
) |
[inline] |
Inequality operator.
- Parameters:
-
- Returns:
- non-zero if vectors are not equal.
int CVector::operator!= |
( |
UINT32 |
i |
) |
[inline] |
Inequality operator.
- Parameters:
-
- Returns:
- non-zero if integer is not equal to this vector
Assignment operator.
- Parameters:
-
| v | integer to assign to vector. |
Assignment operator.
- Parameters:
-
int CVector::operator== |
( |
UINT32 |
i |
) |
|
Equality operator.
- Parameters:
-
- Returns:
- non-zero if integer equals this vector
int CVector::operator== |
( |
CVector & |
v |
) |
|
Equality operator.
- Parameters:
-
- Returns:
- non-zero if vectors are equal.
int CVector::Overflowed |
( |
|
) |
[inline] |
Determine if conversion from ascii overflowed the give vector width.
- Returns:
- non-zero if conversion overflowed.
void CVector::SetPreferredBase |
( |
int |
base |
) |
[inline] |
Set preferred base for printing value.
- Parameters:
-
| base | base for printing: 2, 8, 10, 16 or 0 for string. |
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:
-
| newWidth | new vector width. |
int CVector::Signed |
( |
|
) |
const [inline] |
Get signed attribute.
- Returns:
- non-zero if constant is signed.
void CVector::Signed |
( |
int |
_signed |
) |
[inline] |
set signed attribute.
- Parameters:
-
| _signed | non-zero if constant is signed. |
void CVector::Sized |
( |
int |
sized |
) |
[inline] |
Set sized attribute.
- Parameters:
-
| sized | non-zero if constant was specified with a size specification. |
int CVector::Sized |
( |
|
) |
[inline] |
Get sized attribute.
- Returns:
- non-zero if constant was specified with a size specification.
void CVector::Unbased |
( |
int |
unbased |
) |
[inline] |
Set unbased attribute.
- Parameters:
-
| unbased | non-zero if constant was specified with a unbased specification. |
int CVector::Unbased |
( |
|
) |
[inline] |
Get unbased attribute.
- Returns:
- non-zero if constant was specified with a unbase specification.
The documentation for this class was generated from the following file:
- /net/fileserver/nas/home/mdh/vrq/src/cvector.h