X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=plugins%2Fnet.mograsim.machine%2Fsrc%2Fnet%2Fmograsim%2Fmachine%2FMemoryDefinition.java;fp=plugins%2Fnet.mograsim.machine%2Fsrc%2Fnet%2Fmograsim%2Fmachine%2FMemoryDefinition.java;h=39d12c44a3b5d1ddb6b9e274529c72301557149f;hb=7d05144c25daa53e60fc9ed9fd503546a86567f8;hp=0000000000000000000000000000000000000000;hpb=8bed58cd47f4e53a0a83e066d38864aa6875502f;p=Mograsim.git diff --git a/plugins/net.mograsim.machine/src/net/mograsim/machine/MemoryDefinition.java b/plugins/net.mograsim.machine/src/net/mograsim/machine/MemoryDefinition.java new file mode 100644 index 00000000..39d12c44 --- /dev/null +++ b/plugins/net.mograsim.machine/src/net/mograsim/machine/MemoryDefinition.java @@ -0,0 +1,45 @@ +package net.mograsim.machine; + +public interface MemoryDefinition +{ + + /** + * The number of bits that the main memory uses to address cells. Note that this does not need to equal + * {@link MachineDefinition#getAddressBits()}. + * + * @return the number of bits used to address a memory cell + * @author Christian Femers + */ + int getMemoryAddressBits(); + + /** + * The minimal address possible to address/use. This is usually 0. + * + * @return the minimal possible address. + * @author Christian Femers + */ + long getMinimalAddress(); + + /** + * The maximal address possible to address/use. + * + * @return the maximal possible address as unsigned long + * @author Christian Femers + */ + long getMaximalAddress(); + + /** + * The size of the MainMemory as the amount of addressable memory cells. + * + * @return the amount of addressable memory cells + */ + default long size() + { + return getMaximalAddress() - getMinimalAddress() + 1; + } + + public static MemoryDefinition create(int memoryAddressBits, long minimalAddress, long maximalAddress) + { + return new StandardMemoryDefinition(memoryAddressBits, minimalAddress, maximalAddress); + } +}