Hi, I'm unable to do extraction with and without p...
# ieee-sscs-dc-23
a
Hi, I'm unable to do extraction with and without parasitic using magic on layouts made with klayout. I'm currently working on a makefile to perform most of the actions required on analog design, like lvs, drc, netlist extraction, etc. Klayout actions are working fine, but magic ones aren't.
Copy code
make TOP=resistor magic     # Open magic and load "resistor.gds" with 72 drc errors that klayout was not reporting
make TOP=resistor magic-lvs # Generates a netlist without parasitics. I have not validated it
make TOP=resistor magic-pex # Generates a netlist with parasitics. I have not validated it

make TOP=waffle_1984 magic      # Open layout with +2000 drc errors that klayout was not reporting
make TOP=waffle_1984 magic-lvs  # Is not working
make TOP=waffle_1984 magic-pex  # Is not working

make TOP=pmos1f magic      # Is not working
make TOP=bjt magic         # Is not working
make TOP=cap_mim_2f magic  # Is not working
make TOP=inv_sample magic  # Is not working
All of the gds examples work fine with klayout, and are drc and lvs clean.
t
What part of it isn't working? I don't have any knowledge about how the makefile is set up. Is "make TOP=waffle_1984 magic-lvs" failing to generate a netlist, failing to run LVS, or failing to be LVS clean? The last four look like they're supposed to just run magic as an editor, so what does it mean that they are not working?
I do see an issue with the waffle_1984 extraction that might be caused by tightly overlapping cells in arrays. You might try flattening before extraction (but don't save the flattened version, just use it for extraction).
a
magic-lvs
is a very bad name for the action of generate a netlist without parasitics, since LVS is done with
netgen
. The
magic
rule just load the gds into magic, if that fails then no other
magic-*
rule will work. The
<http://magic.mk|magic.mk>
makefile has the following instructions. These are declared as variables and passed as heredoc to magic.
Copy code
# This are the variables
TOP=resistor
TOP_GDS=resistor.gds
TOP_GDS_CELL=resistor
TOP_GDS_DIR=./
Copy code
# MAGIC_ROUTINE_LOAD

drc off
if { "$(suffix $(TOP_GDS))" == ".gds" } {
    # This is expanded to ".gds" == ".gds"
	puts "Reading a gds"
	gds readonly true
	gds rescale false
	gds read $(TOP_GDS)
	getcell $(TOP_GDS_CELL)
	load $(TOP_GDS_CELL)
	box 0 0 0 0
} else {
	load $(TOP_GDS)
}
Copy code
# MAGIC_ROUTINE_LVS

$(MAGIC_ROUTINE_LOAD)
extract
ext2spice lvs
ext2spice -o "$(TOP_GDS_DIR)/$(TOP_GDS_CELL)_extracted.spice"

puts "Created netlist file $(TOP_GDS_DIR)/$(TOP_GDS_CELL)_extracted.spice"
quit -noprompt
Copy code
# MAGIC_ROUTINE_PEX

$(MAGIC_ROUTINE_LOAD)
flatten $(TOP_GDS_CELL)_pex
load $(TOP_GDS_CELL)_pex
box values 0 0 0 0
extract all
ext2sim labels on
ext2sim
extresist tolerance 10
extresist all
ext2spice lvs
ext2spice extresist on
ext2spice cthresh 0
ext2spice -o "$(TOP_GDS_DIR)/$(TOP_GDS_CELL)_pex.spice"
puts "Created pex file $(TOP_GDS_DIR)/$(TOP_GDS_CELL)_pex.spice"
quit -noprompt
The pex routine is making flattening al the beginning, so that should not be the problem The instructions were originally on the custom magicrc, but that doesn't work either
t
@aquiles viza: For the resistor, at least, the GDS read routine in magic needs to be given the option
gds flatten true
before
gds read
.
gds flatten
is a common option that works around other layout tools' tendency to put contact cuts in their own cells, which interferes with magic's derived layer definitions. That can also be worked around with some complicated detection and handling of bare contacts in the GDS read routines which apparently I didn't put in the gf180mcu tech file, but
gds flatten true
is a quicker/simpler way to deal with the issue.
Anyway, if you add that line to the script, the 72 errors in the resistor layout will go away and it will be DRC clean.
The
waffle_1984
is a similar problem but some of the cells are too complex to be noticed by
gds flatten true
(which flattens cells with fewer than 10 rectangles), requiring a bit more targeted read-in:
Copy code
gds flatten true
gds flatglob pmos*
gds flatglob via*
gds read waffle_1984
load waffle_1984
Then this shows as DRC clean (and will probably extract cleanly, too).
The BJT has some DRC issue in magic that I haven't looked at yet, as it is claiming violation of a rule for tap spacing across a butted junction on what is most definitely not a butted junction. I'm not sure if that's what you meant by "not working"?
I expect the four "not working" ones you listed at the bottom are due to this:
Copy code
Reading "$$$CONTEXT_INFO$$$"
I do not know which tool generates the "$$$CONTEXT_INFO$$$" cell or what it is used for, but it ends up as a top-level cell which then interferes with a lot of processes (such as the script).
Although I don't see anything specific in the script that would cause a problem, as long as TOP_GDS_CELL is correct.
a
I add the
gds flatten true
and the glob pattern lines before
read gds
Then I remove the line `gds readonly true`` and that fix a lot of problems. In the resistor, drc errors didn't go away. Some of them are the following
Copy code
Error area #2:
Diffusion contact width < 0.23um (CO.1 + 2 * CO.6)
Error area #3:
Diffusion contact width < 0.23um (CO.1 + 2 * CO.6)
Error area #4:
Diffusion contact width < 0.23um (CO.1 + 2 * CO.6)
Error area #5:
Diffusion contact width < 0.23um (CO.1 + 2 * CO.6)
Error area #6:
Diffusion contact width < 0.23um (CO.1 + 2 * CO.6)
Error area #7:
Diffusion contact width < 0.23um (CO.1 + 2 * CO.6)
Error area #8:
Diffusion contact width < 0.23um (CO.1 + 2 * CO.6)
Diffusion contact width < 0.23um (CO.1 + 2 * CO.6)
Klayout only drc errors are the density/coverage ones, as always. The use of
gds readonly true
makes magic throw this error
Copy code
Library name: LIB
Error while reading cell "(UNNAMED)" (byte position 62): Incompatible scale factor of 5e-09, must be 1e-9.
Cannot read this file in read-only mode.
Cell bjt couldn't be read
Removing it allows me to open all the layouts that doesn't work before. bjt has 5 drc errors as you said, cap_mim_2f has 0, inv_sample has 0, pmos1f has 0. It seems that all of them makes lvs and pex extraction. waffle_1984 has 0 drc errors and extraction without parasitics gives a netlist with1966 fets, not 1984. I have to validate it. Extraction with parastics still don't work and ends with this line
Extracting waffle_1984_pex into waffle_1984_pex.ext:
t
@aquiles viza: I would have sworn that just
gds flatten true
worked for me last time, but I can confirm that the errors in the resistor are still showing up. I have to add
gds flatglob rectangle*
and
gds flatglob compass*
in addition to the
gds flatglob via*
to get that one to read correctly.
a
Yes, adding those globs reduces the drc count to 0.
The original Pcell that generates the resistor fingers applies a flatten on the cell, removing all the
rectangle*
and
compass*
stuff. It seems mandatory to have those cells flattened to avoid this kind of problems.
t
I didn't have any problem doing a parasitic extraction of waffle_1984 and the output has 1984 devices in it.
The extraction part (where you said it "ends with this line") should only take a few seconds.
a
This are the updated magic commands I'm using
Copy code
define MAGIC_ROUTINE_LOAD =
gds rescale false

gds flatten true
gds flatglob pmos*
gds flatglob via*
gds flatglob compass*
gds flatglob rectangle*

gds read $(TOP_GDS)

getcell $(TOP_GDS_CELL)
load $(TOP_GDS_CELL)
box 0 0 0 0
endef
Copy code
define MAGIC_ROUTINE_LVS =
drc off
$(MAGIC_ROUTINE_LOAD)

extract
ext2spice lvs
ext2spice -o "$(TOP_GDS_DIR)/$(TOP_GDS_CELL)_extracted.spice"

puts "Created netlist file $(TOP_GDS_DIR)/$(TOP_GDS_CELL)_extracted.spice"
quit -noprompt
endef
Copy code
define MAGIC_ROUTINE_PEX =
drc off
$(MAGIC_ROUTINE_LOAD)

flatten $(TOP_GDS_CELL)_pex
load $(TOP_GDS_CELL)_pex
box values 0 0 0 0
#box 0 0 0 0

extract all
ext2sim labels on
ext2sim
extresist tolerance 10
extresist all
ext2spice lvs
ext2spice extresist on
ext2spice cthresh 0
ext2spice -o "$(TOP_GDS_DIR)/$(TOP_GDS_CELL)_pex.spice"

puts "Created pex file $(TOP_GDS_DIR)/$(TOP_GDS_CELL)_pex.spice"

quit -noprompt
endef
It seems that for waffle_1984, lvs netlist extraction sometimes work, maybe is related with memory limitations on my machine. I've run lvs netlist extraction on waffle_1984 and it gives me 1966 pfet_03v3 devices again. I think this could be related with magic version or pdk configuration. I'm using magic 8.3.459 and openpdk commit bdc9412b3e468c102d01b7cf6337be06ec6e9c9a (2024.01.10)
This is the log file from
make TOP=waffle_1984 magic-pex
m
@aquiles viza magic will not automatically flatten cells that have overlapping devices - each cell will contain a separate device. It will also not recognized devices formed by layer interactions in different hierarchies. For example, the implant layers, diffusion layers, and poly layers must all be on the same hierarchy. Use
flatglob
if they are not. With
flatglob
, you’ll need to flatten all the sub-hierarchies too. You can check the
ext
files or the final
spice
to make sure everything is as expected.
t
@aquiles viza: There is something weird going on with the script in which no commands after
extract all
are executed. I have no idea why. When I said that it worked for me, I had run all the commands on the command line in interactive magic. If I run in batch mode, I get the same thing you're getting.
@aquiles viza: Okay, I found the problem. You have the wrong command-line options to run magic in batch mode. In
<http://magic.mk|magic.mk>
, change:
Copy code
MAGIC_BATCH=$(MAGIC) -nowrapper -nowindow -D -dnull
to
Copy code
MAGIC_BATCH=$(MAGIC) -dnull -noconsole
and the pex-extraction should work.
(By the way, the command
getcell $(TOP_GDS_CELL)
in your script does nothing. It instantiates the loaded cell in the default layout, but the cell does not have to be instantiated to be loaded. That line can be removed from the script.)
a
It worked!! Removing the -D and -nowrapper parameters from MAGIC_BATCH allows waffle_1986 lvs and pex extraction, which uses 16MB. Why extraction always takes a different ordering on the parasitics? I would like to store those files on git but It seems useless if they are going to change always. Thanks @Tim Edwards and @Mitch Bailey for your help. I will definitely bother again with simulation problems.
Oh no, neither the
waffle_1984
lvs nor pex extraction has ports. I'm sharing only the lvs netlist. This layout uses Metal3 and Metal5 label layers.
m
t
@aquiles viza: Parasitics are saved in hash tables and the hash order changes. I would need to do some kind of efficient sorting to get them to output in a specific order. It's doable, but would take some time to code up.
a
Hi Tim, sorry for the ultra-late reply. If the hashes are different between runs it means that a pseudo-random number generator is used somewhere. With a fixed seed every run will be the same. I suppose that this PRNG is not the same used in the montecarlo simulations, if that's the case the only solution I see is to create a specific generator for the hash generator used on parasitics. I'm giving importance to this because then we can store pex and clean extractions on git.
Hi, I'm still with the port problem. I've added the
readspice
directive pointing to a schematic netlist but it is not able to find the labels (M3 and M5 labels).
Copy code
Annotating port orders from waffle_1984_noprefix.spice
Annotating cell waffle_1984
Crosshair not in a valid window for this command
Couldn't find label S
Couldn't find label G
Couldn't find label D
In the attached files,
extraction.sh
performs both clean and parasitic netlist extraction but both ignore the ports.
t
There are no ports in the top level cell
waffle_1984
. The labels are defined inside the subcell
external-guardring-trck-3-5.5-10-216.0
. That's why the labels cannot be found.
(
G
is in subcell
gate_mesh-5.5-0.5-2.25
) (as an aside, use of dashes and periods in cell names is generally not a good idea.)
a
Thanks Tim, I'm going to test that