Skip to main content

No project description provided

Project description

ralf_model

RALF(Register Abstraction Layer Format)源文本RalfDocument / 抽象节点类型BlockNodeRegisterNodeFieldNode,并实现 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_ralfload_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_sourcesresolve_source_path(见 ralf_model.source_expand)。

能力范围

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

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

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

python_library_ralf_model-0.1.3.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_library_ralf_model-0.1.3-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file python_library_ralf_model-0.1.3.tar.gz.

File metadata

File hashes

Hashes for python_library_ralf_model-0.1.3.tar.gz
Algorithm Hash digest
SHA256 c84862ffaff161eb294370b47d9ce92dae75e888b7727bde97857552a4dd8b51
MD5 3c1c795b0ae23ff25a7864d25e46c5a1
BLAKE2b-256 25a962af4df8b51ef83d776280e5fb710db5442034d981e56f8e03b45c551124

See more details on using hashes here.

File details

Details for the file python_library_ralf_model-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for python_library_ralf_model-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 22beb3e8f3cef2dafec132db4c4dfbe151527503d36d78a704dd179cbf2c6158
MD5 f7f5a886f3ccb7aeeb811b0bc63907da
BLAKE2b-256 40b36e5b0911137c806aac70df1b13f47565027e091aac00c0d6de1473a9197c

See more details on using hashes here.

Supported by

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