RTimothyEdwards / magic

Magic VLSI Layout Tool
Other
494 stars 103 forks source link

Segfault #134

Open kop316 opened 2 years ago

kop316 commented 2 years ago

Hello!

I am getting a segfault when I run this script:

#! /usr/bin/env bash
set -euo pipefail
#=========================================================================
# mflowgen-run
#=========================================================================
# Generator : /home/ctalbot/skywater/stanford_ee272/mflowgen/mflowgen/core/build_orchestrator.py

# Pre

rm -f .time_end
date +%Y-%m%d-%H%M-%S > .time_start
MFLOWGEN_STEP_HOME=$PWD
export design_name=GcdUnit

# Commands

cp inputs/adk/magicrc .magicrc
magic -noconsole -dnull run_antenna.tcl | tee outputs/antenna_check.log

# Post

cd $MFLOWGEN_STEP_HOME
date +%Y-%m%d-%H%M-%S > .time_end

run_antennd.tcl is:

# Copied from https://github.com/efabless/caravel/blob/master/gds/antenna_on_gds.tcl

gds read inputs/design_merged.gds

load $::env(design_name)

select top cell
extract do local
extract no capacitance
extract no coupling
extract no resisitance
extract no adjust
extract unique
extract

feedback save ./outputs/antenna.feedback.txt

antennacheck debug
antennacheck

quit

.magicrc file is ($PDKPATH is just the root of the open_pdks install path).

puts stdout "Sourcing design .magicrc for technology sky130A ..."

# Put grid on 0.005 pitch.  This is important, as some commands don't
# rescale the grid automatically (such as lef read?).

set scalefac [tech lambda]
if {[lindex $scalefac 1] < 2} {
    scalegrid 1 2
}

# drc off
drc euclidean on
# Change this to a fixed number for repeatable behavior with GDS writes
# e.g., "random seed 12345"
catch {random seed}

# Allow override of PDK path from environment variable PDKPATH
if {[catch {set PDKPATH $env(PDKPATH)}]} {
    set PDKPATH "/afs/ir.stanford.edu/class/ee272/PDKS/sky130A"
}

# loading technology
tech load $PDKPATH/libs.tech/magic/sky130A.tech

# load device generator
source $PDKPATH/libs.tech/magic/sky130A.tcl

# load bind keys (optional)
# source $PDKPATH/libs.tech/magic/sky130A-BindKeys

# set units to lambda grid 
snap lambda

# set sky130 standard power, ground, and substrate names
set VDD VPWR
set GND VGND
set SUB VSUBS

# Allow override of type of magic library views used, "mag" or "maglef",
# from environment variable MAGTYPE

if {[catch {set MAGTYPE $env(MAGTYPE)}]} {
   set MAGTYPE mag
}

# add path to reference cells
if {[file isdir ${PDKPATH}/libs.ref/${MAGTYPE}]} {
    addpath ${PDKPATH}/libs.ref/${MAGTYPE}/sky130_fd_pr
    addpath ${PDKPATH}/libs.ref/${MAGTYPE}/sky130_fd_io
    addpath ${PDKPATH}/libs.ref/${MAGTYPE}/sky130_fd_sc_hd
    addpath ${PDKPATH}/libs.ref/${MAGTYPE}/sky130_fd_sc_hdll
    addpath ${PDKPATH}/libs.ref/${MAGTYPE}/sky130_fd_sc_hs
    addpath ${PDKPATH}/libs.ref/${MAGTYPE}/sky130_fd_sc_hvl
    addpath ${PDKPATH}/libs.ref/${MAGTYPE}/sky130_fd_sc_lp
    addpath ${PDKPATH}/libs.ref/${MAGTYPE}/sky130_fd_sc_ls
    addpath ${PDKPATH}/libs.ref/${MAGTYPE}/sky130_fd_sc_ms
    addpath ${PDKPATH}/libs.ref/${MAGTYPE}/sky130_osu_sc
    addpath ${PDKPATH}/libs.ref/${MAGTYPE}/sky130_osu_sc_t18
    addpath ${PDKPATH}/libs.ref/${MAGTYPE}/sky130_ml_xx_hd
    addpath ${PDKPATH}/libs.ref/${MAGTYPE}/sky130_sram_macros
} else {
    addpath ${PDKPATH}/libs.ref/sky130_fd_pr/${MAGTYPE}
    addpath ${PDKPATH}/libs.ref/sky130_fd_io/${MAGTYPE}
    addpath ${PDKPATH}/libs.ref/sky130_fd_sc_hd/${MAGTYPE}
    addpath ${PDKPATH}/libs.ref/sky130_fd_sc_hdll/${MAGTYPE}
    addpath ${PDKPATH}/libs.ref/sky130_fd_sc_hs/${MAGTYPE}
    addpath ${PDKPATH}/libs.ref/sky130_fd_sc_hvl/${MAGTYPE}
    addpath ${PDKPATH}/libs.ref/sky130_fd_sc_lp/${MAGTYPE}
    addpath ${PDKPATH}/libs.ref/sky130_fd_sc_ls/${MAGTYPE}
    addpath ${PDKPATH}/libs.ref/sky130_fd_sc_ms/${MAGTYPE}
    addpath ${PDKPATH}/libs.ref/sky130_osu_sc/${MAGTYPE}
    addpath ${PDKPATH}/libs.ref/sky130_osu_sc_t18/${MAGTYPE}
    addpath ${PDKPATH}/libs.ref/sky130_ml_xx_hd/${MAGTYPE}
    addpath ${PDKPATH}/libs.ref/sky130_sram_macros/${MAGTYPE}
}

# add path to GDS cells

# add path to IP from catalog.  This procedure defined in the PDK script.
catch {magic::query_mylib_ip}
# add path to local IP from user design space.  Defined in the PDK script.
catch {magic::query_my_projects}
kop316 commented 2 years ago

Here is the gds design_merged_gds.zip

And the logs I get

Magic 8.3 revision 263 - Compiled on Mon Feb 21 14:42:58 EST 2022.
Starting magic under Tcl interpreter
Using the terminal as the console.
Using NULL graphics device.
Processing system .magicrc file
Sourcing design .magicrc for technology sky130A ...
2 Magic internal units = 1 Lambda
Input style sky130(vendor): scaleFactor=2, multiplier=2
The following types are not handled by extraction and will be treated as non-electrical types:
    mvobsactive ubm 
Scaled tech values by 2 / 1 to match internal grid scaling
Loading sky130A Device Generator Menu ...
Loading "run_antenna.tcl" from command line.
Warning: Calma reading is not undoable!  I hope that's OK.
Library written using GDS-II Release 3.0
Library name: sky130_fd_sc_hd__xor3_4
Reading "GcdUnit".
Reading "sky130_fd_sc_hd__clkinv_4".
Reading "sky130_fd_sc_hd__buf_4".
Reading "sky130_fd_sc_hd__clkinv_2".
Reading "sky130_fd_sc_hd__dfrtp_2".
Reading "sky130_fd_sc_hd__dfrbp_2".
Reading "sky130_fd_sc_hd__nand2_1".
Reading "sky130_fd_sc_hd__nor3b_1".
Reading "sky130_fd_sc_hd__nor2_1".
Reading "sky130_fd_sc_hd__clkinv_1".
Reading "sky130_fd_sc_hd__o21ai_1".
Reading "sky130_fd_sc_hd__o31ai_1".
Reading "sky130_fd_sc_hd__and2_0".
Reading "sky130_fd_sc_hd__o22ai_1".
Reading "sky130_fd_sc_hd__a21o_2".
Reading "sky130_fd_sc_hd__sdlclkp_4".
Reading "sky130_fd_sc_hd__conb_1".
Reading "sky130_fd_sc_hd__nand2b_1".
Reading "sky130_fd_sc_hd__xor2_1".
Reading "sky130_fd_sc_hd__xnor2_1".
Reading "sky130_fd_sc_hd__fa_2".
Reading "sky130_fd_sc_hd__o21a_1".
Reading "sky130_fd_sc_hd__o21bai_1".
Reading "sky130_fd_sc_hd__a21oi_1".
Reading "sky130_fd_sc_hd__nand3b_1".
Reading "sky130_fd_sc_hd__a31oi_1".
Reading "sky130_fd_sc_hd__nand3_1".
Reading "sky130_fd_sc_hd__nor4_1".
Reading "sky130_fd_sc_hd__nand4_1".
Reading "sky130_fd_sc_hd__o211ai_1".
Reading "sky130_fd_sc_hd__a22o_1".
Reading "sky130_fd_sc_hd__tapvpwrvgnd_1".
Reading "sky130_fd_sc_hd__decap_12".
Reading "sky130_fd_sc_hd__decap_8".
Reading "sky130_fd_sc_hd__decap_6".
Reading "sky130_fd_sc_hd__decap_4".
Reading "sky130_fd_sc_hd__decap_3".
Reading "sky130_fd_sc_hd__fill_8".
Reading "sky130_fd_sc_hd__fill_4".
Reading "sky130_fd_sc_hd__fill_2".
Reading "sky130_fd_sc_hd__fill_1".
Reading "M2M3_PR".
Reading "L1M1_PR".
Reading "M1M2_PR".
Reading "M1M2_PR_M".
Reading "M3M4_PR".
Reading "M1M2_PR_MR".
Reading "GcdUnit_VIA0".
Reading "GcdUnit_VIA1".
Reading "GcdUnit_VIA2".
Reading "GcdUnit_VIA3".
Reading "GcdUnit_VIA4".
Reading "GcdUnit_VIA5".
Reading "GcdUnit_VIA6".
Reading "GcdUnit_VIA7".
Reading "GcdUnit_VIA8".
Reading "GcdUnit_VIA9".
Usage: extract do option
   or  extract no option
where option is one of:
  adjust            compensate R and C hierarchically
  all           all options
  capacitance       extract substrate capacitance
  coupling      extract coupling capacitance
  length            compute driver-receiver pathlengths
  local         put all generated files in the current directory
  resistance        estimate resistance
  labelcheck        check for connections through sticky labels
  aliases       output all net name aliases
Processing M1M2_PR_MR
Processing sky130_fd_sc_hd__o21bai_1
Processing sky130_fd_sc_hd__clkinv_4
Processing sky130_fd_sc_hd__fill_8
Processing sky130_fd_sc_hd__nand4_1
Processing sky130_fd_sc_hd__o21a_1
Processing sky130_fd_sc_hd__decap_8
Processing sky130_fd_sc_hd__decap_3
Processing sky130_fd_sc_hd__nand3_1
Processing sky130_fd_sc_hd__nand2b_1
Processing sky130_fd_sc_hd__nor4_1
Processing sky130_fd_sc_hd__a21oi_1
Processing sky130_fd_sc_hd__decap_4
Processing sky130_fd_sc_hd__a31oi_1
Processing sky130_fd_sc_hd__nand3b_1
Processing M3M4_PR
Processing sky130_fd_sc_hd__a21o_2
Processing sky130_fd_sc_hd__fa_2
Processing sky130_fd_sc_hd__dfrbp_2
Processing sky130_fd_sc_hd__clkinv_2
Processing sky130_fd_sc_hd__decap_12
Processing sky130_fd_sc_hd__sdlclkp_4
Processing M1M2_PR_M
Processing sky130_fd_sc_hd__and2_0
Processing sky130_fd_sc_hd__o211ai_1
Processing sky130_fd_sc_hd__nand2_1
Processing sky130_fd_sc_hd__o22ai_1
Processing sky130_fd_sc_hd__nor2_1
Processing sky130_fd_sc_hd__o21ai_1
Processing sky130_fd_sc_hd__nor3b_1
Processing sky130_fd_sc_hd__o31ai_1
Processing sky130_fd_sc_hd__xor2_1
Processing sky130_fd_sc_hd__dfrtp_2
Processing sky130_fd_sc_hd__buf_4
Processing sky130_fd_sc_hd__xnor2_1
Processing sky130_fd_sc_hd__decap_6
Processing sky130_fd_sc_hd__clkinv_1
Processing GcdUnit_VIA4
Processing GcdUnit_VIA3
Processing GcdUnit_VIA2
Processing sky130_fd_sc_hd__fill_4
Processing GcdUnit_VIA9
Processing GcdUnit_VIA8
Processing GcdUnit_VIA7
Processing L1M1_PR
Processing sky130_fd_sc_hd__conb_1
Processing sky130_fd_sc_hd__fill_2
Processing sky130_fd_sc_hd__a22o_1
Processing sky130_fd_sc_hd__tapvpwrvgnd_1
Processing sky130_fd_sc_hd__fill_1
Processing GcdUnit_VIA6
Processing GcdUnit_VIA5
Processing M1M2_PR
Processing GcdUnit_VIA1
Processing GcdUnit_VIA0
Processing M2M3_PR
Processing GcdUnit
Extracting sky130_fd_sc_hd__conb_1 into sky130_fd_sc_hd__conb_1.ext:
Extracting GcdUnit into GcdUnit.ext:
Reading extract file.
Building flattened netlist.
Running antenna checks.
   100 gates analyzed.
Cell: sky130_fd_sc_hd__a22o_1_12
Antenna violation detected at plane metal3
Effective antenna ratio 444.139 > limit 400
Gate rect (12127 13919) to (12157 14119)
Antenna rect (12249 19865) to (12315 19868)
   200 gates analyzed.
   300 gates analyzed.
./mflowgen-run: line 18: 26836 Segmentation fault      (core dumped) magic -noconsole -dnull run_antenna.tcl
     26837 Done                    | tee outputs/antenna_check.log
RTimothyEdwards commented 2 years ago

Thanks, I should be able to debug from the posted GDS file.

RTimothyEdwards commented 2 years ago

extflat/EFantenna.c line 252 should be EFFlatDone(NULL) and not EFFlatDone().

I am doing some other bug fixes in magic, but I'll push that fix in a bit. Thanks for the example!

kop316 commented 2 years ago

extflat/EFantenna.c line 252 should be EFFlatDone(NULL) and not EFFlatDone().

I am doing some other bug fixes in magic, but I'll push that fix in a bit. Thanks for the example!

Awesome, thank you for the fast turnaround!