Unit-3 Data Flow Level & Switch Level Modeling: Digital Design Through Verilog
Unit-3 Data Flow Level & Switch Level Modeling: Digital Design Through Verilog
Introduction
Dataflow modeling is a higher level of abstraction. The designer no need have any knowledge of
logic circuit. He should be aware of data flow of the design. The gate level modeling becomes
very complex for a VLSI circuit. Hence dataflow modeling became a very important way of
implementing the design.
In dataflow modeling most of the design is implemented using continuous assignments, which
are used to drive a value onto a net. The continuous assignments are made using the keyword
assign.
The assign statement is used to make continuous assignment in the dataflow modeling. The
assign statement usage is given below:
Note:
• The LHS of assign statement must always be a scalar or vector net or a concatenation. It
cannot be a register.
• Continuous statements are always active statements.
• Registers or nets or function calls can come in the RHS of the assignment.
• The RHS expression is evaluated whenever one of its operands changes. Then the result
is assigned to the LHS.
• Delays can be specified.
Examples:
In the above example out is undeclared, but verilog makes an implicit net declaration for out.
wire out;
assign out = in0 ^ in1;
Delays
There are three types of delays associated with dataflow modeling. They are: Normal/regular
assignment delay, implicit continuous assignment delay and net declaration delay.
If there is any change in the operands in the RHS, then RHS expression will be evaluated after
10 units of time. Lets say that at time t, if there is change in one of the operands in the above
example, then the expression is calculated at t+10 units of time. The value of RHS operands
present at time t+10 is used to evaluate the expression.
is same as
wire out;
assign 10 out = in0 ^ in1;
is same as
wire out;
assign #10 out = in;
Examples
output out[0:3];
input in0, in1;
endmodule
output out;
input in0, in1, in2, in3;
input s0, s1;
assign out = (~s0 & ~s1 & in0)|(s0 & ~s1 & in1)|
(~s0 & s1 & in2)|(s0 & s1 & in0);
endmodule
output out;
input [7:0] in;
input [2:0] sel;
endmodule
endmodule
5. Implementation of a adder/subtractor .
module addSub(A, B, sel, Result);
input sel;
input [3:0] A,B;
output [3:0] Result;
wire [3:0] Result;
assign Result = (sel)? A + B : A - B;
endmodule
testAS.v
module main;
reg [3:0] A, B;
reg sel;
wire [3:0] Result;
addSub as1(A, B, sel, Result);
initial begin
A = 4'b0001;
B = 4'b1010;
end
initial begin
forever begin
#10
A = A + 1'b1;
B = B + 1'b2;
end
end
initial begin
sel = 1;
#200
sel = 0;
end
endmodule
Objectives
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.
Switches are unidirectional or bidirectional and resistive or non resistive, For each group those
primitives that switch on with a positive gate {like an NMOS transistor} and those that switch
on with a negative gate {like aPMOS transistor}. A unidirectional transistor passes
its input value to its output when it is switched on. A bidirectional transistor conducts both ways.
A resistive structure reduces the strength of its input logic when passing it to its output.
In addition to switch level primitives, pull-primitives that are used as pull-up and pull-
down resistors for tri-state outputs.
nmos tranif1
pmos tranif0
rnmos rtranif1
rpmos rtranif0
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.
Since switches are Verilog primitives, like logic gates, the name of the instance is optional.
Therefore, it is acceptable to instantiate a switch without assigning an instance name.
Value of the out signal is determined from the values of in and control signals. Some
combinations of in 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 Switches
CMOS switches are declared with the keyword cmos. A cmos device can be modeled with a
nmos and a pmos device. The symbol for a cmos switch is shown in figure
CMOS switch
The ncontrol and pcontrol are normally complements of each other. When the ncontrol signal
is 1 and pcontrol signal is 0, the switch conducts. If ncontrol is 0 and pcontrol is 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.
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.
➢ Specify no delay
mos_sw [instance_name](output, input, …);
cmos [instance_name](output, input, …);
➢ Specify propagation delay only
mos_sw #(prop_delay)[instance_name](output, input, …);
cmos #(prop_delay)[instance_name](output, input, …);
➢ Specify both rise and fall times
mos_sw #(t_rise, t_fall)[instance_name](output, input, …);
cmos #(t_rise, t_fall)[instance_name](output, input, …);
➢ Specify rise, fall, and turn-off times
mos_sw #(t_rise, t_fall, t_off)[instance_name](output, input, …);
cmos #(t_rise, t_fall, t_off)[instance_name](output, input, …);
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.
The tran switch acts as a buffer between the two signals inoutl and inout2. Either inoutl
or inout2 can be the driver signal. The tranif0 switch connects the two signals inoutl
and inout2 only if the control signal is logical 0. If the control signal is a logical 1, the
nondriver signal gets a high impedance value z. The driver signal retains value from its
driver. The tranifl switch conducts if the control signal is a logical 1.
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
Delay Specifications
➢ Specify no delay
bdsw name [instance name](in, out, control);
➢ Specify a turn-on and turn-off delay
bdsw name #(t_on_off)[instance name](in, out,control);
➢ Specify separately turn-on and turn-off delays
bdsw name #(t_on, t_off)[instance name](in, out, control);
Signal strengths:
Drive Strength:
➢ The pulldown and pullup primitives can have one or two drive strengths
➢ The unidirectional coms, nmos, and pmos switches can have rise, fall, and turn-
off delays
coms #(<delay>) (d, s, ng, pg);
nmos #(<rise_delay>,<fall_delay>) (d, s, g);
pmos #(<rise_delay>,<fall_delay>),<turnoff_delay>) (d, s, g);
➢ The bidirectional switches tranif0 and tranif1 can have turn-on and turn-off
delays,but no source-drain channel delays
tranif0 #(<delay>) (d, s, g);
tranif1 #(<turnon_delay>,<turnoff_delay>) (d, s, g);
➢ The pulldown,pullup,and tran gates cannot have delays
Note: You can specify delays in min:typ:max format.
Examples:
1.CMOS inverter:
endmodule
2. CMOS NAND
4. A 2-to-1 Multiplexer
module my_mux (out, s, i0, i1);
output out;
input s, i0, i1;
//internal wire
wire sbar; //complement of s
not (sbar, s);
//instantiate cmos switches
cmos (out, i0, sbar, s);
cmos (out, i1, s, sbar);
endmodule