Skip to main content

Integrated Circuit Hierarchy

"PyPI" "PyPI" "PyPI" "PyPI" "PyPI"

做什么用?

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

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

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

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

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

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

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

安装

pip install ichier

推荐再安装 ipython 和 rich 库。

pip install ipython rich

描述一个电路

buffer.py

from ichier import *

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

buf = design.modules["buf"]

buf.terminals.figs
# => (Terminal('A', 'input'), Terminal('Z', 'output'))

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

buf.nets.figs
# => (Net('A'), Net('Z'), Net('inter'))
  • 导出为 Spice
print(design.dumpToSpice())
.SUBCKT inv A Z
*.PININFO A:I Z:O
.ENDS


.SUBCKT buf A Z
*.PININFO A:I Z:O
Xi1 A inter inv size=x2
Xi2 inter Z inv size=x4
.ENDS

从网表读入设计

* top.cdl

.SUBCKT inv A Z
*.PININFO A:I Z:O
.ENDS

.SUBCKT buf A Z
*.PININFO A:I Z:O
Xi1 / inv $PINS A=A Z=inter
Xi2 / inv $PINS A=inter Z=Z
.ENDS
  • 解析 Spice 文件
from ichier import fromSpice
design = fromSpice("top.cdl", rebuild=True)
  • 解析 Verilog 文件
// top.v

module inv ( input A, output Z );
endmodule

module buf ( input A, output Z );
wire inter;
inv i1 (.A(A), .Z(inter));
inv i2 (.A(inter), .Z(Z));
endmodule
from ichier import fromVerilog
design = fromVerilog("top.v", rebuild=True)
  • 也可以直接使用 CLI 工具
ichier parse top.v
ichier parse top.cdl

建议预先安装 ipython 和 rich 库,会有更好的交互体验。

parse

LICENSE

GNU Affero General Public License v3

Metadata

Release files for ichier 0.2.7

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

Built distribution (wheel)

Table of built distributions (wheels) for ichier 0.2.7
File Interpreter ABI Platform Actions
ichier-0.2.7-py3-none-any.whl Python 3 none any Details for ichier-0.2.7-py3-none-any.whl

Release files / ichier-0.2.7-py3-none-any.whl

Download URL ichier-0.2.7-py3-none-any.whl
Size 51.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a842c0be55a76190b9e8a6e2b65ca7853c6ba350f66371c8beff0b0e19425c1a
BLAKE2b-256 checksum
How to use checksums
0be7640806080c9096457b3919165121d700b8c38495bf681ff065c5c32a70ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.6

Security for ichier 0.2.7

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