📄 vpassert
字号:
sub operator { # Callback from parser when a operator occurs my ($parser, $token) = @_; my $since = $parser->unreadback(); $parser->unreadback(''); if ($In_Message) { print "Callback OPERATOR $token ($Parens, $Param_Num)\n" if ($Debug); if (($token eq ',') && ($Parens==1)) { # Top level comma $Params[$Param_Num] .= $since; $Param_Num ++; } elsif (($token eq ';' && ($Parens==0))) { # Final statement close if ($In_Message) { if ($Opt_NoPli) { # "" doesn't work, as need semi for "if (1) $x()" # ";" doesn't work, as need empty for "begin $x() end" ::sendout ("begin end "); for (my $p=0; $p<=$#Params; $p++) { while ($Params[$p]=~/\n/g) { ::sendout("\n"); } } } elsif (defined $Vpassert_Conversions {$Params[0]}) { #print " CALLPRE ",join(':',@Params),"\n" if $Debug; my $nl = ""; for (my $p=0; $p<=$#Params; $p++) { while ($Params[$p]=~/\n/g) { $nl .= "\n"; } $Params[$p] = Verilog::Language::strip_comments($Params[$p]); $Params[$p]=~ s/\n//g; } my $func = $Vpassert_Conversions {$Params[0]}; print " CALL ",join(':',@Params),"\n" if $Debug; &$func (@Params); ::sendout ($nl) if $nl; # Adjust for \n's in params } else { ::sendout (""); } } $In_Message=0; } elsif (($token eq ')' || $token eq '}') && ($Parens==1)) { # Final paren $Params[$Param_Num] .= $since; } elsif ($token eq ')' || $token eq '}') { # Other paren $Params[$Param_Num] .= $since . $token; } elsif ($token eq '(' || $token eq '{') { if ($Parens!=0) { $Params[$Param_Num] .= $since . $token; } } else { $Params[$Param_Num] .= $since . $token; } } elsif ($Need_Vpassert_Symbols && ($token eq ';')) { $Need_Vpassert_Symbols = 0; # Squeeze it after module (..); push @Sendout, [$parser->lineno, $since . $token . '/*vpassert beginmodule '.$Last_Module.'*/']; } else { push @Sendout, [$parser->lineno, $since . $token]; } # Track parens if ($token eq '(' || $token eq '{') { $Parens++; } elsif ($token eq ')' || $token eq '}') { $Parens--; } push @Last_Number_Ops, $token;}sub string { # Callback from parser when a string occurs my ($parser, $token) = @_; my $since = $parser->unreadback(); $parser->unreadback(''); if ($In_Message) { print "Callback STRING $token\n" if ($Debug); $Params[$Param_Num] .= $since . $token; } else { push @Sendout, [0, $since . $token]; if (($Last_Keyword eq "`include") && ($token =~ /\//)) { print STDERR "%Warning: ".$parser->fileline.": `include has directory," . " remove and add +incdir+ to input.vc\n"; } }}sub comment { # Callback from parser when a comment # *** To speed things up, this is only invoked when doing vericov my ($parser, $token) = @_; if (!$Opt_Vericov) { $parser->unreadback($parser->unreadback() . $token); return; } my $since = $parser->unreadback(); $parser->unreadback(''); if ($Opt_Vericov && (($token =~ /summit\s+modcovon/ || $token =~ /simtech\s+modcovon/))) { $Vericov_Enabled = 1; } elsif ($token =~ /summit\s+modcovoff/ || $token =~ /simtech\s+modcovoff/) { $Vericov_Enabled = 0; } push @Sendout, [0, $since . $token];}package main;##################################################################################################################################################################################################################__END__=pod=head1 NAMEvpassert - Preprocess Verilog code assertions=head1 SYNOPSISB<vpassert>[ B<--help> ][ B<--date> ][ B<--quiet> ][ -y B<directories...> ][ B<files...> ]=head1 DESCRIPTIONVpassert will read the specified Verilog files and preprocess special PLIassertions. The files are written to the directory named .vpassert unlessanother name is given with B<-o>. If a directory is passed, all files inthat directory will be preprocessed.=head1 ARGUMENTSStandard VCS and GCC-like parameters are used to specify the files to bepreprocessed: +libext+I<ext>+I<ext>... Specify extensions to be processed -f I<file> Parse parameters in file -v I<file> Parse the library file (I<file>) -y I<dir> Parse all files in the directory (I<dir>) -II<dir> Parse all files in the directory (I<dir>) +incdir+I<dir> Parse all files in the directory (I<dir>)To prevent recursion and allow reuse of the input.vc being passed to thesimulator, if the output directory is requested to be preprocessed, thatdirectory is simply ignored.=over 4=item --allfilesPreprocess and write out files that do not have any macros that needexpanding. By default, files that do not need processing are not writtenout.This option may speed up simulator compile times; the file will always befound in the preprocessed directory, saving the compiler from having tosearch a large number of -v directories to find it.=item --chiponlySpecial standalone chip compile=item --dateCheck file dates versus the last run of VPASSERT and don't process if thegiven source file has not changed.=item --excludeExclude processing any files which begin with the specified prefix.=item --helpDisplays this message and program version and exits.=item --language <1364-1995|1364-2001|1364-2005|1800-2005>Set the language standard for the files. This determines which tokens aresignals versus keywords, such as the ever-common "do" (data-out signal,versus a do-while loop keyword).=item --minimumInclude `__message_minimum in the $uinfo test, so that by defining__message_minimum=1 some uinfos may be optimized away at compile time.=item --nolineDo not emit `line directives. If not specified they will be used under--language 1364-2001 and later.=item --nopliDelete all 'simple' PLI calls. PLI function calls inside parenthesis willnot be changed, and thus may still need to be manually ifdef'ed out.Useful for reducing the amount of `ifdef's required to feed non-PLIcompetent synthesis programs.=item --quietSuppress messages about what files are being preprocessed.=item --nostopBy default, $error and $warn insert a $stop statement. With --nostop, thisis replaced by incrementing a variable, which may then be used toconditionally halt simulation.=item --o I<file>Use the given filename for output instead of the input name .vpassert. Ifthe name ends in a / it is used as a output directory with the defaultname.=item --realintentSpecial RealIntent enable/disables added around unreachable code.=item --timeformat-units I<units>If specified, include Verilog $timeformat calls before all messages. Usethe provided argument as the units. Units is in powers of 10, so -9indicates to use nanoseconds.=item --timeformat-precision I<prec>When using --timeformat-units, use this as the precision value, the numberof digits after the decimal point. Defaults to zero.=item --vericovSpecial Vericov enable/disables added around unreachable code.=item --verilatorSpecial Verilator translations enabled.=item --versionDisplays program version and exits.=back=head1 FUNCTIONSThese Verilog pseudo-pli calls are expanded:=over 4=item $uassert (I<case>, "message", [I<vars>...] )Report a $uerror if the given case is FALSE. (Like assert() in C.)=item $uassert_amone (I<sig>, [I<sig>...], "message", [I<vars>...] )Report a $uerror if more than one signal is asserted, or any are X. (Noneasserted is ok.) The error message will include a binary display of thesignal values.=item $uassert_info (I<case>, "message", [I<vars>...] )Report a $uinfo if the given case is FALSE. (Like assert() in C.)=item $uassert_onehot (I<sig>, [I<sig>...], "message", [I<vars>...] )Report a $uerror if other than one signal is asserted, or any are X. Theerror message will include a binary display of the signal values.=item $uassert_req_ack (I<req_sig>, I<ack_sig>, [I<data_sig>,...] )Check for a single cycle request pulse, followed by a single cycleacknowledgment pulse. Do not allow any of the data signals to changebetween the request and acknowledgement.=item $ucheck_ilevel (I<level> )Return true if the __message level is greater or equal to the givenlevel, and that global messages are turned on.=item $ucover_clk (I<clock>, I<label>)Similar to $uerror_clk, add a SystemVerilog assertion at the next specifiedclock's edge, with the label specified. This allows cover properties to bespecified "inline" with normal RTL code.=item $ucover_foreach_clk (I<clock>, I<label>, "I<msb>:I<lsb>", (... $ui ...))Similar to $ucover_clk, however cover a range where $ui in the expressionis replaced with the range index.Range is "I<msb>:I<lsb>" to indicate from I<msb> downto I<lsb> inclusive,and/or a comma separated list of values.Similar to: for ($ui=msb; $ui>=lsb; $ui=$ui-1) begin if (expression with $ui) $ucover_clk(clock, label ## "_" ## bit) endHowever there's no way to form a label from a for loop (as psudocoded with## above), thus this macro.=item $uiLoop index used inside $ucover_foreach_clk.=item $uinfo (I<level>, "message", [I<vars>...] )Report a informational message in standard form. End test if warninglimit exceeded.=item $uerror ("message", [I<vars>...] )Report a error message in standard form. End test if error limit exceeded.=item $uerror_clk (I<clock>, "message", [I<vars>...] )Report a error message in standard form at the next clock edge. If youplace a $uerror etc in a combo logic block (always @*), event basedsimulators may misfire the assertion due to glitches. $uerror_clk fixesthis by instead creating a temporary signal and then moving the assertitself to a new clocked block at the specified edge. Note any variablesprinted will be the values at the time of the next clock edge, which maydiffer from the value where the $uerror_clk is assigned.=item $uwarn ("message", [I<vars>...] )Report a warning message in standard form.=item $uwarn_clk (I<clock> "message", [I<vars>...] )Report a warning message in standard form at the next clock edge. See$uerror_clk.=back=head1 DISTRIBUTIONVerilog-Perl is part of the L<http://www.veripool.org/> free Verilog EDAsoftware tool suite. The latest version is available from CPAN and fromL<http://www.veripool.org/verilog-perl>.Copyright 2000-2009 by Wilson Snyder. This package is free software; youcan redistribute it and/or modify it under the terms of either the GNULesser General Public License or the Perl Artistic License.=head1 AUTHORSWilson Snyder <wsnyder@wsnyder.org>,Duane Galbi <duane.galbi@conexant.com>=head1 SEE ALSOL<Verilog-Perl>,L<Verilog::Parser>, L<Verilog::Pli>=cut######################################################################
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -