X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.core%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fcore%2Fcomponents%2FMux.java;h=3776bde9399760227cb512538d43e40a45475adf;hb=76fdc144f22b60491e61a32860fe2e6881751505;hp=bbb10f5e8db9fc5df6561b1861f4823135e4ef8e;hpb=07faf07e3acb8b2afdc2bf65a46bc868faaed0f8;p=Mograsim.git diff --git a/net.mograsim.logic.core/src/net/mograsim/logic/core/components/Mux.java b/net.mograsim.logic.core/src/net/mograsim/logic/core/components/Mux.java index bbb10f5e..3776bde9 100644 --- a/net.mograsim.logic.core/src/net/mograsim/logic/core/components/Mux.java +++ b/net.mograsim.logic.core/src/net/mograsim/logic/core/components/Mux.java @@ -25,32 +25,32 @@ public class Mux extends BasicComponent private final int outputSize; /** - * Input {@link Wire}s and out must be of uniform length + * Input {@link Wire}s and out must be of uniform width * - * @param out Must be of uniform length with all inputs. + * @param out Must be of uniform width with all inputs. * @param select Indexes the input array which is to be mapped to the output. Must have enough bits to index all inputs. * @param inputs One of these inputs is mapped to the output, depending on the select bits */ public Mux(Timeline timeline, int processTime, ReadWriteEnd out, ReadEnd select, ReadEnd... inputs) { super(timeline, processTime); - outputSize = out.length(); + outputSize = out.width(); this.inputs = inputs.clone(); for (int i = 0; i < this.inputs.length; i++) { - if (inputs[i].length() != outputSize) - throw new IllegalArgumentException("All MUX wire arrays must be of uniform length!"); - inputs[i].addObserver(this); + if (inputs[i].width() != outputSize) + throw new IllegalArgumentException("All MUX wire arrays must be of uniform width!"); + inputs[i].registerObserver(this); } this.select = select; - select.addObserver(this); + select.registerObserver(this); - int maxInputs = 1 << select.length(); + int maxInputs = 1 << select.width(); if (this.inputs.length > maxInputs) throw new IllegalArgumentException("There are more inputs (" + this.inputs.length + ") to the MUX than supported by " - + select.length() + " select bits (" + maxInputs + ")."); + + select.width() + " select bits (" + maxInputs + ")."); this.out = out; } @@ -82,7 +82,7 @@ public class Mux extends BasicComponent @Override public List getAllInputs() { - ArrayList wires = new ArrayList(Arrays.asList(inputs)); + ArrayList wires = new ArrayList<>(Arrays.asList(inputs)); wires.add(select); return Collections.unmodifiableList(wires); }