DAC2009 SystemVerilog Update Part2 SutherlandHDL
DAC2009 SystemVerilog Update Part2 SutherlandHDL
Clifford E. Cummings
Sunburst Design, Inc.
[email protected] www.sunburst-design.com
Stuart Sutherland
Sutherland HDL, Inc.
sponsored by
[email protected] www.sutherland-hdl.com
Part 2:
Stu Sutherland of Sutherland HDL presents the details on the major new features in SystemVerilog-2009 that involve SystemVerilog Assertions See the remaining slides of this presentation, or www.sutherland-hdl.com/papers/ DAC2009_SystemVerilog_Update_Part2_SutherlandHDL.pdf
2009, Sutherland HDL, Inc.
2 of 27
wizard
Independent Verilog/SystemVerilog consultant and trainer Hardware design and verification engineer Have been working with Verilog since 1988 Bachelors in Computer Science / Masters in Education Presented dozens of papers (www.sutherland-hdl.com/papers) Published books on Verilog PLI and SystemVerilog for Design Technical editor of every version of the IEEE Verilog and SystemVerilog "Language Reference Manual" since 1995 Founded Sutherland HDL in 1992 Provides Verilog/SystemVerilog consulting services Provides the absolute best Verilog and SystemVerilog training!
NOTE: NOTE: There There is is a a typo typo on on slide slide 3 3 of of Part Part 1; 1; It It is is Cliff Cliff that that is is a a close close 2nd! 2nd!
2009, Sutherland HDL, Inc.
3 of 27
IEEE SystemVerilog-2005
assertions test program blocks clocking domains process control interfaces nested hierarchy unrestricted ports automatic port connect enhanced literals time values and units uwire ANSI C style ports generate localparam constant functions modules parameters function/tasks always @ assign mailboxes semaphores constrained random values functional coverage packages compilation unit space 2-state modeling specialized procedures array assignments unique/priority case/if `pragma classes inheritance polymorphism strings structures unions const break continue return dynamic arrays associative arrays queues references C types void alias casting typedef enum $clog2 multi dimensional arrays signed types automatic ** (power operator) beginend while for forever ifelse repeat + = * / % >> << dowhile ++ -- += -= *= /= >>= <<= >>>= <<<= &= |= ^= %= ==?
design
IEEE Verilog-2005
`begin_keywords standard file I/O $value$plusargs `ifndef `elsif `line @* $finish $fopen $fclose $display $write $monitor `define `ifdef `else `include `timescale
IEEE Verilog-2001
(* attributes *) configurations memory part selects variable part select initial disable events wait # @ forkjoin wire reg integer real time packed arrays 2D memory
4 of 27
5 of 27
The target is to have an IEEE 1800-2009 SystemVerilog standard First round of balloting was completed in April 2009 100% YES votes, but with lots of comments Second round of balloting to be conducted in August, 2009 Addresses all comments made on first ballot Official release might slip into 2010 due to IEEE "red tape" process A draft of the merged standard is available from the IEEE today
2009, Sutherland HDL, Inc.
6 of 27
let Templates
Mantis 1728
SV-2009 adds a new let construct for defining code templates Can replace the (often abused) `define text macros
Eliminates the problems of `define
let does not have file order dependencies like `define let has a local scope; `define can inadvertently affect other files
package my_templates; let check_mutex(a, b) = assert( !(a && b) ); let valid_arb(request, valid, override) = |(request & valid) || override; endpackage module my_chip (); import my_templates::*; Expands Expands to: to: assert( assert( !(read_enable !(read_enable && && write_enable) write_enable) ); ); always_comb begin check_mutex(read_enable, write_enable); if (valid_arb(.request(start), .valid(d_ok), .override(abort))) begin ... // do arbitration end Expands Expands to: to: end if if ( ( |(start |(start & & d_ok) d_ok) || || abort abort ) ) endmodule
2009, Sutherland HDL, Inc.
7 of 27
Assertion Checkers
Mantis 1900
SV-2009 adds assertion checker blocks Encapsulates assertions and supporting code in a verification unit Provides a mechanism for defining assertion libraries Engineers can use checkers without having to learn SVA
package checker_library; checker check1 (event clk, logic[7:0] a, b); logic [7:0] sum; always @(clk) begin sum <= a + 1b1; p0: assert property (sum < `MAX_SUM); end p1: assert property (@clk sum < `MAX_SUM); p2: assert property (@clk a != b); endchecker // other checker definitions endpackage module my_chip (); check1 check_inputs(posedge clk, in1, in2); // functionality of my chip endmodule
2009, Sutherland HDL, Inc.
A A checker checker can can contain contain (partial (partial list): list): Variables Variables Functions Functions Assertions Assertions Initial, Initial, always always and and final final procedures procedures Generate Generate blocks blocks
A A checker checker can can be: be: Instantiated Instantiated outside outside of of RTL RTL code code Embedded Embedded within within RTL RTL code code
8 of 27
Untyped Untyped arguments arguments allow allow assertions assertions libraries libraries to to be be more more flexible flexible on on the the actual actual argument argument types types
assert property (mclk, data, s1, address); NOTE: NOTE: The The new new let let construct construct can can have have untyped untyped arguments arguments but but the the SV-2009 SV-2009 standard standard does does not not permit permit the the untyped untyped keyword keyword with with let let constructs; constructs; This This was was an an oversight oversight in in the the syntax syntax that that will will be be corrected corrected in in a a future future version version of of the the standard standard (see (see Mantis Mantis 2835) 2835)
2009, Sutherland HDL, Inc.
9 of 27
global global clock clock definition definition in in the the entire entire elaborated elaborated model model Can Can only only be be declared declared in in a a module module or or interface interface
$global_clock returns the event expression specified in the global clocking declaration Can be used anywhere that a clocking event can be specified
property @($global_clock) ... endproperty always @($global_clock) begin ... end
2009, Sutherland HDL, Inc.
Verify Verify that that data data only only changes changes on on a a falling falling edge edge of of clock clock
11 of 27
assert property (p_triggers(in1, in2, posedge clk2)); always @(posedge clk3) begin if (rst3) ... ; else assert property (p_triggers(in1, in2)); end
2009, Sutherland HDL, Inc.
13 of 27
Not fully backward compatible with SystemVerilog-2005! The default in 2005 was that all assertions were strong The default in 2009 is that all assertions are weak unless specified as strong
Weak is the better behavior and avoids inadvertent gotchas
// enable must remain true throughout simulation assert property ( @(posedge clk) enable );
In In SVA-2005 SVA-2005 this this is is a a Gotcha! Gotcha! The The assertion assertion defaults defaults to to strong, strong, and and can can have have a a negative negative impact impact on on simulation simulation performance performance
2009, Sutherland HDL, Inc.
14 of 27
Allows for generic templates in assertion libraries Allows for both weak and strong operations
property p1; nexttime a; endproperty property p2; s_nexttime a; endproperty
2009, Sutherland HDL, Inc.
If If the the clock clock ticks ticks once once more, more, then then a a shall shall be be true true at at the the next next clock clock tick tick The The clock clock shall shall tick tick once once more more and and a a shall shall be be true true at at the the next next clock clock tick tick
15 of 27
SV-2009 adds logical implication and a equivalence operators These operators can be used anywhere, not just in assertions
always_comb begin a_implies_b = (a -> b); a_equiv_b = (a <-> b); end The The implication implication and and equivalence equivalence operators operators return return true true or or false false -> -> is is short short for for the the operation operation (!a (!a || || b) b) <-> <-> is is short short for for the the operation operation ( ( (a (a -> -> b) b) && && (b (b -> -> a) a) ) )
16 of 27
SV-2009 adds a $changed value sample function Returns true if an expression changed value during a clock cycle Can be used in assertions and other verification code
assert property (counter_enable |-> ##1 $changed(count));
17 of 27
SV-2009 allows the operators ##0, |-> and if...else to be used in multiple-clock properties
SV-2005 only allowed these operators with single-clock assertions
property p1; @(posedge clk0) if (b) @(posedge clk1) s1 else @(posedge clk2) s2 endproperty
b b is is checked checked at at posedge posedge clk0 clk0 If If b b is is true true then then s1 s1 is is checked checked at at the the nearest, nearest, possibly possibly overlapping overlapping posedge posedge clk1 clk1 Else Else s2 s2 is is checked checked at at the the nearest nearest non-strictly non-strictly subsequent subsequent posedge posedge clk2 clk2
SV-2009 allows $rose, $fell, $stable and $changed functions to be specified with a different clock than the assertion Adds an optional second argument that specifies the clock
property p2; @(posedge clk1) en && $rose(req, @(posedge clk2)) |=> gnt endproperty
18 of 27
19 of 27
20 of 27
10
Inference Inference rules rules for for clock, clock, disable disable and and enable enable conditions conditions are are well well defined defined Simulation Simulation semantic semantic rules rules are are well well defined defined
SV-2009 add the ability to use procedural concurrent assertions within loops (illegal in SV-2005)
always @(posedge clk) for (i=0; i<MAXI; i=i+1) begin ... assert property (p1); end
2009, Sutherland HDL, Inc.
21 of 27
ack ack must must be be preceded preceded by by a a req req within within 1 1 to to 6 6 clock clock cycles; cycles; ack ack and and req req are are in in different different clock clock domains domains
2009, Sutherland HDL, Inc.
22 of 27
11
23 of 27
24 of 27
12
25 of 27
New Keywords
SystemVerilog-2009 reserves several additional keywords
accept_on checker endchecker eventually global implies let nexttime reject_on restrict s_always s_eventually s_nexttime s_until s_until_with strong sync_accept_on sync_reject_on unique0 until until_with untyped weak
SV-2009 adds a new argument to `begin_keywords Maintains keyword backward compatibility with previous versions of the Verilog and SystemVerilog standard
`begin_keywords "1800-2005"
module old_chip (...); ... endmodule
`begin_keywords "1800-2009"
module new_chip (...); ... endmodule
`end_keywords
`end_keywords
SystemVerilog-2009: SystemVerilog Gets Even Better!
26 of 27
13
Expert SystemVerilog training is available! Sunburst Design and Sutherland HDL might not agree on who has the best SystemVerilog training, but
You will be a winner with training from either company!
2009, Sutherland HDL, Inc.
27 of 27
14