SpyGlass_SimulationRules_Reference
SpyGlass_SimulationRules_Reference
Disclaimer
SYNOPSYS, INC., AND ITS LICENSORS MAKE NO WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, WITH REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.
Trademarks
Synopsys and certain Synopsys product names are trademarks of Synopsys, as set forth
at http://www.synopsys.com/Company/Pages/Trademarks.aspx.
All other product or company names may be trademarks of their respective owners.
Third-Party Links
Any links to third-party websites included in this document are for your convenience
only. Synopsys does not endorse and is not responsible for such websites and their
practices, including privacy practices, availability, and content.
Synopsys, Inc.
690 E. Middlefield Road
Mountain View, CA 94043
www.synopsys.com
Report an Error
The SpyGlass Technical Publications team welcomes your feedback and suggestions on
this publication. Please provide specific feedback and, if possible, attach a snapshot.
Send your feedback to [email protected].
Contents
Preface..........................................................................................7
About This Book ...................................................................................... 7
Contents of This Book ............................................................................. 8
Typographical Conventions ..................................................................... 9
v
Synopsys, Inc.
vi
Synopsys, Inc.
Preface
7
Synopsys, Inc.
Preface
Chapter Describes...
Using the Rules in the SpyGlass Describes how to use the rules in
simulation Product the SpyGlass simulation product
Rules in SpyGlass simulation Describes the rules related to
constructs that are likely to cause
race conditions and therefore non-
determinism during simulation
8
Synopsys, Inc.
Preface
Typographical Conventions
Typographical Conventions
This document uses the following typographical conventions:
Syntax Description
[ ] (Square brackets) An optional entry
{ } (Curly braces) An entry that can be specified once or multiple
times
| (Vertical bar) A list of choices out of which you can choose
one
... (Horizontal Other options that you can specify
ellipsis)
9
Synopsys, Inc.
Preface
Typographical Conventions
10
Synopsys, Inc.
Using the Rules in the
SpyGlass simulation
Product
11
Synopsys, Inc.
Using the Rules in the SpyGlass simulation Product
Refer to the Atrenta Console Reference Guide for more information about
SpyGlass predefined rule severity classes.
12
Synopsys, Inc.
Using the Rules in the SpyGlass simulation Product
check_complete_sensitivity_list
Checks for the implicit or complete always block.
By default, the value of the check_complete_sensitivity_list
parameter is yes and the sim_race01 rule reports violation for implicit or
complete always block.
When the value of the parameter is set to no, the rule will not report any
race for implicit or complete always block with respect to the other always
block.
Used by sim_race01
Options yes, no
Default value yes
Example
Console/Tcl-based usage set_parameter
check_complete_sensitivity_list no
Usage in goal/source -check_complete_sensitivity_list=no
files
effort_level_sim_race
Specifies the amount of effort to be put by the sim_race01 rule while
detecting the race condition.
13
Synopsys, Inc.
Using the Rules in the SpyGlass simulation Product
Used by sim_race01
Options Positive integer value
Default value 0
Example
Console/Tcl-based usage set_parameter effort_level_sim_race 100
Usage in goal/source -effort_level_sim_race=100
files
effort_simloop_level
Specifies the amount of efforts put by the sim_loop01 rule in detecting a
simulation loop
Use this parameter to restrict the traversal through a particular scalar net
while detecting a simulation loop. By default, a net is traversed 200 times
during loop detection. When you set this parameter to a higher value, the
rule might require higher run-time.
Used by sim_loop01
Options Positive integer value
Default value 200
Example
Console/Tcl-based usage set_parameter effort_simloop_level 250
Usage in goal/source -effort_simloop_level=250
files
overlapsimloops
Specifies whether the sim_loop01 rule reports overlapping simulation loops
By default, the rule does not report overlapping simulation loops. Set this
14
Synopsys, Inc.
Using the Rules in the SpyGlass simulation Product
Used by sim_loop01
Options yes, no
Default value no
Example
Console/Tcl-based usage set_parameter overlapsimloops yes
Usage in goal/source -overlapsimloops=yes
files
handle_large_bus
Specifies whether the sim_race01 rule should process large bus signals.
By default, this parameter is set to no and the rule does not process large
bus signals.
Set this parameter to yes to enable the sim_race01 rule to process large
bus signals.
Used by sim_race01
Options yes, no
Default value no
Example
Console/Tcl-based usage set_parameter handle_large_bus yes
Usage in goal/source -handle_large_bus=yes
files
strict
Specifies whether strict rule checking should be enforced by the sim_loop01
and sim_race11 rules.
By default this parameter is set to no and these rules check against
reasonable guidelines, to avoid over-reporting.
15
Synopsys, Inc.
Using the Rules in the SpyGlass simulation Product
Set this parameter to yes to enforce strict rule checking. If the strict
parameter is specified with the list of rule names, strict checking is done
only for the rules specified in the list.
waiver_compat
Enables the waivers in the sim_race01 and sim_race02 rules to work
correctly even if the line numbers of the RTL get changed.
By default, this parameter is set to no and the violations are not waived
when:
Rule message has line number string
Waivers are applied based upon the message string (having line
number), and during subsequent runs
RTL has changed and hence the line number
If you set the value of this parameter to yes or <rule-name>, it ensures
that the rules do not generate the line number information in the first run
itself. Thus waivers work correctly even if the line numbers of the RTL gets
changed in the subsequent runs.
16
Synopsys, Inc.
Using the Rules in the SpyGlass simulation Product
17
Synopsys, Inc.
Using the Rules in the SpyGlass simulation Product
18
Synopsys, Inc.
Rules in SpyGlass
simulation
Overview
The SpyGlass simulation product has the following race condition detection
rules that detect constructs in RTL designs that are likely to cause race
conditions and therefore non-determinism during simulation:
Rule Flags...
sim_race01 Signals that are assigned and used in the same simulation
cycle in the same module
sim_race02 Signals that have multiple assignments in the same simulation
cycle
sim_race03 Flip-flop outputs that have been assigned using blocking
assignment statements
sim_race04 always constructs with functionality that depends on the
number of times the always construct is invoked in the same
simulation step
sim_race05 Time Zero race conditions
sim_race06 Flip-flop data path of a sequential device if any path in the
fan-in cone of the data path has blocking assignments only
sim_race07 Non-blocking assignments in clock path
19
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
Rule Flags...
sim_race08 Clock, asynchronous set, and asynchronous reset signals of
sequential devices that are directly driven by multiple drivers
sim_race11 Signals that are assigned and used in the same simulation
cycle across different modules
sim_loop01 Possible mismatch in gate-RTL simulation due to simulation
event loops
NOTE: As SpyGlass does not have the concept of simulation step or simulation cycle, it is
not possible to pinpoint the occurrence of real race condition based on the time
concept only.
NOTE: All Race Condition Detection rules are primarily meant for RTL designs. SpyGlass
will not find race conditions for components or gates instantiated in the netlist.
However, SpyGlass checks initial like constructs subject to the limitations
described in this document.
20
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
sim_race01
Reports signals that are assigned and used in the same simulation
cycle
When to Use
Use this rule to detect signals that are assigned and used in the same
simulation cycle.
Description
The sim_race01 rule reports signals that are assigned and used within the
same module in the same simulation cycle. This rule detects signals that
are in two always constructs in the same module or one always
construct and one continuous assignment statement in the same module.
NOTE: The sim_race01 rule reports read-write race conditions within the same module
whereas the sim_race11 rule reports read-write race conditions across different
modules. Therefore, all possible read-write races in the design are reported by one
or the other rule.
Rule Exceptions
The sim_race01 rule does not report race conditions based on the time
concept only, as shown in Example 6: Rule Limitations.
Parameters
check_complete_sensitivity_list: The default value is yes. Set the value of
the parameter to no to ignore any violation for race with respect to
implicit or complete always block.
waiver_compat: Default value is no. If you set the value of this parameter
to yes or <rule-name>, it ensures that the rule does not generate
the line number information in the first run itself. Thus waivers work
correctly even if the line numbers of the RTL gets changed in the
subsequent runs.
effort_level_sim_race: Default value is 0. Set this parameter to an integer
value in case of high run time to specify the amount of effort to be
applied while detecting the race condition.
handle_large_bus: Default value is no. Set this parameter to yes to
enable the sim_race01 rule to process large bus signals.
21
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
Constraints
None
22
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
begin
if (b)
begin
...
end
end
Example 2: Blocking Assignment Resulting in Concurrent Assign and
Use
In the following example, when there is a change in the signal d, the signal
a is reevaluated that in turn causes the signal b to be updated in the
assign statement. However, the updated value of the signal b may not be
visible to the if statement in the always construct, which leads to a race
condition.
assign b = a | c;
always @ (d)
begin
a = 0;
if (b)
begin
...
end
end
In the above example, change the blocking assignment to signal a to a
nonblocking assignment to avoid the race condition.
Example 3: No Race Condition
Consider the following example where assignment to the signal a is a
nonblocking assignment that prevents the race condition:
assign b =a | c;
always @ (d)
begin
a <= 0;
if (b)
begin
...
end
23
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
end
There is no race condition even if the assign statement is replaced by the
equivalent always construct.
Example 4: Race Conditions in Flip-Flop Descriptions
Consider the following example where the output of one flip-flop is fed to
the input of another flip-flop at the same clock event:
always @(posedge clk)
sig1 = data;
reg [3:0] b;
reg [5:0] out;
reg a;
wire ad;
wire [3:0] bd;
24
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
else b = b + 1;
assign ad = a;
assign bd = b;
initial
begin
...
#15 if (a)
$display("....");
end
Example 7: Implicit always blocks
Consider the following examples where, by default, the rule reports a
violation for the implicit always block. However, the rule does not report a
violation when the check_complete_sensitivity_list parameter is set to no.
module test;
reg a, b, c, d,e;
25
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
always@(*) begin
a= 1'b0;
a= 1'b1;
b = c;
end
always@(*) begin
c = 1'b0;
c = 1'b1;
d = a;
end
endmodule
module test;
reg a, b, c, d,e;
always@(*) begin
a= 1'b0;
a= 1'b1;
b = c;
end
always@(d) begin
c = 1'b0;
c = 1'b1;
d = a;
end
endmodule
module test;
reg a, b, c, d,e;
always@(*) begin
a= 1'b0;
a= 1'b1;
b = c;
end
always@( posedge d) begin
c = 1'b0;
c = 1'b1;
a = d;
end
endmodule
26
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
Rule Group
simulation
27
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
sim_race02
Reports signals that have multiple assignments in the same
simulation cycle
When to Use
Use this rule to detect signals that have multiple assignments in the same
simulation cycle.
Description
The sim_race02 rule reports signals that have multiple assignments in the
same simulation cycle. Design may contain assignments to a signal in two
always constructs in the same simulation cycle.
Rule Exceptions
The sim_race02 rule has the following limitations:
1. This rule checks for race conditions across two always constructs only.
2. This rule does not report race conditions based on the time concept
only, as shown in Example 4.
NOTE: If you want to detect multi-driven nets, it is better to use the W415 rule instead of
sim_race02.
Parameters
waiver_compat: Default value is no. If you set the value of this parameter
to yes or <rule-name>, it ensures that the rule does not generate
the line number information in the first run itself. Thus waivers work
correctly even if the line numbers of the RTL gets changed in the
subsequent runs.
Constraints
None
28
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
always @(a)
begin
b = d & e;
end
29
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
Example 2
Consider the following example where a race condition exists in sequential
logic for the signal b:
always @(posedge clka)
b = a;
input a;
output b;
reg b,c,e,d;
always @ (a)
b = a | c;
always @(a)
begin
b = d & e;
end
endmodule
Example 4
This rule does not report race conditions based on the time concept only, as
shown in the following example.
initial
begin
fork
#5 a = 1’b0;
#7 b = 1’b0;
30
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
join
#8 a = 1’b1;
end
initial
begin
...
#15 if (a)
$display("....");
end
Rule Group
simulation
31
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
sim_race03
Avoid assigning flip-flop outputs in blocking manner
The sim_race03 rule flags flip-flop outputs that have been assigned using
blocking assignment statements in an always construct.
Using blocking assignment for flip-flop outputs may lead to race conditions
if the output of one flip-flop is the data input of another flip-flop. Then, the
sampling of data input of the second flip-flop may be occurring in the same
simulation step as the output of the first flip-flop, resulting in a race
condition.
Using non-blocking assignments for flip-flop outputs orders the setting and
sampling of signals.
Message Details
The following message appears at the location of a blocking assignment of
a flip-flop output <sig-name>:
[SIMULATION-RACE] Blocking assignment used for flip-flop output
'<sig-name>'
The message is back-annotated to the RTL display.
Rule Severity
Simulation-Race
Examples
Consider the following example where the flip-flop output a of instance
dff0 of module dff is being used as the data input of the flip-flop dff1
of the module dff and the flip-flop output q of the module dff is being
assigned using blocking assignment:
module test (out, in, clk);
input in, clk;
output out;
wire a;
32
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
reg q;
always@(posedge clk)
q = d;
endmodule
For this example, SpyGlass generates the following message:
Blocking assignment used for flip-flop output 'q'
To fix this message, change the blocking assignment to non-blocking
assignment as follows:
always@(posedge clk)
q <= d;
NOTE: The sim_race03 rule flags a message for the module dff even if it was not
instantiated anywhere.
33
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
sim_race04
Avoid Event Counting Code
Message Details
The following message appears at the location of an event counting
statement:
[SIMULATION-RACE] Event counting code used
The message is back-annotated to the RTL display.
Rule Severity
Simulation-Race
Examples
Consider the following examples where the sensitivity list of the always
construct has two variables and the variable i counts the number of times
the always construct is invoked:
always @(A or B)
begin
34
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
i = i + 1;
end
always @ (event1 or event2)
begin
i = i + 1;
end
35
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
sim_race05
Avoid Time Zero race
The sim_race05 rule flags signals in event triggers that are initialized to
values that could cause non-deterministic event trigger.
Message Details
The following message appears when there is a possible race condition for
signal <sig-name> due to initialization at line <num1> and use at line
<num2>:
[SIMULATION-RACE] Time Zero Race condition for signal <sig-
name> on line <num1> and line <num2>
The message is back-annotated to the RTL display.
Rule Severity
Simulation-Race
Examples
Consider the following example where the always construct could be
triggered if the event trigger is established before the initial value is
assigned to the clock signal clk:
initial
begin
clock = 1;
forever #50 clock = ~clock;
end
36
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
either clock was initialized with 0 or event triggering would have been
happening on a negative edge.
This race condition can be fixed by ensuring that there is no transition at
time 0 as follows:
initial
begin
clock = 1’bx;
#50 clock = 1’b0;
forever #50 clock = ~clock;
end
37
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
sim_race06
Flip-flop data path should not be entirely blocking
The sim_race06 rule flags data path of a sequential device if any path in
the fan-in cone of the data path has blocking assignments only.
To ensure that the new value of data arrives after the current edge of the
clock has been processed, the data path should appear as the LHS of a
non-blocking assignment statement. It is not necessary for all the
expressions involved in the data path computation to be non-blocking
assignments. However, all paths having a cone-in into the data pin of a flip-
flop or a latch should have at least one non-blocking assignment.
Message Details
The following message appears when a path from net <sig1-name> to
the data input <sig2-name> of a flip-flop has blocking assignments only:
[SIMULATION-RACE] Entire data path from <sig1-name> to <sig2-
name> (Data pin) is Blocking
The message is back-annotated to the RTL and schematic display.
Rule Severity
Simulation-Race
Examples
Consider the following example where there is no non-blocking assignment
in the path from signal d3 to signal data (data pin of flip-flop q_reg):
module test (clk, d1, d2, d3, d4, out);
input clk, d1, d2, d3, d4;
output out;
reg q_reg;
reg data1, data2;
wire data;
38
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
39
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
sim_race07
Non-blocking assignment should not be used in clock or enable
path
Message Details
The following message appears when a path from net <sig1-name> to
the clock or enable input <sig2-name> of a flip-flop has a non-blocking
assignment:
[SIMULATION-RACE] Non-blocking assignment used in clock path
from <sig1-name> to <sig2-name> (Clock/Enable pin)
The message is back-annotated to the RTL and schematic display.
Rule Severity
Simulation-Race
Examples
Consider the following example where the clock clk1 of the flip-flop
q_req is generated by using a non-blocking assignment:
module test (gating_sig1, clk, data_in, out);
input gating_sig1, clk, data_in;
output out;
40
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
reg q_reg;
reg clk1;
wire clk_w;
41
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
sim_race08
Control signals of a sequential device should not be multiply driven
The sim_race08 rule flags control signals (clock, asynchronous set, and
asynchronous reset signals) of sequential devices that are directly driven
by multiple drivers.
Multi-driven clock, set, or reset signals may drive the sequential element to
unknown or incorrect states.
The sim_race08 rule checks all control signals in the sensitivity list of a
sequential element and flags a message if any control signal is directly
driven by multiple drivers in the same or different module.
NOTE: Multi-driven data input to sequential elements is allowed.
Message Details
The following message appears at the location where a multi-driven signal
<sig-name> is encountered in the sensitivity list of a sequential element:
[RACE] Multiple driven signal '<sig-name>' fed to Clock/Set/
Reset input of sequential element.
The message is back-annotated to the RTL and schematic display.
Rule Severity
Race
Examples
Example of Multi-driven Signal Used in the Same Module
Consider the following example where signal muxed_clk is a multi-driven
signal and is in the sensitivity list of the sequential element q_reg:
module test (scan, clk, tclk, data, scan_in, out);
input scan, clk, tclk, data, scan_in;
output out;
reg q_reg;
wire muxed_clk, non_scan;
42
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
reg d;
wire clock;
reg d;
43
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
endmodule
For this example, SpyGlass generates the following message:
Multiple driven signal 'clock' fed to Clock/Set/Reset input of
sequential element.
44
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
sim_race11
Detect Read-Write Race globally
The sim_race11 rule flags signals that are assigned and used in the same
simulation cycle across different modules.
Assigning and using the signals in the same simulation cycle leads to a race
condition.
The sim_race11 rule detects such signals that are in two always
constructs in different modules or one always construct and one
continuous assignment statement in different modules.
When you set the strict parameter to yes, the rule reports violation inside
module hierarchy.
NOTE: The sim_race01 rule flags read-write race conditions within the same module
whereas the sim_race11 rule flags read-write race conditions across different
modules. Therefore, all possible read-write races in the design are flagged by one
or the other rule.
Message Details
The following message appears at the location where a signal
<sig1-name> is assigned in module <module1-name> when it is read
as <sig2-name> in module <module2-name> in the same simulation
cycle:
[RACE] Read-Write Race for signal '<sig1-name>' (assigned in
module '<module1-name>' and read as signal '<sig2-name>' in
module '<module2-name>')
The message is back-annotated to the RTL display.
Rule Severity
Race
Examples
Consider the following example:
module top(out, in, clk);
input in, clk;
output out;
45
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
wire out1;
reg out1;
reg out1;
46
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
sim_loop01
Possible mismatch in gate-RTL simulation due to simulation event
loops
When to Use
Use this rule to detect event simulation loops in a module.
Description
The sim_loop01 rule reports event simulation loops in a module. These
loops create possible mismatch in gate-RTL simulation.
During simulation, an event can be propagated in any of the following
ways:
From a signal in the sensitivity list to a signal in LHS of blocking
assignment statements of an always block
From a signal in RHS to a signal in LHS of a continuous assignment
statement, which includes a wire assignment
From input ports to output ports in case of Verilog built-in gates
instantiation
An event simulation loop is detected when an event on a signal in the
sensitivity list of a combinatorial always block, say A1, directly or
indirectly triggers continuous assignment statements or combinatorial
always blocks or built-in gate, which again triggers the always block A1.
An event loop should meet the following criteria:
At least one combinatorial always block
A cyclic loop among the combinatorial always block or built-in gate
instantiation or continuous assignment statements
Rule Exceptions
The sim_loop01 rule does not propagate an event on a signal across RTL
modules. Refer to Example 5 for an illustration.
Parameters
effort_simloop_level: Default value is 200. This indicates a net is
traversed 200 times during loop detection. Set this parameter to a
47
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
Constraints
None
48
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
assign c = b;
always @(a or c)
begin
d = c;
b = a;
end
In this case, signal b is assigned in the always block. The signal triggers
signal c of the continuous assignment statement, which again triggers the
the always block. This creates an event simulation loop. As a result, the
sim_loop01 rule reports a violation.
Example 2
Consider the following example:
always @(a or c)
begin
d = c;
b = a;
end
In this case, signal b is assigned in the always block. The signal triggers
signal f of the second continuous assignment statement, which further
triggers signal c of the first continuous assignment statement. Signal c
again triggers the always block. This creates an event simulation loop. As
a result, the sim_loop01 rule reports a violation.
49
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
Example 3
Consider the following example that contains two always blocks:
In this case, signal b is assigned in the second always block. The signal
triggers signal c of the first always block, which again triggers the second
always block. This creates an event simulation loop. As a result, the
sim_loop01 rule reports a violation.
Example 4
Consider the following example that contains three always blocks:
50
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
assign c = f;
always @(a or c or e)
begin
d = c & e;
b = a;
end
In this case, module A1 is an RTL module. As the sim_loop01 rule does not
propagate an event on a signal across RTL modules, the rule does not
report a violation.
51
Synopsys, Inc.
Rules in SpyGlass simulation
Overview
Rule Group
SimulationRules
52
Synopsys, Inc.
List of Topics
53
Synopsys, Inc.
54
Synopsys, Inc.