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

Abierto
#2,540 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
68/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
cpp, python
Área
devtools

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
C++
Estrellas
1.2k
Forks
305
Merge medio
3 d 2 h
PR fusionados (30 d)
11

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de KLayout/klayout

Todos los issues de KLayout/klayout

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.