( ESNUG 291 Item 6 ) ----------------------------------------------- [5/27/98]

From: Peter Kamphuis <kamphuis@hl.siemens.de>
Subject: "Synapropos" -- A Synopsys Equivalent Of The UNIX "Apropos" Command

Hi John,

Recently I had the problem that I didn't know exactly what Synopsys
synthesis command to use.  For UNIX commands one could find something with
the "apropos" command.  I have a paper version of the synthesis quick
reference available, but I thought there must be another way.  I wrote
together a few lines of Perl code (see below) and what I got was a kind of
"apropos" command for the Synopsys synthesis commands: "synapropos".  It
extracts data from the Synopsys man pages and I think it might be useful
for many other Synopsys users.

If, for instance, you want to know what command to use to report loads
on nets, try

	synapropos net load

You'll see what you were looking for was "report_internal_loads".  You'll
also get a short description of the possible commands found.  If you also
want to know the syntax of commands you could use "-s".  In this way you can
also directly find out the syntax of specific commands:

	synapropos -s optimize_registers

Within DC or DA you could use the alias "alias apropos sh synapropos".

Oh, maybe it is possible to create a so-called "whatis" or "apropos"
database for the Synopsys man pages and use the UNIX "apropos" command,
but I didn't want to change our Synopsys installation.

  - Peter Kamphuis
    Siemens Semiconductor Group, Munich


#!/usr/local/bin/perl
#
#   synapropos - Apropos for Synopsys synthesis commands
#
#   May-98, Initial version by
#   Peter Kamphuis, Siemens AG Semiconductor Group, Munich
#   kamphuis@hl.siemens.de

# Command line
require 'getopts.pl';
$pname = substr($0,rindex($0,"/")+1);
$usage = "Usage: $pname [-s] search_string...\n       (-s prints syntax)\n";
die($usage) if !&Getopts('s') || scalar(@ARGV) == 0;
@search = @ARGV;

# Get man file directory
die("$pname: \$SYNOPSYS not set\n") unless length($ENV{'SYNOPSYS'});
$manpath = $ENV{'SYNOPSYS'} . "/doc/syn/man/cat2";
# Get man files sorted
die("$pname: Can't cd to $manpath\n") unless chdir($manpath);
opendir(DH,".");                        # Would `/usr/bin/ls` be better?
@manfiles = readdir(DH);
closedir(DH);
@manfiles = sort(@manfiles);
shift(@manfiles); shift(@manfiles);     # Get rid of "." and ".."

# Process all man files
fe: foreach $manfile (@manfiles) {
  $ARGV[0] = $manfile;
  $inname = $insyntax = $found = 0;
  $name = $syntax = "";
  # Collect in NAME (and SYNTAX) section of each man file
  wl: while (<>) {
    next wl if /^\s*$/ && !$insyntax;   # No newlines, except in SYNTAX
    last wl if /ARGUMENTS/;             # Expected after SYNTAX
    $insyntax = 1, $inname = 0, next wl if /SYNTAX/;   # End NAME, start SYNTAX
    $syntax .= $_ if $opt_s && $insyntax;              # Collect SYNTAX
    $inname = 1, next wl if /_N_A_M_E/;        # Start NAME
    $name .= $_ if $inname;             # Collect NAME
  }
  next fe if !$insyntax;                # Skip man file if no SYNTAX
  # Check for all search words in NAME section
  foreach $search (@search) {
    $found++ if $name =~ /$search/i;    # Case insensitive
  }
  # Output NAME (and SYNTAX) section if all search words were present
  if ($found == scalar(@search)) {
    print("\n$name");
    print("\n$syntax") if $opt_s;
  }
}

exit;
# EoF



 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)