|
StdLogicVector
0.1
|
An implementation of the std_logic_vector VHDL data type in C++. More...
#include <StdLogicVector.h>
Public Member Functions | |
| StdLogicVector () | |
| The default constructor creates a new StdLogicVector of length zero and initializes its value to zero. | |
| StdLogicVector (unsigned int _length) | |
Creates a StdLogicVector of size _length and initializes its value to zero. More... | |
| StdLogicVector (unsigned long long _value, unsigned int _length) | |
Creates a StdLogicVector of size _length and initializes its value to the provided _value. More... | |
| StdLogicVector (string _value, int _base, unsigned int _length) | |
Creates a StdLogicVector of size _length and initializes its value to the given _value provided as a string in the respective number _base. More... | |
| StdLogicVector (string _value, int _base, unsigned int _length, bool _isDontCare) | |
Creates a StdLogicVector of size _length and initializes its value to the given _value provided as a string in the respective number _base. More... | |
| StdLogicVector (unsigned char *_value, int _size, unsigned int _length) | |
Creates a StdLogicVector of size _length and initializes its value using the byte array to which _value points. More... | |
| StdLogicVector (const StdLogicVector &_other) | |
| Copy-constructor. Creates a deep copy of both the length_ and the value_ of the StdLogicVector. More... | |
| virtual | ~StdLogicVector () |
| Destructor. | |
| const mpz_t & | getValue () const |
Returns the value of the StdLogicVector as it is represented internally, i.e., as a GMP-specific mpz_t data type. More... | |
| int | getLength () const |
| Returns the length of the StdLogicVector. More... | |
| bool | isDontCare () const |
| Returns a boolean determining whether the value of the present StdLogicVector is a don't care or not. More... | |
| unsigned long long | ToULL () |
| Converts the value of the current StdLogicVector into an unsigned long long and returns it. More... | |
| unsigned long long | ToULL () const |
| Converts the value of the current StdLogicVector into an unsigned long long and returns it. More... | |
| string | ToString () |
| Returns a string representing the value of the StdLogicVector as a decimal number. More... | |
| string | ToString (bool _pad) |
| Returns a string representing the value of the StdLogicVector as a decimal number with leading zeros (if desired). More... | |
| string | ToString (int _base) |
| Returns a string representing the value of the StdLogicVector as a number in the provided base representation. More... | |
| string | ToString (int _base) const |
| Returns a string representing the value of the StdLogicVector as a number in the provided base representation. More... | |
| string | ToString (int _base, bool _pad) |
| Returns a string representing the value of the StdLogicVector as a number in the provided base representation and with leading zeros (if desired). More... | |
| string | ToString (int _base, bool _pad) const |
| Returns a string representing the value of the StdLogicVector as a number in the provided base representation and with leading zeros (if desired). More... | |
| void | ToByteArray (unsigned char _byteArray[]) const |
| Returns a pointer to an array of bytes containing the value of the StdLogicVector. More... | |
| bool | operator== (const StdLogicVector &_input) const |
| Equality operator. Returns true of both the value and the length of the two StdLogicVectors are identical. More... | |
| bool | operator!= (const StdLogicVector &_input) const |
| Inequality operator. Returns true if one or both the value and the length of the two StdLogicVectors do not match. More... | |
| int | TestBit (int _index) const |
| Tests a single bit of the StdLogicVector whether it is set or not. More... | |
| StdLogicVector & | ShiftLeft (int _bits) |
| Shift left operation. More... | |
| StdLogicVector & | ShiftRight (int _bits) |
| Shift right operation. More... | |
| StdLogicVector & | And (const StdLogicVector &_operand) |
| Bitwise AND operation. More... | |
| StdLogicVector & | Or (const StdLogicVector &_operand) |
| Bitwise OR operation. More... | |
| StdLogicVector & | Xor (const StdLogicVector &_operand) |
| Bitwise XOR operation. More... | |
| StdLogicVector & | TruncateAfter (int _width) |
Truncates the StdLogicVector after _width bits. More... | |
| StdLogicVector & | ReplaceBits (int _begin, const StdLogicVector &_input) |
| Replaces a number of bits within the current StdLogicVector with another StdLogicVector. More... | |
| StdLogicVector & | PadRightZeros (int _width) |
Appends zeroes on the right of the StdLogicVector in order to reach a certain with of _width bits. More... | |
| StdLogicVector & | ReverseBitOrder () |
| Reverses the bit order of the StdLogicVector. More... | |
| StdLogicVector & | Add (const StdLogicVector &_operand) |
| Addition of another StdLogicVector. Per default, the resulting StdLogicVector will have the same length_ as the original one. If this is not the desired behavior, call the overloaded function and do not truncate the carry. More... | |
| StdLogicVector & | Add (const StdLogicVector &_operand, bool _truncateCarry) |
| Addition of another StdLogicVector. More... | |
Friends | |
| ostream & | operator<< (ostream &_os, const StdLogicVector &_stdLogicVec) |
| Provide a nice stream output showing the value of the StdLogicVector in hexadecimal representation and also its length. | |
An implementation of the std_logic_vector VHDL data type in C++.
This class implements a C++ analogue to the VHDL std_logic_vector class. Since the value of a StdLogicVector can be of arbitrary length, its actual value is internally represented using the GMP library [1] for arbitrary arithmetic functions. Therefore, this class represents kind of a wrapper around the GMP library, which allows simple arithmetic as it is often used when designing with VHDL or other hardware description languages.
| StdLogicVector::StdLogicVector | ( | unsigned int | _length | ) |
Creates a StdLogicVector of size _length and initializes its value to zero.
| _length | The length of the StdLogicVector in bits. |
| StdLogicVector::StdLogicVector | ( | unsigned long long | _value, |
| unsigned int | _length | ||
| ) |
Creates a StdLogicVector of size _length and initializes its value to the provided _value.
| _value | The value to be assigned to the StdLogicVector. |
| _length | The length of the StdLogicVector in bits. |
| StdLogicVector::StdLogicVector | ( | string | _value, |
| int | _base, | ||
| unsigned int | _length | ||
| ) |
Creates a StdLogicVector of size _length and initializes its value to the given _value provided as a string in the respective number _base.
| _value | The value to be assigned to the StdLogicVector represented as a string. The left-most character (i.e., the first character) of the string represents to most significant digit, while the right-most character (i.e., the last character) of the string represents the least significant one. |
| _base | The base in which the _value is given. |
| _length | The length of the StdLogicVector in bits. |
| StdLogicVector::StdLogicVector | ( | string | _value, |
| int | _base, | ||
| unsigned int | _length, | ||
| bool | _isDontCare | ||
| ) |
Creates a StdLogicVector of size _length and initializes its value to the given _value provided as a string in the respective number _base.
| _value | The value to be assigned to the StdLogicVector represented as a string. The left-most character (i.e., the first character) of the string represents to most significant digit, while the right-most character (i.e., the last character) of the string represents the least significant one. |
| _base | The base in which the _value is given. |
| _length | The length of the StdLogicVector in bits. |
| _isDontCare | Determines whether the value of the created StdLogicVector should be marked as a don't care. |
| StdLogicVector::StdLogicVector | ( | unsigned char * | _value, |
| int | _bytes, | ||
| unsigned int | _length | ||
| ) |
Creates a StdLogicVector of size _length and initializes its value using the byte array to which _value points.
| _value | A pointer to the byte array to be used for the initialization of the StdLogicVector. |
| _bytes | Number of bytes to be used for the initialization of the present StdLogicVector. |
| _length | The length of the StdLogicVector in bits. |
| StdLogicVector::StdLogicVector | ( | const StdLogicVector & | _other | ) |
Copy-constructor. Creates a deep copy of both the length_ and the value_ of the StdLogicVector.
| _other | The StdLogicVector to be copied. |
| StdLogicVector & StdLogicVector::Add | ( | const StdLogicVector & | _operand | ) |
Addition of another StdLogicVector. Per default, the resulting StdLogicVector will have the same length_ as the original one. If this is not the desired behavior, call the overloaded function and do not truncate the carry.
| _operand | The StdLogicVector to perform the addition with. |
| StdLogicVector & StdLogicVector::Add | ( | const StdLogicVector & | _operand, |
| bool | _truncateCarry | ||
| ) |
Addition of another StdLogicVector.
| _operand | The StdLogicVector to perform the addition with. |
| _truncateCarry | Determines whether to truncate the carry of the sum. If true, the sum will have the length as the original StdLogicVector. If false, the sum will have the length of the original StdLogicVector plus one bit (length_ + 1). |
| StdLogicVector & StdLogicVector::And | ( | const StdLogicVector & | _operand | ) |
Bitwise AND operation.
| _operand | The StdLogicVector to perform the AND operation with. |
| int StdLogicVector::getLength | ( | ) | const |
Returns the length of the StdLogicVector.
| const mpz_t & StdLogicVector::getValue | ( | ) | const |
Returns the value of the StdLogicVector as it is represented internally, i.e., as a GMP-specific mpz_t data type.
| bool StdLogicVector::isDontCare | ( | ) | const |
Returns a boolean determining whether the value of the present StdLogicVector is a don't care or not.
| bool StdLogicVector::operator!= | ( | const StdLogicVector & | _input | ) | const |
Inequality operator. Returns true if one or both the value and the length of the two StdLogicVectors do not match.
| _input | The StdLogicVector to compare with. |
| bool StdLogicVector::operator== | ( | const StdLogicVector & | _input | ) | const |
Equality operator. Returns true of both the value and the length of the two StdLogicVectors are identical.
| _input | The StdLogicVector to compare with. |
| StdLogicVector & StdLogicVector::Or | ( | const StdLogicVector & | _operand | ) |
Bitwise OR operation.
| _operand | The StdLogicVector to perform the OR operation with. |
| StdLogicVector & StdLogicVector::PadRightZeros | ( | int | _width | ) |
Appends zeroes on the right of the StdLogicVector in order to reach a certain with of _width bits.
| _width | The target width of the StdLogicVector. |
_width - length_ zeros on the right.Appends zeroes on the right of the StdLogicVector in order to reach a certain width of _bits bits. If _bits is smaller than the length_ of the current StdLogicVector, this will be returned.
| StdLogicVector & StdLogicVector::ReplaceBits | ( | int | _begin, |
| const StdLogicVector & | _input | ||
| ) |
Replaces a number of bits within the current StdLogicVector with another StdLogicVector.
| _begin | The 0-based index of the first bit to be replaced. If this value is smaller than 0, the replacement will start at the 0th bit. |
| _input | The StdLogicVector which should be used as a replacement. If size(_input) + _begin} exceeds size(this), only the first size(this)- _begin bits of this will be replaced. |
| StdLogicVector & StdLogicVector::ReverseBitOrder | ( | ) |
Reverses the bit order of the StdLogicVector.
| StdLogicVector & StdLogicVector::ShiftLeft | ( | int | _bits | ) |
Shift left operation.
| _bits | Number of bits to be shifted to the left. |
| StdLogicVector & StdLogicVector::ShiftRight | ( | int | _bits | ) |
Shift right operation.
| _bits | Number of bits to be shifted to the right. |
| int StdLogicVector::TestBit | ( | int | _index | ) | const |
Tests a single bit of the StdLogicVector whether it is set or not.
| _index | The index of the bit to be tested (zero-based). |
| 0 | If bit is zero. |
| 1 | If bit is one. |
| void StdLogicVector::ToByteArray | ( | unsigned char | _byteArray[] | ) | const |
Returns a pointer to an array of bytes containing the value of the StdLogicVector.
| _byteArray | The byte array to be filled with the byte values. |
| string StdLogicVector::ToString | ( | ) |
Returns a string representing the value of the StdLogicVector as a decimal number.
| string StdLogicVector::ToString | ( | bool | _pad | ) |
Returns a string representing the value of the StdLogicVector as a decimal number with leading zeros (if desired).
| _pad | Determines whether to pad the returned value using leading zeros (as many as determined by the length of the StdLogicVector). |
| string StdLogicVector::ToString | ( | int | _base | ) |
Returns a string representing the value of the StdLogicVector as a number in the provided base representation.
| _base | The base in which the number should be represented. |
| string StdLogicVector::ToString | ( | int | _base | ) | const |
Returns a string representing the value of the StdLogicVector as a number in the provided base representation.
| _base | The base in which the number should be represented. |
| string StdLogicVector::ToString | ( | int | _base, |
| bool | _pad | ||
| ) |
Returns a string representing the value of the StdLogicVector as a number in the provided base representation and with leading zeros (if desired).
| _base | The base in which the number should be represented. |
| _pad | Determines whether to pad the returned value using leading zeros (as many as determined by the length of the StdLogicVector). |
| string StdLogicVector::ToString | ( | int | _base, |
| bool | _pad | ||
| ) | const |
Returns a string representing the value of the StdLogicVector as a number in the provided base representation and with leading zeros (if desired).
| _base | The base in which the number should be represented. |
| _pad | Determines whether to pad the returned value using leading zeros (as many as determined by the length of the StdLogicVector). |
| unsigned long long StdLogicVector::ToULL | ( | ) |
Converts the value of the current StdLogicVector into an unsigned long long and returns it.
| unsigned long long StdLogicVector::ToULL | ( | ) | const |
Converts the value of the current StdLogicVector into an unsigned long long and returns it.
| StdLogicVector & StdLogicVector::TruncateAfter | ( | int | _width | ) |
Truncates the StdLogicVector after _width bits.
| _width | Number of preserved bits (others will be truncated). |
_width. | StdLogicVector & StdLogicVector::Xor | ( | const StdLogicVector & | _operand | ) |
Bitwise XOR operation.
| _operand | The StdLogicVector to perform the XOR operation with. |