Skip to main content

ralf_model

在 RALF(Register Abstraction Layer Format)源文本 与 RalfDocument / 抽象节点类型(BlockNode、RegisterNode、FieldNode,并实现 AbstractRalf*)之间做解析与生成。

用法

from pathlib import Path

from ralf_model import dump_ralf, load_ralf_file, parse_ralf

doc = parse_ralf(Path("chip.ralf").read_text(encoding="utf-8"))
text = dump_ralf(doc)

亦可使用 loads_ralf / dumps_ralf、load_ralf_file / dump_ralf_file(见 ralf_model.io)。加载时可传入 include_paths(类似 ralgen -I dir),配合 source 行递归展开后再解析;相对路径先相对当前文件目录,再依次在各 include 目录检索。

source 与 include

RALF 常作为 Tcl 脚本。单独成行的 source "f.ralf"、source {path}、source name.ralf(可有行尾 ;、# 注释)会在解析前被展开。不需要展开时:loads_ralf(..., expand_source=False) 或 load_ralf_file(..., expand_source=False)。

from pathlib import Path
from ralf_model import load_ralf_file

doc = load_ralf_file(
    "top.ralf",
    include_paths=[Path("ralf_inc"), Path("../shared")],
)

也可直接使用 expand_ralf_sources、resolve_source_path(见 ralf_model.source_expand)。

能力范围

  • block:定义 block 名 { ... };简单映射 block 名 @地址;;赋值与可选路径、地址 block 左名 = 右名、block 左名 = 右名 (hdl路径)、... @地址,可与 { ... } 组合。
  • register:register 名 [ (hdl路径) ] [ @字节偏移 ] { ... } 或 register 名; 前向引用。
  • field:field 名 [(hdl路径)] [ @位偏移 ] { ... }(括号路径可紧贴字段名,如 field f(hdl.f))。
  • field 花括号内按源顺序保留各条语句(含 enum { ... }; 等),便于往返。
  • @ 后的偏移在写出时统一为 Verilog 风格十六进制字面量(如 'h5);bytes 等为十进制。

与 Synopsys ralgen 全语法并非字节级兼容;复杂构造若解析失败可再扩展解析器。

Metadata

Release files for python-library-ralf-model 0.1.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 python-library-ralf-model 0.1.5
File Size Uploaded Provenance
python_library_ralf_model-0.1.5.tar.gz 15.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for python-library-ralf-model 0.1.5
File Interpreter ABI Platform
python_library_ralf_model-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 29.4 kB

Release files / python_library_ralf_model-0.1.5.tar.gz

Download URL python_library_ralf_model-0.1.5.tar.gz
Size 15.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b0f5e4965d5ada58693efc50d00186c5b6c4d78fa5a08a168d969f0c7ed3dff1
BLAKE2b-256 checksum
How to use checksums
84beec97acac747e9c7ef62805e3310ff1b8df1fa79f73a141fe4ae063819b72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / python_library_ralf_model-0.1.5-py3-none-any.whl

Download URL python_library_ralf_model-0.1.5-py3-none-any.whl
Size 14.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c3ff75f0d328821a8378bd2a5921f30ba8b85356bee0b45ea0876f3be877cf73
BLAKE2b-256 checksum
How to use checksums
aa38caa33fd5e53b8e57efc201612c1fb1cef694fdf0b6b32465c0ab17497634
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for python-library-ralf-model 0.1.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