SigParser(3)
π SigParser(3) β Verilog::SigParser
okay so bestie, buckle up β this is the Perl doc page for Verilog::SigParser (yes, from the User Contributed Perl Documentation collection, we love a community moment β¨). Signal parsing for Verilog language files, and it's giving main character energy fr fr.
πΈ NAME πΈ
Verilog::SigParser β Signal Parsing for Verilog language files. that's the whole vibe, literally.
β¨ SYNOPSIS β¨
like, here's how you actually use it:
use Verilog::Preproc;
use Verilog::SigParser;
my $pp = Verilog::Preproc->new(keep_comments=>0,);
my $parser = new Verilog::SigParser;
$parser->parse_preproc_file($pp);
# The below described callbacks are then invoked
so you spin up a preprocessor, hand it to the parser, and the callbacks below just start firing. iconic behavior honestly π
π¦ DESCRIPTION π¦
Verilog::SigParser builds on top of the Verilog::Parser module β it's the glow-up, the sequel β and it gives you callbacks for when a signal is declared, when a module gets instantiated, or when a module gets defined. three whole moods π«
if you're sitting there like "wait, which parsing package do I even pick for my new app??" β go read the "Which Package" section of Verilog::Netlist... no wait, of Verilog::Language, sorry, my bad π. and if you want a higher level interface to this package, that's Verilog::Netlist, periodt.
π§ METHODS π§
the method interface to Verilog::SigParser is described over in the Verilog::Parser module, which this package inherits from (we're a nepo baby, but a legit one). and ngl, you're probably gonna want to use the preprocessing option of Verilog::Parser with this package. trust π
π CALLBACKS π
so here's the thing β to make the parser actually do anything interesting, you gotta make a subclass and override one or more of these methods as it suits you. that's the assignment. π«Ά
heads up: Verilog::Parser callbacks also get invoked while SigParser is parsing. no cap.
π $self->attribute($text)
scanned an attribute or meta-comment. the parser peeks at the first word of each comment line (//key rest to end of line) or comment block (/*key rest */). then it calls $self->attribute( meta_text ) β but only if that first word has a true value in the hash $self->metacomment. gatekeeping, but make it parsing β¨
π $self->class($token, $name, $virtual)
called at a class. slay.
π $self->covergroup($token, $name)
called at a covergroup.
π $self->contassign($token, $lhs, $rhs)
called at a continuous assign keyword, and it brings the left and right hand part of the assignment along with it. β οΈ important: wire initializations do not count as assignments β those show up through the var callback's value parameter instead. don't get it twisted.
π $self->defparam($token, $lhs, $rhs)
called at a defparam keyword, with the left and right hand part of the assignment. same energy, different keyword.
π $self->endcell($token)
called at the end of defining a cell. super useful for writing clean up routines π§Ή
π $self->endgroup($token)
called at the end of defining a covergroup. also useful for clean up routines.
π $self->endinterface($token)
called at a endinterface keyword. clean up routine material.
π $self->endclass($token)
called at a endclass keyword. clean up routines, you know the drill.
π $self->endtaskfunc($token)
called at a endfunction or endtask keyword. useful for writing clean up routines.
π $self->endmodport($token)
called at a endmodport keyword. clean up routines β¨
π $self->endmodule($token)
called at a endmodule keyword. clean up routines.
π $self->endpackage($token)
called at a endpackage keyword. clean up routines.
π $self->endprogram($token)
called at a endprogram keyword. clean up routines.
π $self->function($keyword, $name, $data-type)
called when a function is defined. type is the output size or typename, plus signed where it applies β for example "", "[3:0]", "integer", or "signed [2:0]". β¨
π $self->import($package, $id)
called when an import is defined.
π $self->instant($module, $cell, $range)
called when an instantiation is defined. first parameter = the name of the module being instantiated. second = the name of the cell, which may be "" for primitives. third = the range, if the cell was arrayed.
π°οΈ lore drop: prior to version 3.000, the name of the parameters was also included in this callback. that's been replaced with the parampin callback. glow-up complete π
π $self->interface($keyword, $name)
called when an interface is defined.
π $self->modport($keyword, $name)
called when an interface modport is defined.
π $self->module($keyword, $name, ignored, $in_celldefine)
called when a module is defined.
π $self->package($keyword, $name)
called when a package is defined.
π $self->parampin($name, $connection, $index)
called when a parameter is connected to an instantiation β IE the "#(...)" syntax. it's also used for UDP delays (three calls for "#(delay0,delay1,delay2)"), because the parser genuinely doesn't know whether the instantiation is for a UDP versus a module. it's doing its best π
π $self->pin($name, $connection, $index)
called when a pin on an instant is defined and "use_pinselects" is not set (that's the default β see pinselects() below). if a pin name wasn't provided and the connection is by position, name will be '' or undef.
if you don't need the pin, var, or port callbacks, consider the "$self->new (... use_vars=>0 ...)" option to accelerate parsing. free speed, bestie π₯
π $self->pinselects($name, $connections, $index)
if "$self->new (... use_pinselects=>1 ...)" is used, this function gets called instead of "$self->pin (...)". the difference? the second parameter ("$connections") is a Perl hash containing all connected nets in the case of concatenations β including the MSB and LSB bounds used at those locations. fancy.
π $self->port($name, $objof, $direction, $data_type, $array, $pinnum)
called when a module port is defined. β οΈ it may get called twice on a port if the 1995 style is used β first call at the port header, second call at the input/output declaration. yeah, twice. it's not a bug, it's a lifestyle.
here's the whole cast, one by one:
$nameβ the name of the port π$objofβ what the port is an object of ('module','function', etc)$directionβ the port direction ('input','output','inout','ref','const ref', or'interface')$data_typeβ the data type ('reg','user_type_t','signed [31:0]', etc β or, for interfaces, the"{interface_id}.{modport_name}")$arrayβ the arraying of the port ('[1:0][2:0]','', etc)$pinnumβ set to the pin number for ANSI style declarations, and0for Verilog 1995 declarations made outside the port list
if you don't need the pin, var, or port callbacks, consider the "$self->new (... use_vars=>0 ...)" option to accelerate parsing. yes I'm repeating myself, it's important π«Ά
π $self->program($keyword, $name)
called when a program is defined.
π $self->signal_decl($keyword, $signame, $vector, $mem, $signed, $value)
girl, this one is no longer used β see $self->var instead. she's retired, let her rest π
π $self->task($keyword, $name)
called when a task is defined.
π $self->var($kwd, $name, $objof, $nettype, $data_type, $array, $value)
called when a variable or net is defined. the whole ensemble:
$kwdβ how it was declared ('port','var','genvar','parameter','localparam','typedef'), or, if applicable, a net type ('supply0','wire', etc)$nameβ the name of the variable$objofβ what the variable is an object of ('module','function', etc)$nettypeβ the net type, if any was defined ('','supply0','wire','tri', etc)$data_typeβ the data type ('user_type_t','[31:0] signed', etc)$arrayβ the arraying of the variable, which is the text AFTER the variable name ('[1:0][2:0]','', etc)$valueβ what the variable was assigned to ('', or expression)
π¨ note: typedefs are included here too, because "parameter type" is both a variable and a type declaration. multi-hyphenate.
if you don't need the pin, var, or port callbacks, consider the "$self->new (... use_vars=>0 ...)" option to accelerate parsing. (third time's the charm π)
below are some example declarations and the callbacks they fire:
reg [4:0] vect = 5'b10100;
# VAR 'var' 'vect' 'module' '' 'reg [4:0]' '' '5'b10100'
wire (weak0, weak1) value = pullval;
# VAR 'net' 'value' 'module' 'wire' '' '' 'pullval'
reg [1:0] mem [12:2];
# VAR 'var' 'mem' 'module' '' 'reg [1:0]' '[12:2]' ''
int n[1:2][1:3] = '{'{0,1,2}, '{3{4}}};
# verilog/parser_sv.v:121: VAR 'var' 'n' 'module' '' 'int' '[1:2][1:3]' ''{'{0,1,2},'{3}}'
module ( output logic [SZ-1:0] o_sized );
# VAR 'port' 'o_sized' 'module' '' 'logic [SZ-1:0]' '' ''
struct packed signed { bit [7:0] m_b; };
# VAR 'member' 'm_b' 'struct' '' 'bit [7:0]' '' ''
π BUGS π
ngl, this is being distributed as a baseline for future contributions. don't expect a lot β the Parser is still naive, and there are many awkward cases that aren't covered. she's doing her best π
also note: SigParser is focused on extracting signal information. it does NOT extract enough information to derive general interconnect β for example, the contents of 'assign' statements are not parsed. so don't come for her about that.
π 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>. go get it bestie β¨
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. two licenses, two vibes, your choice π
π AUTHORS π
Wilson Snyder <wsnyder@wsnyder.org> β the icon, the legend, the author π
π«Ά SEE ALSO π«Ά
Verilog-Perl, Verilog::Parser, Verilog::Language, Verilog::Netlist, Verilog::Getopt β go read them, iykyk π
and that's the whole page, bestie!! this little masterpiece is perl v5.42.0, dated 2025-07-25, and it's page SigParser(3) β see you in the group chat ππ¦β¨
π¦ 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