System Verilog
System Verilog
SystemVerilog extended Verilog by adding powerful new data types and operators that
can be used to declare and manipulate parameters and variables. Extensions like packed
structs provide a very convenient abstraction for manipulating an object that is really just
a bit vector.
SystemVerilog did not extend these new data types to nets. However, with the addition of
continuous assignments to variables, hardware designers can use the extended data types
with variables to model many common network behaviors. Users would like to have
these convenient abstractions for nets too, because other common network behaviors
bidirectionality, multiple driver resolution, and delays cannot be modeled with
variables.
We propose to extend SystemVerilog by making a subset of the new data types available
for nets too. In this first IEEE revision of SystemVerilog, we would like to allow a net or
port to have any fixed-size data type that is based on four-state logic. You can use new
SystemVerilog data types to declare parameters and variables, and by extension you can
use new data types to declare nets too. For example:
typedef struct packed { logic ecc; logic [7:0] data; } MemLoc;
wire MemLoc memsig;
This extension for nets is limited to four-state data types because of schedule constraints
in proposing LRM changes. We would have liked to propose two-state extensions as well.
It is not our intent to preclude the extension of other data types to nets in the future.
These two characteristics of a data object are largely orthogonal. As examples, a variable
can be of any data type, and a bit vector can be the data type of any kind of data object.
Certain kinds of data objects have additional characteristics. For example, a net has a "net
type", such as wire or trireg, that determines how its value is computed.
The diagram below illustrates these concepts. This diagram shows the relationships
between a data object and its significant properties. A data object is a construct that has a
name and a value associated with it. Thus, an important characteristic of a data object is
the set of values that it can have that is, its "data type". Certain kinds of data objects
have additional properties of interest. For example, a variable is also characterized by its
lifetime, and a net is also characterized by its net type.
static
automatic
bit
01
Variable
logic, reg
01XZ
Parameter
integer
-1 0 1
Localparam
Specparam
real
Attribute
Genvar
enum
class
struct
Net
wire
tri
wand
triand
wor
trior
supply0
supply1
tri0
tri1
trireg
array
3.1 Introduction
CHANGE:
Verilog-2001 has net data types, which can have 0, 1, X, or Z, plus 7 strengths, giving
120 values. It also has variable data types such as reg, which have 4 values 0, 1, X, Z.
These are not just different data types, they are used differently. SystemVerilog adds
another 4-value data type, called logic (see Sections 3.3.2 and 5.5).
TO:
Verilog-2001 has data objects that can take on values from a small number of predefined
value systems: the set of four-state logic values, vectors and arrays of logic values, and
the set of floating point values. SystemVerilog extends Verilog by introducing some of
the data types that conventional programming languages provide, such as enumerations
and structures.
In extending the type system, SystemVerilog makes a distinction between an object and
its data type. A data type is a set of values and a set of operations that can be performed
on those values. Data types can be used to declare data objects, or to define user-defined
data types that are constructed from other data types.
The Verilog-2001 logic system is based on a set of four state values: 0, 1, X, and Z.
Although this four-state logic is fundamental to the language, it does not have a name.
SystemVerilog has given this primitive data type a name, logic. This new name can be
used to declare objects and to construct other data types from the four-state data type.
CHANGE:
Verilog-2001 provides arbitrary fixed length arithmetic using reg data types. The reg type
can have bits at X or Z, however, and so are less efficient than an array of bits, because
the operator evaluation must check for X and Z, and twice as much data must be stored.
SystemVerilog adds a bit type which can only have bits with 0 or 1 values. See Section
3.3.2 on 2-state data types.
TO:
Verilog-2001 provides arbitrary fixed length arithmetic using 4-state logic. The 4-state
type can have bits at X or Z, however, and so may be less efficient than an array of bits,
because the operator evaluation must check for X and Z, and twice as much data must be
stored. SystemVerilog adds a bit data type that can only have bits with 0 or 1 values. See
Section 3.3.2 on 2-state data types.
5.1 Introduction
CHANGE:
There are several forms of data in SystemVerilog: literals (see Section 2), parameters (see
Section 21), constants, variables, nets, and attributes (see Section 6)
TO:
There are several forms of data in SystemVerilog: literals (see Section 2), parameters (see
Section 21), constants, variables, nets, and attributes (see Section 6). A data object is a
named construct that has a data value associated with it, such as a parameter, a variable,
or a net.
ADD TO END OF SECTION:
SystemVerilog extends the set of data types that are available for modeling Verilog
storage and transmission elements. In addition to the Verilog-2001 data types, new
predefined data types and user-defined data types can be used to declare constants,
variables, and nets.
If a data type is not specified in the net declaration then the data type of the net is logic.
Certain restrictions apply to the data type of a net. A valid data type for a net shall be one
of the following:
1. A four-state integral type
2. An unpacked array or unpacked struct, where each element has a valid data type
for a net
The effect of this recursive definition is that a net is comprised entirely of four-state bits,
and is treated accordingly. There is no change to the Verilog-2001 semantics related to net
resolution at the bit level, the role of strength, or the treatment of the signed property
across hierarchical boundaries.
A lexical restriction applies to the use of the reg keyword in a net or port declaration. A
Verilog net type keyword shall not be followed directly by the reg keyword. Thus, the
following declarations are in error:
tri reg r;
inout wire reg p;
The reg keyword can be used in a net or port declaration if there are lexical elements
between the net type keyword and the reg keyword.
18.1 Introduction
CHANGE:
An important enhancement in SystemVerilog is the ability to pass any data type through
module ports, including nets, and all variable types including reals, arrays and structures.
TO:
An important enhancement in SystemVerilog is the ability to pass a value of any data
type through module ports, using nets or variables. This includes reals, arrays and
structures.
TO:
With SystemVerilog, a port can be a declaration of an interface, an event, or a variable or
net of any allowed data type, including an array, a structure or a union.
CHANGE:
If the first port direction but no type is specified, then the port type shall default to wire.
This default type can be changed using the `default_nettype compiler directive, as in
Verilog."
TO:
If the first port direction but no net type or data type is specified, then the port shall
default to a net of net type wire. This default net type can be changed using the
`default_nettype compiler directive, as in Verilog.
CHANGE:
For subsequent ports in the port list, if the type and direction are omitted, then both are
inherited from the previous port. If only the direction is omitted, then it is inherited from
the previous port. If only the type is omitted, it shall default to wire. This default type
can be changed using the `default_nettype compiler directive, as in Verilog.
// second port inherits its direction and type from previous port
module mh3 (input byte a, b);
...
endmodule"
TO:
For subsequent ports in the port list, if the direction and the net type and data type are
omitted, then the direction and any net type and data type are inherited from the previous
port. If the direction is omitted, but a net type or data type is present, then the direction is
inherited from the previous port. If the direction is present, but the net type and data
types are omitted, then the port shall default to a net of net type wire. This default net
type can be changed using the `default_nettype compiler directive, as in Verilog.
// second port inherits its direction and data type
// from previous port
module mh3 (input byte a, b);
...
endmodule
For an inout port, if the net type is omitted, then the port shall default to a net of net type
wire. This default net type can be changed using the `default_nettype compiler directive,
as in Verilog.
// the inout port defaults to a net of net type wire
module mh2 (inout integer a);
...
endmodule
TO:
4) A typedef for an enum, struct, union, or class matches itself and the type of data
objects declared using that data type within the scope of the data type identifier.
TO:
The semantics of such an assignment expression are those of a function that evaluates the
right hand side, casts the right hand side to the left hand side data type, stacks it, updates
the left hand side and returns the stacked value. The data type of the value that is returned
is the data type of the left hand side. If the left hand side is a concatenation, then the data
type of the value that is returned shall be an unsigned integral data type whose bit length
is the sum of the length of its operands.
7.12 Concatenation
CHANGE:
SystemVerilog enhances the concatenation operation to allow concatenation of variables
of type string. In general, if any of the operands is of type string, the concatenation is
treated as a string, and all other arguments are implicitly converted to the string type (as
described in Section 3.7). String concatenation is not allowed on the left hand side of an
assignment, only as an expression.
TO:
SystemVerilog enhances the concatenation operation to allow concatenation of data
objects of type string. In general, if any of the operands is of the data type string, the
concatenation is treated as a string, and all other arguments are implicitly converted to the
string data type (as described in Section 3.7). String concatenation is not allowed on the
left hand side of an assignment, only as an expression.
CHANGE:
The replication operator (also called a multiple concatenation) form of braces can also be
used with variables of type string. In the case of string replication, a non-constant
multiplier is allowed.
TO:
The replication operator (also called a multiple concatenation) form of braces can also be
used with data objects of type string. In the case of string replication, a non-constant
multiplier is allowed.
Unpacked structure and array variables, literals, and expressions can all be used as
aggregate expressions.
TO:
Unpacked structure and array data objects, as well as unpacked structure and array
constructors, can all be used as aggregate expressions.
CHANGE:
An expected result type exists in any of the following contexts:
TO:
An expected result data type exists in any of the following contexts:
CHANGE:
The overloading declaration links the + operator to each function prototype according to
the equivalent argument types in the overloaded expression, which normally must match
exactly. The exception is if the actual argument is an integral type and there is only one
prototype with a corresponding integral argument, the actual is implicitly cast to the type
in the prototype.
TO:
The overloading declaration links the + operator to each function prototype according to
the equivalent argument data types in the overloaded expression, which normally must
match exactly. The exception is if the actual argument is an integral type and there is only
one prototype with a corresponding integral argument, the actual is implicitly cast to the
data type in the prototype.
Any data type can be declared as a class property, except for net types since they are
incompatible with dynamically allocated data.
TO:
There are no restrictions on the data type of a class property.
ANNEX J Glossary
ADD:
Data object - A data object is a named construct that has a data value associated with it,
such as a parameter, a variable, or a net. A data object has a data type that determines
which values the data object can have.
ADD:
Data type - A data type is a set of values and a set of operations that can be performed on
those values. Examples of data types are logic, real, and string. Data types can be used to
declare data objects, or to define user-defined data types that are constructed from other
data types.
CHANGE:
Aggregate - An aggregate expression, variable or type represents a set or collection of
singular values. An aggregate type is any unpacked structure, unpacked union, or
unpacked array data type.
TO:
Aggregate - An aggregate expression, data object or data type represents a set or
collection of singular values. An aggregate data type is any unpacked structure, unpacked
union, or unpacked array data type.
CHANGE:
Bit-stream - A bit-stream type or variables is any type that can be represented as a serial
stream of bits. To qualify as a bit-stream type, each and every bit of the type must be
individually addressable. This means that a bit-stream type can be any type that does not
include a handle, chandle, real, shortreal, or event.
TO:
Bit-stream - A bit-stream data type is any data type whose values can be represented as a
serial stream of bits. To qualify as a bit-stream data type, each and every bit of the values
must be individually addressable. This means that a bit-stream data type can be any data
type except for a handle, chandle, real, shortreal, or event.
CHANGE:
Dynamic - A dynamic type or variable is one that can be resized or re-allocated at
runtime. Dynamic types include those that contain dynamic arrays, associative arrays,
queues, or class handles.
TO:
Dynamic - A dynamic data type or variable has values that can be resized
or re-allocated at runtime. Dynamic arrays, associative arrays, queues, class handles and
data types that include such data types are dynamic data types.
CHANGE:
Enumerated type - Enumerated data types provide the capability to declare a variable
which can have one of a set of named values. The numerical equivalents of these values
can be specified. Enumerated types can be easily referenced or displayed using the
enumerated names, as opposed to the enumerated values. Section 3.10 discusses
enumerated types.
TO:
Enumerated type - Enumerated data types provide the capability to declare a data object
that can have one of a set of named values. The numerical equivalents of these values can
be specified. Values of an enumerated data type can be easily referenced or displayed
using the enumerated names, as opposed to the enumerated values. Section 3.10 discusses
enumerated types.
CHANGE:
Integral - An integral expression, variable or type is used to represent integral, or integer
value They may also be called vectored values. Integrals may be signed or unsigned,
sliced into smaller integral values, or concatenated into larger values.
TO:
Integral - An integral data type represents integral, or integer, values. Integral values
may also be called vectored values. Integral values may be signed or unsigned, sliced into
smaller integral values, or concatenated into larger values. An integral expression is an
expression of an integral data type. An integral data object is an object of an integral data
type.
CHANGE:
Singular - A singular expression, variable or type represents a single value, symbol, or
handle. A singular type is any type except an unpacked structure, unpacked union, or
unpacked array data type.
TO:
Singular - A singular expression, data object or data type represents a single value,
symbol, or handle. A singular data type is any data type except an unpacked structure,
unpacked union, or unpacked array data type.