;; Copyright 2019-2021 SkyWater PDK Authors
;;
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;;     https://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.
;;
;; This code is *alternatively* available under a BSD-3-Clause license, see
;; details in the README.md at the top level and the license text at
;; https://github.com/google/skywater-pdk-libs-sky130_bag3_pr/blob/master/LICENSE.alternative
;;
;; SPDX-License-Identifier: BSD-3-Clause OR Apache 2.0


printf("STARTING CDSINIT\n")

; load configuration skill scripts.
let( (configFileList file path saveSkillPath)
    configFileList = '(
                    )
    ; paths of the configuration files.
    path = strcat(
              ".  ~  "
              prependInstallPath("local ")
             )
    saveSkillPath=getSkillPath()
    setSkillPath(path)

    foreach(file configFileList
       if(isFile(file) then
          loadi(file)
         )
    )
    setSkillPath(saveSkillPath)
)

; load key bindings scripts
let( (bindKeyFileList file path saveSkillPath)
    bindKeyFileList = '(
                   "leBindKeys.il"
                   "schBindKeys.il"
                    )
    ; paths of key binding scripts
    path = strcat(
              ".  ~  "
              prependInstallPath("local ")
              prependInstallPath("samples/local")
             )
    saveSkillPath=getSkillPath()
    setSkillPath(path)

    foreach(file bindKeyFileList
       if(isFile(file ) then
          loadi(file)
         )
    )
    setSkillPath(saveSkillPath)
)

sstatus(writeProtect nil)

let((skillPath)
   skillPath= strcat(
    ". ~ "                                          ; Current & home directory
    prependInstallPath("samples/techfile ")         ; sample source technology files
   )
   setSkillPath(skillPath)
)

;
; check CALIBRE_HOME
;
cal_home=getShellEnvVar("CALIBRE_HOME")
if( cal_home==nil then
    cal_home=getShellEnvVar("MGC_HOME")
    if( cal_home!=nil then
        printf("// CALIBRE_HOME environment variable not set; setting it to value of MGC_HOME\n");
    )
)

if( cal_home!=nil && isDir(cal_home) && isReadable(cal_home) then

    ; Load calibre.skl or calibre.4.3.skl, not both!

    if( getShellEnvVar("MGC_CALIBRE_REALTIME_VIRTUOSO_ENABLED") &&
        getShellEnvVar("MGC_REALTIME_HOME") && dbGetDatabaseType()=="OpenAccess" then
      load(strcat(getShellEnvVar("MGC_REALTIME_HOME") "/lib/calibre.skl"))
    else
      ; Load calibre.skl for Cadence versions 4.4 and greater
      load(strcat(cal_home "/lib/calibre.skl"))
    )

    ;;;;Load calibre.4.3.skl for Cadence version 4.3
    ;;; load(strcat(cal_home "/lib/calibre.4.3.skl"))

else

    ; CALIBRE_HOME is not set correctly. Report the problem.

    printf("//  Calibre Error: Environment variable ")

    if( cal_home==nil || cal_home=="" then
        printf("CALIBRE_HOME is not set.");
    else
        if( !isDir(cal_home) then
            printf("CALIBRE_HOME does not point to a directory.");
        else
            if( !isReadable(cal_home) then
                printf("CALIBRE_HOME points to an unreadable directory.");
            )
        )
    )
    printf(" Calibre Skill Interface not loaded.\n")

    ; Display a dialog box message about load failure.

    hiDisplayAppDBox(
        ?name           'MGCHOMEErrorDlg
        ?dboxBanner     "Calibre Error"
        ?dboxText       "Calibre Skill Interface not loaded."
        ?dialogType     hicErrorDialog
        ?dialogStyle    'modal
       ?buttonLayout   'Close
    )
)

printf("END OF STANDARD CONFIG SETTINGS\n")

; set default editor
editor = "emacs"

envLoadFile( "./.cdsenv" )

if( isFile( ".cdsenv.personal" ) then
    envLoadFile( ".cdsenv.personal" )
)

cdlOutKeys = list(nil
    'incFILE                   "$BAG_TECH_CONFIG_DIR/calibre_setup/source.added"
)

if( isFile( ".cdsinit.personal" ) then
    load(".cdsinit.personal")
)

; open library manager
ddsOpenLibManager()


;; Set Default Model Files.  Note the "#;" de-selects the model call.

setModelFiles=strcat(
   " " getShellEnvVar("PDK_HOME") "/MODELS/SPECTRE/" getShellEnvVar("METAL_STACK") "/Models/design_wrapper.lib.scs;tt_fet"
   " " getShellEnvVar("PDK_HOME") "/MODELS/SPECTRE/" getShellEnvVar("METAL_STACK") "/Models/design_wrapper.lib.scs;tt_cell"
   " " getShellEnvVar("PDK_HOME") "/MODELS/SPECTRE/" getShellEnvVar("METAL_STACK") "/Models/design_wrapper.lib.scs;tt_parRC"
   " " getShellEnvVar("PDK_HOME") "/MODELS/SPECTRE/" getShellEnvVar("METAL_STACK") "/Models/design_wrapper.lib.scs;tt_rc"
   " " getShellEnvVar("PDK_HOME") "/MODELS/SPECTRE/" getShellEnvVar("METAL_STACK") "/Models/design_wrapper.lib.scs;npn_t"
)

envSetVal("spectre.envOpts" "modelFiles" 'string setModelFiles)
envSetVal("spectre.envOpts" "controlMode" 'string "batch")


printf("END OF CUSTOM CONFIG SETTINGS\n")
