Hardware Description Language (HDL) What Is The Need For Hardware Description Language? Model, Represent, and Simulate Digital Hardware
Hardware Description Language (HDL) What Is The Need For Hardware Description Language? Model, Represent, and Simulate Digital Hardware
Hardware Description Language (HDL) What Is The Need For Hardware Description Language? Model, Represent, and Simulate Digital Hardware
Example: A Computer
Functionality: Perform user defined computations I/O Ports: Keyboard, Mouse, Monitor, Printer
Example
module HalfAdder (A, B, Sum Carry); input A, B; output Sum, Carry; assign Sum = A ^ B; //^ denotes XOR assign Carry = A & B; // & denotes AND endmodule
Number
decimal, hex, octal, binary unsized decimal form size base form include underlines, +,-
String
" Enclose between quotes on a single line"
4
Strings are limited to 1024 chars First char of identifier must not be a digit Keywords: See text.
Description Styles Structural: Logic is described in terms of Verilog gate primitives Example: not n1(sel_n, sel); and a1(sel_b, b, sel_b); and a2(sel_a, a, sel); or o1(out, sel_b, sel_a); b sel
n1 a1
sel_b
sel_n
a
a2 sel_a
o1
out
Description Styles (cont.) Dataflow: Specify output signals in terms of input signals Example: assign out = (sel & a) | (~sel & b); b sel
sel_b sel_n
out
sel_a
a
7
Description Styles (cont.) Behavioral: Algorithmically specify the behavior of the design
Example: if (select == 0) begin out = b; end else if (select == 1) begin out = a; end
a b
Black Box
out
Sensitivity List
10
Behavioral Modeling (cont.) always statement : Sequential Block Sequential Block: All statements within the block are executed sequentially When is it executed?
Occurrence of an event in the sensitivity list Event: Change in the logical value
11
initial Statement : Executes only once always Statement : Executes in a loop Example:
initial begin Sum = 0; Carry = 0; end always @(A or B) begin Sum = A ^ B; Carry = A & B; end
12
procedural_statement Example:
if (Clk) Q = 0; else Q = D;
13
Verilog Registers
Mix-and-Match Assignments