Skip to main content

Integrated Circuit Hierarchy

Project description

Integrated Circuit Hierarchy

做什么用?

懒得写,AI 帮我总结了一下。

ichier 是一个用于创建和处理电路设计的 Python 库。它允许用户定义设计、模块、端口和实例,并生成对应的代码。这个库可以用于以下几个方面:

  1. 设计创建:通过 DesignModule 等类,可以构建电路设计,并添加多个模块来实现抽象的对应关系。

  2. 终端和网络定义:可以轻松定义模块之间的连接,通过设置输入输出端口 Terminal 和内部网络 net 来描述电路的交互。

  3. 实例化模块:允许将模块实例化多次,以便在设计中复用特定的功能,比如在一个电路中多次使用同一个逻辑门。

  4. 代码解析:支持解析 SPICE 和 Verilog 格式的电路文件,生成 Design 对象,方便分析电路结构和参数,提取设计信息。

  5. 命令行交互:支持在 Python 中启动交互式 shell,方便对电路的信息进行查询。

安装

pip install ichier -U

描述一个电路

buffer.py

from ichier import *

design = Design(
    modules=[
        Module(
            name="inv",
            terminals=[
                Terminal(name="A", direction="input"),
                Terminal(name="Z", direction="output"),
            ],
        ),
        Module(
            name="buf",
            terminals=[
                Terminal(
                    name="A",
                    direction="input",
                    net_name="A",
                ),
                Terminal(
                    name="Z",
                    direction="output",
                    net_name="Z",
                ),
            ],
            nets=[
                Net(name="A"),
                Net(name="Z"),
                Net(name="inter"),
            ],
            instances=[
                Instance(
                    name="i1",
                    reference="inv",
                    connection={
                        "A": "A",
                        "Z": "Z",
                    },
                    parameters={"size": "x2"},
                ),
                Instance(
                    name="i2",
                    reference="inv",
                    connection={
                        "A": "Z",
                        "Z": "A",
                    },
                    parameters={"size": "x4"},
                ),
            ],
        ),
    ],
)
  • 查询信息
design.modules.figs
# (Module(name='inv'), Module(name='buf'))

buf = design.modules["buf"]

buf.terminals.figs
# (Terminal(name=A, in), Terminal(name=Z, out))

buf.instances.figs
# (Instance(name='i1'), Instance(name='i2'))

buf.nets.figs
# (Net(name='A'), Net(name='Z'), Net(name='inter'))

从网表读入设计

  • 解析 SPICE 文件
from ichier.parser import fromSpice
design = fromSpice("top.cdl")
  • 解析 Verilog 文件
from ichier.parser import fromVerilog
design = fromVerilog("top.v")
  • 也可以直接使用 CLI 工具
python -m ichier parse spice top.cdl

预先安装 ipythonrich 库,会有更好的交互体验。

LICENSE

GNU Affero General Public License v3

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

ichier-0.1.2.tar.gz (30.5 kB view details)

Uploaded Source

Built Distribution

ichier-0.1.2-py3-none-any.whl (33.8 kB view details)

Uploaded Python 3

File details

Details for the file ichier-0.1.2.tar.gz.

File metadata

  • Download URL: ichier-0.1.2.tar.gz
  • Upload date:
  • Size: 30.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for ichier-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a583b88c59d45d67e3d273debf8138d71f831b2742cda5673ab94ea493b1cc4d
MD5 c6ef4fccee365ee738b14af0c0175c3e
BLAKE2b-256 ea85a4a31f166b4c3f80385af5fec0b5ec54c36c080b12a921efe05e5b3189a8

See more details on using hashes here.

Provenance

File details

Details for the file ichier-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: ichier-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 33.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for ichier-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b0b6712ecaefc50a24581fe24c25dee91491fd38c0455b681763c509d05589d0
MD5 cdce32d7566df4e4b002d23ca4161eeb
BLAKE2b-256 9a90e40bbee7e419ebd6d7dccff2aac29ad66d8733846fda2fdc5385da99926a

See more details on using hashes here.

Provenance

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