---
name: "Verilog::Getopt"
section: "3pm"
platform: "linux"
package: "libverilog-perl"
version: "3.482-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Verilog::Getopt"
---

# Verilog::Getopt(3pm)

Get Verilog command line options

## NAME

Verilog::Getopt - Get Verilog command line options

## SYNOPSIS

```
  use Verilog::Getopt;
  my $opt = new Verilog::Getopt;
  $opt->parameter (qw( +incdir+standard_include_directory ));
  @ARGV = $opt->parameter(@ARGV);
  ...
  print "Path to foo.v is ", $opt->file_path('foo.v');
```

## DESCRIPTION

Verilog::Getopt provides standardized handling of options similar to Verilog/VCS and cc/GCC.

## OPTIONS

The **new()** constructor accepts the following options:

- filename\_expansion=\>1

  Enable converting filenames to relative filenames when possible.  This option is needed when the -F option will be used.  If flags are passed through Getopt which should otherwise not be expanded (e.g. "--out myfile.v") having this option set may undesirably expand myfile.v to an absolute filename.

- gcc\_style=\>0

  Disable parsing of GCC-like parameters.

- vcs\_style=\>0

  Disable parsing of VCS-like parameters.

## METHODS

- $opt = Verilog::Getopt-\>new ( *opts* )

  Create a new Getopt.  See OPTIONS above.

- $self-\>file\_path(*filename*, \[*lookup\_type*\])

  Returns a new path to the filename, using the library directories and search paths to resolve the file.  Optional lookup\_type is 'module', 'include', or 'all', to use only module\_dirs, incdirs, or both for the lookup.

- $self-\>**get\_parameters()**

  Returns a list of parameters that when passed through `$self`-\>**parameter()** should result in the same state.  Often this is used to form command lines for downstream programs that also use Verilog::Getopt.

- $self-\>parameter(\\@params)

  Parses any recognized parameters in the referenced array, removing the standard parameters from any previous **parameters()** call, and returning a array with all unparsed parameters.

  The below list shows the VCS-like parameters that are supported, and the functions that are called:

  ```
      +libext+I<ext>+I<ext>...    libext (I<ext>)
      +incdir+I<dir>              incdir (I<dir>)
      +define+I<var>=I<value>     define (I<var>,I<value>)
      +define+I<var>              define (I<var>,undef)
      +librescan          Ignored
      -F I<file>          Parse parameters in file relatively
      -f I<file>          Parse parameters in file
      -v I<file>          library (I<file>)
      -y I<dir>           module_dir (I<dir>)
      all others          Put in returned list
  ```

  The below list shows the GCC-like parameters that are supported, and the functions that are called:

  ```
      -DI<var>=I<value>           define (I<var>,I<value>)
      -DI<var>            define (I<var>,undef)
      -UI<var>            undefine (I<var>)
      -II<dir>            incdir (I<dir>)
      -F I<file>          Parse parameters in file relatively
      -f I<file>          Parse parameters in file
      all others          Put in returned list
  ```

- $self-\>write\_parameters\_file(*filename*)

  Write the output from get\_parameters to the specified file.

## ACCESSORS

- $self-\>define($token, $value)

  This method is called when a define is recognized.  The default behavior loads a hash that is used to fulfill define references.  This function may also be called outside parsing to predefine values.

  An optional third argument specifies parameters to the define, and a fourth argument if true indicates the define was set on the command line and should not be removed by \`undefineall.

- $self-\>define\_names\_sorted

  Return sorted list of all define names that currently exist.

- $self-\>defparams($token)

  This method returns the parameter list of the define.  This will be defined, but false, if the define does not have arguments.

- $self-\>defvalue($token)

  This method returns the value of a given define, or prints a warning.

- $self-\>defvalue\_nowarn($token)

  This method returns the value of a given define, or undef.

- $self-\>**depend\_files()**

  Returns reference to list of filenames referenced with file\_path, useful for creating dependency lists.  With argument, adds that file.  With list reference argument, sets the list to the argument.

- $self-\>file\_abs($filename)

  Using the incdir and libext lists, convert the specified module or filename ("foo") to a absolute filename ("include/dir/foo.v").

- $self-\>file\_skip\_special($filename)

  Return true if the filename is one that generally should be ignored when recursing directories, such as for example, ".", "CVS", and ".svn".

- $self-\>file\_substitute($filename)

  Removes existing environment variables from the provided filename.  Any undefined variables are not substituted nor cause errors.

- $self-\>incdir

  Returns reference to list of include directories.  With argument, adds that directory.

- $self-\>includes

  Returns reference to hash of files that included some file, and for each hash value a list of files included.  Only relevant after Verilog::Netlist processing.  With two arguments, adds an include for the given referencing filename to the given include filename.

- $self-\>libext

  Returns reference to list of library extensions.  With argument, adds that extension.

- $self-\>libext\_matches(*filename*)

  Returns true if the passed filename matches the libext.

- $self-\>library

  Returns reference to list of libraries.  With argument, adds that library.

- $self-\>module\_dir

  Returns reference to list of module directories.  With argument, adds that directory.

- $self-\>remove\_defines($token)

  Return string with any definitions in the token removed.

- $self-\>undef($token)

  Deletes a hash element that is used to fulfill define references.  This function may also be called outside parsing to erase a predefined value.

- $self-\>undefineall

  Deletes all non-command line definitions, for implementing \`undefineall.

## DISTRIBUTION

Verilog-Perl is part of the \<https://www.veripool.org/\> free Verilog EDA software tool suite.  The latest version is available from CPAN and from \<https://www.veripool.org/verilog-perl\>.

Copyright 2000-2024 by Wilson Snyder.  This package is free software; you can redistribute it and/or modify it under the terms of either the GNU Lesser General Public License Version 3 or the Perl Artistic License Version 2.0.

## AUTHORS

Wilson Snyder \<wsnyder@wsnyder.org\>

## SEE ALSO

Verilog-Perl, Verilog::Language
