( ESNUG 339 Item 9 ) --------------------------------------------- [1/13/00]

From: Gregg Lahti <glahti@sedona.ch.intel.com>
Subject: A Freeware User-Friendly Synopsys License Fetching TCL Procedure

Hi, John,

In the midst of converting our DC scripts to TCL scripts for use in 99.05,
I noticed that a few things with DC that seem broken:

  1) If you already have a license (say HDL-Compiler) and you request 
     another one, DC offers an error return status with no nice warning.
     Not very useful.

  2) The list_license command in dc_shell-t (TCL) mode is broke.  One
     cannot do a "set licenses [lic_license]" and expect the output
     to be in the $licenses variable.  Instead, one must stuff the
     output to a file and then parse the file to get the actual results.
     How ugly & rude!

Hence, I wrote a modular TCL procedure to fetch a license & provide correct
output status accordingly.  The procedure is setup to retry over for a
period of time (it's user settable, but I just hardcoded the variable in
the procedure.)  We use it to be "license usage friendly".

  #   usage:  P_get_lic {[license]}
  # example:  P_get_lic {HDL-Compiler} 
  #
  # procedure to get a license.  Note that DC gives error status
  # if we already have the license.  Hence, must determine if we
  # do have the license first before we actually get it.
  # Also re-check for the license in 60 second intervals for
  # 1 hour before we exit with an error if we can't get a license.

  proc P_get_lic {ln} {

   set fetch_license 1
   set sleep_val 60;          # sleep in seconds we wait for a license
   set max_timeout 60;        # number of 60-second waits until we die

   # First must determine which licenses we have.  To do this
   # we get the output of list_licenses into a TCL variable.
   #
   # Hack! DC is broke & can't set list_lic output to a variable,
   # so must stuff it to a tmp file & read it back in.  Use process
   # id (pid) in filename as a safer-alternative, touch & rm -rf to
   # first to be extra safe

   exec touch [eval pid].tmp
   exec rm -rf [eval pid].tmp
   list_licenses > [eval pid].tmp
   set licenses [exec cat [eval pid].tmp]
   exec rm -rf [eval pid].tmp

   # now that we have a TCL variable with the list_license output,
   # strip out the crap that DC uselessly puts in and parse the list

   regsub {Licenses in use:} $licenses {} licenses
   foreach checkedout_license $licenses {
      if [string match $checkedout_license $ln] {
         set fetch_license 0
      }
   }
   if {$fetch_license == 1} {
      set sleep_time 0
      set dc_status [get_license $ln];
      while { ($dc_status == 0) && ($sleep_time < $max_timeout) } {
         if {$sleep_time == 0} {
            set current_time [exec date]
            echo "Info: waiting for license $ln @ $current_time\n";
         }
         sh sleep $sleep_val;
         set sleep_time [expr $sleep_time + $sleep_val]
         set dc_status [get_license $ln]
      }
      if {$dc_status == 0} {
         echo "Error: Cannot get license $ln after $sleep_time seconds, dying!\n";
         return 0
      } else {
         echo "Info: checked out license $ln\n";
         return 1
      }
   } else {
      echo "Info: already have license, continuing along\n";
      return 1
   }
  }
  ## end P_get_lic


For those engineers who are always on the cheap-as-possible budget, you
might find this TCL script useful.  ;^)

    - Gregg Lahti
      Intel Corp                                    Chandler, AZ



 Sign up for the DeepChip newsletter.
Email
 Read what EDA tool users really think.


Feedback About Wiretaps ESNUGs SIGN UP! Downloads Trip Reports Advertise

"Relax. This is a discussion. Anything said here is just one engineer's opinion. Email in your dissenting letter and it'll be published, too."
This Web Site Is Modified Every 2-3 Days
Copyright 1991-2024 John Cooley.  All Rights Reserved.
| Contact John Cooley | Webmaster | Legal | Feedback Form |

   !!!     "It's not a BUG,
  /o o\  /  it's a FEATURE!"
 (  >  )
  \ - / 
  _] [_     (jcooley 1991)