dramforever / bitfield.py

Bitfield pretty-printer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bitfield.py

Example

$ ./bitfield.py format/mstatus64.json 0x0000000a00300180
0x   0   0   0   0   0   0   0   a   0   0   3   0   0   1   8   0
0b0000000000000000000000000000101000000000001100000000000110000000
  x-----------------------xxxx<><>---------xxxxxx<><><><>xxxx-x-x-
  |                       |||| | |         |||||| | | | ||||| | '-- [1]     SIE = 0
  |                       |||| | |         |||||| | | | ||||| '---- [3]     MIE = 0
  |                       |||| | |         |||||| | | | ||||'------ [5]     SPIE = 0
  |                       |||| | |         |||||| | | | |||'------- [6]     UBE = 0
  |                       |||| | |         |||||| | | | ||'-------- [7]     MPIE = 1
  |                       |||| | |         |||||| | | | |'--------- [8]     SPP = 1
  |                       |||| | |         |||||| | | | '---------- [10:9]  VS = 0x0 (Off)
  |                       |||| | |         |||||| | | '------------ [12:11] MPP = 0x0 (User)
  |                       |||| | |         |||||| | '-------------- [14:13] FS = 0x0 (Off)
  |                       |||| | |         |||||| '---------------- [16:15] XS = 0x0 (Off)
  |                       |||| | |         |||||'------------------ [17]    MPRV = 0
  |                       |||| | |         ||||'------------------- [18]    SUM = 0
  |                       |||| | |         |||'-------------------- [19]    MXR = 0
  |                       |||| | |         ||'--------------------- [20]    TVM = 1
  |                       |||| | |         |'---------------------- [21]    TW = 1
  |                       |||| | |         '----------------------- [22]    TSR = 0
  |                       |||| | '--------------------------------- [33:32] UXL = 0x2 (rv64)
  |                       |||| '----------------------------------- [35:34] SXL = 0x2 (rv64)
  |                       |||'------------------------------------- [36]    SBE = 0
  |                       ||'-------------------------------------- [37]    MBE = 0
  |                       |'--------------------------------------- [38]    GVA = 0
  |                       '---------------------------------------- [39]    MPV = 0
  '---------------------------------------------------------------- [63]    SD = 0
$ ./bitfield.py format/satp64.json 0xa0000000000810db
0x   a   0   0   0   0   0   0   0   0   0   0   8   1   0   d   b
0b1010000000000000000000000000000000000000000010000001000011011011
  <==><==============><==========================================>
     |               |                                           '- [43:0]  PPN = 0x810db
     |               '--------------------------------------------- [59:44] ASID = 0x0
     '------------------------------------------------------------- [63:60] Mode = 0xa (Sv57)

About

Bitfield pretty-printer


Languages

Language:Python 100.0%