contur2
Loading...
Searching...
No Matches
i_memory.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include "contur/core/error.h"
7#include "contur/core/types.h"
8
9#include "contur/arch/block.h"
10
11namespace contur {
12
18 class IMemory
19 {
20 public:
21 virtual ~IMemory() = default;
22
26 [[nodiscard]] virtual Result<Block> read(MemoryAddress address) const = 0;
27
32 [[nodiscard]] virtual Result<void> write(MemoryAddress address, const Block &block) = 0;
33
35 [[nodiscard]] virtual std::size_t size() const noexcept = 0;
36
38 virtual void clear() = 0;
39 };
40
41} // namespace contur
Block — the fundamental unit of simulated memory.
Abstract interface for linear addressable memory.
Definition i_memory.h:19
virtual ~IMemory()=default
virtual std::size_t size() const noexcept=0
Returns the total number of addressable cells.
virtual Result< void > write(MemoryAddress address, const Block &block)=0
Writes a Block to the given address.
virtual Result< Block > read(MemoryAddress address) const =0
Reads a Block from the given address.
virtual void clear()=0
Clears all memory cells to default (Nop) blocks.
A result type that holds either a success value of type T or an ErrorCode.
Definition error.h:104
Error codes and Result<T> type for fallible operations.
Definition block.h:15
std::uint32_t MemoryAddress
Represents a memory address (physical or virtual).
Definition types.h:15
A single memory cell in the simulated architecture.
Definition block.h:26
Common type aliases, sentinel constants, and forward declarations used throughout the Contur 2 kernel...