Verilog::Parse - parse Verilog language files
This module is no longer supported. Use Verilog::Parser instead.
use Verilog::Parse; $parser = new Verilog::Parse; sub function {my ($parser, $what, $info) = @_; ...} $parser->callback ("xxx", \&function) $string = $parser->unreadback (); $parser->Verilog::Parse::parse ($FileHandle)
This package implements parsing of the Verilog language. A file is parsed and callbacks are called for various entities in the file, as they occur.
Create a new parser.
Request that when the parser hits the given token, function will be called. The tokens that may be parsed are:
"COMMENT" Any text in // or /**/ comments. "STRING" Any quoted string, including the quotes. "KEYWORD" A Verilog keyword. (See C<Verilog::Language>) "SYMBOL" A textual non-keyword "OPERATOR" A non-alphanumeric operator. "NUMBER" A number.
The callback will get three arguments. The first is the parser (self). The second is the exact type of token, one of those listed above. Third is a string with the symbol, number, etc.
Read input from the filehandle, and perform callbacks as needed.
Return any input string from the file that has not been sent to the callback. This will include whitespace and tokens which did not have a callback. (For example comments, if there is no comment callback.) This is useful for recording the entire contents of the input, for preprocessors, pretty-printers, and such.
Here\'s a simple example which will print every symbol in a verilog file. We also remember what line it occured on, just for the heck of it.
sub symbol_cb { # Callback from parser when a symbol occurs sub function (my ($parser, $what, $info) = @_; ...) $signals_and_symbols{$info} = $.; }
sub verilog_read_symbols { my $filename = shift;
local %signals_and_symbols = (); # Signals already found in module my $fh = new FileHandle; my $parser = new Verilog::Parse; $parser->callback ("SYMBOL", \&symbol_cb); $fh->open("<$filename") or die "Can't read $filename."; $parser->Verilog::Parse::parse ($fh); $fh->close; foreach $sym (sort (keys %signals_and_symbols)) { print "Symbol $sym\n"; } }
Verilog::ParseSig, Verilog::Language, FileHandle,
Verilog::ParseSig
Verilog::Language
FileHandle
This is being distributed as a baseline for future contributions. Don\'t expect a lot, the parser is still nieve, and there are many awkward cases that aren\'t covered.
The latest version is available from http://veripool.com/verilog-perl.
http://veripool.com/verilog-perl
Wilson Snyder <wsnyder@wsnyder.org>
To install Verilog::Parse, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Verilog::Parse
CPAN shell
perl -MCPAN -e shell install Verilog::Parse
For more information on module installation, please visit the detailed CPAN module installation guide.