projects
/
Mograsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Integrated new types, tests still work, not used yet
[Mograsim.git]
/
era.mi
/
src
/
era
/
mi
/
logic
/
components
/
gates
/
MultiInputGate.java
diff --git
a/era.mi/src/era/mi/logic/components/gates/MultiInputGate.java
b/era.mi/src/era/mi/logic/components/gates/MultiInputGate.java
index
bfa33ed
..
7d0e485
100644
(file)
--- a/
era.mi/src/era/mi/logic/components/gates/MultiInputGate.java
+++ b/
era.mi/src/era/mi/logic/components/gates/MultiInputGate.java
@@
-1,61
+1,56
@@
package era.mi.logic.components.gates;
\r
\r
package era.mi.logic.components.gates;
\r
\r
-import java.util.Arrays;
\r
-import java.util.Collections;
\r
import java.util.List;
\r
\r
import java.util.List;
\r
\r
-import era.mi.logic.Bit;
\r
import era.mi.logic.components.BasicComponent;
\r
import era.mi.logic.components.BasicComponent;
\r
-import era.mi.logic.
wires.WireArray
;
\r
-import era.mi.logic.wires.Wire
Array.WireArrayInput
;
\r
+import era.mi.logic.
types.Bit
;
\r
+import era.mi.logic.wires.Wire
.WireEnd
;
\r
\r
public abstract class MultiInputGate extends BasicComponent
\r
{
\r
\r
public abstract class MultiInputGate extends BasicComponent
\r
{
\r
- protected WireArray[] in;
\r
- protected WireArray out;
\r
- protected WireArrayInput outI;
\r
+ protected WireEnd[] in;
\r
+ protected WireEnd out;
\r
protected final int length;
\r
protected Operation op;
\r
protected final int length;
\r
protected Operation op;
\r
-
\r
- protected MultiInputGate(int processTime, Operation op, Wire
Array out, WireArray
... in)
\r
+
\r
+ protected MultiInputGate(int processTime, Operation op, Wire
End out, WireEnd
... in)
\r
{
\r
super(processTime);
\r
this.op = op;
\r
{
\r
super(processTime);
\r
this.op = op;
\r
- length = out.length;
\r
+ length = out.length
()
;
\r
this.in = in.clone();
\r
this.in = in.clone();
\r
- if(in.length < 1)
\r
+ if
(in.length < 1)
\r
throw new IllegalArgumentException(String.format("Cannot create gate with %d wires.", in.length));
\r
throw new IllegalArgumentException(String.format("Cannot create gate with %d wires.", in.length));
\r
- for
(WireArray
w : in)
\r
+ for
(WireEnd
w : in)
\r
{
\r
{
\r
- if
(w.length
!= length)
\r
+ if
(w.length()
!= length)
\r
throw new IllegalArgumentException("All wires connected to the gate must be of uniform length.");
\r
w.addObserver(this);
\r
}
\r
this.out = out;
\r
throw new IllegalArgumentException("All wires connected to the gate must be of uniform length.");
\r
w.addObserver(this);
\r
}
\r
this.out = out;
\r
- outI = out.createInput();
\r
}
\r
\r
}
\r
\r
-
\r
@Override
\r
@Override
\r
- public List<Wire
Array
> getAllInputs()
\r
+ public List<Wire
End
> getAllInputs()
\r
{
\r
{
\r
- return
Collections.unmodifiableList(Arrays.asList(in)
);
\r
+ return
List.of(in
);
\r
}
\r
\r
@Override
\r
}
\r
\r
@Override
\r
- public List<Wire
Array
> getAllOutputs()
\r
+ public List<Wire
End
> getAllOutputs()
\r
{
\r
{
\r
- return
Collections.unmodifiableList(Arrays.asList(out)
);
\r
+ return
List.of(out
);
\r
}
\r
}
\r
-
\r
+
\r
+ @Override
\r
protected void compute()
\r
{
\r
Bit[] result = in[0].getValues();
\r
protected void compute()
\r
{
\r
Bit[] result = in[0].getValues();
\r
- for(int i = 1; i < in.length; i++)
\r
+ for
(int i = 1; i < in.length; i++)
\r
result = op.execute(result, in[i].getValues());
\r
result = op.execute(result, in[i].getValues());
\r
- out
I
.feedSignals(result);
\r
+ out.feedSignals(result);
\r
}
\r
}
\r
-
\r
+
\r
protected interface Operation
\r
{
\r
public Bit[] execute(Bit[] a, Bit[] b);
\r
protected interface Operation
\r
{
\r
public Bit[] execute(Bit[] a, Bit[] b);
\r