DSDV Module-4
DSDV Module-4
CONTENT
Introduction to Verilog
Structure of Verilog module,
Operators,
Data Types, Styles of Description.
Verilog Data flow description
Highlights of Data flow description,
Structure of Data flow description.
Introduction to Verilog
Verilog was introduced in 1980s and has gone through several iterations and
standardization by the Institute of Electrical and Electronic Engineers (IEEE), such as in
December 1995 when Verilog HDL became IEEE Standard 1364-1995.
In 2001 when IEEE Std. 1364-2001 was introduced, and in 2005 when IEEE 1800-2005
was introduced.
Verilog Program start with the key word module with module name and should end with
endmodule, which is represent the block shown bellow
module halfadder();
-------------------
------------------- halfadder
endmodule
Note:
module name should never start with number and any special character except
Underscore( _ ).
There should not be any space for the module name like half adder (Error Declaration)
Semicolon(;) act as line separator.
Inside the round bracket total number of external inputs and outputs are declared and
these input outputs are called sensitivity list
A SUM
module halfadder(A, B, SUM, Carry);
input A, B;
output SUM, Carry;
B
halfadder Carry
endmodule
Verilog Ports
input: The port is only an input port. In any assignment statement, the port should appear
only on the right-hand side of the statement (i.e., the port is read).
output: The port is an output port. In contrast to VHDL, the Verilog output port can
appear in either side of the assignment statement.
inout: The port can be used as both an input and output. The inout port represents a
bidirectional bus.
Operators
These operators operate on two operands, and the result is in Boolean: 0 (false) or 1
(true).
Example, Z = X && Y
Relational Operators
Verilog has a set of relational operators, table shows Verilog relational operators
Verilog relational operators also return Boolean values: false (0) or true (1).
if (A === B)
the result is true (1) if all bits of A match that of B. Otherwise, the result is false (0).
Arithmetic Operators
Shift Operators
Shift operators are unary operators; they operate on a single operand. To understand the
function of these operators.
If A = 1110.
Data Types
Nets
Nets are declared by the predefined word wire.
Nets have values that change continuously by
the circuits that are driving them.
Verilog supports four values for nets, as
shown in Table
Examples
wire sum;
wire S1 = 1’b0;
Register
Vectors
Parameter
Parameter represents a global constant. It is declared by the predefined word parameter.
Example
module compr_genr (X, Y, xgty, xlty, xeqy);
parameter N = 3;
input [N:0] X, Y;
output xgty, xlty, xeqy;
wire [N:0] sum, Yb;
Arrays
Verilog, does not have a predefined word for array.
Registers and integers can be written as arrays. Consider the following statements:
parameter N = 4;
parameter M = 3;
reg signed [M:0] carry [0:N];
Styles of Description.
endmodule
Behavioral Description
A behavioral description models the system as to how the outputs behave with the
inputs; usually, a flowchart is used to show this behavior.
always is the Verilog behavioral statement.
all Verilog statements inside always are treated as concurrent
here any signal that is declared as an output or appears at the left-hand side of a
signal-assignment statement should be declared as a register (reg) if it appears
inside always.
module half_add (I1, I2, O1, O2);
input I1, I2;
output O1, O2;
reg O1, O2;
always@(I1, I2)
begin
#10 O1 = I1 ^ I2;
#10 O2 = I1 & I2;
end
endmodule
Structural Description
Verilog has a large number of built-in gates.
Example: - xor X1 (sum, a, b);
Describes a two-input XOR gate.
The inputs are a and b, and the output is sum.
X1 is an optional identifier for the gate; the identifier can be omitted as:
xor (sum, a, b);
module Half_adder1(a,b,SUM,Carry);
input a, b;
output SUM,Carry;
andgate a1(Carry,a,b); // andgate is instantiated
xorgate x1(SUM,a,b); // xorgate is instantiated
endmodule