Electronics > PCB/EDA/CAD

[Solved] Generating SPICE Netlists and PCB Collateral with slotting



I'm having a tough time generating a SPICE netlist (gnetlist) and PCB collateral (gsch2pcb) with the same schematic (gschem).

I have a dual opamp package (lm358n) that is represented in the schematic by two separate op amp symbols that have slotting enabled.

If I give each one the same refdes=U1 and separate slots, the layout in PCB is as expected: one device. BUT I can't generate a SPICE netlist without errors because the refdes are the same and separate refdes are required for simulation.

If I set the refdes of each to separate values U1/U2, the SPICE netlist looks good and simulations work. BUT PCB now shows two devices with incorrect connections.

How can I get the best of both worlds?

It'd be nice if there was a way for gnetlist to know that the same refdes and different slots should be given different refdes in spice, say U1A and U1B. Is this a feature that I'm not aware of?


Going through the backend code for spice-sdb, it seems it should be able to handle this...

Is there some configuration I'm missing? Here is my current gnetlistrc:

--- Code: ---(hierarchy-uref-mangle "enabled")
(hierarchy-uref-order "prepend")
(hierarchy-uref-separator ":")

--- End code ---

The spice-sdb backend code:

--- Code: ---;; Custom get-uref function to append ".${SLOT}" where a component
;; has a "slot=${SLOT}" attribute attached.
;; NOTE: Original test for appending the ".<SLOT>" was this:
;;   (let ((numslots (gnetlist:get-package-attribute package "numslots"))
;;        (slot-count (length (gnetlist:get-unique-slots package)))
;;     (if (or (string=? numslots "unknown") (string=? numslots "0"))
(define get-uref
  (lambda (object)
    (let ((real_uref (gnetlist:get-uref object)))
      (if (null? (get-attrib-value-by-attrib-name object "slot"))
        (string-append real_uref "."
          (car (get-attrib-value-by-attrib-name object "slot")))

--- End code ---

I came across a workaround for this in some ngspice documentation. It seems like a reasonable flow.

Basically, it said to create a subckt definition that instantiates each of the opamps individually and use that subckt definition as the one that the symbol points to with attribute file.

Care has to be taken to ensure all interfaces are synced.

ngspice documentation for reference:
Section 8


[0] Message Index

There was an error while thanking
Go to full version