Week 1-2 Introduction To Hardware Description Language
Week 1-2 Introduction To Hardware Description Language
Introduction to HDL
Hardware Description Language - Introduction
•When a language is used for the above purpose (i.e. to provide an alternative
to schematics), it is referred to as a structural description in which the language
describes an interconnection of components.
•Such a structural description can be used as input to logic simulation just as a
schematic is used.
•Models for each of the primitive components are required.
•If an HDL is used, then these models can also be written in the HDL providing
a more uniform, portable representation for simulation input.
HDL – Introduction (3)
•HDL can be used to represent logic diagrams, Boolean expressions, and other
more complex digital circuits.
•Thus, in top down design, a very high-level description of a entire system can
be precisely specified using an HDL.
•This high-level description can then be refined and partitioned into lower-
level descriptions as a part of the design process.
HDL – Introduction (4)
•The stimulus that tests the functionality of the design is called a test bench.
•To simulate a digital system
• Design is first described in HDL
• Verified by simulating the design and checking it with a test bench which is also written
in HDL.
Logic Simulation
•Verilog HDL has a syntax that describes precisely the legal constructs that can
be used in the language.
•It uses about 100 keywords pre-defined, lowercase, identifiers that define the
language constructs.
•Example of keywords: module, endmodule, input, output wire, and, or, not ,
etc.,
•Any text between two slashes (//) and the end of line is interpreted as a
comment.
•Blank spaces are ignored and names are case sensitive.
Verilog - Module
HDL Example
module smpl_circuit(A,B,C,x,y);
input A,B,C;
output x,y;
wire e;
and g1(e,A,B);
not g2(y,C);
or g3(x,e,y);
endmodule
Verilog – Gate Delays
•In order to simulate a circuit with HDL, it is necessary to apply inputs to the
circuit for the simulator to generate an output response.
•An HDL description that provides the stimulus to a design is called a test
bench.
•The initial statement specifies inputs between the keyword begin and end.
•Initially ABC=000 (A,B and C are each set to 1’b0 (one binary digit with a
value 0).
•$finish is a system task.
Verilog – Module (6)
Bitwise operators
• Bitwise NOT : ~
• Bitwise AND: &
• Bitwise OR: |
• Bitwise XOR: ^
• Bitwise XNOR: ~^ or ^~
Verilog – Module (8)
Boolean Expressions:
•These are specified in Verilog HDL with a continuous assignment
statement consisting of the keyword assign followed by a Boolean
Expression.
•The earlier circuit can be specified using the statement:
assign x = (A&B)|~C)
E.g. x = A + BC + B’D
y = B’C + BC’D’
Verilog – Module (9)
UDP features ….
•UDP’s do not use the keyword module. Instead they are declared
with the keyword primitive.
• There can be only one output and it must be listed first in the
port list and declared with an output keyword.
•There can be any number of inputs. The order in which they are
listed in the input declaration must conform to the order in which
they are given values in the table that follows.
Verilog – Module (12)
//User defined primitive(UDP)
primitive crctp (x,A,B,C);
output x;
input A,B,C;
//Truth table for x(A,B,C) = Minterms (0,2,4,6,7)
table
// A B C : x (Note that this is only a comment)
0 0 0 : 1;
0 0 1 : 0; // Instantiate primitive
0 1 0 : 1;
module declare_crctp;
0 1 1 : 0;
1 0 0 : 1; reg x,y,z;
1 0 1 : 0;
1 1 0 : 1; wire w;
1 1 1 : 1; crctp (w,x,y,z);
endtable
endprimitive endmodule