Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
- type InstImage = [(IAddress, [Inst])]
- type DataImage = [(DAddress, [DValue])]
- type ImemArray = Array IAddress Inst
- type DmemArray = Array DAddress DValue
- type IAddress = Int
- type DAddress = Int
- type DValue = Int
- initImem :: ImemArray
- presetImem :: InstImage -> ImemArray
- modifyImems :: ImemArray -> (IAddress, [Inst]) -> ImemArray
- fetchImem :: ImemArray -> IAddress -> Inst
- getInstImage :: ImemArray -> InstImage
- extractImems :: InstImage -> IAddress -> Int -> [Inst]
- initDmem :: DmemArray
- presetDmem :: DataImage -> DmemArray
- getDmem :: DmemArray -> DAddress -> DValue
- modifyDmem :: DmemArray -> DAddress -> DValue -> DmemArray
- modifyDmems :: DmemArray -> (DAddress, [DValue]) -> DmemArray
- getDataImage :: DmemArray -> DataImage
- extractDmems :: DataImage -> DAddress -> Int -> [DValue]
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
Instruction memory access
presetImem :: InstImage -> ImemArray Source
preset 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
presetDmem :: DataImage -> DmemArray Source
preset the data memory
modifyDmems :: DmemArray -> (DAddress, [DValue]) -> DmemArray Source
modify the data memory by values
getDataImage :: DmemArray -> DataImage Source
get a data memory image