projects
/
Mograsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge logic of origin into logic
[Mograsim.git]
/
era.mi
/
src
/
era
/
mi
/
logic
/
components
/
Merger.java
diff --git
a/era.mi/src/era/mi/logic/components/Merger.java
b/era.mi/src/era/mi/logic/components/Merger.java
index
da9b55e
..
613d523
100644
(file)
--- a/
era.mi/src/era/mi/logic/components/Merger.java
+++ b/
era.mi/src/era/mi/logic/components/Merger.java
@@
-3,80
+3,80
@@
package era.mi.logic.components;
import java.util.List;
import era.mi.logic.Bit;
import java.util.List;
import era.mi.logic.Bit;
-import era.mi.logic.wires.Wire
Array
;
-import era.mi.logic.wires.Wire
Array.WireArray
End;
-import era.mi.logic.wires.Wire
Array
Observer;
+import era.mi.logic.wires.Wire;
+import era.mi.logic.wires.Wire
.Wire
End;
+import era.mi.logic.wires.WireObserver;
-public class Merger implements Wire
Array
Observer, Component
+public class Merger implements WireObserver, Component
{
{
- private Wire
ArrayEnd outI
;
- private Wire
Array
[] inputs;
+ private Wire
End out
;
+ private Wire
End
[] inputs;
private int[] beginningIndex;
/**
*
private int[] beginningIndex;
/**
*
- * @param union The output of merging n {@link Wire
Array
}s into one. Must have length = a1.length() + a2.length() + ... + an.length().
+ * @param union The output of merging n {@link Wire}s into one. Must have length = a1.length() + a2.length() + ... + an.length().
* @param inputs The inputs to be merged into the union
*/
* @param inputs The inputs to be merged into the union
*/
- public Merger(Wire
Array union, WireArray
... inputs)
+ public Merger(Wire
End union, WireEnd
... inputs)
{
this.inputs = inputs;
{
this.inputs = inputs;
- this.out
I = union.createInput()
;
+ this.out
= union
;
this.beginningIndex = new int[inputs.length];
int length = 0;
for (int i = 0; i < inputs.length; i++)
{
beginningIndex[i] = length;
this.beginningIndex = new int[inputs.length];
int length = 0;
for (int i = 0; i < inputs.length; i++)
{
beginningIndex[i] = length;
- length += inputs[i].length;
+ length += inputs[i].length
()
;
inputs[i].addObserver(this);
}
inputs[i].addObserver(this);
}
- if (length != union.length)
+ if (length != union.length
()
)
throw new IllegalArgumentException(
"The output of merging n WireArrays into one must have length = a1.length() + a2.length() + ... + an.length().");
}
throw new IllegalArgumentException(
"The output of merging n WireArrays into one must have length = a1.length() + a2.length() + ... + an.length().");
}
- public Wire
Array
getInput(int index)
+ public Wire
End
getInput(int index)
{
return inputs[index];
}
{
return inputs[index];
}
- public Wire
Array
getUnion()
+ public Wire
End
getUnion()
{
{
- return out
I.owner
;
+ return out;
}
@Override
}
@Override
- public void update(Wire
Array
initiator, Bit[] oldValues)
+ public void update(Wire initiator, Bit[] oldValues)
{
int index = find(initiator);
int beginning = beginningIndex[index];
{
int index = find(initiator);
int beginning = beginningIndex[index];
- out
I.feedSignals(beginning, initiator
.getValues());
+ out
.feedSignals(beginning, inputs[index]
.getValues());
}
}
- private int find(Wire
Array
w)
+ private int find(Wire w)
{
for (int i = 0; i < inputs.length; i++)
{
for (int i = 0; i < inputs.length; i++)
- if (inputs[i] == w)
+ if (inputs[i]
.getWire()
== w)
return i;
return -1;
}
return i;
return -1;
}
- public Wire
Array
[] getInputs()
+ public Wire
End
[] getInputs()
{
return inputs.clone();
}
@Override
{
return inputs.clone();
}
@Override
- public List<Wire
Array
> getAllInputs()
+ public List<Wire
End
> getAllInputs()
{
return List.of(inputs);
}
@Override
{
return List.of(inputs);
}
@Override
- public List<Wire
Array
> getAllOutputs()
+ public List<Wire
End
> getAllOutputs()
{
{
- return List.of(out
I.owner
);
+ return List.of(out);
}
}
}
}