Skip to main content

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 ).

Metadata

Release files for cheap-pie 1.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cheap-pie 1.2.5
File Size Uploaded Provenance Actions
cheap_pie-1.2.5.tar.gz 42.5 kB Without provenance Details for cheap_pie-1.2.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cheap-pie 1.2.5
File Interpreter ABI Platform Actions
cheap_pie-1.2.5-py3-none-any.whl Python 3 none any Details for cheap_pie-1.2.5-py3-none-any.whl

Total release size: 94.8 kB

Release files / cheap_pie-1.2.5.tar.gz

Download URL cheap_pie-1.2.5.tar.gz
Size 42.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c1177191a0a746ae92eac4a1937135598f16b8cbb015d0c60ff10d82f34df3f4
BLAKE2b-256 checksum
How to use checksums
3082ad26dcbda6a4d13566b45941c51b40435041177c6b7508c80ff143a11a96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / cheap_pie-1.2.5-py3-none-any.whl

Download URL cheap_pie-1.2.5-py3-none-any.whl
Size 52.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a86e00bd3beef7092b0f99fdf93a91d493b569a6fc1026b69235c9e27c2b81e4
BLAKE2b-256 checksum
How to use checksums
c087bd79f54779ec03fb810c5b9c897afecfa914cb9ab34c33f66695bf71f9b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.3

Security for cheap-pie 1.2.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page