| Safe Haskell | Safe-Inferred | 
|---|---|
| Language | Haskell2010 | 
LibRISCV.Effects.Operations.Default.Machine.Memory
Description
Provides an implementatio of a byte-addressable memory, intended for internal
 usage in interpreters for the Operations effect.
Synopsis
- data Memory t a
 - class HalfStorage halfType byteType where
- toHalf :: [byteType] -> halfType
 - halfToBytes :: halfType -> [byteType]
 
 - class WordStorage wordType byteType where
- toWord :: [byteType] -> wordType
 - wordToBytes :: wordType -> [byteType]
 
 - mkMemory :: MArray t a IO => Address -> Word32 -> IO (Memory t a)
 - memSize :: MArray t a IO => Memory t a -> IO Word32
 - loadByte :: MArray t a IO => Memory t a -> Address -> IO a
 - loadHalf :: (MArray t a IO, HalfStorage b a) => Memory t a -> Address -> IO b
 - loadWord :: (MArray t a IO, WordStorage b a) => Memory t a -> Address -> IO b
 - storeByte :: MArray t a IO => Memory t a -> Address -> a -> IO ()
 - storeHalf :: (MArray t a IO, HalfStorage b a) => Memory t a -> Address -> b -> IO ()
 - storeWord :: (MArray t a IO, WordStorage b a) => Memory t a -> Address -> b -> IO ()
 - storeByteString :: MArray t a IO => (Word8 -> a) -> Memory t a -> Address -> ByteString -> IO ()
 - mkWord :: [Word8] -> Word32
 - mkBytes :: Word32 -> [Word8]
 
Documentation
Representation of a byte-addressable memory. The type is parameterized
 over an array implementation (such as IOUArray) and a
 generic value type (used to represent instruction operands).
class HalfStorage halfType byteType where Source #
Since the memory is byte-addressable it requires converting values of a larger size to bytes. This type class is responsible for a conversion of 16-bit values (halfs). That is, it converts halfs to bytes (and vice versa) in little endian.
Methods
toHalf :: [byteType] -> halfType Source #
Convert a list of two bytes to a single half.
halfToBytes :: halfType -> [byteType] Source #
Convert a single half to a list of two bytes.
Instances
class WordStorage wordType byteType where Source #
Similar to HalfStorage but handles conversion of 32-bit values (words).
Methods
toWord :: [byteType] -> wordType Source #
Convert a list of four bytes to a single word.
wordToBytes :: wordType -> [byteType] Source #
Convert a single word to a list of four bytes.
Instances
mkMemory :: MArray t a IO => Address -> Word32 -> IO (Memory t a) Source #
Create a new memory of the given size starting at the given address.
memSize :: MArray t a IO => Memory t a -> IO Word32 Source #
Returns the size of the memory in bytes.
loadByte :: MArray t a IO => Memory t a -> Address -> IO a Source #
Load a single byte from memory at the given address.
loadHalf :: (MArray t a IO, HalfStorage b a) => Memory t a -> Address -> IO b Source #
Load a half (16-bit) from memory at the given address.
loadWord :: (MArray t a IO, WordStorage b a) => Memory t a -> Address -> IO b Source #
Load a word (32-bit) from memory at the given address.
storeByte :: MArray t a IO => Memory t a -> Address -> a -> IO () Source #
Store a single byte in memory.
storeHalf :: (MArray t a IO, HalfStorage b a) => Memory t a -> Address -> b -> IO () Source #
Store a half (16-bit) in memory.
storeWord :: (MArray t a IO, WordStorage b a) => Memory t a -> Address -> b -> IO () Source #
Store a word (32-bit) in memory.
storeByteString :: MArray t a IO => (Word8 -> a) -> Memory t a -> Address -> ByteString -> IO () Source #
Write a ByteString to memory in little endian byteorder. Expects a
 function to convert single bytes (Word8) to the chosen value
 representation, a Memory, as well the Address where the string should be
 stored and the ByteString itself.