1 package net.mograsim.logic.ui.modeladapter.componentadapters;
5 import net.mograsim.logic.core.components.gates.AndGate;
6 import net.mograsim.logic.core.components.gates.NotGate;
7 import net.mograsim.logic.core.timeline.Timeline;
8 import net.mograsim.logic.core.wires.Wire;
9 import net.mograsim.logic.ui.model.components.GUINandGate;
10 import net.mograsim.logic.ui.model.wires.Pin;
11 import net.mograsim.logic.ui.modeladapter.LogicModelParameters;
13 public class NandGateAdapter implements ComponentAdapter<GUINandGate>
16 public Class<GUINandGate> getSupportedClass()
18 return GUINandGate.class;
22 @SuppressWarnings("unused") // AndGate and NotGate
23 public void createAndLinkComponent(Timeline timeline, LogicModelParameters params, GUINandGate guiComponent,
24 Map<Pin, Wire> logicWiresPerPin)
26 Wire i0 = logicWiresPerPin.get(guiComponent.getInputPins().get(0));
27 Wire i1 = logicWiresPerPin.get(guiComponent.getInputPins().get(1));
28 Wire o = logicWiresPerPin.get(guiComponent.getOutputPin());
29 Wire w = new Wire(timeline, guiComponent.getOutputPin().logicWidth, 1);
31 new AndGate(timeline, 1, w.createReadWriteEnd(), i0.createReadOnlyEnd(), i1.createReadOnlyEnd());
32 new NotGate(timeline, Math.max(1, params.gateProcessTime - 2), w.createReadOnlyEnd(), o.createReadWriteEnd());