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

Safe HaskellNone
LanguageHaskell2010

Language.Pck.Tool

Contents

Synopsis

Assembler

parseInst :: ByteString -> Either [String] [Inst] Source

parse instructions from a ByteString data

Example:

 > parseInst (B.pack "mov r0,1\n halt\n")
 [MOVI R0 1,HALT]

parseInstFile :: FilePath -> IO [Inst] Source

parse instructions from a file

Example:

 > parseInstFile "examples/test0.asm"
 [MOVI R0 1,HALT]

Debugger

runDbg :: [DbgTrc] -> [DbgBrk] -> InstImage -> DataImage -> (TrcLog, CpuState) Source

debugging run

Example: run with a break condition. (break at pc == 1)

 > runDbg [] [(BrkPc BEQ 1)] [(0,[MOVI R0 7, MOVI R1 8, HALT])] []
 pc : 1
 gr : [7,0,0,0,0,0,0,0]
 fl : [False,False]

Example: run with trace output. (instruction trace)

 > runDbg [TrcInst] [] [(0,[MOVI R0 7, MOVI R1 8, HALT])] []
 TrcInst:        pc : 0  MOVI R0 7
 
 TrcInst:        pc : 1  MOVI R1 8
 
 TrcInst:        pc : 2  HALT

runDbgIO :: [DbgTrc] -> [DbgBrk] -> InstImage -> DataImage -> IO () Source

debugging run for IO output

Example: run with trace output. (instruction trace)

 > runDbgIO [TrcInst] [] [(0,[MOVI R0 7, MOVI R1 8, HALT])] []
 TrcInst:        pc : 0  MOVI R0 7
 
 TrcInst:        pc : 1  MOVI R1 8
 
 TrcInst:        pc : 2  HALT

data DbgTrc Source

trace conditions for runDbg or runDbgIO

Constructors

TrcInst

trace instructions

TrcReg

trace registers

TrcPc

trace pc

TrcCall

trace call target address

TrcBranch

trace branch information

TrcLoad

trace memory load

TrcStore

trace memory store

Instances

data DbgBrk Source

break conditions

Example:

 BrkPc BEQ 3          -- pc == 3
 BrkPc BGE 0x80       -- pc >= 0x80
 BrkGReg R0 BEQ 7     -- R0 == 7
 BrkDmem 0x20 BLT 4   -- *0x20 < 4

Constructors

BrkNon

no break

BrkOne

always one step break

BrkPc DbgOrd Int

pc break

BrkGReg GReg DbgOrd Int

register break

BrkDmem Int DbgOrd Int

data memory break

Instances

data DbgOrd Source

break operators

Constructors

BEQ

equal

BNE

not equal

BLT

little than

BLE

little equal

BGT

greater than

BGE

greater equal

Instances

type TrcLog = ByteString Source

data type for runDbg log

Interactive Debugger

runIdbIO :: [DbgTrc] -> [DbgBrk] -> InstImage -> DataImage -> IO () Source

interactive debugger driver.

Example:

 > runIdbIO [TrcInst] []  [(0,insts)] []
 For help, type "help".
 (idb) info reg
 pc : 0
 gr : [0,0,0,0,0,0,0,0]
 fl : [False,False]
 
 (idb) s
 TrcInst:        pc : 0  MOVI R0 0
 
 (idb) s
 TrcInst:        pc : 1  MOVI R1 1
 
 (idb) b 4
 Num  Enb What
 1    y   pc == 4
 
 (idb) c
 TrcInst:        pc : 2  MOVI R2 2
 
 TrcInst:        pc : 3  MOVI R3 3
 
 (idb) x/10 0
 0x00000000: 0x00000000 0x00000000 0x00000000 0x00000000
 0x00000004: 0x00000000 0x00000000 0x00000000 0x00000000
 0x00000008: 0x00000000 0x00000000
 
 (idb) q

please see "help" command

Profiler

runProf :: [ProfMode] -> InstImage -> DataImage -> String Source

run the profiler

Example: instruction count profile

 > runProf [ProfInst] [(0,[MOVI R1 0, MOVI R2 8, ST R1 R2, HALT])] []
  instruction profile:
  
    MOVI  2
    HALT  1
    ST    1
  
    total 4

Example: memory store profile

 > runProf [ProfStore] [(0,insts)] []
 Memory store address profile:
 
   address       count
   0x00000000    1
   0x00000001    1
   0x00000002    1
   0x00000003    1
   0x00000004    1
   0x00000005    1
   0x00000006    1
 
   total         7

Example: branch,jump,call profile

 > runProf [ProfBranch] [(0,insts)] []
 Branch/Jump/Call target profile:
 
   address       count
   0x00000007    6
 
   total 6
 
 
 Branch/Jump/Call direction profile:
 
   T/N   count
   Taken 6
   Not   1
 
   total 7

runProfIO :: [ProfMode] -> InstImage -> DataImage -> IO () Source

run the profiler for IO output

Example:

> runProfIO [ProfInst] [(0,[MOVI R1 0, MOVI R2 8, ST R1 R2, HALT])] []
 instruction profile:
 
   MOVI  2
   HALT  1
   ST    1
 
   total 4

prof :: [ProfMode] -> ByteString -> String Source

profile function

Example:

> prof [ProfInst] $ fst $ runDbg [TrcInst] [] [(0,insts)] []
 instruction profile:
 
   MOVI  2
   HALT  1
   ST    1
 
   total 4

data ProfMode Source

the profile mode for prof, runProf and runProfIO

Constructors

ProfInst

instruction profile

ProfPC

pc profile

ProfCall

call profile

ProfBranch

branch, jump, call profile

ProfLoad

memory load profile

ProfStore

memory store profile

Instances