Changed GUIMerger/Splitter read end array order; removed resolved TODO
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Mon, 2 Sep 2019 12:02:23 +0000 (14:02 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Mon, 2 Sep 2019 12:02:23 +0000 (14:02 +0200)
net.mograsim.logic.core/src/net/mograsim/logic/core/wires/Wire.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/GUIMerger.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/GUISplitter.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/wires/Pin.java
net.mograsim.logic.model/src/net/mograsim/logic/model/modeladapter/componentadapters/MergerAdapter.java
net.mograsim.logic.model/src/net/mograsim/logic/model/modeladapter/componentadapters/SplitterAdapter.java

index 4063d78..15755ae 100644 (file)
@@ -637,7 +637,7 @@ public class Wire
         * @param bitA The bit of {@link Wire} a to be fused
         * @param bitB The bit of {@link Wire} b to be fused
         */
-       private static void fuse(Wire a, Wire b, int bitA, int bitB)
+       public static void fuse(Wire a, Wire b, int bitA, int bitB)
        {
                if (bitA >= a.width)
                        throw new IllegalArgumentException("No bit " + bitA + " in " + a + " (width " + a.width + ")");
index 313a51a..d8ef015 100644 (file)
@@ -57,8 +57,8 @@ public class GUIMerger extends GUIComponent
                        gc.setForeground(ColorManager.current().toColor(c));
                double outLineY = posY + (logicWidth - 1) * heightPerPin / 2;
                gc.drawLine(posX + width / 2, outLineY, posX + width, outLineY);
-               double inputHeight = posY + (logicWidth - 1) * heightPerPin;
-               for (int i = 0; i < logicWidth; i++, inputHeight -= 10)
+               double inputHeight = posY;
+               for (int i = 0; i < logicWidth; i++, inputHeight += 10)
                {
                        c = BitVectorFormatter.formatAsColor(inputEnds[i]);
                        if (c != null)
index 9527279..6da4658 100644 (file)
@@ -57,8 +57,8 @@ public class GUISplitter extends GUIComponent
                        gc.setForeground(ColorManager.current().toColor(c));
                double inLineY = posY + (logicWidth - 1) * heightPerPin / 2;
                gc.drawLine(posX, inLineY, posX + width / 2, inLineY);
-               double outputHeight = posY + (logicWidth - 1) * heightPerPin;
-               for (int i = 0; i < logicWidth; i++, outputHeight -= 10)
+               double outputHeight = posY;
+               for (int i = 0; i < logicWidth; i++, outputHeight += 10)
                {
                        c = BitVectorFormatter.formatAsColor(outputEnds[i]);
                        if (c != null)
index 5f6504c..0c63d38 100644 (file)
@@ -18,7 +18,6 @@ import net.mograsim.logic.model.model.components.GUIComponent;
  */
 public class Pin
 {
-       // TODO introduce input/output/tristate hints
        /**
         * The {@link GUIComponent} this pin belongs to.
         */
index e5e4430..cb3057e 100644 (file)
@@ -25,8 +25,8 @@ public class MergerAdapter implements ComponentAdapter<GUIMerger>
                ReadEnd[] inputEnds = new ReadEnd[guiComponent.logicWidth];
                for (int i = 0; i < guiComponent.logicWidth; i++)
                {
-                       Wire input = logicWiresPerPin.get(guiComponent.getPin("I" + i));
-                       Wire.fuse(input, output, 0, guiComponent.logicWidth - 1 - i, 1);
+                       Wire input = logicWiresPerPin.get(guiComponent.getPin("I" + (guiComponent.logicWidth - 1 - i)));
+                       Wire.fuse(input, output, 0, i);
                        inputEnds[i] = input.createReadOnlyEnd();
                }
                guiComponent.setLogicModelBinding(inputEnds, output.createReadOnlyEnd());
index 1a5a50e..57cad51 100644 (file)
@@ -25,8 +25,8 @@ public class SplitterAdapter implements ComponentAdapter<GUISplitter>
                ReadEnd[] outputEnds = new ReadEnd[guiComponent.logicWidth];
                for (int i = 0; i < guiComponent.logicWidth; i++)
                {
-                       Wire output = logicWiresPerPin.get(guiComponent.getPin("O" + i));
-                       Wire.fuse(input, output, guiComponent.logicWidth - 1 - i, 0, 1);
+                       Wire output = logicWiresPerPin.get(guiComponent.getPin("O" + (guiComponent.logicWidth - 1 - i)));
+                       Wire.fuse(input, output, i, 0);
                        outputEnds[i] = output.createReadOnlyEnd();
                }
                guiComponent.setLogicModelBinding(input.createReadOnlyEnd(), outputEnds);