import net.mograsim.logic.core.types.BitVector;
-public interface MainMemory {
+public interface MainMemory extends Memory<BitVector> {
- public BitVector getCell(long address);
- public void setCell(long address, BitVector word);
public BigInteger getCellAsBigInteger(long address);
public void setCellAsBigInteger(long address, BigInteger word);
public MainMemoryDefinition getDefinition();
+ public default long size()
+ {
+ return getDefinition().size();
+ }
}
--- /dev/null
+package net.mograsim.machine;
+
+public interface Memory<T>
+{
+ /**
+ * @param address The address of the desired data. Must be non-negative
+ * @return The data at the requested address
+ *
+ * @throws IndexOutOfBoundsException
+ */
+ public T getCell(long address);
+
+ /**
+ * Sets the data at the supplied address
+ * @throws IndexOutOfBoundsException
+ */
+ public void setCell(long address, T data);
+
+ public long size();
+}
package net.mograsim.machine;
-public interface MicroprogramMemory {
-
- /**
- * @param address The address of the desired instruction. Must be non-negative
- * @return The instruction at the requested address
- *
- * @throws IndexOutOfBoundsException
- */
- public MicroInstruction getInstruction(long address);
-
- /**
- * Sets the instruction at the supplied address
- * @param address
- * @param instruction
- *
- * @throws IndexOutOfBoundsException
- */
- public void setInstruction(long address, MicroInstruction instruction);
+public interface MicroprogramMemory extends Memory<MicroInstruction>
+{
}