Skip to main content

A python tool for silicon validation.

Project description

cheap_pie

A python tool for register-based chip verification and validation

"Cheap Pie" is a python tool for register-based chip verification and validation. The name is a translitteration of "chip py" for obvious reasons.

Given an input description file for the chip, it provides a register-level and bitfield-level read/write access, through a generic transport layer.

Currently the implemented description input modes are:

but it should be relatively easy to add different chip description formats.

Although tested on few real chips (NXP QN9080, I.MX RT1010, K64F), cheap_pie parser already supports dozen of devices, listed in the CMSIS-SVD repository https://github.com/posborne/cmsis-svd .

Currently the supported transport layers are jlink and pyocd, but it should be really easy to add support for different transport layers, like for instance openSDA, CMSIS-DAP, Total Phase Cheetah, GDB or any other.

Experimental support for pyverilator transport allows to run interactive simulation of register blocks generated from SystemRDL source.

Author: Marco Merlin Tested on ipython3 (python 3.8.5) on ubuntu 20.04

IPython Example:

    %run cheap_pie
    inval = "0xFFFFFFFF"
    hal.regs.ADC_ANA_CTRL.setreg(inval)
    retval = hex(hal.regs.ADC_ANA_CTRL.getreg())
    assert(literal_eval(inval) == literal_eval(retval))

    # decimal assignement        
    inval = 2
    hal.regs.ADC_ANA_CTRL.setreg(inval)
    retval = hal.regs.ADC_ANA_CTRL.getreg()        
    assert(inval == retval)
    
    hal.regs.ADC_ANA_CTRL
    hal.regs.ADC_ANA_CTRL.display()
            
    print('Test bitfield methods...')
    
    hal.regs.ADC_ANA_CTRL.bitfields.ADC_BM
    hal.regs.ADC_ANA_CTRL.bitfields.ADC_BM.display()
    hal.regs.ADC_ANA_CTRL.bitfields.ADC_BM.display(2)
    hal.regs.ADC_ANA_CTRL.bitfields.ADC_BM.setbit(inval)
    retval = hal.regs.ADC_ANA_CTRL.bitfields.ADC_BM.getbit()
    assert(inval == retval)

    # subscriptable register access
    hal[0]
    # subscriptable bitfield access
    hal[0][0]
    # subscriptable as a dictionary
    hal['SYSCON_RST_SW_SET']
    hal['ADC_ANA_CTRL']['ADC_BM']
    
    # assignement
    hal['ADC_ANA_CTRL'] = 1
    hal['ADC_ANA_CTRL']['ADC_BM'] = 2
    # dict-based assignement in single register write
    hal['ADC_ANA_CTRL'] = {'DITHER_EN': 1, 'CHOP_EN': 1, 'INV_CLK': 1}

    # help
    hal.regs.ADC_ANA_CTRL.help()
    ADC core and reference setting regsiter
               ADC_BM: 
                     : ADC bias current selection.
            ADC_ORDER: 
                     : 1 to enable SD ADC 2 order mode selection
            DITHER_EN: 
                     : 1 to enable SD ADC PN Sequence in chopper mode
              CHOP_EN: 
                     : 1 to enable SD ADC chopper
              INV_CLK: 
                     : 1 to invert SD ADC Output Clock
              VREF_BM: 
                     : SD ADC Reference Driver bias current selection.
           VREF_BM_X3: 
                     : SD ADC Reference Driver bias current triple.
           VINN_IN_BM: 
                     : PGA VlNN Input Driver bias current selection.
          VINN_OUT_BM: 
                     : PGA VlNN Output Driver bias current selection.
       VINN_OUT_BM_X3: 
                     : PGA VlNN Output Driver bias current triple.
          ADC_BM_DIV2: 
                     : SD ADC bias current half.

CLI Example:

    # load RT1010 from local svd file under ./devices/
    # automatically calls ipython and cheap_pie initialization
    ./cheap_pie.sh -rf MIMXRT1011.svd -t jlink

    # load K64 from CMSIS-SVD
    # need to specify vendor for svd not in ./devices/
    ./cheap_pie.sh -rf MK64F12.svd -ve Freescale -t jlink

    # calls QN9080 with dummy transport layer 
    # useful to explore device registers
    ./cheap_pie.sh -t dummy

Default configurations Examples:

    # calls QN9080 device with dummy transport layer
    ./cfgs/cp_qn9080_dummy.sh
    # calls RT1010 device with jlink transport layer
    ./cfgs/cp_rt1010_jlink.sh
    # calls K20 device with dummy transport layer
    ./cfgs/cp_k20_dummy.sh

Verilator interactive simulation Examples:

    ./tools/rdl2verilog.py -f ./devices/rdl/basic.rdl
    ./cheap_pie.sh -dd  ./devices/rdl -rf basic.rdl -fmt rdl -t verilator -topv ./devices/rdl/basic/basic_rf.sv

Install

From pypi

    pip3 install cheap_pie

From github

    pip3 install git+https://github.com/bat52/cheap_pie.git@master

Dependencies for core (required):

    # for XML parsing (used by legacy svd parser and IP-XACT parser)
    pip3 install untangle
    # for exporting XML info into a human-readable document
    pip3 install python-docx
    # for dumping registers
    pip3 install hickle
    # CMSIS-SVD python parser including many svd files https://github.com/posborne/cmsis-svd
    pip3 install cmsis-svd
    # SPIRIT IP-XACT parser through ipyxact https://github.com/olofk/ipyxact
    pip3 install ipyxact                
    # SystemRDL to register-file verilog
    https://github.com/hughjackson/PeakRDL-verilog
    # SystemRDL to IP-XACT
    https://github.com/SystemRDL/PeakRDL-ipxact

Dependencies for validation/transport layers (optional):

    # for JLINK
    pip3 install pylink-square
    # pyOCD for CMSIS-DAP and JLINK support (only tested in python-venv)
    pip3 install pyocd
    # esptool for Espressif devices (not yet functional)
    pip3 install esptool        

Dependencies for verification (optional AND experimental):

    # verilator
    https://www.veripool.org/verilator/
    # pyverilator (python verilator wrapper)
    https://github.com/csail-csg/pyverilator        
    # gtkwave
    http://gtkwave.sourceforge.net/

Register description formats

  • regtool: from opentitan project seems similar, using JSON to represent chip/IP structure, and I2C transport
  • rggen: custom input, output: verilog, VHDL, YAML, JSON, TOML, Spreadsheet (XLSX, XLS, OSD, CSV)
  • ipxact2systemverilog: convert ipxact register file description into verilog register bank

Others

Cheap Pie is modeled after an original Octave/Matlab implementation that cannot be shared due to licensing reasons. The original code was converted to python using SMOP ( https://github.com/ripple-neuro/smop ).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cheap_pie-1.2.5.tar.gz (42.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cheap_pie-1.2.5-py3-none-any.whl (52.3 kB view details)

Uploaded Python 3

File details

Details for the file cheap_pie-1.2.5.tar.gz.

File metadata

  • Download URL: cheap_pie-1.2.5.tar.gz
  • Upload date:
  • Size: 42.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for cheap_pie-1.2.5.tar.gz
Algorithm Hash digest
SHA256 c1177191a0a746ae92eac4a1937135598f16b8cbb015d0c60ff10d82f34df3f4
MD5 d26061bc80acdc70f4f1b8e296f5ef5d
BLAKE2b-256 3082ad26dcbda6a4d13566b45941c51b40435041177c6b7508c80ff143a11a96

See more details on using hashes here.

File details

Details for the file cheap_pie-1.2.5-py3-none-any.whl.

File metadata

  • Download URL: cheap_pie-1.2.5-py3-none-any.whl
  • Upload date:
  • Size: 52.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for cheap_pie-1.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a86e00bd3beef7092b0f99fdf93a91d493b569a6fc1026b69235c9e27c2b81e4
MD5 3c35f7a3c6e340eb69b50ad7bda0f8d4
BLAKE2b-256 c087bd79f54779ec03fb810c5b9c897afecfa914cb9ab34c33f66695bf71f9b1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page