Usually, transistor level modeling is referred to model in hardware structures using transistor models with analog input and output signal values. On the other hand, gate level modeling refers to modeling hard-ware structures wing gate models with digital input and output signal values between these two modeling schemes is referred to as switch level modeling. At this level, a hardware component is described
at the transistor level, but transistors only exhibit digital behavior and their input, and output signal values are only limited to digital values. At the switch level, transistors behave as on-off switches- Verilog uses a 4 value logic value system, so Verilog switch input and output signals can take any of the four 0, 1, Z, and X logic values.
Figure shows standard switches; pull primitives, and tri-state gates that behave like nmos and pmos. Instantiations of these primitives and their corresponding symbols are also shown. Cmos is a unidirectional transmission gate with a true and complemented control lines. Nmos and pmos are unidirectional pass gates representing NMOS and PMOS transistors respectively.
When such a resistive switch conducts, the strength of its output signal is one or two levels below that of its input signal. Delay values for transition to 1, transition to 0, and transition to Z can be specified in the #(to-1, to-0, to-z) format for unidirectional switches. Bidirectional tran switches shown in figure are functionally equivalent to unidirectional switches shown in the adjacent column of this figure. When conducting, the two inout ports are connected and logic values flow in both directions.
pmos p1(out, data, control); // instantiate a pmos switch
nmos (out, data , control); // instantiate nmos switch ; no instance name
pmos (out, data, control); // instantiate pmos switch; no instance name
Value of the out signal is determined from the values of data and control signals. Logic tables for out are shown in table. Some combinations of data and control signals cause the gates to output to either a 1 or 0 or to an z value without a preference for either value. The symbol L stands for 0 or Z; H stands for 1 or z.
Thus, the nmos switch conducts when its control signal is 1. If control signal is 0, the output assumes a high impedance value. Similarly a pmos switch conducts if the control signal is 0.
CMOS switch
A CMOS switch is instantiated as shown in below,
cmos cl(out, data, ncontrol, pcontrol);//instantiate cmos gate
or
cmos (out, data, ncontrol, pcontrol); //no instance name given
1, the output of the switch is high impedance value. The cmos gate is essentially a combination of two gates: one nmos and one pmos. Thus the cmos instantiation shown above is equivalent to the following.
nmos (out, data, ncontrol); //instantiate a nmos switch
pmos (out, data, pcontrol); //instantiate a pmos switch
Since a cmos switch is derived from nmos and pmos switches, it is possible derive the output value from Table, given values of data, ncontrol, and pcontrol signals.
Bidirectional Switches
NMOS, PMOS and CMOS gates conduct from drain to source. It is important to have devices that conduct in both directions. In such cases, signals on either side of the device can be the driver signal. Bidirectional switches are provided for this purpose. Three keywords are used to define bidirectional switches: tran, tranif0, and tranifl.
Symbols for these switches are shown in figure below.
These switches are instantiated as shown in below
tranifO (inoutl, inout2, control); //instance name is not specified
· Resistive switches reduce signal strengths when signals pass through them. The changes are shown below. Regular switches retain strength levels of signals from input to output. The exception is that if the input is of supply, the output is of strength strong. Below table shows the strength reduction due to resistive switches
supply pull
strong pull
pull weak
weak medium
large medium
medium small
small small
high high
Switch element | Delay specification | Examples |
Pmos,nmos,rpmos,rnmos | Zero (no delay) One (same delay on all transitions) Two (rise,fall) Three (rise,fall,turnoff) | pmos p1(out,data,control); pmos#(1) p1(out,data,control); nmos #(1,2) p2(out,data,control); nmos #(1,3,2) p2(out,data,control); |
Cmos,rcmos | Zero, one,two or three delays (same as above) | cmos #(5) c2(out,data,nctrl,pctrl); cmos #(1,2) c1(out,data,nctrl,pctrl); |
Delay Specification on NMOS and CMOS switches
Bidirectional pass switches
Switch element | Delay specification | Examples |
tran, rtran | No delay specification allowed | |
tranif1,rtranif1 tranif0,rtranif0 | Zero (no delay) One (both turn-on and turn-off) Two (turn-on, turn-off) | rtranif0 rt1(inout1,inout2,control); tranif0#(3) T(inout1,inout2,control); tranif1#(1,2) t1(inout1,inout2,control); |
Delay Specification for Bidirectional Switches
Example-CMOS NAND
module my_nand (Out,A,B);
ouput Out;
supply0 Vss;
pmos (Out,B,Vdd);
nmos (Out,A,C);
nmos(C,Vss,B);