System Verilog 1
System Verilog 1
• We need to verify the design to make sure that the design is an accurate
representation of the specification without any bugs. Verification is
carried out to ensure the correctness of design, to avoid surprises at a
later time, to avoid a re-spin of the chip and to enter the market on time
with good quality.
• Hardware Description Languages (HDL) like Verilog and VHDL are used to
describe hardware behavior so that it can be converted to digital blocks
made up of combinational gates and sequential elements. In order to
verify that the hardware description in HDL is correct, there is a need for
a language with more features in OOP that will support complicated
testing procedures and is often called a Hardware Verification Language.
• SystemVerilog is an extension of Verilog with many such verification
features that allow engineers to verify the design using complex
testbench structures and random stimuli in simulation.
Introduction
• SystemVerilog is commonly used in the semiconductor.
It is a hardware description and hardware verification
language used to model, design, simulate testbench.
• SystemVerilog is based on Verilog and some
extensions.
Verification process
• In the process of verification, we are going to verify modules, SOC’s (System
On Chip) by driving the input to check the design behavior. we should check
the behavior of the design by driving correct and an error input, in both
cases need to observe the design as it is behaving as expected, if not then
there will be a bug.
In verification, we use the Testbench/Verification environment to determine
the correctness of the design under test (DUT).
below is the functionality of the Testbench/Verification environment,
• Generate stimulus
• Apply stimulus to the DUT
• Capture the response
• Check for the correctness
• Measure progress against the overall verification goals
WHY SYSTEM VERILOG ?
VERIFICATION FLOW:
Verification
flow
Testbench components
1.Transaction
2.Generator
3.Driver
4.Monitor
5.Agent
6.Scoreboard
7.Environment
8.Testbench top
9.Test
Transaction
SystemVerilog language is used to model, design, simulate, test and implement electronic
02. Verilog language is used to structure and model electronic systems. system.
04. Verilog is based on module level testbench. SystemVerilog is based on class level testbench.
06. Verilog is influenced by C language and Fortran programming language. SystemVerilog is based on Verilog, VHDL and c++ programming language.
07. It has file extension .v or .vh It has file extension .sv or .svh
08. It supports Wire and Reg datatype. It supports various datatypes like enum, union, struct, string, class.
10. It was began in 1983 as proprietary language for hardware modelling. It was originally intended as an extension to Verilog in the year 2005.
Data types
• 2 state data type: It has bits 0 and 1
• 4 state data type: It has bits 0, 1, X, and Z
type byte
2 state data type, 8-bit signed integer or
ASCII character
4 state data type, unsigned, user-defined
logic
vector size
4 state data type, unsigned, user-defined
reg
vector size
4 state data type, 64-bit unsigned
time
integer
Struct
• This data-type allows you to create custom data-type
structure by grouping together by different data-type in
single name
• Ex-
Struct {
string name;
int age;
byte number }student_info;
• Packed structures -: Similar to a packed array, if memory
allocated for variables in a structure is contiguous, then it is
called a packed structure.
• Only packed data types are allowed in packed structures
• A string is not a packed data type, so code will not compile.
To use string as a data type in structure, unpack structures
can be used.
typedef struct packed {
bit[31:0] salary;
integer id;
} employee;
• Unpacked structures -:An unpacked structure is not
as memory efficient as packed data structures.
• By default, a structure is unpacked in nature
• Syntax -:
typedef struct {
string name;
bit[31:0] salary;
integer id } empluee;
module struct_example;
struct {
string name;
bit[31:0] salary;
integer id;
} employee;
initial begin
employee.name = "Alex";
employee.salary = 'h10000;
employee.id = 'd1234;
$display("employee: %p", employee);
// Accessing individual struct member
$display("employee: name = %s, salary = 0x%0h, id = %0d", employee.name, employee.salary, employee.id);
end
endmodule
Unions
• Typedef allows users to create their own names for type definitions that
they will use frequently in their code.
• Typedefs can be very convenient when building up complicated array
definitions.
Syntax -:
typedef reg[7:0] type_def_data;
Above typedef same as reg[7:0] a;
Enum
• SystemVerilog also introduces enumerated types, It is used to define a set of integral values that
represents the states or values
for example, Typedef enum {red, yellow, green} light1,light2;
Methods:
o first( )
o last( )
o next( )
o prev( )
o num( )
Enumerations allow you to define a data type whose values have names. Such data types are
appropriate and useful for representing state values, opcodes and other such non-numeric or
symbolic data.
Typedef is commonly used together with enum, like this:
light1 col;
String
• The string data type is an ordered collection of characters. The length of a string
variable is the no.of characters in the collection.
• Example:
string s0 = “hi aiit”;
string s1 = “hi\0aiit”;
bit[11:0] b = 12’ha41;
string s2 = string’(b);
• A single ASCII character requires 8-bits (1 byte) and to store a string we would need
as many bytes as there are number of characters in the string.
reg [16*8-1:0] my_string; // Can store 16 characters
my_string = "How are you"; // 5 zeros are padded from MSB, and 11 char
are stored
my_string = "How are you doing?"; // 19 characters; my_string will get "w are
you doing?"
String Operators
Returns 1 if the two strings
Equality Str1 == Str2 are equal and 0 if they are
not
Returns 1 if the two strings
Inequality Str1 != Str2 are not equal and 0 if they
are
Str1 < Str2
Returns 1 if the correspondig
Str1 <= Str2
Comparison condition is true and 0 if
Str1 > Str2
false
Str1 >= Str2
All strings will be
Concatenation {Str1, Str2, ..., StrN} concatenated into one
resultant string
Replicates the string N
Replication {multiplier{Str}} number of times, where N is
specified by the multiplier
Returns a byte, the ASCII
code at the given index. If
Indexing Str[index]
given index is out of range,
it returns 0
The dot(.) operator is used
Methods Str.method([args])
Real, shortreal, and realtime data types