X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=net.mograsim.machine%2Fsrc%2Fnet%2Fmograsim%2Fmachine%2Fstandard%2Fmemory%2FWordAddressableMemory.java;h=037b17a9afe7f77643ba4529d5d5bc885743548f;hb=d324b0cd3f8dfd4602f7f3b7efba1c90b3ef325f;hp=719c993eccb075a3dd6f67e152077e4c2f8085d9;hpb=58a0d53298e98eaca73bd7c8d6fa12c54b37be14;p=Mograsim.git diff --git a/net.mograsim.machine/src/net/mograsim/machine/standard/memory/WordAddressableMemory.java b/net.mograsim.machine/src/net/mograsim/machine/standard/memory/WordAddressableMemory.java index 719c993e..037b17a9 100644 --- a/net.mograsim.machine/src/net/mograsim/machine/standard/memory/WordAddressableMemory.java +++ b/net.mograsim.machine/src/net/mograsim/machine/standard/memory/WordAddressableMemory.java @@ -5,24 +5,29 @@ import java.util.HashMap; import net.mograsim.logic.core.types.Bit; import net.mograsim.logic.core.types.BitVector; +import net.mograsim.machine.MainMemory; +import net.mograsim.machine.MainMemoryDefinition; -public class WordAddressableMemory +public class WordAddressableMemory implements MainMemory { private final int cellWidth; private final long minimalAddress, maximalAddress; + private final MainMemoryDefinition definition; private final int pageSize = 64; private HashMap pages; - public WordAddressableMemory(int cellWidth, long minimalAddress, long maximalAddress) + public WordAddressableMemory(MainMemoryDefinition definition) { super(); - this.cellWidth = cellWidth; - this.minimalAddress = minimalAddress; - this.maximalAddress = maximalAddress; + this.cellWidth = definition.getCellWidth(); + this.minimalAddress = definition.getMinimalAddress(); + this.maximalAddress = definition.getMaximalAddress(); + this.definition = definition; this.pages = new HashMap<>(); } + @Override public void setCell(long address, BitVector b) { if (address < minimalAddress || address > maximalAddress) @@ -36,6 +41,7 @@ public class WordAddressableMemory p.setCell(offset, b); } + @Override public BitVector getCell(long address) { long page = address / pageSize; @@ -77,4 +83,10 @@ public class WordAddressableMemory return Arrays.deepToString(memory); } } + + @Override + public MainMemoryDefinition getDefinition() + { + return definition; + } }