projects
/
Mograsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed nand and nor gate to work with more than two inputs
[Mograsim.git]
/
net.mograsim.logic.core
/
src
/
net
/
mograsim
/
logic
/
core
/
wires
/
Wire.java
diff --git
a/net.mograsim.logic.core/src/net/mograsim/logic/core/wires/Wire.java
b/net.mograsim.logic.core/src/net/mograsim/logic/core/wires/Wire.java
index
35addff
..
bae4cb4
100644
(file)
--- a/
net.mograsim.logic.core/src/net/mograsim/logic/core/wires/Wire.java
+++ b/
net.mograsim.logic.core/src/net/mograsim/logic/core/wires/Wire.java
@@
-21,6
+21,7
@@
import net.mograsim.logic.core.types.BitVector.BitVectorMutator;
*/
public class Wire
{
*/
public class Wire
{
+ public final String name;
private BitVector values;
public final int travelTime;
private List<ReadEnd> attached = new ArrayList<>();
private BitVector values;
public final int travelTime;
private List<ReadEnd> attached = new ArrayList<>();
@@
-29,10
+30,16
@@
public class Wire
Timeline timeline;
public Wire(Timeline timeline, int length, int travelTime)
Timeline timeline;
public Wire(Timeline timeline, int length, int travelTime)
+ {
+ this(timeline, length, travelTime, null);
+ }
+
+ public Wire(Timeline timeline, int length, int travelTime, String name)
{
if (length < 1)
throw new IllegalArgumentException(
String.format("Tried to create an array of wires with length %d, but a length of less than 1 makes no sense.", length));
{
if (length < 1)
throw new IllegalArgumentException(
String.format("Tried to create an array of wires with length %d, but a length of less than 1 makes no sense.", length));
+ this.name = name;
this.timeline = timeline;
this.length = length;
this.travelTime = travelTime;
this.timeline = timeline;
this.length = length;
this.travelTime = travelTime;
@@
-186,8
+193,7
@@
public class Wire
private void notifyObservers()
{
private void notifyObservers()
{
- for (ReadEnd o : attached)
- o.update();
+ attached.forEach(r -> r.update());
}
/**
}
/**
@@
-354,8
+360,7
@@
public class Wire
@Override
public void notifyObservers()
{
@Override
public void notifyObservers()
{
- for (LogicObserver ob : observers)
- ob.update(this);
+ observers.forEach(ob -> ob.update(this));
}
}
}
}
@@
-493,7
+498,8
@@
public class Wire
@Override
public String toString()
{
@Override
public String toString()
{
- return String.format("wire 0x%08x value: %s inputs: %s", hashCode(), values, inputs);
+ String name = this.name == null ? String.format("0x%08x", hashCode()) : this.name;
+ return String.format("wire %s value: %s inputs: %s", name, values, inputs);
}
public static ReadEnd[] extractEnds(Wire[] w)
}
public static ReadEnd[] extractEnds(Wire[] w)