Documente Academic
Documente Profesional
Documente Cultură
SystemVerilog
References
Websources:
1.
www.systemverilog.org
2. www.asic-world.com/systemverilog/index.html
3. http://svug.org/
Books :
1. Writing Testbenches using SystemVerilog
- Janick Bergeron
2. Verification Methodology Manual
- Janick Bergeron
3. SystemVerilog For Verification
- Chris Spear
What is SystemVerilog?
What is SystemVerilog?
SystemVerilog is a hardware description and Verification
language(HDVL)
SystemVerilog is an extensive set of enhancements to IEEE
1364 Verilog-2001 standards
It has features inherited from Verilog HDL,VHDL,C,C++
Adds extended features to verilog
What is SystemVerilog?
System verilog is the superset of verilog
It supports all features of verilog plus add on features
Its a super verilog
additional features of system verilog will be discussed
Why SystemVerilog ?
Why SystemVerilog?
Constrained Randomization
OOP support
Assertions
SystemVerilog Intent
Verilog
Verilog
Design entry
SystemVerilog
Verilog
System
SystemVerilog
Verilog
System
Memory Management
Verilog
Verilog
SystemVerilog
Verilog
System
Allocated at runtime
Better memory management
ie,queues
Example:Logic[3:0] length[$];
an empty queue with an
unbounded size of logic data
type
Complexity
Verilog
Verilog
SystemVerilog
Verilog
System
Increase in verification
code to test these designs
Readable
Extra time
SystemVerilog
Verilog
System
It uses three new procedures
always_ff - sequential logic
Combinational logic
always_comb - combinational
logic
Latched logic
Port connections
Verilog
Verilog
SystemVerilog
Verilog
System
Synthesis support
Verilog
Verilog
SystemVerilog
Verilog
System
SystemVerilog Concepts
reg r;
logic w;
bit b;
// 4-state Verilog-2001
// 4-valued logic, see below
// 2-state bit 0 or 1
integer i; //
byte b8;
//
int i;
//
shortint s;//
longint l; //
Initial
Begin
fork
Clk =0;
#5
Fork
#5 a = 0;
#10 b = 0;
join
Join
Clk= 1;
end
Clk becomes 1
at t=15
Initial
Begin
fork
Clk =0;
#5
Fork
#5 a = 0;
#10 b = 0;
Join_any
Join_any
Clk= 1;
end
Clk becomes 1
at t=10
Initial
Begin
fork
Clk =0;
#5
Fork
#5 a = 0;
#10 b = 0;
Join_none
Clk becomes 1
Join_none
at t=5
Clk= 1;
end
Covergroup
Mailbox
Program
Fork/join
Virtual interface
Class
Clocking Block
Constraint
modports
Verification environment
Checks
Checks
correctness
correctness
Creates
Creates
stimulus
stimulus
Executes
Executes
transactions
transactions
Test
Testbench
Testbench
Driver
Identifies
Identifies
transactions
transactions
Self Check
Transactor
Supplies
Supplies data
data
to
to the
the DUT
DUT
Verification
Verification
Environment
Environment
Checker
Assertions
DUT
Monitor
Observes
Observes
data
data
from
from DUT
DUT
SystemVerilog
Verilog
System
File I/o
Random number
generation
Fork/join
Classes
Initial block
Fork/join_any,fork/join_none
Final block
PLI
OOP Concepts
What is OOP?
classes
encapsulation
OOP
polymorphism
inheritance
What is OOP?
What is OOP?
OOP breaks a testbench into blocks that work together to
accomplish the verification goal
Why OOP
Highly abstract system level modelling
Classes are intended for verification
Classes are easily reused and extended
Data security
Classes are dynamic in nature
Easy debugging, one class at a time
relation
SystemVerilog
Verilog
System
to
Interface is required
to interact with Verilog
Superset of Verilog
RTL/Verification language
Assertion language
Constraint language
Code coverage language
Inheritance
Inheritance
Advantages
Common code can be grouped into one class
No need to modify the existing classes
Add new features to existing class by means
of new derived classes
Easy debug & easy to maintain the code base
Randomization
Randomization
Why Randomization ?
Random generation of stimulus
Random setting of parameters
Hard-to-reach corner cases can be reached
Randomization
Shift from directed to random
Directed
Directed
Detect the expected bugs
Time consuming
Random
Random
Detects unexpected bugs (corner
cases)
Tremendously reduce the efforts
Randomization
Constrained Randomization
Improves the result
Speed-up the bug finding process
More interesting cases can be achieved within the
constrained boundary
Assertions
Assertion
Used primarily to validate the behaviour of a design
An assertion is a statement about a designs intended
behaviour
In-line assertions are best added by design engineers
Interface assertions are best added by verification engineers
An assertions sole purpose is to ensure consistency between
the designers intention and design implementation
It increases the bug detection possibility during RTL design
phase
Crux
Crux
SystemVerilog
Verification with
SystemVerilog
This Presentation is
References
Websources:
1.
www.systemverilog.org
3. http://svug.org/
Books :
1. Writing Testbenches using SystemVerilog
- Janick Bergeron
2. Verification Methodology Manual
- Janick Bergeron
3. SystemVerilog For Verification
- Chris Spear
We will discuss
Top SystemVerilog Testbench Constructs
Queue
Covergroup
Mailbox
Program
Fork/join
Interface
Semaphore
Clocking Block
Constraint
modports
Queue
Data storage array [$]
Variable size array with automatic sizing
Searching, sorting and insertion methods
Mailbox
Fifo with flow control
passes data between two processes
put() stimgen calls put() to pass data to bfm
get() bfm calls get() to retrieve data from
stimgen
stimgen
put()
bfm
mailbox
get()
Mailbox
mailbox
mailbox mbx;
mbx;
mbx
mbx == new();
new();
//
// allocate
allocate mailbox
mailbox
mbx.put(data);
mbx.put(data); //
// Put
Put data
data object
object into
into mailbox
mailbox
mbx.get(data);
mbx.get(data); //
// data
data will
will be
be updated
updated with
with data
data from
from FIFO
FIFO
success
success == mbx.try_get(ref
mbx.try_get(ref data);
data); //
// Non-blocking
Non-blocking version
version
mbx.peek(data);
//
mbx.peek(data);
// Look
Look but
but dont
dont remove
remove
count
count == mbx.num();
mbx.num(); //
// Number
Number of
of elements
elements in
in mailbox
mailbox
Fork/join
Fork/join
Initial
Begin
fork
Clk =0;
#5
Fork
#5 a = 0;
#10 b = 0;
join
Join
Clk= 1;
end
Clk becomes 1
at t=15
Fork/join
Fork/join_any
Initial
Begin
fork
Clk =0;
#5
Fork
#5 a = 0;
#10 b = 0;
Join_any
Join_any
Clk= 1;
end
Clk becomes 1
at t=10
Fork/join
Fork/join_none
Initial
Begin
fork
Clk =0;
#5
Fork
#5 a = 0;
#10 b = 0;
Join_none
Clk becomes 1
Join_none
at t=5
Clk= 1;
end
Semaphore
Used for Synchronization
Variable number of keys can be put and removed
controlled access to a shared object
think of two people wanting to drive the same car
the key is a semaphore
Constraint
Control randomization
Values for random variable can be controlled through
constraint expressions
These are declared within constraint block
Class
Class packet
packet ;;
rand
rand logic
logic [7:0]
[7:0] src;
src;
rand
rand logic
logic [7:0]
[7:0] dest;
dest;
Constraint
Constraint my_constraints
my_constraints {{
src[1:0]
src[1:0] ==
== 2b00;
2b00; //
// constraint
constraint expression
expression
//
// always
always set
set src[1:0]
src[1:0] to
to 00
}}
endclass:packet
endclass:packet
Covergroup
Captures results from a random simulation
Encapsulates the coverage specification
bins
transitions
Covergroup
Covergroup check
check @(posedge
@(posedge top.valid
top.valid );
);
coverpoint
coverpoint global;
global;
coverpoint
coverpoint top.test;
top.test;
endgroup:check
endgroup:check
check
check chk
chk == new();
new();
Program Block
Benefits:
Functionality:
Can be instantiated in any hierarchical location
Typically at the top level
Ports can be connected in the same manner as any
other module
Executes in the SV reactive region
Program Block
The testbench (program) runs separately
from design (module)
Triggered by clock
Samples just before clock edge, drives just after clock
clock
Design
Testbench
Sample
inputs
Drive
outputs
Interface
bundling of port signals
provide an abstract encapsulation of communication
between blocks
Directional information (modports)
Timing (clocking blocks)
Functionality (routines,assertions)
device1
interface
device2
Interface
Interface:An example
Interface
Interface bus_a
bus_a (input
(input clock);
clock);
logic
logic [7:0]
[7:0] address;
address;
logic
logic [31:0]
[31:0] data
data ;;
bit
valid
bit
valid ;;
bit
rd_wr
bit
rd_wr ;;
Endinterface:
Endinterface: bus_a
bus_a
Clocking Block
Specify synchronization characteristics of the
design
Offer a clean way to drive and sample signals
Features
Clock specification
Input skew,output skew
Cycle delay (##)
Clocking Block
Can be declared inside interface,module or
program
Clocking Block
Module
Module M1(ck,
M1(ck, enin,
enin, din,
din, enout,
enout, dout);
dout);
input
ck,enin;
input
ck,enin;
input
;;
input [31:0]
[31:0] din
din
output
enout
output
enout ;;
output
output [31:0]
[31:0] dout
dout ;;
clocking
clocking sd
sd @(posedge
@(posedge ck);
ck);
input
;;
input #2ns
#2ns ein,din
ein,din
output
output #3ns
#3ns enout,
enout, dout;
dout;
endclocking:sd
endclocking:sd
reg
reg [7:0]
[7:0] sab
sab ;;
initial
initial begin
begin
sab
sab == sd.din[7:0];
sd.din[7:0];
end
end
endmodule:M1
endmodule:M1
Modports
An interface can have multiple viewpoints
Master/Slave, Transmitter/Receiver
Interface
Interface bus_b
bus_b (input
(input clock);
clock);
logic
logic [7:0]
[7:0] addr,data;
addr,data;
logic
;;
logic [1:0]
[1:0] mode
mode
bit
ready
;;
bit
ready
modport
modport master
master (input
(input ready,output
ready,output addr,data,mode)
addr,data,mode) ;;
modport
modport slave
slave (input
(input addr,data,mode,output
addr,data,mode,output ready)
ready) ;;
endinterface:
endinterface: bus_b
bus_b
Conclusion
Thank you