| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Wrench.Machine.Memory
Synopsis
- sliceMem :: [Int] -> IntMap (Cell isa w) -> [(Int, Cell isa w)]
- data Mem isa w = Mem {
- memorySize :: !Int
- memoryData :: !(IntMap (Cell isa w))
- data Cell isa w
- = Instruction !isa
- | InstructionPart
- | Value !Word8
- class Memory m isa w | m -> isa w where
- readInstruction :: m -> Int -> Either Text (m, isa)
- readWord :: m -> Int -> Either Text (m, w)
- readByte :: m -> Int -> Either Text (m, Word8)
- writeWord :: m -> Int -> w -> Either Text m
- writeByte :: m -> Int -> Word8 -> Either Text m
- dumpCells :: m -> IntMap (Cell isa w)
- memCapacity :: m -> Int
- ioPorts :: m -> [Int]
- accessLog :: m -> AccessLog
- memAccessCount :: m -> AccessCount
- readInstructions :: (ByteSize isa, IsWord w, Memory (Mem isa w) isa w) => IoMem isa w -> Int -> Either Text (IoMem isa w, NonEmpty (Int, isa))
- class WordParts w where
- wordSplit :: w -> [Word8]
- wordCombine :: [Word8] -> w
- byteToWord :: Word8 -> w
- word32ToHex :: Integral a => a -> [Char]
- hexAddr :: Int -> Int -> Text
- hexAddrWidth :: Int -> Int
- prepareDump :: (ByteSize isa, IsWord w) => Int -> [Word8] -> [Section isa w w] -> Either Text (Mem isa w)
- prettyDump :: forall w isa. (ByteSize isa, IsWord w, Show isa) => Bool -> (Int -> Text) -> HashMap Text w -> IntMap (Cell isa w) -> Text
- data DumpStats = DumpStats {}
- computeDumpStats :: (ByteSize isa, ByteSizeT w) => [Section isa w l] -> DumpStats
Documentation
Constructors
| Mem | |
Fields
| |
Instances
| Show isa => Show (Mem isa w) Source # | |
| Eq isa => Eq (Mem isa w) Source # | |
| (ByteSize isa, IsWord w) => Memory (Mem isa w) isa w Source # | |
Defined in Wrench.Machine.Memory Methods readInstruction :: Mem isa w -> Int -> Either Text (Mem isa w, isa) Source # readWord :: Mem isa w -> Int -> Either Text (Mem isa w, w) Source # readByte :: Mem isa w -> Int -> Either Text (Mem isa w, Word8) Source # writeWord :: Mem isa w -> Int -> w -> Either Text (Mem isa w) Source # writeByte :: Mem isa w -> Int -> Word8 -> Either Text (Mem isa w) Source # dumpCells :: Mem isa w -> IntMap (Cell isa w) Source # memCapacity :: Mem isa w -> Int Source # ioPorts :: Mem isa w -> [Int] Source # accessLog :: Mem isa w -> AccessLog Source # memAccessCount :: Mem isa w -> AccessCount Source # | |
Constructors
| Instruction !isa | |
| InstructionPart | |
| Value !Word8 |
class Memory m isa w | m -> isa w where Source #
Minimal complete definition
readInstruction, readWord, readByte, writeWord, writeByte, dumpCells, memCapacity, memAccessCount
Methods
readInstruction :: m -> Int -> Either Text (m, isa) Source #
readWord :: m -> Int -> Either Text (m, w) Source #
readByte :: m -> Int -> Either Text (m, Word8) Source #
writeWord :: m -> Int -> w -> Either Text m Source #
writeByte :: m -> Int -> Word8 -> Either Text m Source #
dumpCells :: m -> IntMap (Cell isa w) Source #
memCapacity :: m -> Int Source #
Total addressable bytes.
ioPorts :: m -> [Int] Source #
Configured memory-mapped IO port starts (each spans one machine word). Default empty for memories without IO.
accessLog :: m -> AccessLog Source #
Runtime address ranges touched by readswritesinstruction-fetches.
Default for memories that don't track (e.g. bare Mem) is empty.
memAccessCount :: m -> AccessCount Source #
How many read/write we perform.
Instances
readInstructions :: (ByteSize isa, IsWord w, Memory (Mem isa w) isa w) => IoMem isa w -> Int -> Either Text (IoMem isa w, NonEmpty (Int, isa)) Source #
Read the instruction at idx a word at a time from idx on, one read
per started word, and return it with every following instruction that
ends inside the first word read. An instruction longer than a word comes
alone.
class WordParts w where Source #
Methods
wordSplit :: w -> [Word8] Source #
wordCombine :: [Word8] -> w Source #
byteToWord :: Word8 -> w Source #
word32ToHex :: Integral a => a -> [Char] Source #
hexAddr :: Int -> Int -> Text Source #
Render a byte address padded to width hex digits, e.g. 0x00ff (or
-0x01 for the negative indices an out-of-bounds check can still
produce).
hexAddrWidth :: Int -> Int Source #
How many hex digits an address into a memory of this capacity could ever need, e.g. a 512-byte memory only ever needs 3 (up to 0x1ff).
prepareDump :: (ByteSize isa, IsWord w) => Int -> [Word8] -> [Section isa w w] -> Either Text (Mem isa w) Source #
prettyDump :: forall w isa. (ByteSize isa, IsWord w, Show isa) => Bool -> (Int -> Text) -> HashMap Text w -> IntMap (Cell isa w) -> Text Source #
Translation-time memory layout statistics, surfaced to report views via the
layout:* namespace.
Constructors
| DumpStats | |
Fields
| |