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

オープン
#2,540 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
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時間
マージ済み PR(30日)
11

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

KLayout/klayout のほかの issue

KLayout/klayout の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。