Appendix A. Strength Modeling and Advanced Net Definitions
A.1 Strength Levels
Verilog allows signals to have logic values and strength values. Logic values are , , x , and z . Logic strength values are used to resolve combinations of multiple signals and to represent behavior of actual hardware elements as accurately as possible. Several logic strengths are available. shows the strength levels for signals. Driving strengths are used for signal values that are driven on a net. Storage strengths are used to model charge storage in trireg type nets, which are discussed later in this appendix.
Table A-1. Strength Levels
Strength Level
Abbreviation
Degree
Strength Type
supply1
Su1
strongest 1
driving
strong1
St1
driving
highz1
HiZ1
weakest1
high impedance
highz
HiZ0
weakest0
high impedance
small0
Sm0
storage
supply0
Su0
strongest0
driving
A.2 Signal Contention
Logic strength values can be used to resolve signal contention on nets that have multiple drivers.There are many rules applicable to resolution of contention. However, two cases of interest that are most commonly used are described below.
A.2.1 Multiple Signals with Same Value and Different Strength
If two signals with same known value and different strength drive the same net, the signal with the higher strength wins.
In the example shown, supply strength is greater than pull . Hence, Su1 wins.
A.2.2 Multiple Signals with Opposite Value and Same Strength
When two signals with opposite value and same strength combine, the resulting value is x .
A.3 Advanced Net Types
We discussed resolution of signal contention by using strength levels. There are other methods to resolve contention without using strength levels. Verilog provides advanced net declarations to model logic contention.
A.3.1 tri
The keywords wire and tri have identical syntax and function. However, separate names are provided to indicate the purpose of the net. Keyword wire denotes nets with single drivers, and tri is denotes nets that have multiple drivers. A multiplexer, as defined below, uses the tri declaration.
module mux(out, a, b, control);output out;input a, b, control;tri out;wire a, b, control;bufif0 b1(out, a, control); //drives a when control = 0; z otherwisebufif1 b2(out, b, control); //drives b when control = 1; z otherwiseendmodule
The net is driven by b1 and b2 in a complementary manner. When b1 drives a, b2 is tristated; when b2 drives b, b1 is tristated. Thus, there is no logic contention. If there is contention on a tri net, it is resolved by using strength levels. If there are two signals of opposite values and same strength, the resulting value of the tri net is x .
A.3.2 trireg
Keyword trireg is used to model nets having capacitance that stores values. The default strength for trireg nets is medium . Nets of type trireg are in one of two states:
Driven state At least one driver drives a , , or x value on the net. The value is continuously stored in the trireg net. It takes the strength of the driver.
Capacitive state All drivers on the net have high impedance ( z) value. The net holds the last driven value. The strength is small , medium , or large (default is medium ).
trireg (large) out;wire a, control;bufif1 (out, a, control); // net out gets value of a when control = 1; //when control = 0, out retains last value of a //instead of going to z . strength is large.
A.3.3 tri0 and tri1
Keywords tri0 and tri1 are used to model resistive pulldown and pullup devices. A tri0 net has a value if nothing is driving the net. Similarly, tri1 net has a value if nothing is driving the net. The default strength is pull .
tri0 out;wire a, control;bufif1 (out, a, control); //net out gets the value of a when control = 1; //when control = 0, out gets the value 0 instead //of z . If out were declared as tri1 , the //default value of out would be instead of .
A.3.4 supply0 and supply1
Keyword supply1 is used to model a power supply. Keyword supply0 is used to model ground. Nets declared as supply1 or supply0 have constant logic value and a strength level supply (strongest strength level).
supply1 vcc; //all nets connected to vcc are connected to power supplysupply0 gnd; //all nets connected to gnd are connected to ground
A.3.5 wor, wand, trior, and triand
When there is logic contention, if we simply use a tri net, we will get an x . This could be indicative of a design problem. However, sometimes the designer needs to resolve the final logic value when there are multiple drivers on the net, without using strength levels. Keywords wor , wand , trior , and triand are used to resolve such conflicts. Net wand perform the and operation on multiple driver logic values. If any value is , the value of the net wand is . Net wor performs the or operation on multiple driver values. If any value is , the net wor is . Nets triand and trior have the same syntax and function as the nets wor and wand . The example below explains the function.
wand out1;wor out2;buf (out1, 1'b0);buf (out1, 1'b1); //out1 is a wand net; gets the final value 1'b0buf (out2, 1'b0);buf (out2, 1'b1); //out2 is a wor net; gets the final value 1'b1
Appendix B. List of PLI Routines
A list of PLI acc_ and tf_ routines is provided. VPI routines are not listed. Names, the argument list, and a brief description of the routine are shown for each PLI routine. For details regarding the use of each PLI routine, refer to the IEEE Standard Verilog Hardware Description Language document.
[1] See the "IEEE Standard Verilog Hardware Description Language" document for details on VPI routines.
B.1 Conventions
Conventions to be used for arguments are shown below.
char *format
Pass formatted string
char *
Pass name of object as a string
underlined arguments
Arguments are optional
*
Pointer to the data type
.........
More arguments of the same type
B.2 Access Routines
Access routines are classified into five categories: handle, next, value change link, fetch, and modify routines.
B.2.1 Handle Routines
Handle routines return handles to objects in the design. The names of handle routines always starts with the prefix acc_handle_ . See .