SystemVerilog Update Part1 Cummings
SystemVerilog Update Part1 Cummings
SystemVerilog Update Part1 Cummings
5 of 59
After
After logging
logging in
in ...
...
Enter
Enter Issue
Issue ## ...
... ...
... then
then select
select the
the
Jump
Jump button
button
890
© 2009, Sunburst Design, Inc.
6 of 59
Scheduling of New SV Commands
Mantis 890
From
Fromprevious
previous Preponed Region
Region for
for new
new
Preponed
time
timeslot
slot SV
SV commands
commands
#1step
#1step
Active
Active
Active
Active region
region
Inactive
Inactive set
set
Used
Usedfor
forsampling
sampling&& NBA
NBA
verifying
verifyingDUT
DUToutputs
outputs Evaluate
Evaluate concurrent
concurrent
(testbench
(testbenchinputs)
inputs) assertions
assertions
Observed
Observed Trigger clocking blocks
Trigger clocking blocks
Reactive
Reactive region
region
Regions
Regions for
for new
new set
Reactive
Reactive set
SV
SV commands
commands
Execute
Execute
Re-Inactive
Re-Inactive
pass/fail
pass/fail assertion
assertion code
code
Update to
Re-NBA
Re-NBA program block
program block code
code
IEEE1800-2005
Standard
New To
Tonext
Newevent
eventscheduling
scheduling Postponed
Postponed next
(already
(alreadyimplemented)
implemented) time
timeslot
slot
© 2009, Sunburst Design, Inc. Sunburst
3 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
7 of 59
SystemVerilog-2009
Display Enhancements
8 of 59
4 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
9 of 59
a=71ec b=00fb
Same a=0003 b=0048
Sameorderly
orderlyprintout
printout a=0ed4 b=00f4
a=8fbb b=0860
a=0003 b=003a
a=00b1 b=4895 %xisisjust
%x just"syntactic
"syntacticsugar"
sugar"
a=0010 b=007c (C-like
(C-like- -not
notreally
reallyneeded)
needed)
a=097a b=00da
10 of 59
$monitor("sum=%4p
$monitor("sum=%4p a=%4p
a=%4p b=%4p
b=%4p ",
", sum,
sum, a,
a, b);
b);
sum='{re: x, im: x} a='{re: x, im: x} b='{re: x, im: x}
sum='{re: 216, im: 240} a='{re: 193, im: 148} b='{re: 23, im: 92}
sum='{re: 158, im: 85} a='{re: 138, im: 154} b='{re: 20, im: 187}
sum='{re: 218, im: 240} a='{re: 36, im: 160} b='{re: 182, im: 80}
sum='{re: 180, im: 4} a='{re: 108, im: 41} b='{re: 72, im: 219}
© 2009, Sunburst Design, Inc.
5 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
11 of 59
module test1;
int a = 32; SystemVerilog2005
SystemVerilog2005
logic [31:0] b = 32'haabbccdd; $sformattask
$sformat taskassigns
assigns
string s; string
stringto
tooutput
outputargument
argument(s(s) )
initial begin
$sformat(s, "\nThe value of b = %0d'h%h\n", a, b);
$display("%s", s);
Output
Outputdisplay
display
end
endmodule
The value of b = 32'haabbccdd
module test2;
int a = 32; SystemVerilog2009
SystemVerilog2009addsadds
logic [31:0] b = 32'haabbccdd; $sformatffunction
$sformatf function
string s; that
thatreturns
returnsaastring
string
initial begin
s = $sformatf("\nThe value of b = %0d'h%h\n", a, b);
$display("%s", s);
Mantis
Mantis1651:
1651:
end
$psprintf
$psprintf was
wasrejected
rejected
endmodule (Proposed synonym for $sformatf )
(Proposed synonym for $sformatf )
© 2009, Sunburst Design, Inc.
12 of 59
InInSystemVerilog2005
SystemVerilog2005
module tb;
... $fatal/ /$error
$fatal $error/ /$warning
$warning/ /$info
$info
could
couldonly
onlybe
beused
usedininassertions
assertions
function void check_output;
if (cb1.y===exp) $display("PASS: y=%h exp=%h", y, exp);
else $display("FAIL: y=%h exp=%h", y, exp);
endfunction
...
endmodule
InInSystemVerilog2009
SystemVerilog2009
module tb;
... $fatal/ /$error
$fatal $error/ /$warning
$warning/ /$info
$info
can
canbe
beused
usedanywhere $displaycan
anywhere$display canbe beused
used
function void check_output;
if (cb1.y===exp) $info ("PASS: y=%h exp=%h", y, exp);
else $fatal("FAIL: y=%h exp=%h", y, exp);
endfunction
...
endmodule
6 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
13 of 59
SystemVerilog-2009
Design Enhancements
14 of 59
always_ff
Logic-Specific Process
• always_ff
– Conveys designer's intent module dff1 (
output bit_t q,
to infer clocked logic
input bit_t d, clk, rst_n);
7 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
15 of 59
Equivalent
Equivalenttotoboth
• SV2009 adds edge keyword posedge /
both
negedge
posedge / negedge
Currently
Currentlyillegal
illegalsyntax
syntax No posedge(clk)
Noposedge (clk)
for
forsynthesis
synthesis No
No negedge(clk)
negedge (clk)
Could
Couldthis
thissynthesize
synthesizeto
toaaDDR
DDRflip-flop
flip-flop
in
inan
anASIC
ASICvendor
vendorlibrary
library??
?? Sunburst
© 2009, Sunburst Design, Inc.
16 of 59
opcode[2:0]
alu (8-bit)
3
alu_out 8 1 1
alu_out[7] 1
zero ones
8
Dangling
Dangling zero
zero
xtend accum & ones outputs
& ones outputs
8 8
clk
.name
.nameallows
allowsunconnected
unconnected
rst_n ports
portsto
tobe
beomitted
omitted
dataout[15:8] dataout[7:0]
16
dataout Not
Notthe
theoriginal
original
intent
intentfor
for.name
.name
© 2009, Sunburst Design, Inc.
8 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
17 of 59
module alu_accum (
output [15:0] dataout, Legal
Legal(but
(butnot
notrequired):
required):
input [7:0] ain, bin, list
input [2:0] opcode, list unconnectedports
unconnected ports
input clk, rst_n);
wire [7:0] alu_out;
Legal:
Legal:
... omit
alu alu (.alu_out, .ain, .bin, .opcode); omitunconnected
unconnectedports
ports
accum accum (.dataout(dataout[7:0]), .datain(alu_out), .clk, .rst_n);
...
Legal
Legal(but
(butWRONG!):
WRONG!):
... omit
omitdesign
designport (alu_out) )
port(alu_out
alu alu (.ain, .bin, .opcode);
accum accum (.dataout(dataout[7:0]), .datain(alu_out), .clk, .rst_n);
...
Another
Anothergood
goodreason
reasonto
toavoid
avoidusing
using.name
.name
© 2009, Sunburst Design, Inc.
18 of 59
9 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
19 of 59
y[1]
a[1]
y[0]
a[0]
20 of 59
10 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
21 of 59
22 of 59
a[1]
SystemVerilog
SystemVerilog a[0] y[3]
dec2_4b
dec2_4b en
dec2_4c
dec2_4c
y[2]
y[1]
y[0]
11 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
23 of 59
priority/unique/unique0 Violations
Mantis 2008
Reported
Reportedas
aswarnings
warnings
(vendors
(vendorsdid
didnot
notwant
want
• SV-2005: priority/unique warnings to
toreport
reportfalse-errors)
false-errors)
Ask
Askvendors
vendorstotoprovide
provide
unique:Only
unique: Onlyone
onecase
case fatal-on-violation
fatal-on-violationoption
option
item
itemshould
shouldmatch
matchthe
the
caseexpression
case expression Simulation
Simulationscenario:
scenario:
(1)
(1)aagoes
goestoto11
always_comb begin: a1 (2) always_comb(a1)
(2)always_comb (a1)triggers
triggers
unique case (1’b1) (3)
(3)unique casedetects
uniquecase detectsviolation
violation
a : z = b; (a
(a&¬_a
not_aboth
bothmatch
match1'b1)
1'b1)
not_a : z = c; (4) violation report generated
(4) violation report generated
endcase (scheduled
(scheduledinto
intoObserved
ObservedRegion)
Region)
end (5) always_comb(a2)
(5)always_comb (a2)triggers
triggers
(6) not_agoes
(6)not_a goesto
to00
always_comb begin: a2 (7) always_comb(a1)
(7)always_comb (a1)re-triggers
re-triggers
not_a = !a; (8)
(8) unique case detectsNO
unique case detects NOviolation
violation
end (9)
(9)violation
violationreport
reportcleared
cleared
(before
(beforeentering
enteringObserved
ObservedRegion)
Region)
© 2009, Sunburst Design, Inc.
24 of 59
12 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
25 of 59
26 of 59
tb overrides
tb overrides default set_n // rst_n
default set_n rst_n values
values
13 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
27 of 59
CAUTION:
CAUTION:more
moreconcise
concisebut
but
perhaps
perhapsmore
moreconfusing(?)
confusing(?)
28 of 59
SystemVerilog-2009
Packages, Parameters, Compiler Directives
14 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
29 of 59
package bit_pkg;
bit_pkg::clk_t
bit_pkg::clk_t
typedef bit clk_t;
typedef bit rst_t; not
notused
used
endpackage
module register (
Use
Usethe data_tand
thedata_t andclk_t
clk_t
output data_pkg::data_t q,
from
fromthe
thedata_pkg
data_pkg
input data_pkg::data_t d,
input data_pkg::clk_t clk,
input bit_pkg::rst_t rst_n);
Use
Usethe rst_tfrom
therst_t from
the
thebit_pkg
bit_pkg
...
endmodule
......somewhat
somewhatverbose
verbose
© 2009, Sunburst Design, Inc.
30 of 59
package bit_pkg;
bit_pkg::clk_t
bit_pkg::clk_t
typedef bit clk_t;
typedef bit rst_t; not
notused
used
endpackage
Use
Usethe data_tand
thedata_t andclk_t
clk_t
import data_pkg::*; from
fromthe
thedata_pkg
data_pkg
import bit_pkg::rst_t;
Use
Usethe rst_tfrom
therst_t from
module register ( the
thebit_pkg
bit_pkg
output data_t q,
input data_t d,
input clk_t clk,
input rst_t rst_n);
......packages
packageshave
havebeen
beenimported
imported
into
intothe $unit/$rootspace
the$unit/$root space
... (depending
endmodule (dependingupon
uponthe
thesimulator)
simulator)
© 2009, Sunburst Design, Inc.
15 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
31 of 59
package bit_pkg;
bit_pkg::clk_t
bit_pkg::clk_t
typedef bit clk_t;
typedef bit rst_t; not
notused
used
endpackage Packages
Packagesare
areavailable
available
to
tothe
themodule
moduleheader
header Use
Usethe data_tand
thedata_t andclk_t
clk_t
module register from
import bit_pkg::rst_t, data_pkg::*; fromthe
thedata_pkg
data_pkg
(output data_t q, Use
input data_t d, Usethe rst_tfrom
therst_t from
the
thebit_pkg
bit_pkg
input clk_t clk,
input rst_t rst_n);
32 of 59
16 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
33 of 59
34 of 59
package pkg3a;
typedef logic [7:0] byte_t; importeach
import eachpackage
package
separately
separately
...
endpackage
Like
Likedoing
doingpackage
package
extension
extension...... ......with
withmultiple
multiple
inheritance
inheritance!!!!
© 2009, Sunburst Design, Inc.
17 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
35 of 59
36 of 59
always_latch
if (!cs_n && !r_wn) mem[addr] <= data;
endmodule DEPTHnot
DEPTH not
listed
listed
raminstantiation:
ram instantiation:
AWIDTH=20(1MB)
AWIDTH=20 (1MB) ram #(20,16) ram1 (...);
DWIDTH=16
DWIDTH=16
© 2009, Sunburst Design, Inc.
18 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
37 of 59
module tb;
parameter SIZE = 64;
logic [SIZE-1:0] q;
logic [SIZE-1:0] d;
logic clk, rst_n;
38 of 59
19 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
39 of 59
Line
Linecontinuation
continuation
character
character \\
Define
Defineaamulti-line
multi-linemacro
macro
(not all Verilog coders know this)
`define assert_clk( ... ) \ (not all Verilog coders know this)
assert property (@(posedge clk) disable iff (!rst_n) ... )
Pass
Passan
anargument
argumentto
to
the
themacro
macro arg
arg Define
Defineaamulti-line
multi-linemacro
macro
with
with inputarguments
input arguments
(not all Verilog coders know this)
`define assert_clk( arg ) \ (not all Verilog coders know this)
assert property (@(posedge clk) disable iff (!rst_n) arg )
40 of 59
By
Bydefault,
default,macro
macrouses
usesclk
clk
for
forassertion
assertionsampling
sampling
ERROR_q_did_not_follow_d:
Use
Usedefault
defaultclk
clk
`assert_clk(q==$past(d));
ERROR_q_did_not_follow_d:
Use
Useclk2
clk2
`assert_clk(q==$past(d), clk2);
20 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
41 of 59
always @* begin
if (!rw_n && en) mem[addr] <= data;
end
endmodule
`undef DSIZE `undefdata
`undef datasize,
size,
`undef ASIZE `undefaddress
`undef addresssize
size
`undef MDEPTH `undefmemory
`undef memorydepth
depth
© 2009, Sunburst Design, Inc.
42 of 59
`undefineall
Mantis 1090
always_latch begin
if (!rw_n && en) mem[addr] <= data;
end
endmodule
`undefineall `undefineallun-defines
`undefineall un-defines
all `definemacros
all`define macros
21 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
43 of 59
always_latch begin
if (!rw_n && en) mem[addr] <= data;
end
endmodule
Guideline:
Guideline:choose parameterfirst
chooseparameter first
Guideline:
Guideline:choose `defineonly
choose`define onlyififneeded
needed
© 2009, Sunburst Design, Inc.
44 of 59
SystemVerilog-2009
Arrays & Queues Enhancements
22 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
45 of 59
46 of 59
Returns
Returnsthe
thenumber
numberof of
elements
elementsininthe
the
associative
associativearray
array
function void aa_display;
$display("%0d ARRAY ELEMENTS %0d", aa.num());
...
endfunction SV2009
SV2009defines
defines
.size()method
.size() method- -
synonym
synonymfor
for
function void aa_display;
.num()method
.num() method
$display("%0d ARRAY ELEMENTS %0d", aa.size());
...
endfunction
© 2009, Sunburst Design, Inc.
23 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
47 of 59
48 of 59
SystemVerilog-2009
Classes & Verification Enhancements
24 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
49 of 59
50 of 59
purerequires
pure requiresthat
thataa
• pure requires: method
methodbebeoverridden
overriddenwith
with
an
anactual
actualimplementation
implementation
– method shall only be a prototype
– no code can be included for the prototype
– not even allowed to have endfunction/endtask keywords
– pure virtual methods MUST be overridden in non-abstract classes
© 2009, Sunburst Design, Inc.
25 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
51 of 59
Pure Constraint
Mantis 2514
Again: purecreates
Again: pure createsaaplace-holder
place-holder
purerequires
pure requiresthat
thataa
constraint
constraintbe
beoverridden
overridden
with
withan
anactual
actualconstraint
constraint
52 of 59
26 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
53 of 59
SystemVerilog-2009
SystemVerilog-2009addsaddsthe
the
ability
abilityto
tohave
haveparameterized
parameterized
class C #(int p = 1, type T = int); classes with external methods
classes with external methods
extern static function T f();
endclass
Declaration
Declarationof
of
extern
externstatic
staticfunction
function(method)
(method)
function C::T C::f();
with
withreturn
returntype
typeTT (parameterized
(parameterizedtype)
type)
return p + C::p;
endfunction
54 of 59
27 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
55 of 59
SystemVerilog-2009
Miscellaneous Enhancements
timeunit
$system task
`__FILE__ & `__LINE__ Macros
SDF Annotation of $timeskew & $fullskew
56 of 59
28 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
57 of 59
module top;
initial $system("mv design.v adder.v");
endmodule
Most
MostVerilog
Verilogsimulators
simulatorsalready
already
have
havethis
thistask,
task,but
butititwas
wasnever
never
part
partof
ofthe
theVerilog
Verilogstandard
standard
58 of 59
• These macros allow access to the current file and line number
from within SystemVerilog code
29 of 30 Rev 1.1
DAC 2009 SystemVerilog-2009 Presentation
by Sunburst Design, Beaverton, Oregon, © 2009
59 of 59
60 of 59
Presented by
30 of 30 Rev 1.1