import net.mograsim.logic.core.types.BitVector;
import net.mograsim.logic.model.model.ViewModel;
import net.mograsim.logic.model.model.ViewModelModifiable;
-import net.mograsim.logic.model.modeladapter.LogicModelParameters;
-import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
+import net.mograsim.logic.model.modeladapter.CoreModelParameters;
+import net.mograsim.logic.model.modeladapter.LogicCoreAdapter;
import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
import net.mograsim.machine.Machine;
import net.mograsim.machine.MachineDefinition;
viewModel = new ViewModelModifiable();
IndirectModelComponentCreator.createComponent(viewModel,
"resloader:Am2900Loader:jsonres:net/mograsim/logic/model/am2900/components/ModelAm2900.json");
- LogicModelParameters params = new LogicModelParameters();
+ CoreModelParameters params = new CoreModelParameters();
params.gateProcessTime = 50;
params.wireTravelTime = 10;
- timeline = ViewLogicModelAdapter.convert(viewModel, params);
+ timeline = LogicCoreAdapter.convert(viewModel, params);
}
@Override
import net.mograsim.logic.model.model.components.submodels.SubmodelComponent;
import net.mograsim.logic.model.model.wires.ModelWire;
import net.mograsim.logic.model.model.wires.Pin;
-import net.mograsim.logic.model.modeladapter.LogicModelParameters;
-import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
+import net.mograsim.logic.model.modeladapter.CoreModelParameters;
+import net.mograsim.logic.model.modeladapter.LogicCoreAdapter;
import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
import net.mograsim.logic.model.util.ModellingTool;
component.getPins().values().forEach(this::extendModelPin);
- // Create logic model
- LogicModelParameters params = new LogicModelParameters();
+ // Create core model
+ CoreModelParameters params = new CoreModelParameters();
params.gateProcessTime = 50;
params.wireTravelTime = 10;
- timeline = ViewLogicModelAdapter.convert(viewModel, params);
+ timeline = LogicCoreAdapter.convert(viewModel, params);
timelineField.ifPresent(f -> setField(f, timeline));
// Bind switches/displays to this test class
#Properties file for net.mograsim.logic.model
Bundle-Vendor = Mograsim Team
-Bundle-Name = Mograsim logic user interface
\ No newline at end of file
+Bundle-Name = Mograsim logic model and user interface
\ No newline at end of file
//TODO maybe move to logic core?
public class LogicExecuter
{
- // TODO replace with LogicModel when it exists
+ // TODO replace with CoreModel when it exists
private final Timeline timeline;
private final AtomicBoolean shouldBeRunningLive;
import net.mograsim.logic.core.timeline.Timeline;
import net.mograsim.logic.model.model.ViewModelModifiable;
-import net.mograsim.logic.model.modeladapter.LogicModelParameters;
-import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
+import net.mograsim.logic.model.modeladapter.CoreModelParameters;
+import net.mograsim.logic.model.modeladapter.LogicCoreAdapter;
public class SimpleLogicUIStandalone
{
public static void executeVisualisation(Consumer<ViewModelModifiable> setupViewModel, Consumer<VisualisationObjects> beforeRun)
{
- LogicModelParameters params = new LogicModelParameters();
+ CoreModelParameters params = new CoreModelParameters();
params.gateProcessTime = 50;
params.wireTravelTime = 10;
executeVisualisation(setupViewModel, params, beforeRun);
}
- public static void executeVisualisation(Consumer<ViewModelModifiable> setupViewModel, LogicModelParameters params)
+ public static void executeVisualisation(Consumer<ViewModelModifiable> setupViewModel, CoreModelParameters params)
{
executeVisualisation(setupViewModel, params, null);
}
- public static void executeVisualisation(Consumer<ViewModelModifiable> setupViewModel, LogicModelParameters params,
+ public static void executeVisualisation(Consumer<ViewModelModifiable> setupViewModel, CoreModelParameters params,
Consumer<VisualisationObjects> beforeRun)
{
// setup view model
ViewModelModifiable viewModel = new ViewModelModifiable();
setupViewModel.accept(viewModel);
- // convert to logic model
- Timeline timeline = ViewLogicModelAdapter.convert(viewModel, params);
+ // convert to core model
+ Timeline timeline = LogicCoreAdapter.convert(viewModel, params);
// initialize UI and executer
LogicUIStandaloneGUI ui = new LogicUIStandaloneGUI(viewModel);
import net.mograsim.logic.core.components.gates.CoreAndGate;
import net.mograsim.logic.model.model.ViewModelModifiable;
-import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
+import net.mograsim.logic.model.modeladapter.LogicCoreAdapter;
import net.mograsim.logic.model.modeladapter.componentadapters.SimpleGateAdapter;
import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
static
{
- ViewLogicModelAdapter.addComponentAdapter(new SimpleGateAdapter<>(ModelAndGate.class, CoreAndGate::new));
+ LogicCoreAdapter.addComponentAdapter(new SimpleGateAdapter<>(ModelAndGate.class, CoreAndGate::new));
IndirectModelComponentCreator.setComponentSupplier(ModelAndGate.class.getCanonicalName(),
(m, p, n) -> new ModelAndGate(m, p.getAsInt(), n));
}
import net.mograsim.logic.model.model.components.ModelComponent;
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.LogicCoreAdapter;
import net.mograsim.logic.model.modeladapter.componentadapters.BitDisplayAdapter;
import net.mograsim.logic.model.serializing.IdentifyParams;
import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
gc.setFont(oldFont);
}
- public void setLogicModelBinding(CoreBitDisplay bitDisplay)
+ public void setCoreModelBinding(CoreBitDisplay bitDisplay)
{
if (this.bitDisplay != null)
this.bitDisplay.deregisterObserver(logicObs);
bitDisplay.registerObserver(logicObs);
}
- public boolean hasLogicModelBinding()
+ public boolean hasCoreModelBinding()
{
return bitDisplay != null;
}
static
{
- ViewLogicModelAdapter.addComponentAdapter(new BitDisplayAdapter());
+ LogicCoreAdapter.addComponentAdapter(new BitDisplayAdapter());
IndirectModelComponentCreator.setComponentSupplier(ModelBitDisplay.class.getCanonicalName(),
(m, p, n) -> new ModelBitDisplay(m, p.getAsInt(), n));
}
import net.mograsim.logic.model.model.components.OrientationCalculator;
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.LogicCoreAdapter;
import net.mograsim.logic.model.modeladapter.componentadapters.ClockAdapter;
import net.mograsim.logic.model.serializing.IdentifyParams;
import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
gc.setFont(oldFont);
}
- public void setLogicModelBinding(CoreClock clock)
+ public void setCoreModelBinding(CoreClock clock)
{
if (this.clock != null)
this.clock.deregisterObserver(logicObs);
clock.registerObserver(logicObs);
}
- public boolean hasLogicModelBinding()
+ public boolean hasCoreModelBinding()
{
return clock != null;
}
static
{
- ViewLogicModelAdapter.addComponentAdapter(new ClockAdapter());
+ LogicCoreAdapter.addComponentAdapter(new ClockAdapter());
IndirectModelComponentCreator.setComponentSupplier(ModelClock.class.getName(), (m, p, n) ->
{
ModelClockParams params = JsonHandler.fromJsonTree(p, ModelClockParams.class);
import net.mograsim.logic.model.model.components.ModelComponent;
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.LogicCoreAdapter;
import net.mograsim.logic.model.modeladapter.componentadapters.FixedOutputAdapter;
import net.mograsim.logic.model.serializing.IdentifyParams;
import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
static
{
- ViewLogicModelAdapter.addComponentAdapter(new FixedOutputAdapter());
+ LogicCoreAdapter.addComponentAdapter(new FixedOutputAdapter());
IndirectModelComponentCreator.setComponentSupplier(ModelFixedOutput.class.getCanonicalName(),
(m, p, n) -> new ModelFixedOutput(m, Objects.requireNonNull(JsonHandler.fromJsonTree(p, BitVector.class)), n));
}
import net.mograsim.logic.model.model.components.ModelComponent;
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.LogicCoreAdapter;
import net.mograsim.logic.model.modeladapter.componentadapters.ManualSwitchAdapter;
import net.mograsim.logic.model.serializing.IdentifyParams;
import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
private final Pin outputPin;
private final LogicObserver logicObs;
- private CoreManualSwitch logicSwitch;
+ private CoreManualSwitch manualSwitch;
public ModelManualSwitch(ViewModelModifiable model, int logicWidth)
{
if (foreground != null)
gc.setForeground(foreground);
gc.drawRectangle(getBounds());
- String label = BitVectorFormatter.formatAsString(logicSwitch == null ? null : logicSwitch.getValues());
+ String label = BitVectorFormatter.formatAsString(manualSwitch == null ? null : manualSwitch.getValues());
Font oldFont = gc.getFont();
Font labelFont = new Font(oldFont.getName(), fontHeight, oldFont.getStyle());
gc.setFont(labelFont);
gc.drawText(label, getPosX() + (width - textExtent.x) / 2, getPosY() + (height - textExtent.y) / 2, true);
gc.setFont(oldFont);
- if (logicSwitch != null && logicWidth > 1 && heightMiniButtons > 0 && visibleRegion.y < getPosY() + heightMiniButtons)
+ if (manualSwitch != null && logicWidth > 1 && heightMiniButtons > 0 && visibleRegion.y < getPosY() + heightMiniButtons)
{
double x = getPosX();
double y = getPosY();
gc.drawLine(x, y + heightMiniButtons, x + width, y + heightMiniButtons);
Color c = gc.getBackground();
gc.setBackground(gc.getForeground());
- BitVector bv = logicSwitch.getValues();
+ BitVector bv = manualSwitch.getValues();
double part = width / bv.length();
for (int i = 0; i < bv.length(); i++)
{
}
}
- public void setLogicModelBinding(CoreManualSwitch logicSwitch)
+ public void setCoreModelBinding(CoreManualSwitch logicSwitch)
{
- if (this.logicSwitch != null)
- this.logicSwitch.deregisterObserver(logicObs);
- this.logicSwitch = logicSwitch;
+ if (this.manualSwitch != null)
+ this.manualSwitch.deregisterObserver(logicObs);
+ this.manualSwitch = logicSwitch;
if (logicSwitch != null)
logicSwitch.registerObserver(logicObs);
}
- public boolean hasLogicModelBinding()
+ public boolean hasCoreModelBinding()
{
- return logicSwitch != null;
+ return manualSwitch != null;
}
@Override
switch (stateID)
{
case "out":
- if (logicSwitch != null)
- return logicSwitch.getValues();
+ if (manualSwitch != null)
+ return manualSwitch.getValues();
return null;
default:
return super.getHighLevelState(stateID);
switch (stateID)
{
case "out":
- if (logicSwitch != null)
- logicSwitch.setState((BitVector) newState);
+ if (manualSwitch != null)
+ manualSwitch.setState((BitVector) newState);
break;
default:
super.setHighLevelState(stateID, newState);
@Override
public boolean clicked(double x, double y)
{
- if (logicSwitch != null)
+ if (manualSwitch != null)
{
if (heightMiniButtons > 0 && y - getPosY() < heightMiniButtons)
{
int part = (int) ((x - getPosX()) * logicWidth / width);
- logicSwitch.setState(logicSwitch.getValues().withBitChanged(part, Bit::not));
+ manualSwitch.setState(manualSwitch.getValues().withBitChanged(part, Bit::not));
} else
{
- logicSwitch.toggle();
+ manualSwitch.toggle();
}
}
return true;
public CoreManualSwitch getManualSwitch()
{
- return logicSwitch;
+ return manualSwitch;
}
public Pin getOutputPin()
static
{
- ViewLogicModelAdapter.addComponentAdapter(new ManualSwitchAdapter());
+ LogicCoreAdapter.addComponentAdapter(new ManualSwitchAdapter());
IndirectModelComponentCreator.setComponentSupplier(ModelManualSwitch.class.getName(),
(m, p, n) -> new ModelManualSwitch(m, p.getAsInt(), n));
}
import net.mograsim.logic.model.model.components.ModelComponent;
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.LogicCoreAdapter;
import net.mograsim.logic.model.modeladapter.componentadapters.MergerAdapter;
import net.mograsim.logic.model.serializing.IdentifyParams;
import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
return logicWidth;
}
- public void setLogicModelBinding(ReadEnd[] inputEnds, ReadEnd outputEnd)
+ public void setCoreModelBinding(ReadEnd[] inputEnds, ReadEnd outputEnd)
{
System.arraycopy(inputEnds, 0, this.inputEnds, 0, logicWidth);
this.outputEnd = outputEnd;
static
{
- ViewLogicModelAdapter.addComponentAdapter(new MergerAdapter());
+ LogicCoreAdapter.addComponentAdapter(new MergerAdapter());
IndirectModelComponentCreator.setComponentSupplier(ModelMerger.class.getCanonicalName(),
(m, p, n) -> new ModelMerger(m, p.getAsInt(), n));
}
import net.mograsim.logic.core.components.gates.CoreNandGate;
import net.mograsim.logic.model.model.ViewModelModifiable;
-import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
+import net.mograsim.logic.model.modeladapter.LogicCoreAdapter;
import net.mograsim.logic.model.modeladapter.componentadapters.SimpleGateAdapter;
import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
static
{
- ViewLogicModelAdapter.addComponentAdapter(new SimpleGateAdapter<>(ModelNandGate.class, CoreNandGate::new));
+ LogicCoreAdapter.addComponentAdapter(new SimpleGateAdapter<>(ModelNandGate.class, CoreNandGate::new));
IndirectModelComponentCreator.setComponentSupplier(ModelNandGate.class.getCanonicalName(),
(m, p, n) -> new ModelNandGate(m, p.getAsInt(), n));
}
import net.mograsim.logic.core.components.gates.CoreNotGate;
import net.mograsim.logic.model.model.ViewModelModifiable;
-import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
+import net.mograsim.logic.model.modeladapter.LogicCoreAdapter;
import net.mograsim.logic.model.modeladapter.componentadapters.SimpleGateAdapter;
import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
static
{
- ViewLogicModelAdapter
+ LogicCoreAdapter
.addComponentAdapter(new SimpleGateAdapter<>(ModelNotGate.class, (t, p, o, i) -> new CoreNotGate(t, p, i[0], o)));
IndirectModelComponentCreator.setComponentSupplier(ModelNotGate.class.getCanonicalName(),
(m, p, n) -> new ModelNotGate(m, p.getAsInt(), n));
import net.mograsim.logic.core.components.gates.CoreOrGate;
import net.mograsim.logic.model.model.ViewModelModifiable;
-import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
+import net.mograsim.logic.model.modeladapter.LogicCoreAdapter;
import net.mograsim.logic.model.modeladapter.componentadapters.SimpleGateAdapter;
import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
static
{
- ViewLogicModelAdapter.addComponentAdapter(new SimpleGateAdapter<>(ModelOrGate.class, CoreOrGate::new));
+ LogicCoreAdapter.addComponentAdapter(new SimpleGateAdapter<>(ModelOrGate.class, CoreOrGate::new));
IndirectModelComponentCreator.setComponentSupplier(ModelOrGate.class.getCanonicalName(),
(m, p, n) -> new ModelOrGate(m, p.getAsInt(), n));
}
import net.mograsim.logic.model.model.components.ModelComponent;
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.LogicCoreAdapter;
import net.mograsim.logic.model.modeladapter.componentadapters.SplitterAdapter;
import net.mograsim.logic.model.serializing.IdentifyParams;
import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
return logicWidth;
}
- public void setLogicModelBinding(ReadEnd inputEnd, ReadEnd[] outputEnds)
+ public void setCoreModelBinding(ReadEnd inputEnd, ReadEnd[] outputEnds)
{
this.inputEnd = inputEnd;
System.arraycopy(outputEnds, 0, this.outputEnds, 0, logicWidth);
static
{
- ViewLogicModelAdapter.addComponentAdapter(new SplitterAdapter());
+ LogicCoreAdapter.addComponentAdapter(new SplitterAdapter());
IndirectModelComponentCreator.setComponentSupplier(ModelSplitter.class.getCanonicalName(),
(m, p, n) -> new ModelSplitter(m, p.getAsInt(), n));
}
import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
import net.mograsim.logic.model.model.ViewModelModifiable;
import net.mograsim.logic.model.model.components.ModelComponent;
-import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
+import net.mograsim.logic.model.modeladapter.LogicCoreAdapter;
import net.mograsim.logic.model.modeladapter.componentadapters.NoLogicAdapter;
import net.mograsim.logic.model.serializing.IdentifyParams;
import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
static
{
- ViewLogicModelAdapter.addComponentAdapter(new NoLogicAdapter<>(ModelTextComponent.class));
+ LogicCoreAdapter.addComponentAdapter(new NoLogicAdapter<>(ModelTextComponent.class));
IndirectModelComponentCreator.setComponentSupplier(ModelTextComponent.class.getName(),
(m, p, n) -> new ModelTextComponent(m, p.getAsString(), n));
}
import net.mograsim.logic.model.model.components.OrientationCalculator;
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.LogicCoreAdapter;
import net.mograsim.logic.model.modeladapter.componentadapters.TriStateBufferAdapter;
import net.mograsim.logic.model.serializing.IdentifyParams;
import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
static
{
- ViewLogicModelAdapter.addComponentAdapter(new TriStateBufferAdapter());
+ LogicCoreAdapter.addComponentAdapter(new TriStateBufferAdapter());
IndirectModelComponentCreator.setComponentSupplier(ModelTriStateBuffer.class.getName(), (m, p, n) ->
{
ModelTriStateBufferParams params = JsonHandler.fromJsonTree(p, ModelTriStateBufferParams.class);
import net.mograsim.logic.model.model.ViewModelModifiable;
import net.mograsim.logic.model.model.components.ModelComponent;
import net.mograsim.logic.model.model.wires.Pin;
-import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
+import net.mograsim.logic.model.modeladapter.LogicCoreAdapter;
import net.mograsim.logic.model.modeladapter.componentadapters.SimpleRectangularHardcodedModelComponentAdapter;
import net.mograsim.logic.model.serializing.IdentifyParams;
import net.mograsim.logic.model.snippets.HighLevelStateHandler;
public abstract Object recalculate(Object lastState, Map<String, ReadEnd> readEnds, Map<String, ReadWriteEnd> readWriteEnds);
- // logic model binding
+ // core model binding
- public void setLogicModelBindingAndResetState(AtomicReference<Object> state, Runnable recalculate)
+ public void setCoreModelBindingAndResetState(AtomicReference<Object> state, Runnable recalculate)
{
this.state = state;
this.recalculate = recalculate;
static
{
- ViewLogicModelAdapter.addComponentAdapter(new SimpleRectangularHardcodedModelComponentAdapter());
+ LogicCoreAdapter.addComponentAdapter(new SimpleRectangularHardcodedModelComponentAdapter());
}
}
\ No newline at end of file
*/
public final String name;
/**
- * The logical width of this wire. Is equal to the logical with of {@link #pin1} and {@link #pin2}.
+ * The logical width of this wire. Is equal to the logical width of {@link #pin1} and {@link #pin2}.
*/
public final int logicWidth;
/**
private final List<Consumer<ModelWire>> pathChangedListeners;
/**
- * A LogicObserver calling redrawListeners. Used for logic model bindings.
+ * A LogicObserver calling redrawListeners. Used for core model bindings.
*/
private final LogicObserver logicObs;
/**
- * A ReadEnd of the logic wire this model wire currently is bound to.
+ * A ReadEnd of the core wire this model wire currently is bound to.
*/
private ReadEnd end;
return new Point(p.x, p.y);
}
- // logic model binding
+ // core model binding
/**
* Binds this {@link ModelWire} to the given {@link ReadEnd}: The color of this {@link ModelWire} will now depend on the state of the
*
* @author Daniel Kirschten
*/
- public void setLogicModelBinding(ReadEnd end)
+ public void setCoreModelBinding(ReadEnd end)
{
if (this.end != null)
this.end.deregisterObserver(logicObs);
}
/**
- * Returns whether this {@link ModelWire} has a logic model binding or not.
+ * Returns whether this {@link ModelWire} has a core model binding or not.
*
* @author Daniel Kirschten
*/
- public boolean hasLogicModelBinding()
+ public boolean hasCoreModelBinding()
{
return end != null;
}
/**
- * If this {@link ModelWire} has a logic model binding, delegates to {@link CoreWire#forceValues(BitVector)} for the {@link CoreWire}
+ * If this {@link ModelWire} has a core model binding, delegates to {@link CoreWire#forceValues(BitVector)} for the {@link CoreWire}
* corresponding to this {@link ModelWire}.
*
* @author Daniel Kirschten
}
/**
- * If this {@link ModelWire} has a logic model binding, delegates to {@link ReadEnd#getValues()} for the {@link ReadEnd} corresponding
- * to this {@link ModelWire}.
+ * If this {@link ModelWire} has a core model binding, delegates to {@link ReadEnd#getValues()} for the {@link ReadEnd} corresponding to
+ * this {@link ModelWire}.
*
* @author Daniel Kirschten
*/
gc.fillOval(getPosX(), getPosY(), CIRCLE_DIAM, CIRCLE_DIAM);
}
- // logic model binding
+ // core model binding
/**
* Binds this {@link ModelWireCrossPoint} to the given {@link ReadEnd}: The color of this {@link ModelWireCrossPoint} will now depend on
*
* @author Daniel Kirschten
*/
- public void setLogicModelBinding(ReadEnd end)
+ public void setCoreModelBinding(ReadEnd end)
{
if (this.end != null)
this.end.deregisterObserver(logicObs);
}
/**
- * Returns whether this {@link ModelWireCrossPoint} has a logic model binding or not.
+ * Returns whether this {@link ModelWireCrossPoint} has a core model binding or not.
*/
- public boolean hasLogicModelBinding()
+ public boolean hasCoreModelBinding()
{
return end != null;
}
--- /dev/null
+package net.mograsim.logic.model.modeladapter;
+
+public class CoreModelParameters
+{
+ public int wireTravelTime;
+ public int gateProcessTime;
+}
\ No newline at end of file
--- /dev/null
+package net.mograsim.logic.model.modeladapter;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+import net.mograsim.logic.core.timeline.Timeline;
+import net.mograsim.logic.core.wires.CoreWire;
+import net.mograsim.logic.core.wires.CoreWire.ReadEnd;
+import net.mograsim.logic.model.model.ViewModel;
+import net.mograsim.logic.model.model.components.ModelComponent;
+import net.mograsim.logic.model.model.components.submodels.SubmodelComponent;
+import net.mograsim.logic.model.model.components.submodels.SubmodelInterface;
+import net.mograsim.logic.model.model.wires.ModelWire;
+import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.ModelWireCrossPoint;
+import net.mograsim.logic.model.modeladapter.componentadapters.ComponentAdapter;
+
+public class LogicCoreAdapter
+{
+ private final static Map<Class<? extends ModelComponent>, ComponentAdapter<? extends ModelComponent>> componentAdapters = new HashMap<>();
+
+ public static void addComponentAdapter(ComponentAdapter<? extends ModelComponent> componentAdapter)
+ {
+ componentAdapters.put(componentAdapter.getSupportedClass(), componentAdapter);
+ }
+
+ public static Timeline convert(ViewModel viewModel, CoreModelParameters params)
+ {
+ // TODO replace Timeline with CoreModel as soon as it exists
+ Timeline timeline = new Timeline(10);
+
+ convert(viewModel, params, timeline, Map.of());
+
+ return timeline;
+ }
+
+ private static void convert(ViewModel viewModel, CoreModelParameters params, Timeline timeline, Map<Pin, CoreWire> externalWires)
+ {
+ Map<Pin, CoreWire> logicWiresPerPin = convertWires(getAllPins(viewModel), viewModel.getWiresByName().values(), externalWires,
+ params, timeline);
+ Map<Pin, CoreWire> logicWiresPerPinUnmodifiable = Collections.unmodifiableMap(logicWiresPerPin);
+
+ for (ModelComponent modelComp : viewModel.getComponentsByName().values())
+ {
+ if (modelComp instanceof SubmodelComponent)
+ {
+ SubmodelComponent modelCompCasted = (SubmodelComponent) modelComp;
+ Map<String, Pin> supermodelPins = modelCompCasted.getSupermodelPins();
+ Map<Pin, CoreWire> externalWiresForSubmodel = supermodelPins.entrySet().stream().collect(
+ Collectors.toMap(e -> modelCompCasted.getSubmodelPin(e.getKey()), e -> logicWiresPerPin.get(e.getValue())));
+ convert(modelCompCasted.submodel, params, timeline, externalWiresForSubmodel);
+ } else if (modelComp instanceof ModelWireCrossPoint)
+ {
+ ModelWireCrossPoint modelCompCasted = (ModelWireCrossPoint) modelComp;
+ modelCompCasted.setCoreModelBinding(logicWiresPerPin.get(modelCompCasted.getPin()).createReadOnlyEnd());
+ } else if (!(modelComp instanceof SubmodelInterface))// nothing to do for SubmodelInterfaces
+ createAndLinkComponent(timeline, params, modelComp, logicWiresPerPinUnmodifiable);
+ }
+ }
+
+ private static Set<Pin> getAllPins(ViewModel viewModel)
+ {
+ return viewModel.getComponentsByName().values().stream().flatMap(component -> component.getPins().values().stream())
+ .collect(Collectors.toSet());
+ }
+
+ private static Map<Pin, CoreWire> convertWires(Set<Pin> allPins, Collection<ModelWire> wires, Map<Pin, CoreWire> externalWires,
+ CoreModelParameters params, Timeline timeline)
+ {
+ Map<Pin, Set<Pin>> connectedPinGroups = getConnectedPinGroups(allPins, wires);
+ Map<Pin, CoreWire> logicWiresPerPin = createLogicWires(params, timeline, connectedPinGroups, externalWires);
+ setModelWiresCoreModelBinding(wires, logicWiresPerPin);
+ return logicWiresPerPin;
+ }
+
+ private static Map<Pin, CoreWire> createLogicWires(CoreModelParameters params, Timeline timeline, Map<Pin, Set<Pin>> connectedPinGroups,
+ Map<Pin, CoreWire> externalWires)
+ {
+ Map<Pin, CoreWire> logicWiresPerPin = new HashMap<>();
+ Map<Set<Pin>, CoreWire> logicWiresPerPinGroup = new HashMap<>();
+ for (Entry<Pin, Set<Pin>> e : connectedPinGroups.entrySet())
+ logicWiresPerPin.put(e.getKey(), logicWiresPerPinGroup.computeIfAbsent(e.getValue(), set ->
+ {
+ CoreWire externalWire = null;
+ for (Pin p : set)
+ {
+ CoreWire externalWireCandidate = externalWires.get(p);
+ if (externalWireCandidate != null)
+ if (externalWire == null)
+ externalWire = externalWireCandidate;
+ else if (externalWire.width == externalWireCandidate.width)
+ CoreWire.fuse(externalWire, externalWireCandidate);
+ else
+ throw new IllegalArgumentException(
+ "Two pins to external wires with different logicWidths can't be connected directly");
+ }
+ return externalWire == null ? new CoreWire(timeline, e.getKey().logicWidth, params.wireTravelTime) : externalWire;
+ }));
+ return logicWiresPerPin;
+ }
+
+ private static void setModelWiresCoreModelBinding(Collection<ModelWire> wires, Map<Pin, CoreWire> logicWiresPerPin)
+ {
+ Map<CoreWire, ReadEnd> modelWireSharedReadEnd = logicWiresPerPin.values().stream().distinct()
+ .collect(Collectors.toMap(Function.identity(), CoreWire::createReadOnlyEnd));
+ for (ModelWire modelWire : wires)
+ modelWire.setCoreModelBinding(modelWireSharedReadEnd.get(logicWiresPerPin.get(modelWire.getPin1())));
+ }
+
+ private static Map<Pin, Set<Pin>> getConnectedPinGroups(Set<Pin> allPins, Collection<ModelWire> wires)
+ {
+ Map<Pin, Set<Pin>> connectedPinsPerPin = new HashMap<>();
+
+ for (Pin p : allPins)
+ {
+ HashSet<Pin> connectedPins = new HashSet<>();
+ connectedPins.add(p);
+ connectedPinsPerPin.put(p, connectedPins);
+ }
+
+ wires.forEach(wire ->
+ {
+ Pin pin1 = wire.getPin1();
+ Pin pin2 = wire.getPin2();
+
+ Set<Pin> pin1ConnectedPins = connectedPinsPerPin.get(pin1);
+ Set<Pin> pin2ConnectedPins = connectedPinsPerPin.get(pin2);
+
+ pin1ConnectedPins.addAll(pin2ConnectedPins);
+ pin1ConnectedPins.add(pin1);
+ pin1ConnectedPins.add(pin2);
+
+ pin2ConnectedPins.forEach(pin -> connectedPinsPerPin.put(pin, pin1ConnectedPins));
+ });
+ return connectedPinsPerPin;
+ }
+
+ @SuppressWarnings("unchecked")
+ private static <G extends ModelComponent> void createAndLinkComponent(Timeline timeline, CoreModelParameters params,
+ ModelComponent modelComponent, Map<Pin, CoreWire> logicWiresPerPin)
+ {
+ Class<?> cls = modelComponent.getClass();
+ ComponentAdapter<? super G> adapter = null;
+ while (cls != ModelComponent.class && adapter == null)
+ {
+ adapter = (ComponentAdapter<? super G>) componentAdapters.get(cls);
+ cls = cls.getSuperclass();
+ }
+ if (adapter == null)
+ throw new IllegalArgumentException("Unknown component class: " + modelComponent.getClass());
+ adapter.createAndLinkComponent(timeline, params, (G) modelComponent, logicWiresPerPin);
+ }
+
+ private LogicCoreAdapter()
+ {
+ throw new UnsupportedOperationException("No LogicCoreAdapter instances");
+ }
+}
\ No newline at end of file
+++ /dev/null
-package net.mograsim.logic.model.modeladapter;
-
-public class LogicModelParameters
-{
- public int wireTravelTime;
- public int gateProcessTime;
-}
\ No newline at end of file
+++ /dev/null
-package net.mograsim.logic.model.modeladapter;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-
-import net.mograsim.logic.core.timeline.Timeline;
-import net.mograsim.logic.core.wires.CoreWire;
-import net.mograsim.logic.core.wires.CoreWire.ReadEnd;
-import net.mograsim.logic.model.model.ViewModel;
-import net.mograsim.logic.model.model.components.ModelComponent;
-import net.mograsim.logic.model.model.components.submodels.SubmodelComponent;
-import net.mograsim.logic.model.model.components.submodels.SubmodelInterface;
-import net.mograsim.logic.model.model.wires.ModelWire;
-import net.mograsim.logic.model.model.wires.Pin;
-import net.mograsim.logic.model.model.wires.ModelWireCrossPoint;
-import net.mograsim.logic.model.modeladapter.componentadapters.ComponentAdapter;
-
-public class ViewLogicModelAdapter
-{
- private final static Map<Class<? extends ModelComponent>, ComponentAdapter<? extends ModelComponent>> componentAdapters = new HashMap<>();
-
- public static void addComponentAdapter(ComponentAdapter<? extends ModelComponent> componentAdapter)
- {
- componentAdapters.put(componentAdapter.getSupportedClass(), componentAdapter);
- }
-
- public static Timeline convert(ViewModel viewModel, LogicModelParameters params)
- {
- // TODO replace Timeline with LogicModel as soon as it exists
- Timeline timeline = new Timeline(10);
-
- convert(viewModel, params, timeline, Map.of());
-
- return timeline;
- }
-
- private static void convert(ViewModel viewModel, LogicModelParameters params, Timeline timeline, Map<Pin, CoreWire> externalWires)
- {
- Map<Pin, CoreWire> logicWiresPerPin = convertWires(getAllPins(viewModel), viewModel.getWiresByName().values(), externalWires,
- params, timeline);
- Map<Pin, CoreWire> logicWiresPerPinUnmodifiable = Collections.unmodifiableMap(logicWiresPerPin);
-
- for (ModelComponent modelComp : viewModel.getComponentsByName().values())
- {
- if (modelComp instanceof SubmodelComponent)
- {
- SubmodelComponent modelCompCasted = (SubmodelComponent) modelComp;
- Map<String, Pin> supermodelPins = modelCompCasted.getSupermodelPins();
- Map<Pin, CoreWire> externalWiresForSubmodel = supermodelPins.entrySet().stream().collect(
- Collectors.toMap(e -> modelCompCasted.getSubmodelPin(e.getKey()), e -> logicWiresPerPin.get(e.getValue())));
- convert(modelCompCasted.submodel, params, timeline, externalWiresForSubmodel);
- } else if (modelComp instanceof ModelWireCrossPoint)
- {
- ModelWireCrossPoint modelCompCasted = (ModelWireCrossPoint) modelComp;
- modelCompCasted.setLogicModelBinding(logicWiresPerPin.get(modelCompCasted.getPin()).createReadOnlyEnd());
- } else if (!(modelComp instanceof SubmodelInterface))// nothing to do for SubmodelInterfaces
- createAndLinkComponent(timeline, params, modelComp, logicWiresPerPinUnmodifiable);
- }
- }
-
- private static Set<Pin> getAllPins(ViewModel viewModel)
- {
- return viewModel.getComponentsByName().values().stream().flatMap(component -> component.getPins().values().stream())
- .collect(Collectors.toSet());
- }
-
- private static Map<Pin, CoreWire> convertWires(Set<Pin> allPins, Collection<ModelWire> wires, Map<Pin, CoreWire> externalWires,
- LogicModelParameters params, Timeline timeline)
- {
- Map<Pin, Set<Pin>> connectedPinGroups = getConnectedPinGroups(allPins, wires);
- Map<Pin, CoreWire> logicWiresPerPin = createLogicWires(params, timeline, connectedPinGroups, externalWires);
- setModelWiresLogicModelBinding(wires, logicWiresPerPin);
- return logicWiresPerPin;
- }
-
- private static Map<Pin, CoreWire> createLogicWires(LogicModelParameters params, Timeline timeline,
- Map<Pin, Set<Pin>> connectedPinGroups, Map<Pin, CoreWire> externalWires)
- {
- Map<Pin, CoreWire> logicWiresPerPin = new HashMap<>();
- Map<Set<Pin>, CoreWire> logicWiresPerPinGroup = new HashMap<>();
- for (Entry<Pin, Set<Pin>> e : connectedPinGroups.entrySet())
- logicWiresPerPin.put(e.getKey(), logicWiresPerPinGroup.computeIfAbsent(e.getValue(), set ->
- {
- CoreWire externalWire = null;
- for (Pin p : set)
- {
- CoreWire externalWireCandidate = externalWires.get(p);
- if (externalWireCandidate != null)
- if (externalWire == null)
- externalWire = externalWireCandidate;
- else if (externalWire.width == externalWireCandidate.width)
- CoreWire.fuse(externalWire, externalWireCandidate);
- else
- throw new IllegalArgumentException(
- "Two pins to external wires with different logicWidths can't be connected directly");
- }
- return externalWire == null ? new CoreWire(timeline, e.getKey().logicWidth, params.wireTravelTime) : externalWire;
- }));
- return logicWiresPerPin;
- }
-
- private static void setModelWiresLogicModelBinding(Collection<ModelWire> wires, Map<Pin, CoreWire> logicWiresPerPin)
- {
- Map<CoreWire, ReadEnd> modelWireSharedReadEnd = logicWiresPerPin.values().stream().distinct()
- .collect(Collectors.toMap(Function.identity(), CoreWire::createReadOnlyEnd));
- for (ModelWire modelWire : wires)
- modelWire.setLogicModelBinding(modelWireSharedReadEnd.get(logicWiresPerPin.get(modelWire.getPin1())));
- }
-
- private static Map<Pin, Set<Pin>> getConnectedPinGroups(Set<Pin> allPins, Collection<ModelWire> wires)
- {
- Map<Pin, Set<Pin>> connectedPinsPerPin = new HashMap<>();
-
- for (Pin p : allPins)
- {
- HashSet<Pin> connectedPins = new HashSet<>();
- connectedPins.add(p);
- connectedPinsPerPin.put(p, connectedPins);
- }
-
- wires.forEach(wire ->
- {
- Pin pin1 = wire.getPin1();
- Pin pin2 = wire.getPin2();
-
- Set<Pin> pin1ConnectedPins = connectedPinsPerPin.get(pin1);
- Set<Pin> pin2ConnectedPins = connectedPinsPerPin.get(pin2);
-
- pin1ConnectedPins.addAll(pin2ConnectedPins);
- pin1ConnectedPins.add(pin1);
- pin1ConnectedPins.add(pin2);
-
- pin2ConnectedPins.forEach(pin -> connectedPinsPerPin.put(pin, pin1ConnectedPins));
- });
- return connectedPinsPerPin;
- }
-
- @SuppressWarnings("unchecked")
- private static <G extends ModelComponent> void createAndLinkComponent(Timeline timeline, LogicModelParameters params,
- ModelComponent modelComponent, Map<Pin, CoreWire> logicWiresPerPin)
- {
- Class<?> cls = modelComponent.getClass();
- ComponentAdapter<? super G> adapter = null;
- while (cls != ModelComponent.class && adapter == null)
- {
- adapter = (ComponentAdapter<? super G>) componentAdapters.get(cls);
- cls = cls.getSuperclass();
- }
- if (adapter == null)
- throw new IllegalArgumentException("Unknown component class: " + modelComponent.getClass());
- adapter.createAndLinkComponent(timeline, params, (G) modelComponent, logicWiresPerPin);
- }
-
- private ViewLogicModelAdapter()
- {
- throw new UnsupportedOperationException("No ViewLogicModelConverter instances");
- }
-}
\ No newline at end of file
import net.mograsim.logic.core.wires.CoreWire.ReadEnd;
import net.mograsim.logic.model.model.components.atomic.ModelBitDisplay;
import net.mograsim.logic.model.model.wires.Pin;
-import net.mograsim.logic.model.modeladapter.LogicModelParameters;
+import net.mograsim.logic.model.modeladapter.CoreModelParameters;
public class BitDisplayAdapter implements ComponentAdapter<ModelBitDisplay>
{
}
@Override
- public void createAndLinkComponent(Timeline timeline, LogicModelParameters params, ModelBitDisplay modelComponent,
+ public void createAndLinkComponent(Timeline timeline, CoreModelParameters params, ModelBitDisplay modelComponent,
Map<Pin, CoreWire> logicWiresPerPin)
{
ReadEnd end = logicWiresPerPin.get(modelComponent.getInputPin()).createReadOnlyEnd();
CoreBitDisplay bitDisplay = new CoreBitDisplay(timeline, end);
- modelComponent.setLogicModelBinding(bitDisplay);
+ modelComponent.setCoreModelBinding(bitDisplay);
}
}
\ No newline at end of file
import net.mograsim.logic.core.wires.CoreWire.ReadWriteEnd;
import net.mograsim.logic.model.model.components.atomic.ModelClock;
import net.mograsim.logic.model.model.wires.Pin;
-import net.mograsim.logic.model.modeladapter.LogicModelParameters;
+import net.mograsim.logic.model.modeladapter.CoreModelParameters;
public class ClockAdapter implements ComponentAdapter<ModelClock>
{
}
@Override
- public void createAndLinkComponent(Timeline timeline, LogicModelParameters params, ModelClock modelClock,
+ public void createAndLinkComponent(Timeline timeline, CoreModelParameters params, ModelClock modelClock,
Map<Pin, CoreWire> logicWiresPerPin)
{
ReadWriteEnd out = logicWiresPerPin.get(modelClock.getOutputPin()).createReadWriteEnd();
CoreClock c = new CoreClock(timeline, out, modelClock.getDelta());
- modelClock.setLogicModelBinding(c);
+ modelClock.setCoreModelBinding(c);
}
}
\ No newline at end of file
import net.mograsim.logic.core.wires.CoreWire;
import net.mograsim.logic.model.model.components.ModelComponent;
import net.mograsim.logic.model.model.wires.Pin;
-import net.mograsim.logic.model.modeladapter.LogicModelParameters;
+import net.mograsim.logic.model.modeladapter.CoreModelParameters;
public interface ComponentAdapter<G extends ModelComponent>
{
public Class<G> getSupportedClass();
- public void createAndLinkComponent(Timeline timeline, LogicModelParameters params, G modelComponent,
+ public void createAndLinkComponent(Timeline timeline, CoreModelParameters params, G modelComponent,
Map<Pin, CoreWire> logicWiresPerPin);
}
\ No newline at end of file
import net.mograsim.logic.core.wires.CoreWire;
import net.mograsim.logic.model.model.components.atomic.ModelFixedOutput;
import net.mograsim.logic.model.model.wires.Pin;
-import net.mograsim.logic.model.modeladapter.LogicModelParameters;
+import net.mograsim.logic.model.modeladapter.CoreModelParameters;
public class FixedOutputAdapter implements ComponentAdapter<ModelFixedOutput>
{
}
@Override
- public void createAndLinkComponent(Timeline timeline, LogicModelParameters params, ModelFixedOutput modelComponent,
+ public void createAndLinkComponent(Timeline timeline, CoreModelParameters params, ModelFixedOutput modelComponent,
Map<Pin, CoreWire> logicWiresPerPin)
{
logicWiresPerPin.get(modelComponent.getPin("out")).createReadWriteEnd().feedSignals(modelComponent.bits);
import net.mograsim.logic.core.wires.CoreWire.ReadWriteEnd;
import net.mograsim.logic.model.model.components.atomic.ModelManualSwitch;
import net.mograsim.logic.model.model.wires.Pin;
-import net.mograsim.logic.model.modeladapter.LogicModelParameters;
+import net.mograsim.logic.model.modeladapter.CoreModelParameters;
public class ManualSwitchAdapter implements ComponentAdapter<ModelManualSwitch>
{
}
@Override
- public void createAndLinkComponent(Timeline timeline, LogicModelParameters params, ModelManualSwitch modelComponent,
+ public void createAndLinkComponent(Timeline timeline, CoreModelParameters params, ModelManualSwitch modelComponent,
Map<Pin, CoreWire> logicWiresPerPin)
{
ReadWriteEnd end = logicWiresPerPin.get(modelComponent.getOutputPin()).createReadWriteEnd();
CoreManualSwitch manualSwitch = new CoreManualSwitch(timeline, end);
- modelComponent.setLogicModelBinding(manualSwitch);
+ modelComponent.setCoreModelBinding(manualSwitch);
}
}
\ No newline at end of file
import net.mograsim.logic.core.wires.CoreWire.ReadEnd;
import net.mograsim.logic.model.model.components.atomic.ModelMerger;
import net.mograsim.logic.model.model.wires.Pin;
-import net.mograsim.logic.model.modeladapter.LogicModelParameters;
+import net.mograsim.logic.model.modeladapter.CoreModelParameters;
public class MergerAdapter implements ComponentAdapter<ModelMerger>
{
}
@Override
- public void createAndLinkComponent(Timeline timeline, LogicModelParameters params, ModelMerger modelComponent,
+ public void createAndLinkComponent(Timeline timeline, CoreModelParameters params, ModelMerger modelComponent,
Map<Pin, CoreWire> logicWiresPerPin)
{
CoreWire output = logicWiresPerPin.get(modelComponent.getPin("O"));
CoreWire.fuse(input, output, 0, i);
inputEnds[i] = input.createReadOnlyEnd();
}
- modelComponent.setLogicModelBinding(inputEnds, output.createReadOnlyEnd());
+ modelComponent.setCoreModelBinding(inputEnds, output.createReadOnlyEnd());
}
}
\ No newline at end of file
import net.mograsim.logic.core.wires.CoreWire;
import net.mograsim.logic.model.model.components.ModelComponent;
import net.mograsim.logic.model.model.wires.Pin;
-import net.mograsim.logic.model.modeladapter.LogicModelParameters;
+import net.mograsim.logic.model.modeladapter.CoreModelParameters;
/**
* For ModelComponents that do not have any simulation logic behaviour
}
@Override
- public void createAndLinkComponent(Timeline timeline, LogicModelParameters params, T modelComponent,
+ public void createAndLinkComponent(Timeline timeline, CoreModelParameters params, T modelComponent,
Map<Pin, CoreWire> logicWiresPerPin)
{
// do nothing
import net.mograsim.logic.core.wires.CoreWire.ReadWriteEnd;
import net.mograsim.logic.model.model.components.atomic.SimpleRectangularModelGate;
import net.mograsim.logic.model.model.wires.Pin;
-import net.mograsim.logic.model.modeladapter.LogicModelParameters;
+import net.mograsim.logic.model.modeladapter.CoreModelParameters;
public class SimpleGateAdapter<G extends SimpleRectangularModelGate> implements ComponentAdapter<G>
{
}
@Override
- public void createAndLinkComponent(Timeline timeline, LogicModelParameters params, G modelComponent,
+ public void createAndLinkComponent(Timeline timeline, CoreModelParameters params, G modelComponent,
Map<Pin, CoreWire> logicWiresPerPin)
{
ReadWriteEnd out = logicWiresPerPin.get(modelComponent.getPin("Y")).createReadWriteEnd();
import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedModelComponent;
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.CoreModelParameters;
public class SimpleRectangularHardcodedModelComponentAdapter implements ComponentAdapter<SimpleRectangularHardcodedModelComponent>
{
}
@Override
- public void createAndLinkComponent(Timeline timeline, LogicModelParameters params,
+ public void createAndLinkComponent(Timeline timeline, CoreModelParameters params,
SimpleRectangularHardcodedModelComponent modelComponent, Map<Pin, CoreWire> logicWiresPerPin)
{
Map<String, ReadEnd> readEnds = new HashMap<>();
Runnable recalculate = () -> state.updateAndGet(s -> modelComponent.recalculate(s, readEnds, readWriteEnds));
LogicObserver logicObs = c -> timeline.addEvent(e -> recalculate.run(), params.gateProcessTime);
- modelComponent.setLogicModelBindingAndResetState(state, recalculate);
+ modelComponent.setCoreModelBindingAndResetState(state, recalculate);
for (Pin pin : modelComponent.getPins().values())
{
import net.mograsim.logic.core.wires.CoreWire.ReadEnd;
import net.mograsim.logic.model.model.components.atomic.ModelSplitter;
import net.mograsim.logic.model.model.wires.Pin;
-import net.mograsim.logic.model.modeladapter.LogicModelParameters;
+import net.mograsim.logic.model.modeladapter.CoreModelParameters;
public class SplitterAdapter implements ComponentAdapter<ModelSplitter>
{
}
@Override
- public void createAndLinkComponent(Timeline timeline, LogicModelParameters params, ModelSplitter modelComponent,
+ public void createAndLinkComponent(Timeline timeline, CoreModelParameters params, ModelSplitter modelComponent,
Map<Pin, CoreWire> logicWiresPerPin)
{
CoreWire input = logicWiresPerPin.get(modelComponent.getPin("I"));
CoreWire.fuse(input, output, i, 0);
outputEnds[i] = output.createReadOnlyEnd();
}
- modelComponent.setLogicModelBinding(input.createReadOnlyEnd(), outputEnds);
+ modelComponent.setCoreModelBinding(input.createReadOnlyEnd(), outputEnds);
}
}
\ No newline at end of file
import net.mograsim.logic.core.wires.CoreWire.ReadWriteEnd;
import net.mograsim.logic.model.model.components.atomic.ModelTriStateBuffer;
import net.mograsim.logic.model.model.wires.Pin;
-import net.mograsim.logic.model.modeladapter.LogicModelParameters;
+import net.mograsim.logic.model.modeladapter.CoreModelParameters;
public class TriStateBufferAdapter implements ComponentAdapter<ModelTriStateBuffer>
{
@SuppressWarnings("unused")
@Override
- public void createAndLinkComponent(Timeline timeline, LogicModelParameters params, ModelTriStateBuffer modelTsb,
+ public void createAndLinkComponent(Timeline timeline, CoreModelParameters params, ModelTriStateBuffer modelTsb,
Map<Pin, CoreWire> logicWiresPerPin)
{
ReadEnd in = logicWiresPerPin.get(modelTsb.getPin("IN")).createReadOnlyEnd();
{
BitVector result = BitVector.of(Bit.ZERO, logicWidth);
for (ModelWire wire : wiresToForceInverted)
- if (wire.hasLogicModelBinding())
+ if (wire.hasCoreModelBinding())
result = result.or(wire.getWireValues());
result = result.not();
for (ModelWire wire : wiresToForce)
- if (wire.hasLogicModelBinding())
+ if (wire.hasCoreModelBinding())
result = result.and(wire.getWireValues());
return result;
}
else
vector = (BitVector) newState;
for (ModelWire wire : wiresToForce)
- if (wire.hasLogicModelBinding())
+ if (wire.hasCoreModelBinding())
wire.forceWireValues(vector);
vector = vector.not();
for (ModelWire wire : wiresToForceInverted)
- if (wire.hasLogicModelBinding())
+ if (wire.hasCoreModelBinding())
wire.forceWireValues(vector);
}
import net.mograsim.logic.model.model.components.atomic.ModelAndGate;
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.LogicCoreAdapter;
import net.mograsim.logic.model.serializing.IdentifyParams;
import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
import net.mograsim.logic.model.snippets.Renderer;
return rWPin;
}
- public void setLogicModelBinding(WordAddressableMemoryComponent memory)
+ public void setCoreModelBinding(WordAddressableMemoryComponent memory)
{
this.memory = memory;
}
static
{
- ViewLogicModelAdapter.addComponentAdapter(new WordAddressableMemoryAdapter());
+ LogicCoreAdapter.addComponentAdapter(new WordAddressableMemoryAdapter());
IndirectModelComponentCreator.setComponentSupplier(ModelAndGate.class.getCanonicalName(), (m, p, n) ->
{
ModelMemoryWAParams params = JsonHandler.fromJsonTree(p, ModelMemoryWAParams.class);
ReadEnd address = logicWiresPerPin.get(modelComponent.getAddressPin()).createReadOnlyEnd();
ReadEnd mode = logicWiresPerPin.get(modelComponent.getReadWritePin()).createReadOnlyEnd();
WordAddressableMemoryComponent mem = new WordAddressableMemoryComponent(timeline, 2, modelComponent.getDefinition(), data, mode, address);
- modelComponent.setLogicModelBinding(mem);
+ modelComponent.setCoreModelBinding(mem);
}
}
import net.mograsim.logic.model.model.components.atomic.ModelOrGate;
import net.mograsim.logic.model.model.wires.ModelWire;
import net.mograsim.logic.model.model.wires.ModelWireCrossPoint;
-import net.mograsim.logic.model.modeladapter.LogicModelParameters;
-import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
+import net.mograsim.logic.model.modeladapter.CoreModelParameters;
+import net.mograsim.logic.model.modeladapter.LogicCoreAdapter;
import net.mograsim.preferences.Preferences;
public class SimulationPreview implements IThemePreview
Preferences.setPreferences(currentThemePreferences);
ViewModelModifiable model = new ViewModelModifiable();
- LogicModelParameters params = new LogicModelParameters();
+ CoreModelParameters params = new CoreModelParameters();
params.gateProcessTime = 50;
params.wireTravelTime = 10;
o2.moveCenterTo(150, 72.5);
new ModelWire(model, p2, o2);
- Timeline t = ViewLogicModelAdapter.convert(model, params);
+ Timeline t = LogicCoreAdapter.convert(model, params);
exec = new LogicExecuter(t);
rIn.clicked(0, 0);