System Verilog Quick Ref
System Verilog Quick Ref
SystemVerilog Symposium
Sunburst Design
Track I: SystemVerilog Basic Training
Sunburst Design
Sunburst
2 of 133
Sunburst Design
Copyright notice
©2003
All slides in this presentation are copyrighted by Sunburst Design, Inc. of Beaverton,
Oregon and are solely intended for distribution to, and use by SystemVerilog
Symposium attendees. All rights reserved. No material from this seminar may be
used by any individual or company for training without the express written
permission of Sunburst Design, Inc.
Voice: 503-641-8446
FAX: 503-641-8486
e-mail: [email protected]
web: www.sunburst-design.com
Sunburst Design
Sunburst
3 of 133
Sunburst
Sunburst Design
4 of 133
• Pending Publications
– SystemVerilog by Sutherland, Davidmann & Flake
– The Art of Verification with SystemVerilog by Haque, Khan & Michelson
(same authors as "The Art of Verification with Vera")
Sunburst Design
Sunburst
5 of 133
SystemVerilogSunburst
Methodology
Design & Overview
Sunburst Design
Sunburst
6 of 133
Reference
History of the Sunburst Design
Material
Verilog HDL
• 1984: Gateway Design Automation introduced Verilog
• 1989: Gateway merged into Cadence Design Systems
• 1990: Cadence put Verilog HDL into the public domain
• 1993: OVI enhanced the Verilog language - not well accepted
• 1995: IEEE standardized the Verilog HDL (IEEE 1364-1995)
• 2001: IEEE standardized the Verilog IEEE Std1364-2001
• 2002: IEEE standardized the Verilog IEEE Std1364.1-2002
RTL synthesis
• 2002: Accellera standardized SystemVerilog 3.0 subset
Superset of Verilog-2001
SystemVerilog
assertions mailboxes from C / C++
test program blocks semaphores classes dynamic arrays
clocking domains constrained random values inheritance associative arrays
verification
process control direct C function calls strings references
SystemVerilog
Netlist RTL RTL
Hardware-assisted verification
Co-Sim
HDL Simulation Testbench
Overhead Enhanced Verification
Sunburst
SystemVerilog Testbench
Veriication Speed
Sunburst Design
10 of 133
Co-Sim
HDL Simulation Testbench
Overhead
Enables faster tools
and acceleration
SystemVerilog Testbench
Veriication Speed
SystemVerilog Design
Sunburst DesignLanguage
Sunburst Design
Sunburst
14 of 133
Verilog-2001 Event Scheduling
Current time slot
Sunburst Design
$monitor command
New name will be $strobe command
"Postponed"
events region To next
Monitor time slot
Sunburst Design
Sunburst
15 of 133
Guideline #4: Mixed sequential and combinational logic in the same always block
- use nonblocking assignments
Guideline #5: Do not mix blocking and nonblocking assignments in the same
always block
Guideline #6: Do not make assignments to the same variable from more than one
always block
Guideline #7: Use $strobe to display values that have been assigned using
nonblocking assignments
These guidelines still apply to
Guideline #8: Do not make #0 procedural assignments SystemVerilog RTL designs
Sunburst Design
Sunburst
16 of 133
reg r;
// 4-state, Verilog-2001 (sizeable) data type
integer i;
// 4-state, Verilog-2001 32-bit signed data type
logic w;
// 4-state, (sizeable) 0, 1, X or Z
reg [15:0] r16;
logic [15:0] w16;
bit b; // 2-state, (sizeable) 1-bit 0 or 1
bit [15:0] b16;
byte b8; // 2-state, 8-bit signed integer
shortint s; // 2-state, 16-bit signed integer
int i; // 2-state, 32-bit signed integer
reg, logic & bit
longint l; // 2-state, 64-bit signed integer can be sized
(or reg)
• logic is roughly equivalent to the VHDL std_ulogic type
– Unresolved
– Either permits only a single driving source -OR- procedural assignments
from one or more procedural blocks
– In SystemVerilog: logic and reg are Illegal to make both
continuous assignments
now the same and procedural assignments
(like wire and tri in Verilog) to the same variable
bit is an equivalent
logic is a 4-state type
unresolved 2-state type
defines.vh
`ifdef STATE2
typedef bit bit_t; // 2-state
`else
typedef logic bit_t; // 4-state
`endif
Sunburst Design
Sunburst
19 of 133
defines.vh
`ifdef STATE2
• Interesting design strategy to typedef bit bit_t; // 2-state
switch easily between 4-state `else
and 2-state simulations typedef logic bit_t; // 4-state
`endif
– Only use typedef-ed types
tb.v dff.v
module tb; module dff (
bit_t q, d, clk, rst_n; output bit_t q,
input bit_t d, clk, rst_n);
dff u1 (.q(q), .d(d), .clk(clk),
.rst_n(rst_n)); always @(posedge clk)
if (!rst_n) q <= 0;
initial begin else q <= d;
// stimulus ... endmodule
end
endmodule Default
4-state simulation
verilog_cmd defines.vh tb.v dff.v
Faster
verilog_cmd defines.vh tb.v dff.v +define+STATE2 2-state simulation
Sunburst Design
Sunburst
20 of 133
(Internal to a Module)
Module inputs
must be nets
endmodule endmodule
Net output
(driven by
Reg output assign)
(LHS of procedural assignment
must be a variable type)
Sunburst Design
Sunburst
22 of 133
(External to a Module)
module test;
reg t_in;
wire a2b; module A (out,in); module B (out,in);
wire t_out;
Often, instance
inputs are driven by
testbench variables
Sunburst Design
Sunburst
23 of 133
module test;
reg t_in;
wire a2b; module A (out,in); module B (out,in);
wire t_out; output out; output out;
input in; input in;
A u1(.out(a2b), a2b t_out
.in (t_in)); reg out; wire out;
B u2(.out(t_out), wire in; wire in;
.in (a2b));
always @(in) assign out = in;
out = in;
initial
t_in = 1; endmodule endmodule
module test;
logic t_in;
logic a2b; module A (out,in); module B (out,in);
logic t_out; output out; output out;
input in; input in;
A u1(.out(a2b), a2b t_out
.in (t_in)); logic out; logic out;
B u2(.out(t_out), logic in; logic in;
.in (a2b));
always @(in) assign out = in;
out = in;
initial
t_in = 1; endmodule endmodule
always @* begin
next = 'x; 'x is equivalent to Verilog-2001 'bx
case (state)
Logic-Specific Processes
Sunburst Design
always_latch
if (en) q <= d;
Logic-Specific Process
always_comb begin
tmp1 = a & b;
Correct tmp2 = c & d;
y = tmp1 | tmp2;
end
endmodule
module ao1b (
Possible error message: output bit_t q,
input bit_t en, d);
always_comb
ERROR: combinational logic requested if (en) q <= d;
but latch was inferred endmodule
Sunburst Design
Sunburst
28 of 133
Logic-Specific Process
module lat1b (
output bit_t q,
Possible error message: input bit_t en, d);
always_latch
if (en) q <= d;
ERROR: combinational feedback loop else q <= q;
- latch not inferred endmodule Sunburst Design
Sunburst
29 of 133
Logic-Specific Process
• always_ff
– permits simulation tool to module dff1 (
output bit_t q,
check for correct registered
input bit_t d, clk, rst_n);
logic coding style
always_ff @(posedge clk, negedge rst_n)
if (!rst_n) q <= 0;
Correct else q <= d;
endmodule
module dff1b (
Possible error message: output bit_t q,
input bit_t d, clk, rst_n);
ERROR: incorrect sensitivity list
always_ff @(clk, rst_n)
- flip-flop not inferred
if (!rst_n) q <= 0;
else q <= d;
endmodule Sunburst Design
Sunburst
30 of 133
... ...
endmodule endmodule
Sunburst Design
Sunburst
32 of 133
module comb1 (
output bit_t [2:1] y,
input bit_t a, b, c);
Equivalent to: Equivalent to:
always @(a,b,c) always_comb -OR- always @* always @(a)
orf1(a); orf1(a);
A void function
function void orf1;
behaves like input a; b & c are hidden inputs
0-delay task
y[1] = a | b | c;
endfunction
Equivalent to: Equivalent to:
always_comb always @*
always @(a) -OR- always @(a)
ort1(a); ort1(a);
Sunburst Design
Sunburst
则 将 执
35 of 133
Diagram
• FSM state diagram
go=0
Except where noted,
outputs "rd" and
"ds" equal 0 IDLE
go=1
DONE READ
ds=1 rd=1
ws=0
DLY ws=1
rd=1
Sunburst Design
Sunburst
38 of 133
Sunburst Design
Sunburst
39 of 133
Two-Always Block Coding Style
Sunburst Design
...
always @(state or go or ws) begin
next = 2'bx; Simulation debug trick
case (state)
IDLE : if (go) next = READ; Synthesis optimization trick
else next = IDLE;
READ : next = DLY;
DLY :
if (!ws) next = DONE;
else next = READ;
DONE : next = IDLE;
endcase
end
assign rd = ((state==READ)||(state==DLY));
assign ds = (state==DONE);
endmodule Output method #1
(continuous assignments)
Sunburst Design
Sunburst
40 of 133
...
always @(state or go or ws) begin
next = 2'bx; Initial default
rd = 1'b0; value assignments
ds = 1'b0; initialize the outputs
case (state) to a default state
IDLE : if (go) next = READ;
else next = IDLE;
READ : begin rd = 1'b1;
next = DLY;
end
DLY : begin rd = 1'b1;
if (!ws) next = DONE;
else next = READ;
end
DONE : begin ds = 1'b1;
next = IDLE;
end
endcase Output method #2
end (always-block assignments)
endmodule Sunburst Design
Sunburst
41 of 133
silver=4, gold=5
enum {bronze=3, silver, gold} medal;
Anonymous
2-state Syntax error
int types (implicit) c=8
enum {a=0, b=7, c, d=8} alphabet;
(explicit) d=8
go=0
Except where noted,
outputs "rd" and
IDLE "ds" equal 0
go=1
DONE READ
ds=1 rd=1
...
endmodule
Enumerated variables
state & next
Sunburst Design
Sunburst
43 of 133
module fsm_sv1b_3
...
...
endmodule
Sunburst Design
Sunburst
44 of 133
fsm1 Example - 3 Always Blocks
comma-separated
sensitivity list
Abstract Enums
Sunburst Design
module fsm_sv1b_3
...
...
endmodule
X-assignment is very useful for
simulation debugging and synthesis
"don't-care" optimization
Sunburst Design
Sunburst
46 of 133
fsm1 Example - 3 Always Blocks
Assigned Enums
Sunburst Design
clk
rst_n
go Display
ASCII radix -or-
ws Enum radix (??)
state 00 01 10 01 11 00
rd Display
Binary radix (??)
ds
Separate
Local
iteration-variable
iteration-variable
Verilog-2001 declaration
SystemVerilog declaration
module for4a (
module for4b (
output reg [31:0] y,
output logic [31:0] y,
input [31:0] a,
input [31:0] a, Auto-
input s);
Explicit input s); increment
integer i;
increment
always @(a or s)
always @(a or s)
for (int i=0; i<32; i++)
for (i=0; i<32; i=i+1)
if (!s) y[i] = a[i];
if (!s) y[i] = a[i];
else y[i] = a[31-i];
else y[i] = a[31-i];
endmodule
endmodule
Sunburst Design
Sunburst
52 of 133
module calu3 (
inout [15:0] data,
input [ 4:0] bs_lshft,
input [ 2:0] alu_op,
input [ 1:0] shft_lshft,
input calu_muxsel, en_shft, ld_acc, ld_bs,
input ld_multop1, ld_multout, ld_shft, en_acc,
input clk, rst_n);
Matching port names
wire [31:0] acc, alu_in, alu_out, bs, mult, multout;
wire [15:0] mop1; are listed just once
...
Barrel Shifter*
barrel_shifter barrel_shifter (.bs, .data, .bs_lshft,
(0-16)
.ld_bs, .clk, .rst_n);
mux2 mux (.y(alu_in),
MUX .i0(multout), .i1(acc),
.sel1(calu_muxsel));
alu alu (.alu_out, .zero(), .neg(),
ALU (32-bit) .alu_in, .acc, .alu_op);
accumulator accumulator (.acc, .alu_out, .ld_acc,
.clk, .rst_n);
Accumulator* shifter shifter (.data, .acc, .shft_lshft,
.ld_shft, .en_shft,
.clk, .rst_n);
Shifter (0,1,4)*
tribuf tribuf (.data, .acc(acc[15:0]),
.en_acc);
endmodule
Sunburst Design
Sunburst
55 of 133
module calu4 (
inout [15:0] data, Much less
input [ 4:0] bs_lshft, verbose!
input [ 2:0] alu_op,
input [ 1:0] shft_lshft,
input calu_muxsel, en_shft, ld_acc, ld_bs, MultOp1 reg*
input ld_multop1, ld_multout, ld_shft, en_acc,
input clk, rst_n);
Multiplier
wire [31:0] acc, alu_in, alu_out, bs, mult, multout;
wire [15:0] mop1; MultOut reg*
This style emphasizes
multop1 multop1 (.*); Barrel Shifter*
where port differences (0-16)
multiplier multiplier (.*);
occur
multoutreg multoutreg (.*);
barrel_shifter barrel_shifter (.*); MUX
mux2 mux (.y(alu_in), .i0(multout),
.i1(acc), .sel1(calu_muxsel)); ALU (32-bit)
alu alu (.*, .zero(), .neg());
accumulator accumulator (.*); Accumulator*
shifter shifter (.*);
tribuf tribuf (.*, .acc(acc[15:0])); Shifter (0,1,4)*
endmodule
Sunburst Design
Sunburst
56 of 133
• Permitted:
– .name and .name(signal) connections in the same instantiation
-OR-
– .* and .name(signal) connections in the same instantiation
NOTE: stronger typing of ports than Verilog-2001 and more concise! Sunburst Design
Sunburst
57 of 133
wire [31:0] acc, alu_in, alu_out, bs, mult, multout; wire [31:0] acc, alu_in, alu_out, bs, mult, multout; wire [31:0] acc, alu_in, alu_out, bs, mult, multout;
wire [15:0] mop1; wire [15:0] mop1; wire [15:0] mop1;
multop1 multop1 (mop1, data, ld_multop1, multop1 multop1 (.mop1(mop1), .data(data), multop1 multop1 (.mop1, .data, .ld_multop1,
clk, rst_n); .ld_multop1(ld_multop1), .clk, .rst_n);
multiplier multiplier (mult, mop1, data); .clk(clk), .rst_n(rst_n)); multiplier multiplier (.mult, .mop1, .data);
multoutreg multoutreg (multout, mult, multiplier multiplier (.mult(mult), .mop1(mop1), multoutreg multoutreg (.multout, .mult,
ld_multout, clk, rst_n); .data(data)); .ld_multout, .clk, .rst_n);
barrel_shifter barrel_shifter (bs, data, bs_lshft, multoutreg multoutreg (.multout(multout), barrel_shifter barrel_shifter (.bs, .data, .bs_lshft,
ld_bs, clk, rst_n); .mult(mult), .ld_bs, .clk, .rst_n);
mux2 mux (alu_in, multout, acc, .ld_multout(ld_multout), mux2 mux (.y(alu_in),
calu_muxsel); .clk(clk), .rst_n(rst_n)); .i0(multout), .i1(acc),
alu alu (alu_out, , , barrel_shifter barrel_shifter (.bs(bs), .data(data), .sel1(calu_muxsel));
alu_in, acc, alu_op); .bs_lshft(bs_lshft), alu alu (.alu_out, .zero(), .neg(),
accumulator accumulator (acc, alu_out, ld_acc, .ld_bs(ld_bs), .alu_in, .acc, .alu_op);
clk, rst_n); .clk(clk), .rst_n(rst_n)); accumulator accumulator (.acc, .alu_out, .ld_acc,
shifter shifter (data, acc, shft_lshft, mux2 mux (.y(alu_in), .clk, .rst_n);
ld_shft, en_shft, .i0(multout), shifter shifter (.data, .acc, .shft_lshft,
clk, rst_n); .i1(acc), .ld_shft, .en_shft,
tribuf tribuf (data, acc[15:0], .sel1(calu_muxsel)); .clk, .rst_n);
en_acc); alu alu (.alu_out(alu_out), tribuf tribuf (.data, .acc(acc[15:0]),
endmodule .zero(), .neg(), .alu_in(alu_in), .en_acc);
.acc(acc), .alu_op(alu_op)); endmodule
accumulator accumulator (.acc(acc), .alu_out(alu_out),
.ld_acc(ld_acc), .clk(clk),
.rst_n(rst_n));
shifter shifter (.data(data), .acc(acc),
.shft_lshft(shft_lshft),
.ld_shft(ld_shft),
31 lines of code .en_shft(en_shft),
.clk(clk), .rst_n(rst_n));
.* implicit ports
tribuf tribuf (.data(data), .acc(acc[15:0]),
module calu2 (
inout [15:0] data,
input [ 4:0] bs_lshft,
input [ 2:0] alu_op,
757 characters
input clk, rst_n);
518 characters
alu alu (.*, .zero(), .neg());
accumulator accumulator (.*);
shifter shifter (.*);
tribuf tribuf (.*, .acc(acc[15:0]));
Sunburst Design
endmodule
Sunburst
58 of 133
Disadvantage of Implicit .*
Port Connections Sunburst Design
sel[1]
sel[0] ena
Intended a
logic enb
b
• Easy to connect the wrong ports enc y
to the wrong nets for common c
ene
identifier names d
– Could be difficult to debug
module drivera ( module driverb (
output [7:0] y, Common enable output [7:0] y,
input [7:0] a, name input [7:0] b,
input ena); input ena);
SystemVerilog Enhancements
Sunburst Design
for
Design & Verification
Sunburst Design
Sunburst
62 of 133
Sunburst Design
Sunburst
63 of 133
unused a0
Unpacked array unused a1
bit a [3:0];
of bits unused a2
unused a3
Packed array
bit [3:0] p; unused p3 p2 p1 p0
of bits
[7:0]
[1:0]
[3:0]
Sunburst Design
Sunburst
65 of 133
Unpacked
[7:0]
[1:0]
[3:0]
Sunburst Design
Sunburst
66 of 133
Unpacked
[7:0]
[1:0]
[3:0]
Sunburst Design
Sunburst
67 of 133
...
[7:0]
The entire packed
[1:0] array!
[3:0]
Sunburst Design
Sunburst
68 of 133
Sunburst Design
Sunburst
69 of 133
Sunburst Design
Sunburst
70 of 133
Data Organization –
Sunburst Design
Break!
Sunburst Design
(10:15 - 10:30 AM)
Sunburst Design
Sunburst
74 of 133
Port Connections
• SystemVerilog Enhancements Concise instantiation
– Inferred port connections using .name & .*
Encapsulation of
– SystemVerilog connections by interface - level I interface information
Sunburst Design
Sunburst
75 of 133
Interface Capabilities
Sunburst Design
Sunburst Design
Sunburst
76 of 133
SystemVerilog Interfaces
Sunburst Design
Complex signals
SystemVerilog • Bus protocol repeated in blocks
Interface Bus • Hard to add signal through hierarchy
Design Signal 1
Signal 2
Read() Communication encapsulated in interface
Write()
• Reduces errors - easier to modify
Bus Bus Assert
• Significant code reduction - saves time
• Enables efficient transaction modeling
Bus • Allows automated block verification
Sunburst Design
Sunburst
77 of 133
Sunburst Design
Sunburst
78 of 133
Referencing Interface
Sunburst Design
top
interface intf;
logic a, b; mod_a intf mod_b
logic c, d; m1 w m2
logic e, f;
endinterface
module mod_a;
endmodule
No ports yet
module mod_b;
endmodule
Sunburst Design
Sunburst
80 of 133
top
interface intf;
logic a, b; mod_a intf intf intf mod_b
logic c, d; m1 i1 w i2 m2
logic e, f;
endinterface
module top;
intf w ();
mod_a m1 ();
mod_b m2 ();
endmodule
module mod_a
mod_a;(intf i1);
endmodule Add interface references
to mod_a and mod_b
module mod_b
mod_b;(intf i2);
endmodule
Sunburst Design
Sunburst
81 of 133
top
interface intf;
logic a, b; mod_a intf intf mod_b
logic c, d; m1 i1-w-i2 w m2
logic e, f;
endinterface
An interface is similar to a module
module top; straddling two other modules
intf w ();
Show that the w instance of the interface
mod_a m1 (.i1(w)); is aliased to the i1 reference in mod_a
mod_b m2 (.i2(w)); and the i2 reference in mod_b
endmodule
top
interface intf;
logic a, b; mod_a intf mod_b
Interface type
logic c, d; m1 i1-w-i2 m2
declaration
logic e, f;
endinterface
interface intf;
logic a, b; intf
Interface type
logic c, d; w
declaration
logic e, f;
endinterface
endmodule
It is legal to declare and instantiate
an interface without accessing the
interface nets and variables ...
Sunburst Design
Sunburst
84 of 133
Illegal Usage
endmodule
Sunburst Design
Sunburst
87 of 133
u1 instance of m5
initial begin
b_if.s2
write(1'b1); a.s2
... a.clk a.q
task write (input val); q b_if.q
@(negedge clk) b_if.s2 = val;
endtask Modport d u1.a.q = b_if.q
endmodule output
Sunburst Design
Sunburst
89 of 133
SystemVerilog Enhancements
Sunburst Design
for
Verification
Sunburst Design
Sunburst
92 of 133
Program Blocks
• Clocking blocks (domains) and cycle-based attributes
– To ease testbench development
– Promote testbench reuse
– Cycle-based signal sampling
– Cycle-based stimulus generation (drives)
– Synchronous samples
– Race-free program context
Sunburst Design
Sunburst
93 of 133
SystemVerilog Powerful
Sunburst Design
Assertion Enhancements
• Assertion mechanism for verifying
– design intent
– functional coverage intent
Assertions will be
discussed later
Sunburst Design
Sunburst
94 of 133
Verification Enhancements
• Direct Programming Interface (DPI) - DirectC Briefly discussed later
• New types:
– 'C'-types, string, dynamic array, associative array
• Pass by reference subroutine arguments
– better than Verilog-2001 reentrant tasks
• Synchronization:
– Dynamic process creation
– Process control Download a copy of the
– Inter-process communication. SystemVerilog LRM
• Enhancements to existing Verilog events
• Built-in synchronization primitives:
– Semaphore & mailbox
• Classes & methods
– Object-Oriented mechanism for abstraction &
encapsulation Sunburst Design
Sunburst
95 of 133
$finish command
• A final block is like an initial block
Triggers at the end of a simulation Event queue is empty
final begin
if ((ERROR_CNT == 0) && (VECT_CNT != 0)) begin final blocks
$write("\nTEST PASSED - %0d vectors", VECT_CNT); cannot have
$write(" - %0d passed\n\n", PASS_CNT); delays
end
else begin
$write("\nTEST FAILED - %0d vectors", VECT_CNT);
$write(" - %0d passed - %0d failed\n\n", PASS_CNT, ERROR_CNT);
end
end Sunburst Design
Sunburst
96 of 133
SystemVerilog Enhanced Scheduling Region for new
SV commands
Current time slot
Sunburst Design
From previous
Preponed
time slot
#1step
Active
NBA
clock
A clocking block encapsulates
input when inputs are sampled and
input when stimulus is driven
skew
output
output
skew Sunburst Design
Sunburst
100 of 133
wclk
input wfull
output skew
skew (negedge wclk)
wdata, winc, wrst
Sunburst Design
Sunburst
101 of 133
Active Active
wclk
wdata
winc
NBA NBA
wrst
Observed Observed
output skew
(negedge wclk) Reactive Reactive
Postponed Postponed
DRIVE
Sunburst Design
Sunburst
102 of 133
Drives
• Designate one clocking as default
default clocking tb.fifo.wclk;
– Special semantics
RTL design Inactive
Executes in Reactive region
design → clocking/assertions → program
NBA
clocking &
assertions Observed
Reactive
program name (<port_list>);
<declarations>; // type, func, class, clocking…
<continuous_assign> Postponed
initial <statement_block>
endprogram
Sunburst Design
Sunburst
104 of 133
SystemVerilog DPI
Sunburst Design
Sunburst Design
Sunburst
105 of 133
☺
Proposal has been made to allow
exporting of SystemVerilog tasks Sunburst Design
Sunburst
106 of 133
SystemVerilog to SystemC
Sunburst Design
(cont.)
Sunburst Design
Sunburst
109 of 133
Sunburst Design
Sunburst
110 of 133
SystemVerilog Assertions
Sunburst Design
New SystemVerilog
assertions book Assertion book shows examples using:
SystemVerilog Assertions (SVA)
Property Specification Language (PSL)
Open Verification Library (OVL) assertions
Sunburst Design
Sunburst
111 of 133
What Is An Assertion?
Sunburst Design
Sunburst Design
Sunburst
112 of 133
Source - Harry Foster, Adam Krolnik & David Lacey, Assertion Based Design,
Kluwer Academic Publishers, www.wkap.nl, 2003 Sunburst Design
Sunburst
113 of 133
*Source - Sean Smith, Synergy between Open Verification Library and Specman Elite,
Club Verification, Verisity Users' Group Proceedings, Santa Clara, CA, March 18-20,
Sunburst2002
Design
Sunburst
114 of 133
Bug-Detection Efficiency
Sunburst Design
Using Assertions
• Designers from these companies reported success :
– 34% of all bugs found by assertions on DEC Alpha 21164 project
– 25% of all bugs found by assertions on DEC Alpha 21264 project
750 bugs were identified The week after adding multiple assertions to
prior to adding assertions the design, the bug reporting rate tripled!
Bug-Detection Efficiency
Sunburst Design
HP Update
• Update on HP ASIC project status (~August 2002):
~4,300 assertions
~10% simulation overhead
~85% of total bugs reported in a one year period
– HDL verification does not detect HDL testing typically detects a bug
bugs directly in the offending logic multiple clocks after it happened
• Cyrix design:
– Bug report rate tripled after assertions were added
20 issues per week increased The time required to close out problems
to 60 issues per week fell from 7 days to 2 days
Unified Assertions
• Common subset of SVA and PSL
• Syntax and semantics mostly based on SVA
• Compatible for formal and simulation
Source:
http://www.accellera.org/membermeetdac.html Sunburst Design
Sunburst
124 of 133
Assertion Capabilities
Simulation
• Accessible to every designer Checks
SystemVerilog
Assertions
• Same familiar Verilog-like language Automated
Testbench
Fast learning curve
Hardware
• Part of SystemVerilog Assisted
– No pragmas or specialized language Verification
for maximum user productivity
– Easily usable by both design and Coverage
verification engineers
Formal Property
• Flexible usage – inlined or in a
separate file
Synthesis
SystemVerilog Assertions
Sunburst Design
• Immediate assertions
– Executed like a statement in a procedural block
– Primarily intended to be used with simulation
– Uses the keyword: assert
• Concurrent assertions
– Based on clock semantics
– Used to sample values of variables
– Uses the key words: assert property
Sunburst Design
Sunburst
126 of 133
Strobes
Disable assertion testing
when rst is high
property no_two_ads;
@(posedge busclk)
disable iff (rst) not (ADSOut [*2]);
endproperty
ADSOut should never be asserted on
assert property (no_two_ads); 2 consecutive posedge busclk's
Alternatively:
PSL-like
If this is true in the
non-overlapping
current cycle ...
implication |=>
... this should NOT be true
property no_two_ads; starting in the next cycle
@(posedge busclk)
disable iff (rst) (ADSOut |=> !ADSOut);
endproperty
ADSOut should be followed by !ADSOut
on the next posedge busclk
Sunburst Design
Sunburst
127 of 133
owngoes
own goeshigh
highinin1-5
1-5cycles
cycles...
then
bus request (breq) should go low
1 cycle after own goes high
sequence own_then_release_breq;
##[1:5] own ##1 !breq
endsequence PSL-like
overlapping
implication |->
property legal_breq_handshake;
@(posedge busclk) disable iff (rst)
$rose(breq) |-> own_then_release_breq;
endproperty
Wait for breq to go high ( $rose ) and then look
for the own_then_release_breq sequence
Assert the
legal_breq_handshake
property
Sunburst Design
Sunburst
128 of 133
Sunburst Design
Sunburst
129 of 133
$warning ( ... );
Reports run-time warning
(can be suppressed - tool specific)
SystemVerilog Assertions
Sunburst Design
– Immediate assertions
– Concurrent assertions
– Boolean expressions
– Sequences
– Property definitions
– Multiple clock support
– Binding properties to instances
Sunburst Design
Sunburst
132 of 133
Accellera SystemVerilog
Sunburst Design
Update &
Plan for the future!
EDA Vendor Fair
Take time to talk to the vendors about
SystemVerilog products and solutions
SystemVerilog Symposium
Sunburst Design
Track I: SystemVerilog Basic Training
Thank you for taking time to come and listen!
Sunburst Design
Sunburst