import net.mograsim.logic.model.model.ViewModelModifiable;
import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position;
{
super(model, name, "D flip flop\n12 bits");
setSize(40, 20);
- addPin(new Pin(this, "D", 12, 20, 20), Usage.INPUT, Position.TOP);
- addPin(new Pin(this, "C", 1, 0, 10), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "Y", 12, 20, 0), Usage.OUTPUT, Position.BOTTOM);
+ addPin(new Pin(this, "D", 12, PinUsage.INPUT, 20, 20), Position.TOP);
+ addPin(new Pin(this, "C", 1, PinUsage.INPUT, 0, 10), Position.RIGHT);
+ addPin(new Pin(this, "Y", 12, PinUsage.OUTPUT, 20, 0), Position.BOTTOM);
}
@Override
import net.mograsim.logic.model.model.ViewModelModifiable;
import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position;
{
super(model, name, "D flip flop\n4 bits");
setSize(35, 90);
- addPin(new Pin(this, "C", 1, 0, 5), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "_WE1", 1, 0, 15), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "_WE2", 1, 0, 25), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "_WE3", 1, 0, 35), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "_WE4", 1, 0, 45), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "D1", 1, 0, 55), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "D2", 1, 0, 65), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "D3", 1, 0, 75), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "D4", 1, 0, 85), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "Q1", 1, 35, 5), Usage.OUTPUT, Position.LEFT);
- addPin(new Pin(this, "Q2", 1, 35, 15), Usage.OUTPUT, Position.LEFT);
- addPin(new Pin(this, "Q3", 1, 35, 25), Usage.OUTPUT, Position.LEFT);
- addPin(new Pin(this, "Q4", 1, 35, 35), Usage.OUTPUT, Position.LEFT);
+ addPin(new Pin(this, "C", 1, PinUsage.INPUT, 0, 5), Position.RIGHT);
+ addPin(new Pin(this, "_WE1", 1, PinUsage.INPUT, 0, 15), Position.RIGHT);
+ addPin(new Pin(this, "_WE2", 1, PinUsage.INPUT, 0, 25), Position.RIGHT);
+ addPin(new Pin(this, "_WE3", 1, PinUsage.INPUT, 0, 35), Position.RIGHT);
+ addPin(new Pin(this, "_WE4", 1, PinUsage.INPUT, 0, 45), Position.RIGHT);
+ addPin(new Pin(this, "D1", 1, PinUsage.INPUT, 0, 55), Position.RIGHT);
+ addPin(new Pin(this, "D2", 1, PinUsage.INPUT, 0, 65), Position.RIGHT);
+ addPin(new Pin(this, "D3", 1, PinUsage.INPUT, 0, 75), Position.RIGHT);
+ addPin(new Pin(this, "D4", 1, PinUsage.INPUT, 0, 85), Position.RIGHT);
+ addPin(new Pin(this, "Q1", 1, PinUsage.OUTPUT, 35, 5), Position.LEFT);
+ addPin(new Pin(this, "Q2", 1, PinUsage.OUTPUT, 35, 15), Position.LEFT);
+ addPin(new Pin(this, "Q3", 1, PinUsage.OUTPUT, 35, 25), Position.LEFT);
+ addPin(new Pin(this, "Q4", 1, PinUsage.OUTPUT, 35, 35), Position.LEFT);
}
@Override
import net.mograsim.logic.model.model.ViewModelModifiable;
import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position;
{
super(model, name, "Incrementer");
setSize(40, 20);
- addPin(new Pin(this, "A", 12, 20, 20), Usage.INPUT, Position.TOP);
- addPin(new Pin(this, "CI", 1, 40, 10), Usage.INPUT, Position.LEFT);
- addPin(new Pin(this, "Y", 12, 20, 0), Usage.OUTPUT, Position.BOTTOM);
+ addPin(new Pin(this, "A", 12, PinUsage.INPUT, 20, 20), Position.TOP);
+ addPin(new Pin(this, "CI", 1, PinUsage.INPUT, 40, 10), Position.LEFT);
+ addPin(new Pin(this, "Y", 12, PinUsage.OUTPUT, 20, 0), Position.BOTTOM);
}
@Override
import net.mograsim.logic.model.model.ViewModelModifiable;
import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position;
{
super(model, name, "=0");
setSize(35, 20);
- addPin(new Pin(this, "D", 12, 0, 10), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "Y", 1, 35, 10), Usage.OUTPUT, Position.LEFT);
+ addPin(new Pin(this, "D", 12, PinUsage.INPUT, 0, 10), Position.RIGHT);
+ addPin(new Pin(this, "Y", 1, PinUsage.OUTPUT, 35, 10), Position.LEFT);
}
@Override
import net.mograsim.logic.model.model.ViewModelModifiable;
import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position;
{
super(model, name, "RAM\n5 x 12 Bit");
setSize(40, 40);
- addPin(new Pin(this, "A", 3, 10, 0), Usage.INPUT, Position.BOTTOM);
- addPin(new Pin(this, "B", 3, 30, 0), Usage.INPUT, Position.BOTTOM);
- addPin(new Pin(this, "WE", 1, 0, 5), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "C", 1, 0, 15), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "Y", 12, 0, 30), Usage.OUTPUT, Position.RIGHT);
- addPin(new Pin(this, "D", 12, 20, 40), Usage.INPUT, Position.TOP);
+ addPin(new Pin(this, "A", 3, PinUsage.INPUT, 10, 0), Position.BOTTOM);
+ addPin(new Pin(this, "B", 3, PinUsage.INPUT, 30, 0), Position.BOTTOM);
+ addPin(new Pin(this, "WE", 1, PinUsage.INPUT, 0, 5), Position.RIGHT);
+ addPin(new Pin(this, "C", 1, PinUsage.INPUT, 0, 15), Position.RIGHT);
+ addPin(new Pin(this, "Y", 12, PinUsage.OUTPUT, 0, 30), Position.RIGHT);
+ addPin(new Pin(this, "D", 12, PinUsage.INPUT, 20, 40), Position.TOP);
}
@Override
import net.mograsim.logic.model.model.ViewModelModifiable;
import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position;
{
super(model, name, "4-way SEL\n12 bit");
setSize(80, 40);
- addPin(new Pin(this, "SA", 1, 0, 5), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "SB", 1, 0, 15), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "SC", 1, 0, 25), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "SD", 1, 0, 35), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "A", 12, 10, 0), Usage.INPUT, Position.BOTTOM);
- addPin(new Pin(this, "B", 12, 30, 0), Usage.INPUT, Position.BOTTOM);
- addPin(new Pin(this, "C", 12, 50, 0), Usage.INPUT, Position.BOTTOM);
- addPin(new Pin(this, "D", 12, 70, 0), Usage.INPUT, Position.BOTTOM);
- addPin(new Pin(this, "Y", 12, 40, 40), Usage.OUTPUT, Position.TOP);
+ addPin(new Pin(this, "SA", 1, PinUsage.INPUT, 0, 5), Position.RIGHT);
+ addPin(new Pin(this, "SB", 1, PinUsage.INPUT, 0, 15), Position.RIGHT);
+ addPin(new Pin(this, "SC", 1, PinUsage.INPUT, 0, 25), Position.RIGHT);
+ addPin(new Pin(this, "SD", 1, PinUsage.INPUT, 0, 35), Position.RIGHT);
+ addPin(new Pin(this, "A", 12, PinUsage.INPUT, 10, 0), Position.BOTTOM);
+ addPin(new Pin(this, "B", 12, PinUsage.INPUT, 30, 0), Position.BOTTOM);
+ addPin(new Pin(this, "C", 12, PinUsage.INPUT, 50, 0), Position.BOTTOM);
+ addPin(new Pin(this, "D", 12, PinUsage.INPUT, 70, 0), Position.BOTTOM);
+ addPin(new Pin(this, "Y", 12, PinUsage.OUTPUT, 40, 40), Position.TOP);
}
@Override
import net.mograsim.logic.model.model.ViewModelModifiable;
import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position;
{
super(model, name, "Instruction\ndecode");
setSize(80, 80);
- addPin(new Pin(this, "I5-0", 6, 0, 30), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "I12-11", 2, 0, 50), Usage.INPUT, Position.RIGHT);
+ addPin(new Pin(this, "I5-0", 6, PinUsage.INPUT, 0, 30), Position.RIGHT);
+ addPin(new Pin(this, "I12-11", 2, PinUsage.INPUT, 0, 50), Position.RIGHT);
// muSR MUX:
// 00: 0
// 01: 1
// 10: M
// 11: I
- addPin(new Pin(this, "muSR_MUX", 2, 80, 10), Usage.OUTPUT, Position.LEFT);
- addPin(new Pin(this, "muSR_OVRRET", 1, 80, 20), Usage.OUTPUT, Position.LEFT);
- addPin(new Pin(this, "muSR_CINV", 1, 80, 30), Usage.OUTPUT, Position.LEFT);
- addPin(new Pin(this, "muSR_WEZ", 1, 80, 40), Usage.OUTPUT, Position.LEFT);
- addPin(new Pin(this, "muSR_WEC", 1, 80, 50), Usage.OUTPUT, Position.LEFT);
- addPin(new Pin(this, "muSR_WEN", 1, 80, 60), Usage.OUTPUT, Position.LEFT);
- addPin(new Pin(this, "muSR_WEOVR", 1, 80, 70), Usage.OUTPUT, Position.LEFT);
+ addPin(new Pin(this, "muSR_MUX", 2, PinUsage.OUTPUT, 80, 10), Position.LEFT);
+ addPin(new Pin(this, "muSR_OVRRET", 1, PinUsage.OUTPUT, 80, 20), Position.LEFT);
+ addPin(new Pin(this, "muSR_CINV", 1, PinUsage.OUTPUT, 80, 30), Position.LEFT);
+ addPin(new Pin(this, "muSR_WEZ", 1, PinUsage.OUTPUT, 80, 40), Position.LEFT);
+ addPin(new Pin(this, "muSR_WEC", 1, PinUsage.OUTPUT, 80, 50), Position.LEFT);
+ addPin(new Pin(this, "muSR_WEN", 1, PinUsage.OUTPUT, 80, 60), Position.LEFT);
+ addPin(new Pin(this, "muSR_WEOVR", 1, PinUsage.OUTPUT, 80, 70), Position.LEFT);
// MSR MUX:
// 000: 0
// 001: 1
// 101: I, invert C
// 110: Swap OVR and C
// 111: _M
- addPin(new Pin(this, "MSR_MUX", 3, 20, 0), Usage.OUTPUT, Position.BOTTOM);
- addPin(new Pin(this, "OEN", 1, 60, 0), Usage.OUTPUT, Position.BOTTOM);
+ addPin(new Pin(this, "MSR_MUX", 3, PinUsage.OUTPUT, 20, 0), Position.BOTTOM);
+ addPin(new Pin(this, "OEN", 1, PinUsage.OUTPUT, 60, 0), Position.BOTTOM);
// Y MUX:
// 00: mu
// 01: mu
// 10: M
// 11: I
- addPin(new Pin(this, "Y_MUX", 2, 10, 80), Usage.OUTPUT, Position.TOP);
+ addPin(new Pin(this, "Y_MUX", 2, PinUsage.OUTPUT, 10, 80), Position.TOP);
// CT MUX:
// see Am2900 Family Data Book, Am2904, Table 4 (CT_MUX2-0 = I3-1)
- addPin(new Pin(this, "CT_MUX", 3, 30, 80), Usage.OUTPUT, Position.TOP);
- addPin(new Pin(this, "CT_INV", 1, 40, 80), Usage.OUTPUT, Position.TOP);
- addPin(new Pin(this, "CT_EXP", 1, 50, 80), Usage.OUTPUT, Position.TOP);
+ addPin(new Pin(this, "CT_MUX", 3, PinUsage.OUTPUT, 30, 80), Position.TOP);
+ addPin(new Pin(this, "CT_INV", 1, PinUsage.OUTPUT, 40, 80), Position.TOP);
+ addPin(new Pin(this, "CT_EXP", 1, PinUsage.OUTPUT, 50, 80), Position.TOP);
// C0 MUX:
// 00xx: 0
// 01xx: 1
// 1101: _muC
// 1110: MC
// 1111: _MC
- addPin(new Pin(this, "C0_MUX", 4, 70, 80), Usage.OUTPUT, Position.TOP);
+ addPin(new Pin(this, "C0_MUX", 4, PinUsage.OUTPUT, 70, 80), Position.TOP);
}
@Override
import net.mograsim.logic.model.model.ViewModelModifiable;
import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position;
{
super(model, name, "Shift \ninstruction\ndecode");
setSize(60, 80);
- addPin(new Pin(this, "I", 5, 0, 25), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "_SE", 1, 0, 55), Usage.INPUT, Position.RIGHT);
+ addPin(new Pin(this, "I", 5, PinUsage.INPUT, 0, 25), Position.RIGHT);
+ addPin(new Pin(this, "_SE", 1, PinUsage.INPUT, 0, 55), Position.RIGHT);
// SIO0 MUX:
// 000: 0
// 001: 1
// 01x: SIOn
// 10x: QIOn
// 11x: MC
- addPin(new Pin(this, "SIO0_MUX", 3, 60, 5), Usage.OUTPUT, Position.LEFT);
+ addPin(new Pin(this, "SIO0_MUX", 3, PinUsage.OUTPUT, 60, 5), Position.LEFT);
// SIOn MUX:
// 000: 0
// 001: 1
// 101: MN
// 110: IC
// 111: IN xor IVOR
- addPin(new Pin(this, "SIOn_MUX", 3, 60, 15), Usage.OUTPUT, Position.LEFT);
+ addPin(new Pin(this, "SIOn_MUX", 3, PinUsage.OUTPUT, 60, 15), Position.LEFT);
// QIO0 MUX:
// 000: 0
// 001: 1
// 01x: SIOn
// 10x: QIOn
// 11x: MC
- addPin(new Pin(this, "QIO0_MUX", 3, 60, 25), Usage.OUTPUT, Position.LEFT);
+ addPin(new Pin(this, "QIO0_MUX", 3, PinUsage.OUTPUT, 60, 25), Position.LEFT);
// QIOn MUX:
// 000: 0
// 001: 1
// 01x: SIO0
// 10x: QIO0
// 11x: MN
- addPin(new Pin(this, "QIOn_MUX", 3, 60, 35), Usage.OUTPUT, Position.LEFT);
- addPin(new Pin(this, "OEn", 1, 60, 45), Usage.OUTPUT, Position.LEFT);
- addPin(new Pin(this, "OE0", 1, 60, 55), Usage.OUTPUT, Position.LEFT);
+ addPin(new Pin(this, "QIOn_MUX", 3, PinUsage.OUTPUT, 60, 35), Position.LEFT);
+ addPin(new Pin(this, "OEn", 1, PinUsage.OUTPUT, 60, 45), Position.LEFT);
+ addPin(new Pin(this, "OE0", 1, PinUsage.OUTPUT, 60, 55), Position.LEFT);
// 00: SIO0
// 01: QIO0
// 1x: SIOn
- addPin(new Pin(this, "MC_MUX", 2, 60, 65), Usage.OUTPUT, Position.LEFT);
- addPin(new Pin(this, "MC_EN", 1, 60, 75), Usage.OUTPUT, Position.LEFT);
+ addPin(new Pin(this, "MC_MUX", 2, PinUsage.OUTPUT, 60, 65), Position.LEFT);
+ addPin(new Pin(this, "MC_EN", 1, PinUsage.OUTPUT, 60, 75), Position.LEFT);
}
@Override
import net.mograsim.logic.model.model.ViewModelModifiable;
import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position;
{
super(model, name, "Instr.\nPLA");
setSize(30, 85);
- addPin(new Pin(this, "PASS", 1, 0, 5), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "I", 4, 0, 20), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "R=0", 1, 15, 0), Usage.INPUT, Position.BOTTOM);
- addPin(new Pin(this, "_PL", 1, 5, 85), Usage.OUTPUT, Position.TOP);
- addPin(new Pin(this, "_MAP", 1, 15, 85), Usage.OUTPUT, Position.TOP);
- addPin(new Pin(this, "_VECT", 1, 25, 85), Usage.OUTPUT, Position.TOP);
- addPin(new Pin(this, "RWE", 1, 30, 5), Usage.OUTPUT, Position.LEFT);
- addPin(new Pin(this, "RDEC", 1, 30, 15), Usage.OUTPUT, Position.LEFT);
- addPin(new Pin(this, "YD", 1, 30, 25), Usage.OUTPUT, Position.LEFT);
- addPin(new Pin(this, "YR", 1, 30, 35), Usage.OUTPUT, Position.LEFT);
- addPin(new Pin(this, "YF", 1, 30, 45), Usage.OUTPUT, Position.LEFT);
- addPin(new Pin(this, "YmuPC", 1, 30, 55), Usage.OUTPUT, Position.LEFT);
- addPin(new Pin(this, "STKI0", 1, 30, 65), Usage.OUTPUT, Position.LEFT);
- addPin(new Pin(this, "STKI1", 1, 30, 75), Usage.OUTPUT, Position.LEFT);
+ addPin(new Pin(this, "PASS", 1, PinUsage.INPUT, 0, 5), Position.RIGHT);
+ addPin(new Pin(this, "I", 4, PinUsage.INPUT, 0, 20), Position.RIGHT);
+ addPin(new Pin(this, "R=0", 1, PinUsage.INPUT, 15, 0), Position.BOTTOM);
+ addPin(new Pin(this, "_PL", 1, PinUsage.OUTPUT, 5, 85), Position.TOP);
+ addPin(new Pin(this, "_MAP", 1, PinUsage.OUTPUT, 15, 85), Position.TOP);
+ addPin(new Pin(this, "_VECT", 1, PinUsage.OUTPUT, 25, 85), Position.TOP);
+ addPin(new Pin(this, "RWE", 1, PinUsage.OUTPUT, 30, 5), Position.LEFT);
+ addPin(new Pin(this, "RDEC", 1, PinUsage.OUTPUT, 30, 15), Position.LEFT);
+ addPin(new Pin(this, "YD", 1, PinUsage.OUTPUT, 30, 25), Position.LEFT);
+ addPin(new Pin(this, "YR", 1, PinUsage.OUTPUT, 30, 35), Position.LEFT);
+ addPin(new Pin(this, "YF", 1, PinUsage.OUTPUT, 30, 45), Position.LEFT);
+ addPin(new Pin(this, "YmuPC", 1, PinUsage.OUTPUT, 30, 55), Position.LEFT);
+ addPin(new Pin(this, "STKI0", 1, PinUsage.OUTPUT, 30, 65), Position.LEFT);
+ addPin(new Pin(this, "STKI1", 1, PinUsage.OUTPUT, 30, 75), Position.LEFT);
}
@Override
import net.mograsim.logic.model.model.ViewModelModifiable;
import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position;
{
super(model, name, "Register/\nCounter");
setSize(40, 40);
- addPin(new Pin(this, "D", 12, 20, 0), Usage.INPUT, Position.BOTTOM);
- addPin(new Pin(this, "_RLD", 1, 0, 5), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "WE", 1, 0, 20), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "DEC", 1, 0, 30), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "C", 1, 40, 20), Usage.INPUT, Position.LEFT);
- addPin(new Pin(this, "Y", 12, 20, 40), Usage.OUTPUT, Position.TOP);
+ addPin(new Pin(this, "D", 12, PinUsage.INPUT, 20, 0), Position.BOTTOM);
+ addPin(new Pin(this, "_RLD", 1, PinUsage.INPUT, 0, 5), Position.RIGHT);
+ addPin(new Pin(this, "WE", 1, PinUsage.INPUT, 0, 20), Position.RIGHT);
+ addPin(new Pin(this, "DEC", 1, PinUsage.INPUT, 0, 30), Position.RIGHT);
+ addPin(new Pin(this, "C", 1, PinUsage.INPUT, 40, 20), Position.LEFT);
+ addPin(new Pin(this, "Y", 12, PinUsage.OUTPUT, 20, 40), Position.TOP);
}
@Override
import net.mograsim.logic.model.model.ViewModelModifiable;
import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position;
{
super(model, name, "Stack\npointer");
setSize(40, 30);
- addPin(new Pin(this, "STKI0", 1, 0, 5), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "STKI1", 1, 0, 15), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "C", 1, 0, 25), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "A", 3, 10, 30), Usage.OUTPUT, Position.TOP);
- addPin(new Pin(this, "B", 3, 30, 30), Usage.OUTPUT, Position.TOP);
- addPin(new Pin(this, "_FULL", 1, 40, 15), Usage.OUTPUT, Position.LEFT);
+ addPin(new Pin(this, "STKI0", 1, PinUsage.INPUT, 0, 5), Position.RIGHT);
+ addPin(new Pin(this, "STKI1", 1, PinUsage.INPUT, 0, 15), Position.RIGHT);
+ addPin(new Pin(this, "C", 1, PinUsage.INPUT, 0, 25), Position.RIGHT);
+ addPin(new Pin(this, "A", 3, PinUsage.OUTPUT, 10, 30), Position.TOP);
+ addPin(new Pin(this, "B", 3, PinUsage.OUTPUT, 30, 30), Position.TOP);
+ addPin(new Pin(this, "_FULL", 1, PinUsage.OUTPUT, 40, 15), Position.LEFT);
}
@Override
import net.mograsim.logic.model.model.components.GUIComponent;
import net.mograsim.logic.model.model.components.atomic.GUIBitDisplay;
import net.mograsim.logic.model.model.components.atomic.GUIManualSwitch;
-import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent;
-import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent.Usage;
import net.mograsim.logic.model.model.wires.GUIWire;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
public class GUIComponentTestbench
{
GUIComponent comp = IndirectGUIComponentCreator.createComponent(model, "file:components/am2904/GUIAm2904.json");
- // guess which pins are outputs and which are inputs
- // TODO this code exists four times... but it seems too "hacky" to put it in a helper class
List<String> inputPinNames = new ArrayList<>();
List<String> outputPinNames = new ArrayList<>();
- if (comp instanceof SimpleRectangularHardcodedGUIComponent)
- {
- SimpleRectangularHardcodedGUIComponent compCasted = (SimpleRectangularHardcodedGUIComponent) comp;
- for (Pin p : comp.getPins().values())
- if (compCasted.getPinUsage(p) == Usage.INPUT)
- inputPinNames.add(p.name);
- else
- outputPinNames.add(p.name);
- } else
- for (Pin p : comp.getPins().values())
- if (p.getRelX() < comp.getWidth())
- inputPinNames.add(p.name);
- else
- outputPinNames.add(p.name);
+ for (Pin p : comp.getPins().values())
+ if (p.usage == PinUsage.INPUT)
+ inputPinNames.add(p.name);
+ else
+ outputPinNames.add(p.name);
inputPinNames.sort(Comparator.comparing(comp::getPin, Comparator.comparing(Pin::getRelY)));
outputPinNames.sort(Comparator.comparing(comp::getPin, Comparator.comparing(Pin::getRelY)));
import net.mograsim.logic.model.model.components.atomic.TextComponent;
import net.mograsim.logic.model.model.components.submodels.SubmodelComponent;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.model.wires.WireCrossPoint;
import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
import net.mograsim.logic.model.util.ModellingTool;
and.moveTo(135, -30);
Pin last = and.getPin("Y");
- // guess which pins are outputs and which are inputs
- // TODO this code exists four times... but it seems too "hacky" to put it in a helper class
List<String> inputPinNames = new ArrayList<>();
List<String> outputPinNames = new ArrayList<>();
for (Pin p : comp.getPins().values())
- if (p.getRelX() == 0)
+ if (p.usage == PinUsage.INPUT)
inputPinNames.add(p.name);
else
outputPinNames.add(p.name);
import net.mograsim.logic.model.editor.ui.DialogManager;
import net.mograsim.logic.model.model.wires.MovablePin;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
public class SelectionState extends EditorState
{
editor.getSelection().clear();
if ((stateMask & SWT.ALT) == SWT.ALT)
{
- String[] result = DialogManager.openMultiTextDialog("Add Pin...", "Add", "Cancel", "Name", "Logic Width");
+ String[] result = DialogManager.openMultiTextDialog("Add Pin...", "Add", "Cancel", "Name", "Logic Width", "Usage");
if (result != null)
{
try
{
- Pin p = editor.toBeEdited.addSubmodelInterface(
- new MovablePin(editor.toBeEdited, result[0], Integer.parseInt(result[1]), clicked.x, clicked.y));
+ Pin p = editor.toBeEdited.addSubmodelInterface(new MovablePin(editor.toBeEdited, result[0], Integer.parseInt(result[1]),
+ PinUsage.valueOf(result[2]), clicked.x, clicked.y));
editor.handleManager.getInterfacePinHandle(p).reqMove(clicked.x, clicked.y);
}
catch (NumberFormatException e)
{
editor.dialogManager.openWarningDialog("Failed to create Pin!", "Bit width must be a number!");
}
+ catch (IllegalArgumentException e)
+ {
+ editor.dialogManager.openWarningDialog("Failed to create Pin!", "Usage must be one of INPUT, OUTPUT, TRISTATE!");
+ }
}
}
}
import net.mograsim.logic.model.model.ViewModelModifiable;
import net.mograsim.logic.model.model.components.GUIComponent;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
import net.mograsim.logic.model.modeladapter.componentadapters.BitDisplayAdapter;
import net.mograsim.logic.model.serializing.IdentifierGetter;
logicObs = (i) -> model.requestRedraw();
setSize(width, height);
- addPin(this.inputPin = new Pin(this, "", logicWidth, 0, height / 2));
+ addPin(this.inputPin = new Pin(this, "", logicWidth, PinUsage.INPUT, 0, height / 2));
}
@Override
import net.haspamelodica.swt.helper.swtobjectwrappers.Font;
import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
-import net.mograsim.logic.core.LogicObservable;
import net.mograsim.logic.core.LogicObserver;
import net.mograsim.logic.core.components.ManualSwitch;
import net.mograsim.logic.core.types.BitVector;
import net.mograsim.logic.core.types.BitVectorFormatter;
-import net.mograsim.logic.core.wires.Wire.ReadEnd;
import net.mograsim.logic.model.model.ViewModelModifiable;
import net.mograsim.logic.model.model.components.GUIComponent;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
import net.mograsim.logic.model.modeladapter.componentadapters.ManualSwitchAdapter;
import net.mograsim.logic.model.serializing.IdentifierGetter;
private final LogicObserver logicObs;
private ManualSwitch logicSwitch;
- private ReadEnd end;
public GUIManualSwitch(ViewModelModifiable model, int logicWidth)
{
logicObs = (i) -> model.requestRedraw();
setSize(width, height);
- addPin(this.outputPin = new Pin(this, "", logicWidth, width, height / 2));
+ addPin(this.outputPin = new Pin(this, "", logicWidth, PinUsage.OUTPUT, width, height / 2));
}
@Override
public void render(GeneralGC gc, Rectangle visibleRegion)
{
- // TODO maybe draw switch state too?
Color foreground = Preferences.current().getColor("net.mograsim.logic.model.color.foreground");
if (foreground != null)
gc.setForeground(foreground);
gc.drawRectangle(getBounds());
- String label = BitVectorFormatter.formatValueAsString(end);
+ String label = BitVectorFormatter.formatAsString(logicSwitch == null ? null : logicSwitch.getValues());
Font oldFont = gc.getFont();
Font labelFont = new Font(oldFont.getName(), fontHeight, oldFont.getStyle());
gc.setFont(labelFont);
gc.setFont(oldFont);
}
- public void setLogicModelBinding(ManualSwitch logicSwitch, ReadEnd end)
+ public void setLogicModelBinding(ManualSwitch logicSwitch)
{
- deregisterLogicObs(this.end);
- deregisterLogicObs(this.logicSwitch);
+ if (this.logicSwitch != null)
+ this.logicSwitch.deregisterObserver(logicObs);
this.logicSwitch = logicSwitch;
- this.end = end;
- registerLogicObs(end);
- registerLogicObs(logicSwitch);
+ if (logicSwitch != null)
+ logicSwitch.registerObserver(logicObs);
}
public boolean hasLogicModelBinding()
}
}
- private void registerLogicObs(LogicObservable observable)
- {
- if (observable != null)
- observable.registerObserver(logicObs);
- }
-
- private void deregisterLogicObs(LogicObservable observable)
- {
- if (observable != null)
- observable.deregisterObserver(logicObs);
- }
-
@Override
public boolean clicked(double x, double y)
{
import net.mograsim.logic.model.model.ViewModelModifiable;
import net.mograsim.logic.model.model.components.GUIComponent;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
import net.mograsim.logic.model.modeladapter.componentadapters.MergerAdapter;
import net.mograsim.logic.model.serializing.IdentifierGetter;
setSize(width, logicWidth * heightPerPin);
double inputHeight = 0;
for (int i = 0; i < logicWidth; i++, inputHeight += 10)
- addPin(new Pin(this, "I" + i, 1, 0, inputHeight));
- addPin(this.outputPin = new Pin(this, "O", logicWidth, width, (logicWidth - 1) * heightPerPin / 2));
+ addPin(new Pin(this, "I" + i, 1, PinUsage.TRISTATE, 0, inputHeight));
+ addPin(this.outputPin = new Pin(this, "O", logicWidth, PinUsage.TRISTATE, width, (logicWidth - 1) * heightPerPin / 2));
inputEnds = new ReadEnd[logicWidth];
}
import net.mograsim.logic.model.model.ViewModelModifiable;
import net.mograsim.logic.model.model.components.GUIComponent;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
import net.mograsim.logic.model.modeladapter.componentadapters.SplitterAdapter;
import net.mograsim.logic.model.serializing.IdentifierGetter;
super(model, name);
this.logicWidth = logicWidth;
setSize(width, logicWidth * heightPerPin);
- addPin(this.inputPin = new Pin(this, "I", logicWidth, 0, (logicWidth - 1) * heightPerPin / 2));
+ addPin(this.inputPin = new Pin(this, "I", logicWidth, PinUsage.TRISTATE, 0, (logicWidth - 1) * heightPerPin / 2));
double outputHeight = 0;
for (int i = 0; i < logicWidth; i++, outputHeight += 10)
- addPin(new Pin(this, "O" + i, 1, width, outputHeight));
+ addPin(new Pin(this, "O" + i, 1, PinUsage.TRISTATE, width, outputHeight));
outputEnds = new ReadEnd[logicWidth];
}
import net.mograsim.logic.model.model.ViewModelModifiable;
import net.mograsim.logic.model.model.components.GUIComponent;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
import net.mograsim.logic.model.modeladapter.componentadapters.TriStateBufferAdapter;
import net.mograsim.logic.model.serializing.IdentifierGetter;
int isInv = ordi % 2;
int isStd = 1 ^ isInv;
- this.input = new Pin(this, "IN", params.logicWidth, width * isInv * isHori + wHalf * isVerti,
+ this.input = new Pin(this, "IN", params.logicWidth, PinUsage.INPUT, width * isInv * isHori + wHalf * isVerti,
height * isVerti * isStd + hHalf * isHori);
- this.output = new Pin(this, "OUT", params.logicWidth, width * isStd * isHori + wHalf * isVerti,
+ this.output = new Pin(this, "OUT", params.logicWidth, PinUsage.OUTPUT, width * isStd * isHori + wHalf * isVerti,
height * isVerti * isInv + hHalf * isHori);
- this.enable = new Pin(this, "EN", 1, wQuar * isVerti + wHalf * (isAlt | isHori), hQuar * isHori + hHalf * (isAlt | isVerti));
+ this.enable = new Pin(this, "EN", 1, PinUsage.INPUT, wQuar * isVerti + wHalf * (isAlt | isHori),
+ hQuar * isHori + hHalf * (isAlt | isVerti));
this.path = new double[] { width * (isStd ^ isHori), height * (isStd ^ isHori), width * isInv, height * isStd,
width * isStd * isHori + wHalf * isVerti, height * isVerti * isInv + hHalf * isHori };
import net.mograsim.logic.model.model.components.GUIComponent;
import net.mograsim.logic.model.model.wires.MovablePin;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.serializing.IdentifierGetter;
import net.mograsim.preferences.Preferences;
this.logicWidth = logicWidth;
this.isInverted = isInverted;
this.rectWidth = width - (isInverted ? invertedCircleDiam : 0);
- this.outputPin = new MovablePin(this, "Y", logicWidth, width, 0);
+ this.outputPin = new MovablePin(this, "Y", logicWidth, PinUsage.OUTPUT, width, 0);
addPin(outputPin);
this.inputPins = new ArrayList<>();
setInputCount(1);
for (int i = oldInputCount; i < inputCount; i++)
{
// TODO what for more than 24 input pins?
- Pin pin = new Pin(this, String.valueOf((char) ('A' + i)), logicWidth, 0, pinDistance / 2 + i * pinDistance);
+ Pin pin = new Pin(this, String.valueOf((char) ('A' + i)), logicWidth, PinUsage.INPUT, 0, pinDistance / 2 + i * pinDistance);
inputPins.add(pin);
addPin(pin);
}
package net.mograsim.logic.model.model.components.atomic;
-import java.util.HashMap;
import java.util.Map;
import net.haspamelodica.swt.helper.gcs.GeneralGC;
private static final double pinNamesHeight = 3.5;
private static final double pinNamesMargin = .5;
- // TODO maybe make this more general?
- private final Map<Pin, Usage> pinUsages;
-
private final DefaultOutlineRenderer outlineRenderer;
private final CenteredTextSymbolRenderer centerTextRenderer;
private final PinNamesSymbolRenderer pinNamesRenderer;
public SimpleRectangularHardcodedGUIComponent(ViewModelModifiable model, String name, String centerText)
{
super(model, name);
- pinUsages = new HashMap<>();
this.outlineRenderer = new DefaultOutlineRenderer(this);
CenteredTextParams centeredTextParams = new CenteredTextParams();
centeredTextParams.text = centerText;
// pins
- protected void addPin(Pin pin, Usage usage, Position namePosition)
+ protected void addPin(Pin pin, Position namePosition)
{
super.addPin(pin); // do this first to catch errors
- pinUsages.put(pin, usage);
pinNamesRenderer.setPinPosition(pin, namePosition);
}
private void pinRemoved(Pin pin)
{
- pinUsages.remove(pin);
pinNamesRenderer.setPinPosition(pin, null);
}
- public Usage getPinUsage(Pin pin)
- {
- return pinUsages.get(pin);
- }
-
// logic
protected abstract Object recalculate(Object lastState, Map<String, ReadEnd> readEnds, Map<String, ReadWriteEnd> readWriteEnds);
@Override
protected void addPin(Pin pin)
{
- throw new UnsupportedOperationException("Can't add pins without setting usage, call addPin(Pin, Usage [, Position]) instead");
- }
-
- public static enum Usage
- {
- INPUT, OUTPUT, TRISTATE;
+ throw new UnsupportedOperationException("Can't add pins without setting usage, call addPin(Pin [, Position]) instead");
}
static
import net.mograsim.logic.model.model.ViewModelModifiable;
import net.mograsim.logic.model.model.wires.MovablePin;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.snippets.outlinerenderers.DefaultOutlineRenderer;
import net.mograsim.logic.model.snippets.symbolrenderers.SimpleRectangularLikeSymbolRenderer;
import net.mograsim.logic.model.snippets.symbolrenderers.SimpleRectangularLikeSymbolRenderer.SimpleRectangularLikeParams;
protected void setInputPins(String... pinNames)
{
- setIOPins(0, inputPinNames, outputPinNames, pinNames);
+ setIOPins(0, inputPinNames, outputPinNames, PinUsage.INPUT, pinNames);
}
protected void setOutputPins(String... pinNames)
{
- setIOPins(width, outputPinNames, inputPinNames, pinNames);
+ setIOPins(width, outputPinNames, inputPinNames, PinUsage.OUTPUT, pinNames);
}
- private void setIOPins(double relX, List<String> pinNamesListThisSide, List<String> pinNamesListOtherSide, String... newPinNames)
+ private void setIOPins(double relX, List<String> pinNamesListThisSide, List<String> pinNamesListOtherSide, PinUsage usage,
+ String... newPinNames)
{
int inputCount = newPinNames.length;
List<String> newPinNamesList = Arrays.asList(newPinNames);
String pinName = newPinNames[i];
int oldPinIndex = pinNamesListThisSide.indexOf(pinName);
if (oldPinIndex == -1)
- super.addSubmodelInterface(new MovablePin(this, pinName, logicWidth, relX, pinDistance / 2 + i * pinDistance));
+ super.addSubmodelInterface(new MovablePin(this, pinName, logicWidth, usage, relX, pinDistance / 2 + i * pinDistance));
else
getSupermodelMovablePin(pinName).setRelPos(relX, pinDistance / 2 + i * pinDistance);
}
import net.mograsim.logic.model.model.components.GUIComponent;
import net.mograsim.logic.model.model.wires.MovablePin;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.snippets.Renderer;
/**
super.addPin(supermodelPin);// do this first to be fail-fast if the supermodel does not belong to this component
String name = supermodelPin.name;
- MovablePin submodelPin = new MovablePin(submodelInterface, name, supermodelPin.logicWidth, supermodelPin.getRelX() / submodelScale,
- supermodelPin.getRelY() / submodelScale);
+ // TODO if we upgrade to Java 12, replace with switch-expression
+ PinUsage submodelPinUsage;
+ switch (supermodelPin.usage)
+ {
+ case INPUT:
+ submodelPinUsage = PinUsage.OUTPUT;
+ break;
+ case OUTPUT:
+ submodelPinUsage = PinUsage.INPUT;
+ break;
+ case TRISTATE:
+ submodelPinUsage = PinUsage.TRISTATE;
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown enum constant: " + supermodelPin.usage);
+ }
+ MovablePin submodelPin = new MovablePin(submodelInterface, name, supermodelPin.logicWidth, submodelPinUsage,
+ supermodelPin.getRelX() / submodelScale, supermodelPin.getRelY() / submodelScale);
submodelPin.addPinMovedListener(p ->
{
*/
public class MovablePin extends Pin
{
- public MovablePin(GUIComponent component, String name, int logicWidth, double relX, double relY)
+ public MovablePin(GUIComponent component, String name, int logicWidth, PinUsage usage, double relX, double relY)
{
- super(component, name, logicWidth, relX, relY);
+ super(component, name, logicWidth, usage, relX, relY);
}
@Override
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
import java.util.function.Consumer;
import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
{
// TODO introduce input/output/tristate hints
/**
- * The {@link GUIComponent} this pin belongs to
+ * The {@link GUIComponent} this pin belongs to.
*/
public final GUIComponent component;
/**
* The logical width of this pin. Denotes how many bits this pin consists of.
*/
public final int logicWidth;
+ /**
+ * How this pin is used by the component it belongs to.<br>
+ * Note that this is only a hint.
+ */
+ public final PinUsage usage;
/**
* The X position of this pin, relative to its component's location.
*
* @author Daniel Kirschten
*/
- public Pin(GUIComponent component, String name, int logicWidth, double relX, double relY)
+ public Pin(GUIComponent component, String name, int logicWidth, PinUsage usage, double relX, double relY)
{
this.component = component;
this.name = name;
this.logicWidth = logicWidth;
+ this.usage = Objects.requireNonNull(usage);
this.relX = relX;
this.relY = relY;
--- /dev/null
+package net.mograsim.logic.model.model.wires;
+
+public enum PinUsage
+{
+ /**
+ * The component never affects the value of the wire connected to the pin.
+ */
+ INPUT,
+ /**
+ * The component is never affected by the value of the wire connected to this pin. This includes the look of the component.
+ */
+ OUTPUT,
+ /**
+ * The component (sometimes) affects the value of the wire connected to the pin, but is also (sometimes) affected by the value of this
+ * wire.
+ */
+ TRISTATE;
+}
\ No newline at end of file
logicObs = (i) -> model.requestRedraw();
setSize(CIRCLE_DIAM, CIRCLE_DIAM);
- addPin(this.pin = new Pin(this, "", logicWidth, CIRCLE_RADIUS, CIRCLE_RADIUS));
+ addPin(this.pin = new Pin(this, "", logicWidth, PinUsage.TRISTATE, CIRCLE_RADIUS, CIRCLE_RADIUS));
}
// pins
{
ReadWriteEnd end = logicWiresPerPin.get(guiComponent.getOutputPin()).createReadWriteEnd();
ManualSwitch manualSwitch = new ManualSwitch(timeline, end);
- guiComponent.setLogicModelBinding(manualSwitch, end);
+ guiComponent.setLogicModelBinding(manualSwitch);
}
}
\ No newline at end of file
import net.mograsim.logic.core.wires.Wire.ReadEnd;
import net.mograsim.logic.core.wires.Wire.ReadWriteEnd;
import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent;
-import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent.Usage;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.modeladapter.LogicModelParameters;
//TODO support HighLevelStates
{
Wire wire = logicWiresPerPin.get(pin);
ReadEnd end;
- if (guiComponent.getPinUsage(pin) != Usage.INPUT)
+ if (pin.usage != PinUsage.INPUT)
{
ReadWriteEnd rwEnd = wire.createReadWriteEnd();
readWriteEnds.put(pin.name, rwEnd);
} else
end = wire.createReadOnlyEnd();
readEnds.put(pin.name, end);
- if (guiComponent.getPinUsage(pin) != Usage.OUTPUT)
+ if (pin.usage != PinUsage.OUTPUT)
end.registerObserver(logicObs);
}
}
import net.mograsim.logic.model.model.wires.GUIWire;
import net.mograsim.logic.model.model.wires.MovablePin;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.serializing.LegacySubmodelComponentParams.LegacyInterfacePinParams;
import net.mograsim.logic.model.serializing.LegacySubmodelComponentParams.LegacySubmodelParameters;
import net.mograsim.logic.model.serializing.LegacySubmodelComponentParams.LegacySubmodelParameters.LegacyInnerComponentParams;
comp.setSubmodelScale(params.submodel.innerScale);
comp.setSize(params.width, params.height);
for (LegacyInterfacePinParams iPinParams : params.interfacePins)
- comp.addSubmodelInterface(
- new MovablePin(comp, iPinParams.name, iPinParams.logicWidth, iPinParams.location.x, iPinParams.location.y));
+ // TRISTATE because we don't have a better choice
+ comp.addSubmodelInterface(new MovablePin(comp, iPinParams.name, iPinParams.logicWidth, PinUsage.TRISTATE, iPinParams.location.x,
+ iPinParams.location.y));
LegacySubmodelParameters submodelParams = params.submodel;
ViewModelModifiable submodelModifiable = comp.getSubmodelModifiable();
Map<String, GUIComponent> componentsByName = submodelModifiable.getComponentsByName();
import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
import net.mograsim.logic.model.model.components.submodels.SubmodelComponent;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.util.Version;
/**
public Point location;
public String name;
public int logicWidth;
+ public PinUsage usage;
}
}
\ No newline at end of file
import net.mograsim.logic.model.model.components.submodels.SubmodelComponent;
import net.mograsim.logic.model.model.wires.MovablePin;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.serializing.SubmodelComponentParams.InterfacePinParams;
import net.mograsim.logic.model.snippets.HighLevelStateHandler;
import net.mograsim.logic.model.snippets.Renderer;
*/
public final class SubmodelComponentSerializer
{
- public static final Version CURRENT_JSON_VERSION = Version.parseSemver("0.1.4");
+ // TODO serialize pin usage
+ // TODO set pin usages of existing components
+ public static final Version JSON_VERSION_CURRENT_SERIALIZING = Version.parseSemver("0.1.4");
+ public static final Version JSON_VERSION_LATEST_SUPPORTED_DESERIALIZING = Version.parseSemver("0.1.5");
+ public static final Version JSON_VERSION_EARLIEST_WITH_USAGE_SERIALIZED = Version.parseSemver("0.1.4");
// convenience methods
/**
public static SubmodelComponent deserialize(ViewModelModifiable model, SubmodelComponentParams params, String name,
String idForSerializingOverride, JsonElement paramsForSerializingOverride)
{
+ Version version = params.version;
+ if (version.compareTo(JSON_VERSION_LATEST_SUPPORTED_DESERIALIZING) > 0)
+ throw new IllegalArgumentException("JSON version " + version + " not supported yet");
+ boolean hasUsageSerialized = version.compareTo(JSON_VERSION_EARLIEST_WITH_USAGE_SERIALIZED) > 0;
DeserializedSubmodelComponent comp = new DeserializedSubmodelComponent(model, name, idForSerializingOverride,
paramsForSerializingOverride);
comp.setSubmodelScale(params.innerScale);
comp.setSize(params.width, params.height);
for (InterfacePinParams iPinParams : params.interfacePins)
- comp.addSubmodelInterface(
- new MovablePin(comp, iPinParams.name, iPinParams.logicWidth, iPinParams.location.x, iPinParams.location.y));
+ comp.addSubmodelInterface(new MovablePin(comp, iPinParams.name, iPinParams.logicWidth,
+ hasUsageSerialized ? iPinParams.usage : PinUsage.TRISTATE, iPinParams.location.x, iPinParams.location.y));
ViewModelModifiable submodelModifiable = comp.getSubmodelModifiable();
ViewModelSerializer.deserialize(comp.getSubmodelModifiable(), params.submodel);
comp.setSymbolRenderer(SubmodelComponentSnippetSuppliers.symbolRendererSupplier.getSnippetSupplier(params.symbolRendererSnippetID)
*/
public static SubmodelComponentParams serialize(SubmodelComponent comp, IdentifierGetter idGetter)
{
- SubmodelComponentParams params = new SubmodelComponentParams(CURRENT_JSON_VERSION);
+ SubmodelComponentParams params = new SubmodelComponentParams(JSON_VERSION_CURRENT_SERIALIZING);
params.innerScale = comp.getSubmodelScale();
params.submodel = ViewModelSerializer.serialize(comp.submodel, idGetter);
import net.mograsim.logic.model.util.Version.VersionJSONAdapter;
@JsonAdapter(VersionJSONAdapter.class)
-public final class Version
+public final class Version implements Comparable<Version>
{
public final int major, minor, patch;
return is(major, minor) && this.patch == patch;
}
+ /**
+ * Compares this {@link Version} with the specified version.<br>
+ * As required by {@link Comparable#compareTo(Object)}, returns a negative integer, zero, or a positive integer as this version is less
+ * (earlier) than, equal to, or greater (later) than the specified version.
+ * <p>
+ * If the versions are equal ({@link #major}, {@link #minor}, {@link #patch} are the same), returns 0. <br>
+ * If they differ in {@link #patch}, but neither {@link #major} or {@link #minor} , returns +-1. <br>
+ * If they differ in {@link #minor}, but not {@link #major}, returns +-2.<br>
+ * If they differ in {@link #major}, returns +-3.
+ */
+ @Override
+ public int compareTo(Version o)
+ {
+ if (major != o.major)
+ {
+ if (major > o.major)
+ return 3;
+ return -3;
+ }
+ if (minor != o.minor)
+ {
+ if (minor > o.minor)
+ return 2;
+ return -2;
+ }
+ if (patch != o.patch)
+ {
+ if (patch > o.patch)
+ return 1;
+ return -1;
+ }
+ return 0;
+ }
+
static class VersionJSONAdapter extends TypeAdapter<Version>
{
@Override
import net.mograsim.logic.model.model.components.GUIComponent;
import net.mograsim.logic.model.model.components.atomic.GUIAndGate;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
import net.mograsim.logic.model.serializing.IdentifierGetter;
import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
super(model, name);
this.definition = definition;
setSize(width, height);
- addPin(addrPin = new Pin(this, "A", definition.getMemoryAddressBits(), 0, 10));
- addPin(dataPin = new Pin(this, "D", definition.getCellWidth(), 0, 30));
- addPin(rWPin = new Pin(this, "RW", 1, 0, 50));
+ //TODO check the usages
+ addPin(addrPin = new Pin(this, "A", definition.getMemoryAddressBits(), PinUsage.INPUT, 0, 10));
+ addPin(dataPin = new Pin(this, "D", definition.getCellWidth(), PinUsage.TRISTATE, 0, 30));
+ addPin(rWPin = new Pin(this, "RW", 1, PinUsage.INPUT, 0, 50));
}
public Pin getAddressPin()
import net.mograsim.logic.model.model.components.atomic.GUIManualSwitch;
import net.mograsim.logic.model.model.wires.GUIWire;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.modeladapter.LogicModelParameters;
import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
{
GUIComponent comp = IndirectGUIComponentCreator.createComponent(model, "GUIAm2901");
- // TODO this code exists four times... but it seems too "hacky" to put it in a helper class
List<String> inputPinNames = new ArrayList<>();
List<String> outputPinNames = new ArrayList<>();
for (Pin p : comp.getPins().values())
- if (p.getRelX() == 0)
+ if (p.usage == PinUsage.INPUT)
inputPinNames.add(p.name);
else
outputPinNames.add(p.name);