Spyglass Customization
Spyglass Customization
Customization Guide
Version 4.4.1
October 2010
Atrenta, Inc.
2077 Gateway Place, Suite 300
San Jose, California 95110
1-866-ATRENTA (1-866-287-3682)
http://www.atrenta.com
Preface............................................................................................................................. 7
About This Book......................................................................................................................................7
Contents of This Book ............................................................................................................................7
Typographical Conventions ...................................................................................................................8
Table of Contents
Table of Contents
Chapter Describes...
SpyGlass Rule-Checking Environment How SpyGlass performs rule-checking
SpyGlass Rule Definition SpyGlass Rule definition concepts
Developing New SpyGlass Rules How to develop custom rules using
standard rule-Primitives
Creating Custom Reports How to create SpyGlass report generators
for your custom rules
Overloading SpyGlass Policies How to design overloaded policies
Appendix A: Introduction to Perl Basic Perl concepts
Typographical Conventions
This document uses the following typographical conventions:
Convention Indicate...
Square brackets “[ ]” An optional entry or parameter.
Braces “{ }” An entry that can be specified one or more times
Vertical bar “|” A list of choices out of which you can choose one
Horizontal ellipsis “. . .” Other items that are normally provided
Overview
The Atrenta® SpyGlass® Predictive Analyzer runs on one or more
HDL files (either Verilog, VHDL, or both) and analyses these designs
for predefined rules, contained in “policy” ruledeck files. The policy
ruledeck files enable SpyGlass to be used repeatedly with different
source files, calling up different sets of rules to be checked at different
times.
The overall SpyGlass Rule-Checking environment is shown in the
following figure:
Schematic Data
Options
Source Files
Policies
Reports
Rule-Primitive Libraries
Section Contains...
Header Section Policy description and revision history
Use Section Policy Package information
Policy Registration Section Policy Registration and Information
Library Registration Section Associated SpyGlass-compatible libraries’
declarations
Severity Declaration Section Rule severity-labels’ declarations
Require File Section Child files’ declarations
Rule Parameter Description Section Rule parameters’ declarations
Rule Description Section Rules’ declarations
Rule Group Description Section Rule Groups’ declarations
Report Description Section Rule Reports’ declarations
End-of-Policy Section Policy file termination command
Header Section
The Header section contains the policy description and policy revision
history. Each line in the Header section must be a Perl comment line,
that is, starting with Perl comment character (#) as the first character in
the line.
The Header section is optional but is recommended for better
understanding of policy users.
If your policy description is distributed over a number of files, it is
recommended that each file has its own Header section.
Use Section
The Use section specifies the policy package details.
To avoid Perl Callback function namespace clashes between different
SpyGlass Policies that are simultaneously registered, SpyGlass
supports the package concept where you can specify declare a package
namespace for a SpyGlass Policy. Then, you should specify the Policy-
specific Perl Callback functions in the following format:
<package-name>::<func-name>
For example, the SpyGlass STARC Policy has the following use
section:
package starc;
This statement declares the Policy Package namespace as starc.
Now, all Perl Callback functions in SpyGlass STARC Policy are
specified as in the following example:
$msg="Primary port/module '%s' does not follow naming convention.";
spyRegisterRule(
"Verilog", "STARC-1.1.1.6", "PrimModPortName",
"veSrpNames_Init", "veSrpNames",
"Mandatory", $msg, 5,
"starc::veSRP_1_1_1_6 topmodule topport", 1);
You also need to include the following mandatory call that includes
the standard package named spyglass to enable standard SpyGlass
Policy APIs:
use spyglass;
spyRegisterPolicy(
"starc", "1.6.6",
"SpyGlass rules that check HDL designs
for IP Reuse guidelines compiled by STARC.",
"3.3.0", "", "", "", "");
The first line prints STARC Rules to stdout and SpyGlass log file
provided you are not running the STARC policy from the SpyGlass
Design Environment (controlled by !defined $spyinIspy) and
you have not specified the -norules command-line option
(controlled by !defined $norules).
Next lines have a call to spyRegisterPolicy function call that
sets the following values:
recommended that you declare the library file(s) associated with the
rules described in a file in that file itself.
if (uc($spyglass_language) eq "VERILOG") {
require "verilogstarc.pl";
require "mixedstarc.pl";
}
if (uc($spyglass_language) eq "VERILOG+VHDL") {
require "verilogstarc.pl";
require "vhdlstarc.pl";
require "mixedstarc.pl";
}
The Require File section is not required if your policy is entirely
spyParameter("starc","STARC-3.5.2.1","src_master_dir","");
You can see from the examples that the possible values of a rule
parameter can be a number, a string, a list, or null.
NOTE: You should appropriately fill the rule list in the spyParameter API. If a
rule dependent on a given parameter is not mentioned in the rule list argument
of spyParameter API, then SpyGlass may generate spurious
'checkCMD_unused_param01' warning messages for such parameters, even if
their dependent rules are active in the current run.
NOTE: If you use special characters $, %, @, \, or " (double quote) in the rule
parameter values, you are required to precede each such special character
with a \..
If your policy description is distributed over a number of files, it is
recommended that you declare the rule parameters associated with the
rules described in a file in that file itself and the global rule parameters
in the main policy ruledeck file.
End-of-Policy Section
Each policy must end with the following line:
1;
Overview
At the heart of the SpyGlass environment are the rules, normally
managed together in policies. The policies are text (Perl) files that
define the rules to be checked. Atrenta ships several standard policies
covering Lint, OpenMORE, and other optional policies covering ERC
and DFT. You can modify these standard rule policies and can also
develop your own policies from scratch.
The rules are the definitions of issues to be checked in the design. Each
rule needs to be ‘registered’ to make it visible to SpyGlass and has a
number of programmable attributes to define the specific function (see
Registering Individual Rules for the full definition of the attributes).
Among the attributes is, very importantly, the rule-primitive that should
be called for the rule. The aim of the rule-primitive is to split the
database access from the rule definition to make rule definition as easy
as possible while still providing great flexibility and power.
The rule primitive is a set of C functions, found either in the SpyGlass
core, or in a shared library, which does the real work of checking the
Rule Name
Rule Language Short Help
Policy Name Long Help
int condition;
ruleInitFuncPtrType initFunc;
ruleExecFuncPtrType execFunc;
void *attribute;
long violationCnt;
long nviolations;
int debugEnabled;
int ruleType;
long maxviolperline;
long maxviolperfile;
long maxviolperrun;
int enable;
int returnStatus;
void *Data;
int all_waived;
char* policy_name;
int severity_label_index;
char *exitFuncName;
ruleExitFuncPtrType exitFunc;
};
The purpose of various fields in the ruleInfo object that you need to
supply are as follows:
NOTE: You should leave all other fields as empty strings:
language Indicates the language to which the rule applies. The possible values of
this field are Verilog, VHDL, or Verilog+VHDL. The values are
case-insensitive.
registeredName The name under which the rule will be registered by SpyGlass. The rule
name must be a string of alphanumerical characters and underscore
character.
The rule name is used with the -rules and -ignorerules
command-line options to select or deselect the rule for a given
SpyGlass analysis run. The rule name appears in all reports and can be
used to control waivers, filtering, and other features (see the SpyGlass
Predicitive Analyzer User Guide for more details). You can have the
same name for a rule that works on Verilog designs and a rule that
works on VHDL design. However, rule names must be unique (case-
insensitive) within one language. If you use the same name for more
than one rule within a language, the second definition overrides the first
definition.
weight (Optional) A weight value you want to associate with the rule. This
weight value is useful in computing reusability scores.
command-line option, a rule is run or not run as per the following table:
NOTE: With the corresponding policy specified, only the rules with condition
value 4 are run even when the -norules command-line option is also specified.
Registering Rules
In order for SpyGlass to check any rules, they must first be made
visible to the analysis engine by ‘registering’ them. Once registered,
they are then available for checking. This is true both for rules supplied
by Atrenta as well as custom rules defined by users. Rules can be
registered individually (see Registering Individual Rules), as a group
(see Registering Rule Groups), or as a ‘policy’, as shown below:
Multiple
Rule Decks
As can be seen, the same rule can be included in more than once (e.g.
Rule 5), and rule groups can include other groups as well as individual
rules (Group A included in Group B). SpyGlass will ensure at run-time
that if the same rule is registered more than once, it will only be
checked once for each instance in the design.
This flexibility in registration allows SpyGlass to be set up to run
differing sets of rules at different times in the design process, as well as
being able to switch the rule set used based on runtime options. It also
allows users, if they so wish, to be able to concentrate on fixing critical
design issues associated with a specific rule (e.g. clock domain
crossings) without being distracted by other lower priority rules.
The rule registration can be defined in one or more standalone policies
(such as those supplied by Atrenta) which are then pointed to by a
control file or the rules/groups can be explicitly registered as part of the
control file.
$msg = "Active low signal name '%s' must end with _X";
spyRegisterRule("vhdl", "STARC-1.1.1.7", "ActLowName", "",
"vhNames", "Mandatory", $msg, 5, "vhSrp_1_1_1_7_actLowName activelow", 1);
Here, the rule alias is ActLowName, associated rule-primitive is
vhNames, the rule severity-label is Mandatory, and the rule-
ordering condition is 1 (that is, the rule is ON by default). Also, there is
an associated Perl function vhSrp_1_1_1_7_actLowName that is
invoked on the signal name with argument activelow.
to associate with the rule. Refer to the severity section for more details.
<msg> (mandatory) indicates the message text given for a rule
<weight> (optional) defines the weight of the message. If the weight
value is provided, then the value will be associated with the current
message. If the value is not provided, then the weight registered with
the spyRegisterRule API will be used.
<msgArgInfo> (optional) defines the message arguments and also
the internal type of bus-merging objects. The supported argument types
are s, d, f, c, e, l, vn, ve, vs, and vh.
<bmInfo> (optional) defines the information related to bus-merging.
It helps in manipulating the type of bus-merging (OW/TW), the bus-
merging arguments, the TAG, and the attributes for bus-merging and so
on.
The spyRegisterRuleMessage API registers the multiple rule
messages. If there are N messages (with different severity) for a rule,
then there are as many calls to spyRegisterRuleMessage API,
with each call defining one of the messages. In addition, each of these
calls associates a unique label with which a message can be referred to
later. The arguments associated with the
spyRegisterRuleMessage API are key-based and hence position
independent.
The spyRegisterRuleMessage API should be called just after the
spyRegisterRule API. The severity label and message can be left blank
in the spyRegisterRule API, if the same are being defined using the
spyRegisterRuleMessage API.
Once the rule messages and their severities have been defined using the
spyRegisterRuleMessage API, these should be accessed in rule-
cprimitives to flag the desired messages.
This new myLineLength rule will flag RTL code lines that are longer
than 80 characters.
that is, they will always be triggered and cannot be waived or ignored
to ensure that any fatal and non-recoverable syntax errors will always
be reported.
WRN messages do not refer to syntax errors but rather violations of the
built-in rule checks.
Most of the WRN messages are mapped to rules in LINT policy. For
example, the W442a rule works on the WRN144 built-in message:
=pod+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
W442a Verilog lint
*
The specified reset sequence is not synthesizable. First statement in block must
be an if statement
*
Only certain forms of asynchronous reset are recognized by synthesis tools. The
first statement after the sensitivity list on the always block must be an
'if' statement.
=cut+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
$msg = "First statement in asynchronous block must be an 'if'";
spyRegisterRule("Verilog", "W442a", "", "veBuiltInInit", "", "Warning",
$msg, 5, "144", 1);
Thus, you can suppress WRN144 messages by specifying W442a rule
with the –ignorerules command-line option. Or, you can limit the
number of WRN144 messages by specifying W442a rule with the
-lvpr command-line option.
For built-in warning messages not covered, you can create a new rule
as follows to control a particular built-in warning message:
SpyRegisterRule (“Verilog”, “myWRNnnn”, “”, “veBuiltInInit”, “”,
“Warning”, “Massage for myWRNnnn”, 0, “nnn”, 1);
Where nnn is the Built-in Warning Message number for which you are
creating a new rule. Now, you can turn on or off reporting of the
WRNnnn as required.
NOTE: For rules based on built-in checks, the initFuncName is
veBuiltInInit, there is no exec-function and thus the
LANGUAGE verilog:
PURPOSE :
Function to check that all storage elements are
reset as specified
DESIGN VIEW : RTLDU (RTL)
LIBRARY NAME : libCoreRules
SEARCH KEYWORD LIST : reset related check
SPYGLASS CONSTRAINT INFORMATION :
None
DETAILED DESCRIPTION :
This primitive checks that all storage elements are reset as specified.
It reports a violation at the assignment statement within edge-triggered
block for which signal appears on left-hand side of assignment (ie.
location which causes signal to be registered).
C-PRIMITIVE ARGUMENTS :
Argument Format:
<type_list>
Argument Description:
<type_list>: One or more of the following:
any
all registered elements must be reset
synch
all registered elements must be synchronously reset
asynch
all registered elements must be asynchronously reset
globalsynch
require synch reset if any come directly from top-level
port
PERL CALLBACK SUBROUTINE CUSTOMIZATION :
None
OUTPUT MESSAGE ARGUMENTS :
(%s) Name of signal that is not reset as specified
(%s) Name of the corresponding module, in case of C-PRIMITIVE ARGUMENT
"globalsynch"
OUTPUT MESSAGE LOCATION :
At the assignment statement within edge-triggered block for which signal
appears on left-hand side of assignment (ie. location which causes
signal to be registered).
OUTPUT SCHEMATIC :
Not Applicable
EXAMPLES :
module synctop(d,clk1,async);
input d, clk1;
output async;
reg async;
reg a;
wire buf_clk = clk1;
REVISION HISTORY :
Jan-22-2003/SPYSO 3.3/Spyglass 3.3 :
Initial Draft
Oct-28-2003/SPYSO 3.4/Spyglass 3.4.1 :
No violation will be reported if all the bits of a vector are reset.
(if any) that are provided by the C rule primitive for inclusion in the
error message and the location (in the original HDL source) where the
violation message will be generated. We will use the string representing
the name of the signal in our error message.
Here is the new ResetAll rule (ignoring the rule documentation in pod/
cut):
$msg = “Signal %s is not reset”;
spyRegisterRule (“Verilog”, “ResetAll”, “”, “”, “veResetLD”,
“Error”, $msg, 10, “any”, 1);
The rule registration defines, in order:
Verilog - The rule will be registered for Verilog
ResetAll - The rule name.
“” – There is no alias for this rule.
“” – There is no initialization function for this rule
“veResetLD” – The execution function for the rule-primitive that
we extracted from the documentation above.
“Error” – We have chosen to give our rule a severity-label of
“Error”.
$msg - If the ResetAll rule is violated (that is, veResetLD detects an
error on one of the registers in the design), the message to be output
in the report file is $msg. The actual content of $msg is defined in
the rule registration prior to the rule itself, and will appear in the
report as:
Signal %s is not reset”
where %s represents a string and will be replaced by the name of the
violating signal as defined in the OUTPUT MESSAGE
ARGUMENTS section of the veResetLD documentation listed above.
In this case, the rule provides one string argument to your violation
message, which names the violating signal when you want to use the
any rule argument.
Depending on the specific rule-primitive, there may be none, one or
more than one Output Message Arguments provided and these can
be used when creating as detailed an error message as required. The
error message can obviously be created in a non-English language
by changing the $msg statement in the rule registration.
10 – As it has a severity of Error, we have chosen to give the
ResetAll rule a weight of 10 (only useful for scoring purposes).
These scores are typically used when the –report more or
-report score options are used when running SpyGlass (see the
SpyGlass Predicitive AnalyzerUser Guide for more details).
“any” – this is the argument for the veResetLD rule-primitive to
ensure checks are run on all registered elements in the design (see
the C-PRIMITIVE ARGUMENTS section for the full listing of
arguments for the primitive).
1 - The final argument to the ResetAll rule enables the registration.
If you wanted to keep the code in your policy but temporarily dis-
able the registration, you would change this value to 0. This could
also be a Perl variable (e.g. $EnableResetAll) that is set to 1 or 0
elsewhere in the policy or via command line options (see Adding
Command-line Options to SpyGlass Rules).
The objective of the second rule is to check that clock signal names are
all either clock or names that end in _clk.
Again, searching the Rule-Primitive Description files for suitable
primitives reveals the veNamesLD primitive with the following
information:
C-PRIMITIVE NAME : veNamesLD
SUPPORT : Production
LANGUAGE : verilog
DETAILED DESCRIPTION :
This C-Primitive performs general purpose checks on names of various
design construct. It checks the naming conventions for various objects
by passing the object to the perl function and depending upon the
return value of perl callback, it flags violation.
C-PRIMITIVE ARGUMENTS :
Argument Format:
<perl-fn> <type-list> [-limitviol <num>]
Argument Description:
<perl-fn> : A user-defined Perl callback. Name of perl call-back
sub-routine. (see section 'PERL CALLBACK SUBROUTINE
CUSTOMIZATION' for more detail)
module
all module names. Calls Perl function with args:
name of object, "module", isCellDefined
topmodule
all top module names. Calls Perl function with args:
name of object, "topmodule", isCellDefined
submodule
all sub module names. Calls Perl function with args:
name of object, "submodule", isCellDefined
ncoutputsignal
all unconnected output signals (subset of signal).
Calls Perl function with args: name of object, "ncoutputsignal"
nextstate
all state machine signals (subset of signal).
Calls Perl function with args: name of object, "nextstate",
isCellDefined
non_port
names of all non-port signals. The constructs checked by this
argument is: wire, reg, real, integer, and time.
output_port
output port names. Calls Perl function with args:
name of object, "output_port", isCellDefined
topport
all top level port names. Calls Perl function with args:
name of object, "topport", isCellDefined
parameter
all parameter names. Calls Perl function with args:
name of object, "parameter", isCellDefined
localparameter
all local parameter names. Calls Perl function with args:
name of object, "localparameter", isCellDefined
paramforvar
all signals which are parameterized (subset of signal).
Calls Perl function with args: name of object, "paramforvar"
port
all port names. Calls Perl function with args:
name of object, "port", isCellDefined
real
all variable names of type real. Calls Perl function with args:
name of object, "real", isCellDefined
register
-limitviol
this requires one argument to follow it, and can be used to limit the
number of violations reported in the design. If the next argument is
"all", all violations are reported. If it is an integer N, only N
violations for the corresponding rule are flagged.
OUTPUT SCHEMATIC:
Not Applicable
EXAMPLES :
1. This example illustrates how to check naming convention of
macros and parameters.
sub veConstName {
my $name = shift;
return 1
if ( $name !~ /^[A-Z][A-Z0-9_]*\$/ and /^.{1,8}\$/ and not /__/);
return 0;
}
$msg = "Constant '%s' does not follow recommended naming convention";
spyRegisterRule(
"Verilog", "ConstName", "",
"", "veNamesLD", "Guideline",
$msg, 2, "veConstName macro parameter", 1);
REVISION HISTORY :
Jan-17-2003/SPYSO 3.3/Spyglass 3.3 :
Initial Draft
April-12-2003/SPYSO 3.5.0/Spyglass 3.5 :
Aded argument localparameter
$msg = "Clock name '%s' does not follow the naming convention”;
spyRegisterRule("Verilog", "ClkName", "", "veNames_Init",
"veNames", "Guideline", $msg, 2, "ck_check clock", 1);
The first statement in the ck_check function shifts the clock name off
the argument stack. The if-else statement tests the name against the two
alternatives allowed by the naming convention.
If the name does not meet the objective, the ck_check function
returns 0, signalling a violation. If one of the regular expression checks
passes, the ck_check function returns 1, signalling no violation.
NOTE: All Perl call-backs must return either 0 or 1. Results are unpredictable if
you do not return a value and therefore the success path through the Perl
function must always end in “1;”. For example, the following callback will have
unpredictable behavior if the $name value does not match any of the
conditions:
sub bad_check {
my $name = shift;
if ( $name =~ /ck/ ) {
return 0 if $name != /end$/;
} elseif ( $name =~ /clk/ ) {
return 0 if $name != /^start/;
}
}
For our ClkName rule, we create the message variable $msg that will
include the name of the failing clock signal in place of the %s variable
returned by the veNamesLD primitive (and defined in OUTPUT
MESSAGE ARGUMENTS section of the documentation).
Finally, having registered the individual rules, we register
myRuleGroup, grouping our new rules together:
# myRuleGroup: A group containing ResetAll and ClkName
spyRegisterGroup(“Verilog”,”MyRuleGroup”, “”, “ResetAll ClkName”);
This call simply defines a group called myRuleGroup as a Verilog
group and puts rules ResetAll and ClkName into that group. Note that
this list of names in a group can itself contain group-names.
3. If the original rule has separate registration for verilog and vhdl
language, then the spyCreateRuleByCopy function create
separate verilog and vhdl language copies of the original rule.
In the above example, as the W467 rule is registered separately for
verilog and vhdl (see the mixedlint.pl file), then there will
be two copies of the ABCD467 rule for verilog (same as the
W467 verilog registration) and vhdl (same as the W467 vhdl
registration). As one copy per language is created, it is the same
behavior as the original rule independent of the language.
In case, you want to overload such rules, you need to overload the
two versions (the Verilog version and the VHDL version) separately.
4. The new rule requires the following elements from the original rule
policy file:
Requires ALL licenses to run the specified Atrenta standard
policy
Loads ALL SpyGlass-compatible library files (.spyso files) of the
specified Atrenta standard policy.
Runs ALL pre-requisite rules in the specified Atrenta standard
policy
ALL rule parameters in the specified Atrenta standard policy are
available.
Currently, it is not possible to locate the specific requirements of
the original rule. Hence, all requirements for the specified Atrenta
standard policy should be available.
5. Recursive calls to the spyCreateRuleByCopy function are
allowed.
6. You can also create a rule description section for the new rule
(=pod=cut section). Otherwise, the rule description of the original
rule is applicable (from spyexplain utility or in the SpyGlass
Design Environment).
spyObsoleteRule(“Clk_Gen12”,””);
Then, specifying the spygalss command as:
spyglass -batch -policy=lint -rule=Clk_Gen12
will display the following warning message:
WARNING [124] Ignoring obsolete 'Clk_Gen12' rule.
Consider another example of using spyObsoleteRule API, where the
Clk_Gen16 rule is made obsolete:
spyObsoleteRule(“Clk_gen16”, “SDCPARSE”);
Now specifying the spyglass command as given below:
spyglass -batch -policy=lint -rule=Clk_Gen12
Displays a warning message for the obsolete rule:
WARNING [123] Running 'SDCPARSE' rule instead of obsolete 'Clk_Gen16' rule.
Overview
Besides the standard reports, SpyGlass allows you to create your own
custom reports.
These custom reports can be any of the following:
Custom reports for Atrenta standard policies
Custom reports for your custom policies.
These custom reports can be based on the message information
available in the SpyGlass Violation Database.
sub error_generator {
my $vdb = $_[1];
my $out = $_[2];
my $violId = 0;
spyDumpFileHeader($vdb,"Error" ,$out,"");
open(IN, $vdb ) or die "Could not open VDB file '$vdb' for reading\n";
open(OUT, ">>$out") || die "Could not open Output file '$out' for writing\n";
select(OUT);
while (<IN>)
{
next if (/^#/);
$violId++;
next if spyViolationIsWaived($violId); #skip waived violation
chomp;
($rule,$alias,$severity,$file,$line,$col,$wt,$msg) = split(/
$::vdb_delimiter/);
next if $severity ne "Error" ;
print "rule: $rule, file: $file, error: $msg\n" ;
}
close(OUT);
select(STDOUT);
close(IN);
In this case, we first register the report, then define the report function.
The report will be generated when the user invokes SpyGlass with the
–report OnlyErrors command line option, and the Perl function
called to generate the report is called error_generator.
Among the arguments passed to error_generator,
$_[1] contains the name of the violation database. The
spyDumpFileHeader($vdb,"error" ,$out,"") function
generates a summary header on top of the report. It also generates some
internal data structures so that the spyViolationIsWaived API
works correctly. The spyDumpFileHeader function takes the
following arguments:
VDB filename
Report name
Output filename
use, and replicate them (with changed function names and global variable
names) in your custom report generator.
Introduction
The Atrenta® SpyGlass® Predictive Analyzer provides the feature to
overload a policy to meet local preferences of user base. This feature is
typically required when you want to use an Atrenta-standard policy but
with certain customizations such as different severity-labels, short
description, long description, alias name, etc.
NOTE: The rule-checking results with overloaded policies may be different from
results from normal policies.
There are two overloaded policy features:
Single overload feature
The Single overload feature allows you to create and use a single
overload for a policy.
Named overloads feature
You can also create and use multiple named overloads for each
policy.
Customizing Rules
To customize rules in the SpyGlass Design Environment, follow these
steps:
1. Set the Policy Customization setting to On in the Misc Page of the Tools
> Preferences... menu option.
2. Choose the Setup > Policies/Rules/Parameters... menu option.
The Policies/Rules/Parameters Selection window appears.
3. Activate the policy that you want to overload, if not already
activated.
4. To overload a rule, right-click on the rule description and select the
Customize This Rule... context menu option.
The Rule Customization window appears as in the following
example:
Customizing Parameters
Just like rules, you can also customize rule parameters to suit your
specific requirements.
To customize rule parameters in the SpyGlass Design Environment,
follow these steps:
1. Set the Policy Customization setting to On in the Misc Page of the Tools
> Preferences... menu option.
2. Choose the Setup > Policies/Rules/Parameters... menu option.
The Policies/Rules/Parameters Selection window appears.
3. Activate the policy that you want to overload, if not already
activated.
4. To customize a rule parameter, click the Customize button next to the
rule parameter name.
The Parameter Customization window appears as in the following
example:
Overloading Rules
The following keywords are available for overloading rules using the
<keyword> <overloaded-value>
RULE Rulename for which overload is applied.
This rule is expected to belong to the same policy as the one
where overload is being applied.
NOTE: This argument must be present in all spyOverload
function calls.
LANGUAGE This keyword acts as a filter on what RULE we want to
overload i.e spyOverload API function will apply to RULE of
given LANGUAGE only.
If this field is NOT used, then "rule name match" is sufficient
for identifying which rule to overload.
NOTE: Please note the following points:
• The -overloadrules specification is used in
conjunction with the spyOverload specification. However,
SpyGlass gives precedence to the -overloadrules
specification over the spyOverload specification.
• If a rule is registered in a single language (Verilog or
VHDL), and there is no overloadrule specification in the
same language (through -overloadrules or through
spyOverload) then overloadrules specification with
Verilog+VHDL is still applied for backward compatibility
purposes. However, this is not a recommended use-model
and should not be used.
• Language of the -overloadrules specification should
be same as used in the corresponding rule registration. For
example, if a rule is registered with Verilog + VHDL
language, its -overloadrules specification should
also be Verilog + VHDL.
• If you are not sure about the language specification of rule
registration, you can omit the language option from
overloadrule specification.
<keyword> <overloaded-value>
ALIASNAME Replaces the originally registered Alias name.
It is recommended that you do not use name (or alias) of
some other rule for new overload value, since it may result in
ambiguous behavior at time of SpyGlass output review.
SpyGlass, however, does not perform any check on
overloaded value.
MESSAGELABEL Replaces the original registered severity of the rule.
This keyword enables a rule to have multiple messages with
same/different severities.
If you want to overload severity or message for a multi
message rule, it will be mandatory to specify the
MESSAGELABEL argument, otherwise SpyGlass will
generate an error. For single message rules the
MESSAGELABEL argument is not required.
SEVERITY Replaces the originally registered severity-label.
The overloaded severity-label must be pre-registered using
spyRegisterSeverity API function. A new severity-label can
also be defined within the policy overload scope.
MESSAGETEXT Replaces the originally registered message text.
Though permitted by SpyGlass, this field should be
overloaded (if at all necessary) with utmost care. This field
serves as (printf-style) format string for final output of the rule
(violation) message, and may result in runtime error if
mismatching argument type is specified.
<keyword> <overloaded-value>
WEIGHT Replaces the originally registered weight.
This is typically useful when you want to modify the relative
significance of rules belong to the same severity.
NOTE: If you want to overload the weight for a rule, then if
the MESSAGELABEL argument is given, the overload value
of the weight will be applicable only for the corresponding
message. If the MESSAGELABEL argument is not specified,
then, it will be applicable to all the messages in the rule.
ORDERING Replaces the originally registered Rule-ordering value.
<pod-cut> In addition to the various rule-registration specification, the
description associated pod-cut text description (also known as, short-
help and long-help) can also be overloaded from within the
policy overload implementation. Both in the SpyGlass
Design Environment and the spyexplain utility, the pod-cut
description of the overload file takes precedence over the
original pod-cut in the original policy description.
<keyword> <overloaded-value>
VALUELIST Replaces the originally registered Value list.
NOTE: SpyGlass does not perform any check on
overloaded value, for any kind of compatibility with
original values.
<param-cut> description The associated param-cut text description can be
overloaded from within the policy overload
implementation.
Command-line
Specification Effect
-overloadpolicy Apply Policy overload on all policy being selected to
run. This is subject to policy overload file being found
in the specified search path.
-overloadpolicy=none Disables search and loading of overload files.
or not specified
-overloadpolicy=a,b Apply policy overload to policy named ‘a’ and ‘b’ only
(assuming one or more of these policy are selected to
run.
-overloadpolicy=all Apply policy overload on all policy selected to run. If
policy overload file is not found for any policy, it is
considered as an error condition, and (frequently) may
be because of incorrect or no ‘-I’ specification.
4. Enter the identifier for the new named overload in Enter Overload
Name. Specify the location where the new named overload file is to
created in Enter Directory or click Browse and select the location.
Click OK.
5. You return to the Rule Customization window where the new named
overload file is now added under the policy name.
6. The rule-groups and rules of the policy being overloaded are now
displayed in the Rule tree as in the following example:
7. To overload a particular rule, locate the rule in the Rule tree and
double-click on it.
The rule is added to the Overload Grid on the top with blank values
under the overloadable items.
A rule with multiple severities will have as many entries in the
Overload Grid as shown below:
For example, if a rule has two severities with different weight and
message strings, then the rule will have two entries for the rule in the
Rule Customization window.
To view the default values of the selected rule, right-click on the rule
name in the Overload Grid and select View Default... The rule default
values are displayed as in the following example:
You can use the Ctrl+P and Ctrl+N key combinations to go to the
previous overloaded rule and the next overloaded rule respectively.
12.To view the policy default, overload values of a rule’s overloadable
items under the different named overloads, and the effective
overload value, double-click on the rule name in the Overload Grid.
The rule overload details are displayed in the bottom pane as in the
following example:
The first line shows the policy defaults, the next lines show the
overload values, if any under different named overloads, and the last
line shows the effective overload value for each overloadable item
of the rule.
NOTE: The last entered overload value of an overloadable item is the
effective overload value of that item.
13.If required, you can change the overload values in the last listed
named overload to change the effective overload value.
14.On completion, click OK to save the settings and exit.
Now, any SpyGlass analysis run in the current SpyGlass Design
Environment session will use the overload values set.
Each named overload file has the same format as the single (unnamed)
overload file. See Working in the Batch Mode for details of creating
overload files.
You can supply the named overload files using the -overload
command-line option as in the following example:
%> spyglass -batch -verilog -policies=lint
-overload='CAD CAD1 METEOR'
-I <named-overload-dir> <other-options>
Using Perl
In order to customize SpyGlass, you need to understand Perl. If you are
not familiar with Perl, you should find a local expert, or visit your local
bookstore. A popular series of books is published by O'Reilly and
Associates - www.ora.com. We suggest you start with Learning Perl. If
you know how to write shell scripts and are familiar with sed regular
expressions or awk programming, you should not find Perl very
challenging. We will attempt a very superficial introduction to the
language here, solely to help you make simple modifications. We
strongly recommend you make the investment to learn Perl - if you are
like many engineers and developers, you will find it extremely valuable
as a general purpose tool.
Perl similarities to C
If you understand C programming, you will find much in Perl very
familiar:
Statements are free-format and all statements must end with a semi-
colon.
Flow control statements - if, while, for - look just like they do in C
Blocks of code are defined using { and }, for example: if (x) {$a = 1;
}
Perl supports pre and post-increment and assignment operators like
++, --, +=, ...
Perl even has functions like printf, sprintf, ...
on.
Perl variables can be automatically defined, by being referenced.
Alternatively they can be defined as essentially local variables (local to
the routine in which they are being defined) using "my". This is
probably the most appropriate method for a beginner. Thus you can
define a number of scalar variables by:
my $foo = 3;
my $bas = 'abc';
my $xyz = "def";
Scalar variable names are prefixed by '$'. Also note that strings can be
quoted by single quotes or by double quotes: 'c' and "c" are entirely
equivalent. There is a difference between single and double quotes in
Perl: if a variable name appears in a double quoted string, it will be
replaced by the value of the variable (a process known as
interpolation). If the string is single quoted, this will not happen.
Array variables are not very complex:
@foo = (3,4,5);
@bas = ("abc","def",2);
You can refer to an element of an array much as you would in C. Array
indices are 0-based so $foo[1] is 4. Why $foo and not @foo? Because
when you refer to an element, you are referring to a scalar value. If you
want to dig into this more, please buy a book! Similarly, $bas[0]
contains "abc".
Hash variables have no direct equivalent in C and are amazingly useful.
A hash variable is like an array except that it is indexed by values
which are not necessarily numeric. For each entry, a hash has a key (the
index value) and a value. For example:
%days = ('Mon',1,"Tue',2,'Wed',3'Thu',4,'Fri',5,'Sat',6, 'Sun',7);
Once you have defined this hash, you can refer to $days{'Wed'} which
has the value 3. (Note again the use of $ since we are referring to a
scalar value. Also, note the {} parentheses the hash equivalent of [ ] for
arrays).
Perl variables can be combined and tested much as you would perform
those operations in C. For example:
$x = 1;
for ( $i = 0 ; $i<20 ; $i++ )
{ $x = $x * $i; }
To print a value, use print (simpler to use than printf):
print "i is $i, x is $x\n";
Remember that variables are substituted in double-quoted strings so
this will print: i is 10, x is 20 (for example).