Getopt(3)
π Getopt(3) β Verilog::Getopt, but make it make sense
okay so bestie, you know how I'm always going on about the Verilog-Perl suite? yeah. this is the manual page for Verilog::Getopt, and no, it's not literally the C getopt(3) β it's the Perl one that speaks Verilog tooling. it ships as part of the perl v5.42.0 docs, and we'll get to the whole source/version/date thing at the end, mwah π
β¨ NAME β¨
Verilog::Getopt β the one that gets your Verilog command line options. yes. that's the whole bit. π
πΈ 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');
like, look at her go. she's literally parsing arbitrary Verilog args and telling you where foo.v lives. icon behavior.
π¦ DESCRIPTION π¦
Verilog::Getopt gives you standardized handling of options β in the same flavor as Verilog/VCS and cc/GCC. so if you already know how those tools munch on flags, you already get the vibe here. no cap. π«Ά
π OPTIONS π
the new() constructor is where you get to be picky. these are the little knobs it accepts:
filename_expansion=>1β turns filenames into relative filenames when it can, which is π chef's kiss π. you're gonna want this on when you're using the-Foption, fr fr. BUT π heads up: if you pass flags through Getopt that shouldn't get expanded (think"--out myfile.v"), then having this on might undesirably expandmyfile.vinto an absolute filename. like, not ideal, bestie.gcc_style=>0β turn this off and parsing of GCC-like parameters is a no-go. π«vcs_style=>0β same energy, but for VCS-like parameters. off = deprecated vibes for that syntax. (just kidding, it just disables it π)
π§ METHODS π§
$opt = Verilog::Getopt->new ( opts )
make a whole new Getopt. the opts? that's the OPTIONS section up there β peek at it, bestie. β¬οΈ
$self->file_path(filename, [lookup_type])
hands you a new path to filename, using the library directories and search paths to figure out where that file actually lives. π
that optional lookup_type? it's 'module', 'include', or 'all' β pick module to only use module_dirs, include for just incdirs, or all for both. choose your fighter π
$self->get_parameters()
returns a list of parameters that, when passed back through $self->parameter(), lands you in the exact same state. literally a round trip. π
people use this all the time to build command lines for downstream programs that also use Verilog::Getopt. it's giving teamwork.
$self->parameter(\@params)
this is the main character right here π. it parses any recognized parameters in the referenced array, removes the standard parameters from any previous parameters() call, and returns an array with all the unparsed parameters. slay.
the VCS-like parameters it supports (and what gets 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
and the GCC-like parameters π
-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
note the all others line in both β anything not recognized just gets put in the returned list like it's no big deal. π¦
$self->write_parameters_file(filename)
writes the output from get_parameters straight into the specified file. it's giving "save your work, bestie." πΎ
β ACCESSORS β
$self->define($token, $value)
called whenever a define gets recognized. by default it loads a hash that's used to fulfill define references β but you can also call it outside parsing to predefine values. π₯
there's an optional third argument that specifies parameters to the define, and a fourth argument β if true, it means the define was set on the command line and should not be removed by `undefineall. important detail, don't skip it π«Ά
$self->define_names_sorted
returns a sorted list of every define name that currently exists. alphabetized. tidy. iconic. β¨
$self->defparams($token)
returns the parameter list of the define. ngl this one's a little cursed β it will be defined, but false, if the define doesn't have arguments. like, she exists but she's also not there. π
$self->defvalue($token)
returns the value of a given defineβ¦ or prints a warning π (so, you know, handle that)
$self->defvalue_nowarn($token)
same deal but no warning β returns the value of the given define, or undef. π
$self->depend_files()
returns a reference to the list of filenames referenced with file_path β super useful for building dependency lists π§Ύ
- with an argument β adds that file
- with a list reference argument β sets the list to the argument
$self->file_abs($filename)
uses the incdir and libext lists to convert a module or filename ("foo") into an absolute filename ("include/dir/foo.v"). glow up from relative bee to queen bee π
$self->file_skip_special($filename)
returns true if the filename is one of those "should generally be ignored when recursing directories" situations β like for example ".", "CVS", and ".svn". bye girl, you're not a real file π
$self->file_substitute($filename)
strips existing environment variables out of the provided filename. any undefined variables just stay as-is β no substitution, no errors, no drama. πΈ
$self->incdir
returns a reference to the list of include directories. pass an argument and it adds that directory. easy.
$self->includes
returns a reference to a hash of files that included some file β and each hash value is a list of the files that were included. π«Ά
lowkey important: this is only relevant after Verilog::Netlist processing.
with two arguments β adds an include, from the given referencing filename to the given include filename.
$self->libext
returns a reference to the list of library extensions. with an argument, adds that extension. π
$self->libext_matches(filename)
returns true if the filename you passed matches the libext. vibe check: passed β
$self->library
returns a reference to the list of libraries. with an argument, adds that library. π
$self->module_dir
returns a reference to the list of module directories. with an argument, adds that directory. ποΈ
$self->remove_defines($token)
returns a string with any definitions in the token removed. poof. gone. π«§
$self->undef($token)
deletes a hash element used to fulfill define references. you can also call this outside parsing to erase a predefined value. so like, off with their head π
$self->undefineall
deletes all non-command-line definitions β this is what makes `undefineall actually work. command-line ones survive. periodt. π«Ά
π DISTRIBUTION π
Verilog-Perl is part of the <https://www.veripool.org/> free Verilog EDA software tool suite β yes, the whole suite, obsessed π§
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. pick your license, bestie. π
π AUTHORS π
Wilson Snyder <wsnyder@wsnyder.org> β the icon who made this happen π
π SEE ALSO π
Verilog-Perl, Verilog::Language
okay and for the little sign-off β this page is from the perl v5.42.0 docs, the User Contributed Perl Documentation flavor of Getopt(3), dated 2025-07-25. β¨ that's the version and the date, all wrapped up in a bow π stay parsing, bestie π
π¦ where this page comes from
- fedora 43: perl-Verilog-Perl 3.482-6.fc43 Β· LGPL-3.0-only OR Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms