SPICE reader: recognize `.option scale` and suffixed scale factors

未关闭
#2,540 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
cpp, python
领域
devtools

调研方向

Start with the NetlistSpiceReader control-statement handling for .options and .option, and with where the scale value is parsed through tl::Extractor::try_read(double). Run the Python repro from the issue against the three directives and confirm that L and W come out as 0.45 and 1.5 in each case. Done means that .option scale=1e-6 is accepted without a warning, that suffixed values such as 1u scale correctly, and that the reader tests still pass.

由索引模型根据 Issue 内容生成。

描述

NetlistSpiceReader can read micrometre geometry one million times too large when a deck uses the ngspice scale syntax found in sky130 model libraries.

For the same native M device:

Directive Read L (µm) Read W (µm)
.options scale=1e-6 0.45 1.5
.options scale=1u 450000 1500000
.option scale=1e-6 450000 1500000

Expected: all three declarations yield L=0.45, W=1.5. The singular spelling emits a control-statement warning. The suffixed value is accepted without the intended scaling.

The sky130 model library uses .option scale=1.0u. This affects comparison of those schematic dimensions with layout geometry.

from pathlib import Path
from tempfile import TemporaryDirectory
import pya

with TemporaryDirectory() as directory:
    path = Path(directory) / 'scale.cir'
    for option in ('.options scale=1e-6', '.options scale=1u', '.option scale=1e-6'):
        path.write_text('* scale\n' + option + '\n.subckt cell d g s b\n'
                        'M1 d g s b n L=0.45 W=1.5\n.ends\n', encoding='utf-8')
        netlist = pya.Netlist()
        netlist.read(str(path), pya.NetlistSpiceReader())
        device = next(netlist.top_circuit().each_device())
        print(option, device.parameter('L'), device.parameter('W'))

Run with klayout -b -r repro.py, or replace import pya with import klayout.db as pya when using the Python module.

Current master still recognizes only .options and reads its value with tl::Extractor::try_read(double), which leaves the SPICE suffix unconsumed.

Versions: KLayout Python module 0.30.13 from PyPI, Python 3.14, macOS; ngspice 47 used to verify the intended geometry-scale behavior

主要语言
C++
星标
1.2k
派生
305
平均合并
3 天 2 小时
30 天内合并 PR
11

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

KLayout/klayout 的其他 Issue

查看 KLayout/klayout 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。