SVA Excercise 1
SVA Excercise 1
Location
SVA/lab_1
Design
The design file is named traffic.v. There are 2 state machines that control the lights
for the North/South traffic and for the East/West traffic. The state variables are named
ps0 and ps1. There are also 6 binary signals that are the outputs of the traffic module
and directly control the 2 traffic lights:
Signal
Functionality
ps0
ps1
g0
y0
r0
g1
y1
r1
1 of 9
3/6/2006
Use the appropriate checkers from the SVA Checker Library and instantiate them in the
design. Consider the following checkers:
Name
assert_one_hot
assert_mutex
Parameters
#(severity_level, width, options, msg, category)
severity_level: Default value is 0.
options: Unused. (The only supported option is
options=1, which defines the assertion as a
constraint for formal tools.) Default is 0.
width: Width of the port test_expr.
msg: String to be printed upon failure.
category: Category value for control over
assertions. Default is 0.
#(severity_level, edge_expr, msg, category)
severity_level: Default value is 0.
edge_expr: Defines clock sampling edge. 0 =
posedge, 1 = negedge. Default is 0.
msg: String to be printed upon failure.
category: Category value for control over
assertions. Default is 0.
Arguments
(clk,reset_n,test_expr)
reset_ n: reset signal,
active low
clk: sampling clock at
posedge
test_expr: expression to be
checked
(clk, reset_n, a, b)
reset_ n: reset signal,
active low
clk: sampling clock at
specified edge
a, b: two expressions that
must never be 1 at the
same time
2 of 9
3/6/2006
Open the file vcdplus.vpd and then in the hierarchy window open tb and then dut. You
should see 4 assertion groups. Each group contains the associated design signals as well
as another group of signals named clk_event, result and end_time. Drag all the signals
onto the wave panel and examine how the assertion successes and failures are presented.
To enable SVA coverage add the cm assert switch at compile and run times, i.e.:
> vcs traffic.v -sverilog -PP -assert enable_diag \
+define+ASSERT_ON -y $VCS_HOME/packages/sva +libext+.v \
+incdir+$VCS_HOME/packages/sva cm assert
> simv -assert success -assert report cm assert
> assertCovReport
To view the coverage results use Netscape:
> netscape simv.vdb/reports/report.index.html
3 of 9
3/6/2006
Location
SVA/lab_2
Design
In this lab the objective is to create a number of custom SVA assertions that will be
placed in a separate module and file. This checker module will then be bound to the
design using the bind statement.
Use the file traffic.sv as a template for the custom assertions. In the file the module
interface and the binding is already done.
Write SVA assertions to verify the following behaviors of the traffic controller:
1) Proper state transitions following the cycle green -> yellow -> red -> red ->
green, for both lights (Note that the light will remain in the red state for 2
cycles). More specifically, verify that
If (currently green) then (next is yellow)
If (currently yellow) then (next is red for two clock cycles)
If (changed to red in the past cycle and is red) then ( next it is green)
Hint: Create a property (sequence) |-> (sequence), and then assert that property,
repeat this 5 more times.
Hint: Consider using the built-in functions $past and $rose.
Should these properties hold also during reset? If not, what can you do about it?
2) Only one light (red or green or yellow) may be on for the N/S lane. Repeat for
the E/W lane.
Hint: Use the built-in function $countones.
3) Upon exiting reset, both lights should be red (reset is active high).
Hint: Use the built-in function $fell.
The following two built-in functions can be used when writing the properties:
2004 Synopsys, Inc.
4 of 9
3/6/2006
$countones( x )
$past( x, n )
$rose( x )
$fell( x )
5 of 9
3/6/2006
Location
SVA/lab_3
Design
Memory Controller
The protocol followed by the controller is shown on the next page. The start of Read or
Write operation is marked by a 1-cycle-wide pulse on adxStrb. If it is a Write operation,
busRdWr_N is pulsed low at the same time.
Read operation: busRdWr_N is held high with adxStrb. When adxStrb is sampled high,
the address is transferred from busAddr[5:0] to ramAddr and remains stable for 2 cycles.
busAddr[7:0] is decoded and the appropriate cex_N (x = 0, 1, 2, or 3) line is driven low
for one cycle one cycle after adxStrb is sampled high. When cex_N is sampled low, the
data on ramData is driven to busData for one cycle. This completes the Read operation.
Write operation: busRdWr_N is pulsed low with adxStrb high. When adxStrb is sampled
high, the address from busAddr [5:0] is transferred to ramAddr and remains stable for 4
cycles. busAddr[7:0] are decoded and drive the appropriate cex_N line low 2 cycles later,
for one cycle. rdWr_N is driven low at the same time as cex_N. busData is sampled with
adxStrb high and transferred to ramData 1 cycle later where it stays stable for 3 cycles.
This completes the Write operation.
6 of 9
3/6/2006
The memory Read protocol is as shown in the following diagram (delays in cycles).
2
N
The memory Write protocol is as shown in the following diagram (delays in cycles).
1
3
4
N
2004 Synopsys, Inc.
7 of 9
3/6/2006
The following are two useful boolean expressions that when true mark the beginning of a
Read, resp. Write, operation:
read_req
write_req
Read operation starts when adxStrb is high, busRdWr_N high, and !reset
Write operation starts when adxStrb is high, busRdWr_N low and !reset
Questions:
1) How many times did a Read operation occur?
____________________________________
2) How many times did a memory operation occur (Read + Write)?
____________________________________
8 of 9
3/6/2006
Advanced SVA
Location
SVA/lab_4
Design
Memory Controller
The design is the same as in Lab 3. Write assertions that verify the following behaviors:
1. Once cex_N returns inactive (all deasserted), they all four must remain inactive until
the next assertion of adxStrb.
Use repetition [*M:N] in the property.
As it is not known when the next address strobe will arrive, you can specify an
open-ended range for N. You could specify a finite value of N as an equivalent of
a watchdog timer check. However, in that case the finite delay is in fact verifying
that the environment is behaving correctly, while the assertion is to verify the
behavior of the DUT. Would this be a correct formulation of the property?
2. Verify that
the address is correctly transferred from busAddr to ramAddr, and
it remains stable for the required number of clock cycles, in both Read and Write
operations.
3. Verify that the controller correctly transfers data from busData to ramData during a
Write operation.
4. Verification of the memory and controller: Verify that
the memory retains the last written value to an address. I.e., after a Write, a
subsequent Read operation will read back that value, regardless other intervening
operations to different addresses, as observed from the bus signals.
after a reset, as long as an address has not been written into, the value read out
should be 0.
Question: Consider implementing the above assertions using SVA local variables and
using Verilog variables. What are the pros and cons, in particular regarding property 4?
9 of 9