Tuesday, August 25, 2026

Coming Soon : Wiring Through Hierarchy! Xschem Adds Pins for You Automatically!


It's like stitching - kind of :)

You want to draw a wire. Who says you need to be limited to the current schematic? The 20th century ended a quarter century ago. Listening Cadence?

Saturday, August 22, 2026

Can Xschem do Verilog Import? Not Yet

EDA tooling · Notes from a session

Precedent Is Not a Reason

I reached for awk because every importer in the repo was awk. That is a description of the codebase, not an argument about the problem. One question from the user was enough to take the whole recommendation apart.

The question was simple: does XSCHEM have Verilog import — can it read a netlist and draw the corresponding schematic? The plan behind it was to run behavioral Verilog through yosys, get a gate-level netlist, and see it as a schematic.

The first half of the answer was easy and held up. The second half was wrong, and it was wrong in a way worth writing down, because the mistake is a common one and it does not feel like a mistake while you are making it.

The easy half: no, it doesn't

XSCHEM writes Verilog. src/verilog_netlist.c is a netlist backend, one of five alongside SPICE, Spectre, VHDL and tEDAx. Nothing reads Verilog back in. There is no Import menu in src/xschem.tcl at all.

What exists instead is a set of standalone awk scripts in src/, shipped and installed (src/Makefile.in:19) but wired to no menu item. You run them by hand:

ScriptInput
make_sch_from_spice.awkstructural SPICE netlist → .sch + .sym
make_sch_from_vhdl.awkVHDL entity / structural
make_sch_from_cadence_pin.awkCadence pin file
gschemtoxschem.awkgEDA gschem
viewdraw_import/ViewDraw

No Verilog entry. So the obvious move: yosys can emit SPICE, and there is already a SPICE importer. Bridge the gap with a format both sides speak.

yosys -p '
  read_verilog design.v
  hierarchy -top top
  proc; opt; fsm; opt; memory; opt
  techmap; opt
  dfflibmap -liberty sky130_fd_sc_hd__tt_025C_1v80.lib
  abc        -liberty sky130_fd_sc_hd__tt_025C_1v80.lib
  opt_clean
  write_spice netlist.sp'

awk -f src/make_sch_from_spice.awk netlist.sp

That much is defensible. It has real traps, and I listed them.

The traps

The killer

Pin-order mismatch. yosys's SPICE backend emits positional X lines. insert_symbol() at make_sch_from_spice.awk:105 recovers pin order by scraping B 5 records out of .sym files in the order they happen to appear. Nothing guarantees that order matches the module's port order. When it doesn't, the netlist is silently wrong — no error, just a schematic that lies.

Three more, less severe:

  • No *.PININFO. The SPICE backend doesn't emit it, so every pin direction defaults to B (inout). Layout degrades; connectivity survives.
  • Hardcoded sky130. Line 39 globs a specific symbol directory, line 59 strips the sky130_fd_sc_hd__ prefix, lines 51 and 61 set the device prefix and symbol type. All editable, none parameterized.
  • No wires. print_signals() at line 575 drops a lab_pin.sym at each pin carrying the net name. Connectivity is by label only, instances tiled on a grid at xoffset=1300 with a 920-unit column pitch. It reads as a connectivity dump, not a schematic.

Then I recommended writing make_sch_from_verilog.awk — a new importer, in awk, modeled on the existing ones, reusing print_sch (line 524), print_signals (575) and print_sym (676) verbatim. Named port connections in structural Verilog would kill the pin-order trap. Roughly 150 lines.

The question that broke it

are you sure Awk is the best language to use for this?

No. And the reason I had said awk was not a reason at all.

Every importer in that repo is awk. The build ships them as awk. The convention is unambiguous, and matching it felt like good citizenship — a maintainer opening the directory would find what they expected. But "this codebase does X" answers what will look consistent. It does not answer what will work. I had let the first question stand in for the second without noticing the substitution.

Worse, I had smuggled in a real technical argument that was doing no work: reuse the existing emit functions verbatim. That sounds like engineering. It is only engineering if those functions should exist.

The reframe: two choices, not one

There were two decisions here and I had collapsed them into one. Input format, and implementation language. The first matters more, and getting it right shrinks the second.

Input format

I had assumed the input was Verilog text. Structural yosys output looks regular — it is machine-generated, after all — but parsing it is not cheap:

  • Escaped identifiers. yosys emits things like \foo[3] , where the trailing space is part of the token terminator, required by the LRM.
  • Concatenations and part-selects: {a, b[3:0], 1'b0}.
  • assign aliases, attribute blocks (* ... *), block comments spanning lines.

awk is record-oriented on newlines. Handling that means hand-rolling a tokenizer inside it, and the failure mode of a subtly wrong tokenizer is the same as the pin-order trap: silent, plausible, wrong.

But nothing forced the input to be Verilog. yosys has write_json, which emits modules, cells, ports, netnames and connections as an already-parsed structure, bit-vector indexed. Choosing it does not make the parsing easier — it deletes the parsing problem. There is no Verilog parser in the design at all.

That is the shape of the better decision: not a smarter solution to the stated problem, but a move that makes the problem stop existing.

Language

With parsing gone, the remaining work is emitting a schematic. And here the codebase argues against its own convention, if you actually look at it: XSCHEM is a Tcl application. The C core exposes essentially everything through one dispatcher, and a Tcl importer can build the schematic through the live API instead of hand-writing file text.

VerbLocation
xschem instance <sym> <x> <y> <rot> <flip> <prop>scheduler.c:6665
xschem instance_pin_coord <inst> name <pin> → pin x yscheduler.c:6954
xschem setprop instance ...scheduler.c:12257
xschem instance_nodemap / instance_netscheduler.c:6887 / :6852

Those verbs delete the two worst parts of the awk design outright.

  1. Symbol pin geometry. insert_symbol() regexes B 5 records out of .sym files to recover pin names and coordinates. instance_pin_coord returns them from the symbol table XSCHEM already has loaded. Correct by construction — and pin-order mismatch, the killer trap, stops being a failure mode that can occur rather than one you defend against.
  2. File format drift. print_sch and print_sym hand-write .sch/.sym text. That text is versioned: XSCHEM_FILE_VERSION is "1.3" at src/xschem.h:27, and it moves. An external emitter silently falls behind it. Going through the API, it cannot.

There is a third, smaller win. The awk importers are wired to no menu precisely because they are external processes. A Tcl importer can be a File → Import item, which is what someone asking this question actually wanted.

What the machine said

Two things worth checking before recommending them, and both came back negative:

tcllib json:  NO  (can't find package json)
yosys:        not installed

The second is just a note — the pipeline is still right, it merely wasn't runnable there, which also means the claim about positional X lines in the SPICE backend went unverified locally.

The first is a live decision. A pure-Tcl JSON path needs either a tcllib dependency or a hand-rolled reader. For a tool meant to ship inside XSCHEM, hand-roll it: yosys JSON is machine-generated and regular, the reader is 60–80 lines, and that is a better trade than adding a package dependency or dragging Python into a two-stage pipeline as a third language.

Revised pipeline.

yosys:  read_verilog → … → abc -liberty → write_json out.json
tcl:    out.json → parse → xschem instance / instance_pin_coord → schematic

One thing survives unchanged from the first answer: the output is label-connected, with no routed wires. That is a layout problem, and it is independent of every choice above.


The part worth keeping

The awk recommendation was not absurd. Given the input format I had assumed, it was close to reasonable, and the reuse argument had genuine pull. That is exactly what made it hard to see: it was not a guess, it was a conclusion reached from a real premise I had never examined.

Two things generalize.

Consistency with a codebase is a tiebreaker, not a reason. It earns its weight only after the options are otherwise close. I had promoted it to first place and then decorated it with a technical justification — reuse those emit functions — that was really just consistency wearing a different hat. make_sch_from_spice.awk is awk because SPICE is genuinely line-oriented and nothing better existed when it was written. Neither of those facts transfers.

Interrogate the input format before the implementation. Most of the difficulty I was about to design around — the tokenizer, the escaped identifiers, the pin-order trap — was downstream of accepting Verilog text as the input. One flag on the yosys side removed it. The language debate was real, but it was second; and by the time the format question was settled, it had mostly answered itself.

It took one six-word question to surface all of this. Worth remembering how cheap that was, relative to the afternoon on the other side.

Repository: XSCHEM · branch open_pdk
Line references verified against the working tree at time of writing.
yosys SPICE-backend port-ordering claim: unverified locally (yosys not installed).

Wednesday, July 8, 2026

Beware - Fable 5 the token Hog. And, You Definitely Want the Caveman Mindset

When I did have Fable 5, for a week or so, till Trump killed it, I didn't notice anything special.

What I *have* noticed is that you burn through tokens *fast* if you ultracode with Fable 5. So, don't - unless someone else is paying :)

Sadly, it's taken two months and sheer luck to realize that Claude was hacking a C project using workarounds (bespoke address sanitizers created as needed) because it didn't find gdb or valgrind - when those two would have taken barely a minute to install.

Lesson - think about what you would need if you were hand coding and also ask Claude proactively. I lucked out seeing a message "no gdb/valgrind here".

The other thing that disappointed me - it's using the existing functionality of the tool to try and recreate fails. Once I asked it why it didn't just add hooks to print out trace information, it started flying. If only I'd known :)

So, there you have it - caveman + gdb + valgrind + trace hooks.

Enjoy!




Shipped - Wire Stubbing, Cadence Style Library Manager, Cliosoft SOS Visual Diff, Cadence Style Property Forms, etc..


https://youtu.be/gtipAPsql_M?is=YO0OvlpVY0nlW4VX


https://youtu.be/JOmzWO55FzM?is=qqPYxRrxg0ts58zk


https://youtu.be/NWJ0Bo_14CY?is=6vFUFcrUpdRQJ4jz




Tuesday, March 24, 2026

Who Needs Cadence Anymore (for Schematic Tree Reporting that is :)? Make Your Own Reporter with chatGPT!

You know what I mean, if you've used Cadence - the SHIFT-T thing that gives you the schematic tree can be VERY useful, at times.

No Cadence? No problem! The great thing about our version, it even has a --depth (-d) option. But, you do need a netlist to work with.


Say this is your netlist:
 
.subckt A in out vdd vss
XB1 n1 n2 B
XB2 n3 n4 B
XC1 n5 n6 C
XC2 n7 n8 C
.ends
.subckt B a b
XD1 x y D
XD2 x y D
XD3 x y D
XD4 x y D
XC1 p q C
XE1 p q E
.ends
.subckt C p q
R1 p q 1k
.ends
.subckt D p q
R2 p q 1k
.ends
.subckt E p q
R3 p q 1k
.ends
XTOP in out vdd vss A

This is what you'll get with just python3 report_hierarchy.py netlist.sp:
 
A
|----- B (2)
|      |----- C
|      |----- D (4)
|      \----- E
\----- C (2)

That's right. I wasn't sleeping in the presentation skills class. Don't report (1)!! Maximize info to ink ratio!

Getting a Useful VcXsrv Crash Dump

Winner of the first Nobel Prize in Physics ❯ tell me how to do the VcXsrv shortcut that I currently have in my Startup folder so that we get...