From: Christian Femers Date: Tue, 3 Sep 2019 06:12:38 +0000 (+0200) Subject: Merge branch 'development' into json-fix-extended X-Git-Url: https://mograsim.net/gitweb/?a=commitdiff_plain;h=c3f6c48944beecd51a41a6e9c123b73d8b630dfb;hp=ccf83da0021c673571ef8d8e42631d76808d6b3d;p=Mograsim.git Merge branch 'development' into json-fix-extended Conflicts: net.mograsim.logic.model.am2900/META-INF/MANIFEST.MF net.mograsim.machine/META-INF/MANIFEST.MF --- diff --git a/net.mograsim.logic.model.am2900/META-INF/MANIFEST.MF b/net.mograsim.logic.model.am2900/META-INF/MANIFEST.MF index e063ca68..6dfa1831 100644 --- a/net.mograsim.logic.model.am2900/META-INF/MANIFEST.MF +++ b/net.mograsim.logic.model.am2900/META-INF/MANIFEST.MF @@ -7,6 +7,7 @@ Export-Package: net.mograsim.logic.model.am2900, net.mograsim.logic.model.am2900.components, net.mograsim.logic.model.am2900.components.am2904, net.mograsim.logic.model.am2900.components.am2910, + net.mograsim.logic.model.am2900.machine, net.mograsim.logic.model.examples Bundle-RequiredExecutionEnvironment: JavaSE-11 Require-Bundle: net.mograsim.machine;bundle-version="0.1.0";visibility:=reexport, diff --git a/net.mograsim.logic.model.am2900/build.properties b/net.mograsim.logic.model.am2900/build.properties index d6642e65..ba7fb993 100644 --- a/net.mograsim.logic.model.am2900/build.properties +++ b/net.mograsim.logic.model.am2900/build.properties @@ -1,4 +1,5 @@ source.. = src/ bin.includes = META-INF/,\ .,\ - OSGI-INF/ + OSGI-INF/,\ + plugin.xml diff --git a/net.mograsim.logic.model.am2900/plugin.xml b/net.mograsim.logic.model.am2900/plugin.xml new file mode 100644 index 00000000..7cfe4a72 --- /dev/null +++ b/net.mograsim.logic.model.am2900/plugin.xml @@ -0,0 +1,14 @@ + + + + + + + + + diff --git a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/machine/Am2900Machine.java b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/machine/Am2900Machine.java new file mode 100644 index 00000000..df3b726f --- /dev/null +++ b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/machine/Am2900Machine.java @@ -0,0 +1,80 @@ +package net.mograsim.logic.model.am2900.machine; + +import net.mograsim.logic.core.components.Clock; +import net.mograsim.logic.core.timeline.Timeline; +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.model.components.atomic.GUIClock; +import net.mograsim.logic.model.modeladapter.LogicModelParameters; +import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter; +import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator; +import net.mograsim.machine.Machine; +import net.mograsim.machine.MachineDefinition; +import net.mograsim.machine.Register; + +public class Am2900Machine implements Machine +{ + private Am2900MachineDefinition machineDefinition; + private ViewModel viewModel; + private Timeline timeline; + private Clock clock; + + public Am2900Machine(Am2900MachineDefinition am2900MachineDefinition) + { + this.machineDefinition = am2900MachineDefinition; + ViewModelModifiable viewModelModifiable = new ViewModelModifiable(); + IndirectGUIComponentCreator.createComponent(viewModelModifiable, "resource:Am2900Loader:/components/GUIAm2900.json"); + LogicModelParameters params = new LogicModelParameters(); + params.gateProcessTime = 50; + params.wireTravelTime = 10; + timeline = ViewLogicModelAdapter.convert(viewModelModifiable, params); + clock = ((GUIClock) viewModelModifiable.getComponentsByName().get("GUIClock#0")).getClock(); + } + + @Override + public MachineDefinition getDefinition() + { + return machineDefinition; + } + + @Override + public void reset() + { + // TODO Auto-generated method stub + + } + + @Override + public ViewModel getModel() + { + return viewModel; + } + + @Override + public Timeline getTimeline() + { + return timeline; + } + + @Override + public Clock getClock() + { + return clock; + } + + @Override + public BitVector getRegister(Register r) + { + // TODO Auto-generated method stub + return null; + } + + @Override + public void setRegister(Register r, BitVector value) + { + // TODO Auto-generated method stub + + } + +} diff --git a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/machine/Am2900MachineDefinition.java b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/machine/Am2900MachineDefinition.java new file mode 100644 index 00000000..6f9b6d8c --- /dev/null +++ b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/machine/Am2900MachineDefinition.java @@ -0,0 +1,47 @@ +package net.mograsim.logic.model.am2900.machine; + +import java.util.Set; + +import net.mograsim.machine.ISASchema; +import net.mograsim.machine.Machine; +import net.mograsim.machine.MachineDefinition; +import net.mograsim.machine.MainMemoryDefinition; +import net.mograsim.machine.Register; + +public class Am2900MachineDefinition implements MachineDefinition +{ + private MainMemoryDefinition memoryDefinition = new Am2900MainMemoryDefinition(); + + @Override + public Machine createNew() + { + return new Am2900Machine(this); + } + + @Override + public ISASchema getISASchema() + { + // TODO Auto-generated method stub + return null; + } + + @Override + public Set getRegisters() + { + // TODO Auto-generated method stub + return null; + } + + @Override + public int getAddressBits() + { + return 16; + } + + @Override + public MainMemoryDefinition getMainMemoryDefinition() + { + return memoryDefinition; + } + +} diff --git a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/machine/Am2900MainMemoryDefinition.java b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/machine/Am2900MainMemoryDefinition.java new file mode 100644 index 00000000..478ec242 --- /dev/null +++ b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/machine/Am2900MainMemoryDefinition.java @@ -0,0 +1,32 @@ +package net.mograsim.logic.model.am2900.machine; + +import net.mograsim.machine.MainMemoryDefinition; + +public class Am2900MainMemoryDefinition implements MainMemoryDefinition +{ + + @Override + public int getMemoryAddressBits() + { + return 16; + } + + @Override + public long getMinimalAddress() + { + return 0; + } + + @Override + public long getMaximalAddress() + { + return 0xFFFF; + } + + @Override + public int getCellWidth() + { + return 16; + } + +} diff --git a/net.mograsim.machine/META-INF/MANIFEST.MF b/net.mograsim.machine/META-INF/MANIFEST.MF index 8c6df1e7..69361685 100644 --- a/net.mograsim.machine/META-INF/MANIFEST.MF +++ b/net.mograsim.machine/META-INF/MANIFEST.MF @@ -8,7 +8,9 @@ Automatic-Module-Name: net.mograsim.machine Bundle-RequiredExecutionEnvironment: JavaSE-11 Require-Bundle: net.mograsim.logic.core;bundle-version="0.1.0";visibility:=reexport, net.mograsim.logic.model;bundle-version="0.1.0";visibility:=reexport, - net.mograsim.preferences;visibility:=reexport + net.mograsim.preferences;visibility:=reexport, + org.eclipse.e4.core.di.annotations, + org.eclipse.core.runtime Export-Package: net.mograsim.machine, net.mograsim.machine.isa, net.mograsim.machine.isa.types, diff --git a/net.mograsim.machine/build.properties b/net.mograsim.machine/build.properties index e9863e28..3090e4c0 100644 --- a/net.mograsim.machine/build.properties +++ b/net.mograsim.machine/build.properties @@ -1,5 +1,5 @@ source.. = src/ -output.. = bin/ bin.includes = META-INF/,\ .,\ - plugin.xml + plugin.xml,\ + schema/ diff --git a/net.mograsim.machine/plugin.xml b/net.mograsim.machine/plugin.xml index 4171a8db..8f737144 100644 --- a/net.mograsim.machine/plugin.xml +++ b/net.mograsim.machine/plugin.xml @@ -1,6 +1,5 @@ - - + diff --git a/net.mograsim.machine/schema/net.mograsim.machine.machinedefinition.exsd b/net.mograsim.machine/schema/net.mograsim.machine.machinedefinition.exsd new file mode 100644 index 00000000..43763a6e --- /dev/null +++ b/net.mograsim.machine/schema/net.mograsim.machine.machinedefinition.exsd @@ -0,0 +1,109 @@ + + + + + + + + + Mograsim extension for defining a machine + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The machines name + + + + + + + A Class that implements the Mograsim Machine Definition + + + + + + + + + + + + + + + 0.1.0 + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + diff --git a/net.mograsim.machine/schema/net.mograsim.machinedefinition.exsd b/net.mograsim.machine/schema/net.mograsim.machinedefinition.exsd deleted file mode 100644 index ea6d2580..00000000 --- a/net.mograsim.machine/schema/net.mograsim.machinedefinition.exsd +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - - - - Mograsim extension for defining a machine - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The machines name - - - - - - - A Class that implements the Mograsim Machine Definition - - - - - - - - - - - - - - - 0.1.0 - - - - - - - - - [Enter extension point usage example here.] - - - - - - - - - [Enter API information here.] - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - diff --git a/net.mograsim.machine/src/net/mograsim/machine/Machine.java b/net.mograsim.machine/src/net/mograsim/machine/Machine.java index 00a1e34c..dc544da6 100644 --- a/net.mograsim.machine/src/net/mograsim/machine/Machine.java +++ b/net.mograsim.machine/src/net/mograsim/machine/Machine.java @@ -1,6 +1,7 @@ package net.mograsim.machine; import net.mograsim.logic.core.components.Clock; +import net.mograsim.logic.core.timeline.Timeline; import net.mograsim.logic.core.types.BitVector; import net.mograsim.logic.model.model.ViewModel; @@ -16,4 +17,6 @@ public interface Machine { BitVector getRegister(Register r); void setRegister(Register r, BitVector value); + + Timeline getTimeline(); } diff --git a/net.mograsim.machine/src/net/mograsim/machine/MachineRegistry.java b/net.mograsim.machine/src/net/mograsim/machine/MachineRegistry.java new file mode 100644 index 00000000..865a8993 --- /dev/null +++ b/net.mograsim.machine/src/net/mograsim/machine/MachineRegistry.java @@ -0,0 +1,69 @@ +package net.mograsim.machine; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.ISafeRunnable; +import org.eclipse.core.runtime.SafeRunner; +import org.eclipse.e4.core.di.annotations.Execute; + +public class MachineRegistry +{ + private static final String MACHINE_EXT_ID = "net.mograsim.machine.machinedefinition"; + + private static Set installedMachines = new HashSet<>(); + + @Execute + public void execute(IExtensionRegistry registry) + { + System.out.println(Arrays.toString(registry.getExtensionPoints("net.mograsim.machine"))); + IConfigurationElement[] config = registry.getConfigurationElementsFor(MACHINE_EXT_ID); + try + { + for (IConfigurationElement e : config) + { + final Object o = e.createExecutableExtension("class"); + if (o instanceof MachineDefinition) + { + executeExtension(o); + } else + { + System.err.println("Invalid machine definition: " + o); + } + } + } + catch (CoreException ex) + { + System.out.println(ex.getMessage()); + } + } + + private void executeExtension(final Object o) + { + ISafeRunnable runnable = new ISafeRunnable() + { + @Override + public void handleException(Throwable e) + { + System.out.println("Exception in client"); + } + + @Override + public void run() throws Exception + { + System.out.println(((MachineDefinition) o).getAddressBits()); + } + }; + SafeRunner.run(runnable); + } + + public static Set getinstalledMachines() + { + return Collections.unmodifiableSet(installedMachines); + } +}