• 沒有找到結果。

Unified Hardware Design, Specification, and Verification Language

6. Data types

6.7 Net declarations

The syntax for net declarations is given in Syntax 6-2.

net_declaration12 ::= // from A.2.1.3

net_type [ drive_strength | charge_strength ] [ vectored | scalared ] data_type_or_implicit [ delay3 ] list_of_net_decl_assignments ;

| net_type_identifier [ delay_control ] list_of_net_decl_assignments ;

| interconnect implicit_data_type [ # delay_value ] net_identifier { unpacked_dimension }

[ , net_identifier { unpacked_dimension }] ;

net_type ::= // from A.2.2.1

supply0 | supply1 | tri | triand | trior | trireg | tri0 | tri1 | uwire | wire | wand | wor

drive_strength ::= // from A.2.2.2

( strength0 , strength1 )

# delay_value | # ( mintypmax_expression [ , mintypmax_expression [ , mintypmax_expression ] ] ) delay2 ::= # delay_value | # ( mintypmax_expression [ , mintypmax_expression ] )

list_of_net_decl_assignments ::= net_decl_assignment { , net_decl_assignment } // from A.2.3 net_decl_assignment ::= net_identifier { unpacked_dimension } [ = expression ] // from A.2.4 12) A charge strength shall only be used with the trireg keyword. When the vectored or scalared keyword is

used, there shall be at least one packed dimension.

Syntax 6-2—Syntax for net declarations (excerpt from Annex A)

VERIFICATION LANGUAGE

6.7.1 Net declarations with built-in net types

Net declarations without assignments and whose nettype is not a user-defined nettype are described in this subclause. Net declarations with assignments are described in Clause 10.

A net declaration begins with a net type that determines how the values of the nets in the declaration are resolved. The declaration can include optional information such as delay values, drive or charge strength, and a data type.

If a set of nets share the same characteristics, they can be declared in the same declaration statement.

Any 4-state data type can be used to declare a net. For example:

trireg (large) logic #(0,0,0) cap1;

typedef logic [31:0] addressT;

wire addressT w1;

wire struct packed { logic ecc; logic [7:0] data; } memsig;

If a data type is not specified in the net declaration or if only a range and/or signing is specified, then the data type of the net is implicitly declared as logic. For example:

wire w; // equivalent to "wire logic w;"

wire [15:0] ww; // equivalent to "wire logic [15:0] ww;"

A net declared as an interconnect net shall:

— have no data type but may have optional packed or unpacked dimensions;

— not specify drive_strength or charge_strength;

— not have assignment expressions;

— specify at most one delay value.

Certain restrictions apply to the data type of a net. A valid data type for a net shall be one of the following:

a) A 4-state integral type, including a packed array or packed structure.

b) A fixed-size unpacked array or unpacked structure, where each element has a valid data type for a net.

The effect of this recursive definition is that a net is composed entirely of 4-state bits and is treated accordingly. In addition to a signal value, each bit of a net shall have additional strength information. When bits of signals combine, the strength and value of the resulting signal shall be determined as described in 28.12.

A lexical restriction applies to the use of the reg keyword in a net or port declaration. A 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.

The default initialization value for a net shall be the value z. Nets with drivers shall assume the output value of their drivers. The trireg net is an exception. The trireg net shall default to the value x, with the strength specified in the net declaration (small, medium, or large).

As described in 6.6.8, an interconnect net is restricted in terms of its declaration and use. The following are some examples of legal and illegal interconnect net declarations:

interconnect w1; // legal

interconnect [3:0] w2; // legal interconnect [3:0] w3 [1:0]; // legal

interconnect logic [3:0] w4; // illegal – data type specified interconnect #(1,2,3) w5; // illegal – only one delay permitted assign w1 = 1; // illegal – not allowed in a

// continuous assign

initial $display(w1); // illegal – not allowed in a // procedural context

6.7.2 Net declarations with user-defined nettypes

A net with a user-defined nettype allows users to describe more general abstract values for a wire. A net declared with a nettype uses the data type and any associated resolution function for that nettype.

// an unresolved nettype wT whose data type is T

// Refer to example in 6.6.7 for declaration of the data type T nettype T wT;

// a nettype wTsum whose data type is T and // resolution function is Tsum

// Refer to example in 6.6.7 for the declaration of Tsum nettype T wTsum with Tsum;

// a net of unresolved nettype wT wT w1;

// an array of nets, each net element is of unresolved nettype wT wT w2[8];

// a net of resolved nettype wTsum and resolution function Tsum wTsum w3;

// an array of nets, each net is of resolved nettype wTsum wTsum w4[8];

// user-defined data type TR which is an array of reals typedef real TR[5];

// an unresolved nettype wTR with data type TR nettype TR wTR;

// a net with unresolved nettype wTR and data type TR wTR w5;

// an array of nets, each net has an unresolved nettype wTR // and data type TR

wTR w6[8];

6.7.3 Initialization of nets with user-defined nettypes

The resolution function for any net of a user-defined nettype shall be activated at time zero at least once.

This activation occurs even for such nets with no drivers or no value changes on drivers at time zero. Since the actual evaluation of the resolution function is subject to scheduling nondeterminism, no assumptions can

VERIFICATION LANGUAGE

be made regarding the state of driven values during the guaranteed call, which may precede or follow any driver changes at time zero.

The initial value of a net with a user-defined nettype shall be set before any initial or always procedures are started and before the activation of the guaranteed time zero resolution call. The default initialization value for a net with a user-defined nettype shall be the default value defined by the data type. Table 6-7 defines the default value for data types of variables if no initializer is provided; those default values shall also apply to nets of user-defined nettypes for valid data types of a net. For a net with a user-defined nettype whose data type is a struct type, any initialization expressions for the members within the struct shall be applied.

NOTE— The default value for a logic net of a user-defined nettype is X. This default means that a bit of a logic data type in an unresolved user-defined nettype will be X if it has no drivers, not Z. For a net with a resolved net-type, the value would be determined by the resolution function executed with an empty array of driver values.