projects
/
Mograsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Refactored BitVector and added test cases
[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
fbfd0d5
..
8bff357
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;
}
+ public boolean isBinary()
+ {
+ return this == ONE || this == ZERO;
+ }
+
@Override
public Bit and(Bit other)
{
@Override
public Bit and(Bit other)
{
@@
-81,6
+86,16
@@
public enum Bit implements StrictLogicType<Bit>
return symbol;
}
return symbol;
}
+ public static Bit lastBitOf(int value)
+ {
+ return values()[2 + (value & 1)];
+ }
+
+ public static Bit of(boolean binaryValue)
+ {
+ return binaryValue ? ONE : ZERO;
+ }
+
public static Bit parse(String s)
{
Bit bit = SYMBOL_MAP.get(s);
public static Bit parse(String s)
{
Bit bit = SYMBOL_MAP.get(s);