projects
/
Mograsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Refactored Wire and finally renamed length to width
[Mograsim.git]
/
net.mograsim.logic.core
/
src
/
net
/
mograsim
/
logic
/
core
/
components
/
gates
/
MultiInputGate.java
diff --git
a/net.mograsim.logic.core/src/net/mograsim/logic/core/components/gates/MultiInputGate.java
b/net.mograsim.logic.core/src/net/mograsim/logic/core/components/gates/MultiInputGate.java
index
6b183e3
..
d7fecc1
100644
(file)
--- a/
net.mograsim.logic.core/src/net/mograsim/logic/core/components/gates/MultiInputGate.java
+++ b/
net.mograsim.logic.core/src/net/mograsim/logic/core/components/gates/MultiInputGate.java
@@
-13,26
+13,33
@@
public abstract class MultiInputGate extends BasicComponent
{
protected ReadEnd[] in;
protected ReadWriteEnd out;
{
protected ReadEnd[] in;
protected ReadWriteEnd out;
- protected final int
leng
th;
+ protected final int
wid
th;
protected MutationOperation op;
protected MutationOperation op;
+ protected boolean invert = false;
protected MultiInputGate(Timeline timeline, int processTime, MutationOperation op, ReadWriteEnd out, ReadEnd... in)
{
super(timeline, processTime);
this.op = op;
protected MultiInputGate(Timeline timeline, int processTime, MutationOperation op, ReadWriteEnd out, ReadEnd... in)
{
super(timeline, processTime);
this.op = op;
-
length = out.leng
th();
+
width = out.wid
th();
this.in = in.clone();
if (in.length < 1)
throw new IllegalArgumentException(String.format("Cannot create gate with %d wires.", in.length));
for (ReadEnd w : in)
{
this.in = in.clone();
if (in.length < 1)
throw new IllegalArgumentException(String.format("Cannot create gate with %d wires.", in.length));
for (ReadEnd w : in)
{
- if (w.
length() != leng
th)
+ if (w.
width() != wid
th)
throw new IllegalArgumentException("All wires connected to the gate must be of uniform length.");
w.registerObserver(this);
}
this.out = out;
}
throw new IllegalArgumentException("All wires connected to the gate must be of uniform length.");
w.registerObserver(this);
}
this.out = out;
}
+ protected MultiInputGate(Timeline timeline, int processTime, MutationOperation op, boolean invert, ReadWriteEnd out, ReadEnd... in)
+ {
+ this(timeline, processTime, op, out, in);
+ this.invert = invert;
+ }
+
@Override
public List<ReadEnd> getAllInputs()
{
@Override
public List<ReadEnd> getAllInputs()
{
@@
-51,6
+58,6
@@
public abstract class MultiInputGate extends BasicComponent
BitVectorMutator mutator = BitVectorMutator.empty();
for (ReadEnd w : in)
op.apply(mutator, w.getValues());
BitVectorMutator mutator = BitVectorMutator.empty();
for (ReadEnd w : in)
op.apply(mutator, w.getValues());
- out.feedSignals(
mutator.get
());
+ out.feedSignals(
invert ? mutator.toBitVector().not() : mutator.toBitVector
());
}
}
}
}