puts stdout "Sourcing design magicrc.well for technology $::env(PDK) ..."

# Put internal grid on 0.005 pitch.  This is important to match vendor file
# input (as opposed to SCMOS-style layout.  The default lambda grid is 0.05um).

set scalefac [tech lambda]

if {[string first sky130 $::env(PDK)] >= 0} {
    if {[lindex $scalefac 1] < 2} {
        scalegrid 1 2
    }
    # set sky130 standard power, ground, and substrate names
    set VDD VPWR
    set GND VGND
    set SUB VSUBS

} elseif {[string first gf180mcu $::env(PDK)] >= 0} {
    if {[lindex $scalefac 1] < 10} {
        scalegrid 1 10
    }
    # set gf180mcu standard power, ground, and substrate names
    set VDD VDD
    set GND VSS
    set SUB VSUBS

} else {
	puts "ERROR: Unknown PDK - $::env(PDK)"
}

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

tech load $::env(LVS_ROOT)/tech/$::env(PDK)/$::env(PDK).tech

# set units to lambda grid 
snap lambda

# BE-EDIT: BE checks work on gds. do not want to load from libraries.

# 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 ${PDK_ROOT}/gf180mcuC/libs.ref/${MAGTYPE}]} {
#    addpath ${PDK_ROOT}/gf180mcuC/libs.ref/${MAGTYPE}/gf180mcu_fd_pr
#    addpath ${PDK_ROOT}/gf180mcuC/libs.ref/${MAGTYPE}/gf180mcu_mcu7t5v0
#    addpath ${PDK_ROOT}/gf180mcuC/libs.ref/${MAGTYPE}/gf180mcu_mcu9t5v0
#    addpath ${PDK_ROOT}/gf180mcuC/libs.ref/${MAGTYPE}/gf180mcu_fd_io
#    addpath ${PDK_ROOT}/gf180mcuC/libs.ref/${MAGTYPE}/gf180mcu_fd_ip_sram
#} else {
#    addpath ${PDK_ROOT}/gf180mcuC/libs.ref/gf180mcu_fd_pr/${MAGTYPE}
#    addpath ${PDK_ROOT}/gf180mcuC/libs.ref/gf180mcu_fd_sc_mcu7t5v0/${MAGTYPE}
#    addpath ${PDK_ROOT}/gf180mcuC/libs.ref/gf180mcu_fd_sc_mcu9t5v0/${MAGTYPE}
#    addpath ${PDK_ROOT}/gf180mcuC/libs.ref/gf180mcu_fd_io/${MAGTYPE}
#    addpath ${PDK_ROOT}/gf180mcuC/libs.ref/gf180mcu_fd_ip_sram/${MAGTYPE}
#}
#
## 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}
