wrench-0.0.6.3
Safe HaskellNone
LanguageHaskell2010

Wrench.Machine.Memory

Synopsis

Documentation

sliceMem :: [Int] -> IntMap (Cell isa w) -> [(Int, Cell isa w)] Source #

data Mem isa w Source #

Constructors

Mem 

Fields

Instances

Instances details
Show isa => Show (Mem isa w) Source # 
Instance details

Defined in Wrench.Machine.Types

Methods

showsPrec :: Int -> Mem isa w -> ShowS #

show :: Mem isa w -> String #

showList :: [Mem isa w] -> ShowS #

Eq isa => Eq (Mem isa w) Source # 
Instance details

Defined in Wrench.Machine.Types

Methods

(==) :: Mem isa w -> Mem isa w -> Bool #

(/=) :: Mem isa w -> Mem isa w -> Bool #

(ByteSize isa, IsWord w) => Memory (Mem isa w) isa w Source # 
Instance details

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 #

data Cell isa w Source #

Constructors

Instruction !isa 
InstructionPart 
Value !Word8 

Instances

Instances details
Show isa => Show (Cell isa w) Source # 
Instance details

Defined in Wrench.Machine.Types

Methods

showsPrec :: Int -> Cell isa w -> ShowS #

show :: Cell isa w -> String #

showList :: [Cell isa w] -> ShowS #

Eq isa => Eq (Cell isa w) Source # 
Instance details

Defined in Wrench.Machine.Types

Methods

(==) :: Cell isa w -> Cell isa w -> Bool #

(/=) :: Cell isa w -> Cell isa w -> Bool #

class Memory m isa w | m -> isa w where Source #

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

Instances details
(ByteSize isa, IsWord w, Memory (Mem isa w) isa w) => Memory (IoMem isa w) isa w Source # 
Instance details

Defined in Wrench.Machine.Memory

Methods

readInstruction :: IoMem isa w -> Int -> Either Text (IoMem isa w, isa) Source #

readWord :: IoMem isa w -> Int -> Either Text (IoMem isa w, w) Source #

readByte :: IoMem isa w -> Int -> Either Text (IoMem isa w, Word8) Source #

writeWord :: IoMem isa w -> Int -> w -> Either Text (IoMem isa w) Source #

writeByte :: IoMem isa w -> Int -> Word8 -> Either Text (IoMem isa w) Source #

dumpCells :: IoMem isa w -> IntMap (Cell isa w) Source #

memCapacity :: IoMem isa w -> Int Source #

ioPorts :: IoMem isa w -> [Int] Source #

accessLog :: IoMem isa w -> AccessLog Source #

memAccessCount :: IoMem isa w -> AccessCount Source #

(ByteSize isa, IsWord w) => Memory (Mem isa w) isa w Source # 
Instance details

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 #

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 #

Instances

Instances details
WordParts Int32 Source # 
Instance details

Defined in Wrench.Machine.Types

WordParts Int8 Source # 
Instance details

Defined in Wrench.Machine.Types

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 #

data DumpStats Source #

Translation-time memory layout statistics, surfaced to report views via the layout:* namespace.

Constructors

DumpStats 

Fields

Instances

Instances details
Show DumpStats Source # 
Instance details

Defined in Wrench.Machine.Memory

Eq DumpStats Source # 
Instance details

Defined in Wrench.Machine.Memory

computeDumpStats :: (ByteSize isa, ByteSizeT w) => [Section isa w l] -> DumpStats Source #

Translation-time layout summary derived from the section list.