processor-creative-kit-0.1.0.1: a creation kit for instruction sets and cpu simulators and development tools

Safe HaskellSafe-Inferred
LanguageHaskell2010

Language.Pck.Cpu.Memory

Contents

Synopsis

Abstraction Memory type

type InstImage = [(IAddress, [Inst])] Source

the instruction memory image

 [(StartAddress, [Instruction1,  Instruction2, ...])]

Example:

 [(0, [MOVI R1 0,  LD R0 R1,  HALT])]

type DataImage = [(DAddress, [DValue])] Source

the data memory image

 [(StartAddress, [Data1,  Data2, ...])]

Example:

 [(0, [1, 5, 7, 0x20])]

Implementation dependent types and functions

It's better to use the functions in Language.Pck.Cpu.State.

Internal types

type ImemArray = Array IAddress Inst Source

the instruction memory array

type DmemArray = Array DAddress DValue Source

the data memory array

Instruction memory access

initImem :: ImemArray Source

initialize the instruction memory

presetImem :: InstImage -> ImemArray Source

preset the instruction memory

modifyImems :: ImemArray -> (IAddress, [Inst]) -> ImemArray Source

modify the instruction memory

fetchImem :: ImemArray -> IAddress -> Inst Source

fetch an instruction from the instruction memory

getInstImage :: ImemArray -> InstImage Source

get an instruction memory image

extractImems :: InstImage -> IAddress -> Int -> [Inst] Source

extract instructions from the instruction memory

Data memory access

initDmem :: DmemArray Source

initialize the data memory

presetDmem :: DataImage -> DmemArray Source

preset the data memory

getDmem :: DmemArray -> DAddress -> DValue Source

get a data from the data memory

modifyDmem :: DmemArray -> DAddress -> DValue -> DmemArray Source

modify the data memory

modifyDmems :: DmemArray -> (DAddress, [DValue]) -> DmemArray Source

modify the data memory by values

getDataImage :: DmemArray -> DataImage Source

get a data memory image

extractDmems :: DataImage -> DAddress -> Int -> [DValue] Source

extract data values from the data memory