| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Language.QBE.Simulator.Memory
Description
This module provides an implementation of a simple byte-addressable memory based on Data.Array.
Synopsis
- type Address = Word64
- type Size = Word64
- showAddr :: Address -> String
- class Storable valTy byteTy where
- data Memory (a :: Type -> k -> Type) (v :: k)
- mkMemory :: forall (t :: Type -> Type -> Type) a. MArray t a IO => Address -> Size -> IO (Memory t a)
- memSize :: forall (t :: Type -> Type -> Type) a. MArray t a IO => Memory t a -> IO Size
- loadBytes :: forall (t :: Type -> Type -> Type) a. MArray t a IO => Memory t a -> Address -> Size -> IO [a]
- storeBytes :: forall (t :: Type -> Type -> Type) a. MArray t a IO => Memory t a -> Address -> [a] -> IO ()
- toMemAddr :: forall {k} (t :: Type -> k -> Type) (a :: k). Memory t a -> Address -> Address
- addrOverlap :: Address -> Address -> Size -> Bool
- alignAddr :: Address -> Size -> Address
Type Aliases
Value Representation
class Storable valTy byteTy where Source #
Type class for types that can be stored in memory. That is, types whose values can be converted to the given byte representation and vice versa.
Memory Representation
mkMemory :: forall (t :: Type -> Type -> Type) a. MArray t a IO => Address -> Size -> IO (Memory t a) Source #
Create a new Memory which starts at the given base address and
has a maximum capacity (i.e., can store up to the given amount of bytes).
The memory is not initialized, reading an uninitialized values results
in an error.
memSize :: forall (t :: Type -> Type -> Type) a. MArray t a IO => Memory t a -> IO Size Source #
Returns the size of the memory in bytes.
loadBytes :: forall (t :: Type -> Type -> Type) a. MArray t a IO => Memory t a -> Address -> Size -> IO [a] Source #
Load the given amount of bytes at the given address.
storeBytes :: forall (t :: Type -> Type -> Type) a. MArray t a IO => Memory t a -> Address -> [a] -> IO () Source #
Write the list of bytes to memory at the given address.
Memory Address
toMemAddr :: forall {k} (t :: Type -> k -> Type) (a :: k). Memory t a -> Address -> Address Source #
Translate global address to a memory-local address. That is, performs
address translation relative to the base address of the Memory.