projects
/
Mograsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Shortcut for single bit BitVector creation added to Bit
[Mograsim.git]
/
net.mograsim.logic.core
/
src
/
net
/
mograsim
/
logic
/
core
/
types
/
Bit.java
diff --git
a/net.mograsim.logic.core/src/net/mograsim/logic/core/types/Bit.java
b/net.mograsim.logic.core/src/net/mograsim/logic/core/types/Bit.java
index
8bff357
..
752fbb8
100644
(file)
--- a/
net.mograsim.logic.core/src/net/mograsim/logic/core/types/Bit.java
+++ b/
net.mograsim.logic.core/src/net/mograsim/logic/core/types/Bit.java
@@
-18,6
+18,11
@@
public enum Bit implements StrictLogicType<Bit>
this.symbol = symbol;
}
this.symbol = symbol;
}
+ /**
+ * Returns if the Bit is binary, this is only true for <code>ZERO</code> and <code>ONE</code>.
+ *
+ * @return true if and only if <code>this == ONE || this == ZERO</code>
+ */
public boolean isBinary()
{
return this == ONE || this == ZERO;
public boolean isBinary()
{
return this == ONE || this == ZERO;
@@
-29,18
+34,36
@@
public enum Bit implements StrictLogicType<Bit>
return fromTable(AND_TABLE, this, other);
}
return fromTable(AND_TABLE, this, other);
}
+ public static void and(Bit[] dst, Bit[] src)
+ {
+ for (int i = 0; i < dst.length; i++)
+ dst[i] = dst[i].and(src[i]);
+ }
+
@Override
public Bit or(Bit other)
{
return fromTable(OR_TABLE, this, other);
}
@Override
public Bit or(Bit other)
{
return fromTable(OR_TABLE, this, other);
}
+ public static void or(Bit[] dst, Bit[] src)
+ {
+ for (int i = 0; i < dst.length; i++)
+ dst[i] = dst[i].or(src[i]);
+ }
+
@Override
public Bit xor(Bit other)
{
return fromTable(XOR_TABLE, this, other);
}
@Override
public Bit xor(Bit other)
{
return fromTable(XOR_TABLE, this, other);
}
+ public static void xor(Bit[] dst, Bit[] src)
+ {
+ for (int i = 0; i < dst.length; i++)
+ dst[i] = dst[i].xor(src[i]);
+ }
+
@Override
public Bit not()
{
@Override
public Bit not()
{
@@
-64,6
+87,11
@@
public enum Bit implements StrictLogicType<Bit>
return bits;
}
return bits;
}
+ public BitVector toVector()
+ {
+ return BitVector.of(this, 1);
+ }
+
public BitVector toVector(int length)
{
return BitVector.of(this, length);
public BitVector toVector(int length)
{
return BitVector.of(this, length);
@@
-75,6
+103,12
@@
public enum Bit implements StrictLogicType<Bit>
return fromTable(JOIN_TABLE, this, other);
}
return fromTable(JOIN_TABLE, this, other);
}
+ public static void join(Bit[] dst, Bit[] src)
+ {
+ for (int i = 0; i < dst.length; i++)
+ dst[i] = dst[i].join(src[i]);
+ }
+
@Override
public String toString()
{
@Override
public String toString()
{