Skip to main content

A bitfield diagram renderer

Project description

A Python3 port of the javascript bit-field library by Aliaksei Chapyzhenka.

Install

pip install bit_field

To install this package with JSON5 support:

pip install bit_field[JSON5]

Library usage

from bit_field import render, jsonml_stringify

reg = [
  {'bits': 8, 'name': 'data'}
]

jsonml = render(reg, hspace=888)
html = jsonml_stringify(jsonml)
# <svg...>

CLI Usage

bit_field [options] input > alpha.svg

options

input        : input JSON filename - must be specified always
--input      : input JSON filename (kept for compatibility)
--compact    : compact rendering mode
--vspace     : vertical space - default 80
--hspace     : horizontal space - default 640
--lanes      : rectangle lanes - default 2
--bits       : overall bitwidth - default 32
--fontfamily : - default sans-serif
--fontweight : - default normal
--fontsize   : - default 14
--hflip      : horizontal flip
--vflip      : horizontal flip

--beautify   : use xml beautifier

--json5      : force json5 input format (need json5 python module)
--no-json5   : never use json5 input format

alpha.json

[
    { "name": "IPO",   "bits": 8, "attr": "RO" },
    {                  "bits": 7 },
    { "name": "BRK",   "bits": 5, "attr": "RW", "type": 4 },
    { "name": "CPK",   "bits": 1 },
    { "name": "Clear", "bits": 3 },
    { "bits": 8 }
]

alpha.svg

Heat Sink

Licensing

This work is based on original work by Aliaksei Chapyzhenka under the MIT license (see LICENSE-ORIGINAL).

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

bit_field-0.4.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

bit_field-0.4.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file bit_field-0.4.0.tar.gz.

File metadata

  • Download URL: bit_field-0.4.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.11

File hashes

Hashes for bit_field-0.4.0.tar.gz
Algorithm Hash digest
SHA256 45805705a42b9c14e975ad951569bf2aefdda8ea8edfe22f897cbf8815420786
MD5 9460c9889c61c5caefd6ed26a3655911
BLAKE2b-256 fbffb519dd23053426d7c681e329e9c6276d64963c15f0f4217301fefbd0c5c0

See more details on using hashes here.

File details

Details for the file bit_field-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: bit_field-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.11

File hashes

Hashes for bit_field-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b21a5f20d2c414ca9575b185da8b2791cab071b165b3cc107caf7e95ebe11ae6
MD5 7560eeb4b6a376f6872bfc6c10f48539
BLAKE2b-256 879e8377c61fe0e5d3333677409281c2e995eea6b5e0632f732b879969aff8e3

See more details on using hashes here.

Supported by

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