X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.machine%2Fsrc%2Fnet%2Fmograsim%2Fmachine%2Fstandard%2Fmemory%2FModelMemoryWA.java;fp=net.mograsim.machine%2Fsrc%2Fnet%2Fmograsim%2Fmachine%2Fstandard%2Fmemory%2FModelMemoryWA.java;h=0000000000000000000000000000000000000000;hb=7b8035a065c7b64f38850907d519f9a7dfb67e24;hp=20f27fb92ab722e11a3a961c91c31ac26bb7e4fd;hpb=d09827f6dc03fa3cded8e996b4ce45fdae3755ca;p=Mograsim.git diff --git a/net.mograsim.machine/src/net/mograsim/machine/standard/memory/ModelMemoryWA.java b/net.mograsim.machine/src/net/mograsim/machine/standard/memory/ModelMemoryWA.java deleted file mode 100644 index 20f27fb9..00000000 --- a/net.mograsim.machine/src/net/mograsim/machine/standard/memory/ModelMemoryWA.java +++ /dev/null @@ -1,128 +0,0 @@ -package net.mograsim.machine.standard.memory; - -import net.haspamelodica.swt.helper.gcs.GeneralGC; -import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle; -import net.mograsim.logic.model.model.LogicModelModifiable; -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.LogicCoreAdapter; -import net.mograsim.logic.model.serializing.IdentifyParams; -import net.mograsim.logic.model.serializing.IndirectModelComponentCreator; -import net.mograsim.logic.model.snippets.Renderer; -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; -import net.mograsim.logic.model.util.JsonHandler; -import net.mograsim.machine.MainMemoryDefinition; - -public class ModelMemoryWA extends ModelComponent -{ - private final MainMemoryDefinition definition; - private final Pin addrPin, dataPin, rWPin, clock; - private CoreWordAddressableMemory memory; - private final static int width = 100, height = 300; - private Renderer symbolRenderer; - private Renderer outlineRenderer; - - public ModelMemoryWA(LogicModelModifiable model, MainMemoryDefinition definition, String name) - { - super(model, name, false); - this.definition = definition; - - SimpleRectangularLikeParams rendererParams = new SimpleRectangularLikeParams(); - rendererParams.centerText = "RAM"; - rendererParams.centerTextHeight = 24; - rendererParams.horizontalComponentCenter = width / 100; - rendererParams.pinLabelHeight = 17.5; - rendererParams.pinLabelMargin = 2.5; - this.symbolRenderer = new SimpleRectangularLikeSymbolRenderer(this, rendererParams); - this.outlineRenderer = new DefaultOutlineRenderer(this); - - setSize(width, height); - //TODO check the usages - addPin(addrPin = new Pin(model, this, "A", definition.getMemoryAddressBits(), PinUsage.INPUT, 0, 10)); - addPin(dataPin = new Pin(model, this, "D", definition.getCellWidth(), PinUsage.TRISTATE, 0, 30)); - addPin(rWPin = new Pin(model, this, "RW", 1, PinUsage.INPUT, 0, 50)); - addPin(clock = new Pin(model, this, "C", 1, PinUsage.INPUT, 0, 70)); - - init(); - } - - public Pin getAddressPin() - { - return addrPin; - } - - public Pin getDataPin() - { - return dataPin; - } - - public Pin getReadWritePin() - { - return rWPin; - } - - public Pin getClockPin() - { - return clock; - } - - public void setCoreModelBinding(CoreWordAddressableMemory memory) - { - this.memory = memory; - } - - public MainMemoryDefinition getDefinition() - { - return definition; - } - - public CoreWordAddressableMemory getMemory() - { - return memory; - } - - @Override - public void render(GeneralGC gc, Rectangle visibleRegion) - { - symbolRenderer.render(gc, visibleRegion); - outlineRenderer.render(gc, visibleRegion); - } - - @Override - public String getIDForSerializing(IdentifyParams idParams) - { - return "MemoryWA"; - } - - @Override - public ModelMemoryWAParams getParamsForSerializing(IdentifyParams idParams) - { - ModelMemoryWAParams params = new ModelMemoryWAParams(); - params.addrBits = definition.getMemoryAddressBits(); - params.cellWidth = definition.getCellWidth(); - params.minAddr = definition.getMinimalAddress(); - params.maxAddr = definition.getMaximalAddress(); - return params; - } - - static - { - LogicCoreAdapter.addComponentAdapter(new WordAddressableMemoryAdapter()); - IndirectModelComponentCreator.setComponentSupplier(ModelMemoryWA.class.getCanonicalName(), (m, p, n) -> - { - ModelMemoryWAParams params = JsonHandler.fromJsonTree(p, ModelMemoryWAParams.class); - return new ModelMemoryWA(m, MainMemoryDefinition.create(params.addrBits, params.cellWidth, params.minAddr, params.maxAddr), n); - }); - } - - public static class ModelMemoryWAParams - { - public int addrBits; - public int cellWidth; - public long minAddr; - public long maxAddr; - } -}