X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.machine%2Fsrc%2Fnet%2Fmograsim%2Fmachine%2FMemoryDefinition.java;h=39d12c44a3b5d1ddb6b9e274529c72301557149f;hb=8bed58cd47f4e53a0a83e066d38864aa6875502f;hp=5f42d10c74c40df908e0b934e8fd9703b4783304;hpb=976f7f2be00457b5cda2489545635ccd076c9afd;p=Mograsim.git diff --git a/net.mograsim.machine/src/net/mograsim/machine/MemoryDefinition.java b/net.mograsim.machine/src/net/mograsim/machine/MemoryDefinition.java index 5f42d10c..39d12c44 100644 --- a/net.mograsim.machine/src/net/mograsim/machine/MemoryDefinition.java +++ b/net.mograsim.machine/src/net/mograsim/machine/MemoryDefinition.java @@ -1,10 +1,11 @@ package net.mograsim.machine; -public interface MemoryDefinition { +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()}. + * 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 @@ -26,7 +27,7 @@ public interface MemoryDefinition { * @author Christian Femers */ long getMaximalAddress(); - + /** * The size of the MainMemory as the amount of addressable memory cells. * @@ -34,9 +35,9 @@ public interface MemoryDefinition { */ default long size() { - return getMaximalAddress() - getMinimalAddress(); + return getMaximalAddress() - getMinimalAddress() + 1; } - + public static MemoryDefinition create(int memoryAddressBits, long minimalAddress, long maximalAddress) { return new StandardMemoryDefinition(memoryAddressBits, minimalAddress, maximalAddress);