|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecthades.models.StdLogicVector
StdLogicVector: represents multi-bit StdLogic1164 values.
StdLogicVector is modeled in close analogy to the IEEE StdLogicVector and StdLogic1164 data types used in VHDL, with some changes to use OO-style and Java. Please note that the VHDL "UNSIGNED" type is not supported yet, because all integer datatypes in Java are signed. Also note a limitation to at most 63 bits for a single StdLogicVector.
Each bus (StdLogicVector) is modeled as an array of StdLogic1164 values, where the array size is specified by giving its upper and lower indices. Therefore, a StdLogicVector is mainly a means for easier editing, but not a means to improve simulation speed above the use of individual StdLogic1164 signals. If necessary, use other signal data types like hades.models.ruge.IntegerSignal to speed up simulation with buses.
As a convenience, this class supplies a double set of methods for most arithmetic and logic functions - member functions which take one argument, and static functions.
A resolution function, if any, is applied for each bit of the array in turn. WARNING: Note that the current implementation of StdLogicVector and the current resolution function will fail if different bits of one StdLogicVector are short-circuited by external circuits.
Field Summary | |
static boolean |
debug
|
static long |
INVALID_XXX
|
static long |
MAX_BITS
|
static long |
TRISTATE_ZZZ
|
static long |
UNDEFINED_UUU
|
Constructor Summary | |
StdLogicVector(int n_bits)
construct a new StdLogicVector with n_bits bits, all initialized to the undefined value (hades.models.StdLogic1164._U). |
|
StdLogicVector(int n_bits,
long value)
construct a new StdLogicVector with n_bits bits, pre-initialized by 'value'. |
|
StdLogicVector(int n_bits,
StdLogic1164 defaultValue)
|
|
StdLogicVector(int n_bits,
java.lang.String bitString)
construct a new StdLogicVector with n_bits (< MAX_BITS) and initialize it from the String 'bitString', which is expected to contain a suitable binary StdLogic1164 compatible representation, e.g. |
Method Summary | |
StdLogicVector |
add(StdLogicVector R)
|
static StdLogicVector |
add(StdLogicVector L,
StdLogicVector R)
|
java.lang.String |
addLeadingZeroes(java.lang.String s,
int width)
|
StdLogicVector |
and_bitwise(StdLogicVector B)
|
StdLogic1164 |
and_onebit()
return the logical AND of all bits in this StdLogicVector |
StdLogicVector |
append(StdLogic1164 tail)
|
StdLogicVector |
append(StdLogicVector tail)
|
static boolean |
check(StdLogicVector L,
StdLogicVector R)
check whether this StdLogicVector has the arithmetic value 1, that is, the last bit (LSB) is 1, and all other bits are zero public boolean is_001() { return ( (_0_mask | _1_mask) == _length_mask) && (_1_mask == 1L)); } /** an utility method to check the validity of operands L and R to binary arithmetic or logical operations. |
static void |
checkWidth(StdLogicVector L,
StdLogicVector R)
|
static StdLogicVector |
concat(StdLogicVector head,
StdLogicVector tail)
convenience duplicate of append() |
StdLogicVector |
copy()
|
StdLogicVector |
decr()
|
static void |
demonstrateHotspot101Bug(int n_bits)
|
boolean |
equals(java.lang.Object arg)
check whether Object arg is a StdLogicVector, and whether the this-object have the same width and the same StdLogic1164 values at each bit position. |
static StdLogic1164 |
get2ComplementAddOverflow(StdLogicVector L,
StdLogicVector R)
check whether the 2-complement addition of vectors L and R results in an overflow. |
StdLogic1164 |
getBitAt(int index)
get the StdLogic1164 value (object) at vector postion 'index'. |
int |
getBitIntValueAt(int index)
|
long |
getBitMask()
return a bit mask in which the lowest n bits are set, where n is the length (width) of this StdLogicVector. |
long |
getSignedValue()
return the signed long integer value representation of this StdLogicVector. |
long |
getValue()
return the unsigned integer (long) value representation of this StdLogicVector. |
int |
getWidth()
|
java.lang.String |
getWidthString()
|
boolean |
has_0()
|
boolean |
has_1()
|
boolean |
has_D()
|
boolean |
has_H()
|
boolean |
has_L()
|
boolean |
has_U()
|
boolean |
has_UXZ()
check whether any bit in this StdLogicVector is undefined, that is, _U, _X, _Z, _W, or _D. |
boolean |
has_W()
|
boolean |
has_X()
|
boolean |
has_Z()
|
StdLogicVector |
incr()
|
StdLogicVector |
invert_bitwise()
return the a bitwise inverted copy of this StdLogicVector. |
boolean |
is_000()
check whether all bits of this StdLogicVector are '0' |
boolean |
is_111()
|
boolean |
is_ZZZ()
|
static boolean |
isEqual(StdLogicVector L,
StdLogicVector R)
|
static boolean |
isGreaterEqual(StdLogicVector L,
StdLogicVector R)
|
static boolean |
isGreaterThan(StdLogicVector L,
StdLogicVector R)
|
static boolean |
isLessEqual(StdLogicVector L,
StdLogicVector R)
|
static boolean |
isLessThan(StdLogicVector L,
StdLogicVector R)
|
static void |
main(java.lang.String[] argv)
|
static void |
msg(java.lang.String msg)
|
StdLogic1164 |
nand_onebit()
|
StdLogic1164 |
nor_onebit()
|
StdLogicVector |
or_bitwise(StdLogicVector B)
|
StdLogic1164 |
or_onebit()
return the logical OR of all bits in this StdLogicVector |
void |
parse(java.lang.String s)
parse a bin/dec/hex-formatted value from a String and set the value of this StdLogicVector correspondingly. |
static StdLogicVector |
resolve(StdLogicVector[] inputs)
resolve(): StdLogic1164-compatible resolution function of any number of input vectors. |
java.lang.String |
rightAlign(java.lang.String s,
int minWidth)
|
StdLogicVector |
rol(int count)
|
StdLogicVector |
ror(int count)
|
static void |
selftest()
|
void |
setBitAt(int index,
int value)
|
void |
setBitAt(int index,
StdLogic1164 value)
|
void |
setValue(long value)
set the bits in this StdLogicVector from the numerical 'value'. |
StdLogicVector |
shl(int count)
create a left-shifted (by count bits) copy of this StdLogicVector |
StdLogicVector |
shr_arithmetical(int count)
create a right-shifted (by count bits) copy of this StdLogicVector. |
StdLogicVector |
shr_logical(int count)
create a right-shifted (by count bits) copy of this StdLogicVector. |
StdLogicVector |
sub(StdLogicVector R)
|
static StdLogicVector |
sub(StdLogicVector L,
StdLogicVector R)
|
StdLogicVector |
subset(int upper,
int lower)
return the subset from 62 >= upper ... |
static void |
testGetSignedValue()
|
static void |
testShiftRight()
|
java.lang.String |
toBinString()
|
java.lang.String |
toBinString(int minWidth)
|
java.lang.String |
toDecString()
|
java.lang.String |
toDecString(int minWidth)
|
java.lang.String |
toDecStringPadded()
|
java.lang.String |
toDecStringPadded(int minWidth)
|
java.lang.String |
toHexString()
|
java.lang.String |
toHexString(int minWidth)
|
static StdLogicVector |
toStdLogicVector(int value,
int n_bits)
|
java.lang.String |
toString()
|
StdLogic1164 |
xnor_onebit()
return the logical XNOR (inverted parity) of all bits in this vector |
StdLogicVector |
xor_bitwise(StdLogicVector B)
|
StdLogic1164 |
xor_onebit()
return the logical XOR (parity) of all bits in this StdLogicVector |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final boolean debug
public static final long INVALID_XXX
public static final long UNDEFINED_UUU
public static final long TRISTATE_ZZZ
public static final long MAX_BITS
Constructor Detail |
public StdLogicVector(int n_bits)
Indices run from (n_bits-1 downto 0), where n_bits is limited to MAX_BITS in the current implementation.
public StdLogicVector(int n_bits, long value)
StdLogicVector
public StdLogicVector(int n_bits, java.lang.String bitString)
If the parser fails on the given bitString, the StdLogicVector is constructed and silently initialized with a 'U's.
public StdLogicVector(int n_bits, StdLogic1164 defaultValue)
Method Detail |
public StdLogicVector copy()
public static StdLogicVector toStdLogicVector(int value, int n_bits)
public int getWidth()
public final long getBitMask()
Note that getBitMask() also returns the largest possible integer (long) value representable with this StdLogicVector.
public int getBitIntValueAt(int index)
public StdLogic1164 getBitAt(int index)
public void setBitAt(int index, StdLogic1164 value)
public void setBitAt(int index, int value)
public void setValue(long value)
public long getValue()
public long getSignedValue()
public StdLogicVector incr()
public StdLogicVector decr()
public static void checkWidth(StdLogicVector L, StdLogicVector R)
public StdLogicVector add(StdLogicVector R)
public static StdLogicVector add(StdLogicVector L, StdLogicVector R)
public static StdLogic1164 get2ComplementAddOverflow(StdLogicVector L, StdLogicVector R)
Note that there may be better realizations for this method.
public StdLogicVector sub(StdLogicVector R)
public static StdLogicVector sub(StdLogicVector L, StdLogicVector R)
public StdLogicVector shr_arithmetical(int count) throws java.lang.Exception
Don't use negative or too large shift counts.
java.lang.Exception
public StdLogicVector shr_logical(int count) throws java.lang.Exception
Don't use negative or too large shift counts.
java.lang.Exception
public StdLogicVector ror(int count) throws java.lang.Exception
java.lang.Exception
public StdLogicVector shl(int count) throws java.lang.Exception
java.lang.Exception
public StdLogicVector rol(int count) throws java.lang.Exception
java.lang.Exception
public StdLogicVector invert_bitwise()
public StdLogicVector and_bitwise(StdLogicVector B)
public StdLogicVector or_bitwise(StdLogicVector B)
public StdLogicVector xor_bitwise(StdLogicVector B)
public static final StdLogicVector resolve(StdLogicVector[] inputs) throws java.lang.Exception
java.lang.Exception
public StdLogic1164 and_onebit()
public StdLogic1164 or_onebit()
public StdLogic1164 xor_onebit()
public StdLogic1164 nand_onebit()
public StdLogic1164 nor_onebit()
public StdLogic1164 xnor_onebit()
public StdLogicVector append(StdLogicVector tail)
public StdLogicVector append(StdLogic1164 tail)
public static StdLogicVector concat(StdLogicVector head, StdLogicVector tail)
public StdLogicVector subset(int upper, int lower)
public boolean equals(java.lang.Object arg)
public static boolean isEqual(StdLogicVector L, StdLogicVector R)
public boolean has_UXZ()
public boolean has_U()
public boolean has_X()
public boolean has_0()
public boolean has_1()
public boolean has_Z()
public boolean has_L()
public boolean has_H()
public boolean has_W()
public boolean has_D()
public boolean is_000()
public boolean is_111()
public boolean is_ZZZ()
public static boolean check(StdLogicVector L, StdLogicVector R) throws java.lang.Exception
java.lang.Exception
public static boolean isLessThan(StdLogicVector L, StdLogicVector R) throws java.lang.Exception
java.lang.Exception
public static boolean isLessEqual(StdLogicVector L, StdLogicVector R) throws java.lang.Exception
java.lang.Exception
public static boolean isGreaterThan(StdLogicVector L, StdLogicVector R) throws java.lang.Exception
java.lang.Exception
public static boolean isGreaterEqual(StdLogicVector L, StdLogicVector R) throws java.lang.Exception
java.lang.Exception
public java.lang.String toString()
public void parse(java.lang.String s) throws java.lang.NumberFormatException
java.lang.NumberFormatException
public java.lang.String toHexString()
public java.lang.String toHexString(int minWidth)
public java.lang.String toDecString()
public java.lang.String toDecString(int minWidth)
public java.lang.String toDecStringPadded()
public java.lang.String toDecStringPadded(int minWidth)
public java.lang.String toBinString()
public java.lang.String toBinString(int minWidth)
public java.lang.String addLeadingZeroes(java.lang.String s, int width)
public java.lang.String rightAlign(java.lang.String s, int minWidth)
public java.lang.String getWidthString()
public static void msg(java.lang.String msg)
public static void demonstrateHotspot101Bug(int n_bits)
public static void selftest()
public static void testShiftRight()
public static void testGetSignedValue()
public static void main(java.lang.String[] argv)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |