1 package net.mograsim.logic.model.examples;
3 import java.util.ArrayList;
4 import java.util.Comparator;
7 import net.mograsim.logic.model.SimpleLogicUIStandalone;
8 import net.mograsim.logic.model.am2900.Am2900Loader;
9 import net.mograsim.logic.model.model.LogicModelModifiable;
10 import net.mograsim.logic.model.model.components.ModelComponent;
11 import net.mograsim.logic.model.model.components.atomic.ModelBitDisplay;
12 import net.mograsim.logic.model.model.components.atomic.ModelManualSwitch;
13 import net.mograsim.logic.model.model.wires.ModelWire;
14 import net.mograsim.logic.model.model.wires.Pin;
15 import net.mograsim.logic.model.model.wires.PinUsage;
16 import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
18 public class ModelComponentTestbench
20 public static void main(String[] args)
22 SimpleLogicUIStandalone.executeVisualisation(ModelComponentTestbench::createTestbench);
25 @SuppressWarnings("unused") // for ModelWires being created
26 public static void createTestbench(LogicModelModifiable model)
29 // ModelComponent comp = new StrictAm2900MachineDefinition().createNew(model).getAm2900();
30 ModelComponent comp = IndirectModelComponentCreator.createComponent(model, "Am2910");
32 List<String> inputPinNames = new ArrayList<>();
33 List<String> outputPinNames = new ArrayList<>();
34 for (Pin p : comp.getPins().values())
35 if (p.usage == PinUsage.INPUT)
36 inputPinNames.add(p.name);
38 outputPinNames.add(p.name);
40 inputPinNames.sort(Comparator.comparing(comp::getPin, Comparator.comparing(Pin::getRelY)));
41 outputPinNames.sort(Comparator.comparing(comp::getPin, Comparator.comparing(Pin::getRelY)));
44 for (int i = 0; i < inputPinNames.size(); i++)
46 String pinName = inputPinNames.get(i);
47 ModelManualSwitch sw = new ModelManualSwitch(model, comp.getPin(pinName).logicWidth, pinName);
49 new ModelWire(model, comp.getPin(pinName), sw.getOutputPin());
51 for (int i = 0; i < outputPinNames.size(); i++)
53 String pinName = outputPinNames.get(i);
54 ModelBitDisplay bd = new ModelBitDisplay(model, comp.getPin(pinName).logicWidth, pinName);
55 bd.moveTo(200, 20 * i);
56 new ModelWire(model, comp.getPin(pinName), bd.getInputPin());