Hardware Description Language (HDL)

Slides:



Advertisements
Similar presentations
Verilog.
Advertisements

The Verilog Hardware Description Language
Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Combinational Logic.
ELEN 468 Lecture 21 ELEN 468 Advanced Logic Design Lecture 2 Hardware Modeling.
Chapter 11 Verilog HDL Application-Specific Integrated Circuits Michael John Sebastian Smith Addison Wesley, 1997.
Table 7.1 Verilog Operators.
Verilog Intro: Part 1.
16/04/20151 Hardware Descriptive Languages these notes are taken from Mano’s book It can represent: Truth Table Boolean Expression Diagrams of gates and.
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part3: Verilog – Part 1.
CSE 201 Computer Logic Design * * * * * * * Verilog Modeling
HDL Programming Fundamentals UNIT 3: Behavioral Descriptions OBJECTIVES  Understand the concept of sequential statements in VHDL and how they are different.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
 HDLs – Verilog and Very High Speed Integrated Circuit (VHSIC) HDL  „ Widely used in logic design  „ Describe hardware  „ Document logic functions.
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
Verilog Sequential Circuits Ibrahim Korpeoglu. Verilog can be used to describe storage elements and sequential circuits as well. So far continuous assignment.
ECE 353 Computer Systems Lab I Verilog Hardware Description Language.
CSE241 R1 Verilog.1Kahng & Cichy, UCSD ©2003 CSE241 VLSI Digital Circuits Winter 2003 Recitation 1: Verilog Introduction.
ENEE 408C Lab Capstone Project: Digital System Design Spring 2006 Class Web Site:
ECEN ECEN475 Introduction to VLSI System Design Verilog HDL.
VHDL Asutosh Kar Asst. Prof. in IIIT, Bhubaneswar.
Digital System Design EEE344 Lecture 3 Introduction to Verilog HDL Prepared by: Engr. Qazi Zia, Assistant Professor EED, COMSATS Attock1.
Today’s Lecture Process model –initial & always statements Assignments –Continuous & procedural assignments Timing Control System tasks.
Overview Logistics Last lecture Today HW5 due today
1 Verilog Digital System Design Z. Navabi, 2006 Digital Design Flow  Digital Design Flow begins with specification of the design at various levels of.
Verilog Intro: Part 2. Procedural Blocks There are two types of procedural blocks in Verilog. – initial for single-pass behavior: initial blocks execute.
ECE 2372 Modern Digital System Design
Verilog Language Concepts
CS 3850 Lecture 3 The Verilog Language. 3.1 Lexical Conventions The lexical conventions are close to the programming language C++. Comments are designated.
Digital System 數位系統 Verilog HDL Ping-Liang Lai (賴秉樑)  
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
ECE/CS 352 Digital System Fundamentals© 2001 C. Kime 1 ECE/CS 352 Digital Systems Fundamentals Spring 2001 Chapters 3 and 4: Verilog – Part 2 Charles R.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
Fall 2004EE 3563 Digital Systems Design EE 3563 VHSIC Hardware Description Language  Required Reading: –These Slides –VHDL Tutorial  Very High Speed.
Charles Kime & Thomas Kaminski © 2004 Pearson Education, Inc. Terms of Use (Hyperlinks are active in View Show mode) Terms of Use Verilog Part 3 – Chapter.
1 Hardware description languages: introduction intellectual property (IP) introduction to VHDL and Verilog entities and architectural bodies behavioral,
Behavioral Modelling - 1. Verilog Behavioral Modelling Behavioral Models represent functionality of the digital hardware. It describes how the circuit.
1 Verilog Digital System Design Z. Navabi, 2006 Verilog Language Concepts.
Verilog A Hardware Description Language (HDL ) is a machine readable and human readable language for describing hardware. Verilog and VHDL are HDLs.
ELEE 4303 Digital II Introduction to Verilog. ELEE 4303 Digital II Learning Objectives Get familiar with background of HDLs Basic concepts of Verilog.
Introduction to ASIC flow and Verilog HDL
Multiplexers Section Topics Multiplexers – Definition – Examples – Verilog Modeling.
Introduction to Verilog
Verilog® HDL Behavioral Modeling (2)
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
Chapter1: Introduction Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 1-1 Chapter 1: Introduction Prof. Ming-Bo.
Verilog Intro: Part 1. Hardware Description Languages A Hardware Description Language (HDL) is a language used to describe a digital system, for example,
1 University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part4: Verilog – Part 2.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Exp#5 & 6 Introduction to Verilog COE203 Digital Logic Laboratory Dr. Ahmad Almulhem KFUPM Spring 2009.
1 A hardware description language is a computer language that is used to describe hardware. Two HDLs are widely used Verilog HDL VHDL (Very High Speed.
Hardware Description Languages: Verilog
An Introduction to Verilog: Transitioning from VHDL
Adapted from Krste Asanovic
Verilog Introduction Fall
Verilog-HDL-1 by Dr. Amin Danial Asham.
Verilog-HDL-3 by Dr. Amin Danial Asham.
Hardware Description Languages: Verilog
Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-I]
Hardware Descriptive Languages these notes are taken from Mano’s book
Behavioral Modeling in Verilog
UNIT 3: Behavioral Descriptions
Introduction to Verilog
The Verilog Hardware Description Language
The Verilog Hardware Description Language
Introduction to Digital IC Design
COE 202 Introduction to Verilog
Presentation transcript:

Hardware Description Language (HDL) What is the need for Hardware Description Language? Model, Represent, And Simulate Digital Hardware Hardware Concurrency Parallel Activity Flow Semantics for Signal Value And Time Special Constructs And Semantics Edge Transitions Propagation Delays Timing Checks

VERILOG HDL Basic Unit – A module Module Example: A Computer Describes the functionality of the design States the input and output ports Example: A Computer Functionality: Perform user defined computations I/O Ports: Keyboard, Mouse, Monitor, Printer

Module General definition Example module module_name ( port_list ); port declarations; … variable declaration; description of behavior endmodule 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

Lexical Conventions Comments Number String // Single line comment /* Another single line comment */ /* Begins multi-line (block) comment All text within is ignored Line below ends multi-line comment */ Number decimal, hex, octal, binary unsized decimal form size base form include underlines, +,- String " Enclose between quotes on a single line"

Lexical Conventions (cont.) Identifier A ... Z a ... z 0 ... 9 Underscore Strings are limited to 1024 chars First char of identifier must not be a digit Keywords: See text. Operators: See text. Verilog is case sensitive

Structural: Logic is described in terms of Verilog gate primitives 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); sel b a out sel_n sel_b sel_a n1 a1 a2 o1

Description Styles (cont.) Dataflow: Specify output signals in terms of input signals Example: assign out = (sel & a) | (~sel & b); sel b a out sel_n sel_b sel_a

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; a b sel out Black Box 2x1 MUX

Execution: Concurrent Format (Primitive Gates): Structural Modeling Execution: Concurrent Format (Primitive Gates): and G2(Carry, A, B); First parameter (Carry) – Output Other Inputs (A, B) - Inputs

Uses continuous assignment statement Dataflow Modeling Uses continuous assignment statement Format: assign [ delay ] net = expression; Example: assign sum = a ^ b; Delay: Time duration between assignment from RHS to LHS All continuous assignment statements execute concurrently Order of the statement does not impact the design

Dataflow Modeling (cont.) Delay can be introduced Example: assign #2 sum = a ^ b; “#2” indicates 2 time-units No delay specified : 0 (default) Associate time-unit with physical time `timescale time-unit/time-precision Example: `timescale 1ns/100 ps Timescale `timescale 1ns/100ps 1 Time unit = 1 ns Time precision is 100ps (0.1 ns) 10.512ns is interpreted as 10.5ns

Dataflow Modeling (cont.) Example: `timescale 1ns/100ps module HalfAdder (A, B, Sum, Carry); input A, B; output Sum, Carry; assign #3 Sum = A ^ B; assign #6 Carry = A & B; endmodule

Dataflow Modeling (cont.)

Behavioral Modeling Example: Sensitivity List module mux_2x1(a, b, sel, out); input a, a, sel; output out; always @(a or b or sel) begin if (sel == 1) out = a; else out = b; end endmodule Sensitivity List

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 Statements with a Sequential Block: Procedural Assignments Delay in Procedural Assignments Inter-Statement Delay Intra-Statement Delay

Behavioral Modeling (cont.) Inter-Assignment Delay Example: Sum = A ^ B; #2 Carry = A & B; Delayed execution Intra-Assignment Delay Carry = #2 A & B; Delayed assignment

Procedural Constructs Two Procedural Constructs initial Statement always Statement 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

Event Control Event Control Edge Triggered Event Control Level Triggered Event Control @ (posedge CLK) //Positive Edge of CLK Curr_State = Next_state; @ (A or B) //change in values of A or B Out = A & B;

Loop Statements Loop Statements Repeat Loop Repeat While For Example: repeat (Count) sum = sum + 5; If condition is a x or z it is treated as 0

Loop Statements (cont.) While Loop Example: while (Count < 10) begin sum = sum + 5; Count = Count +1; end If condition is a x or z it is treated as 0 For Loop for (Count = 0; Count < 10; Count = Count + 1) begin

Conditional Statements if Statement Format: if (condition) procedural_statement else if (condition) else Example: if (Clk) Q = 0; Q = D;

Conditional Statements (cont.) Case Statement Example 1: case (X) 2’b00: Y = A + B; 2’b01: Y = A – B; 2’b10: Y = A / B; endcase Example 2: case (3’b101 << 2) 3’b100: A = B + C; 4’b0100: A = B – C; 5’b10100: A = B / C; //This statement is executed

Conditional Statements (cont.) Variants of case Statements: casex and casez casez – z is considered as a don’t care casex – both x and z are considered as don’t cares Example: casez (X) 2’b1z: A = B + C; 2’b11: A = B / C; endcase

Net Types: Physical Connection between structural elements Data Types Net Types: Physical Connection between structural elements Register Type: Represents an abstract storage element. Default Values Net Types : z Register Type : x Net Types: wire, tri, wor, trior, wand, triand, supply0, supply1 Register Types : reg, integer, time, real, realtime

Data Types Net Type: Wire Register Type: Reg wire [ msb : lsb ] wire1, wire2, … Example wire Reset; // A 1-bit wire wire [6:0] Clear; // A 7-bit wire Register Type: Reg reg [ msb : lsb ] reg1, reg2, … reg [ 3: 0 ] cla; // A 4-bit register reg cla; // A 1-bit register

Restrictions on Data Types Data Flow and Structural Modeling Can use only wire data type Cannot use reg data type Behavioral Modeling Can use only reg data type (within initial and always constructs) Cannot use wire data type

Memories An array of registers Example reg [ msb : lsb ] memory1 [ upper : lower ]; Example reg [ 0 : 3 ] mem [ 0 : 63 ]; // An array of 64 4-bit registers reg mem [ 0 : 4 ]; // An array of 5 1-bit registers

`define – (Similar to #define in C) used to define global parameter Compiler Directives `define – (Similar to #define in C) used to define global parameter Example: `define BUS_WIDTH 16 reg [ `BUS_WIDTH - 1 : 0 ] System_Bus; `undef – Removes the previously defined directive … `undef BUS_WIDTH

Compiler Directives (cont.) `include – used to include another file Example `include “./fulladder.v”

Simulation Control Task System Tasks Display tasks $display : Displays the entire list at the time when statement is encountered $monitor : Whenever there is a change in any argument, displays the entire list at end of time step Simulation Control Task $finish : makes the simulator to exit $stop : suspends the simulation Time $time: gives the simulation

Type of Port Connections Connection by Position parent_mod

Type of Port Connections (cont.) Connection by Name parent_mod

Empty Port Connections If an input port of an instantiated module is empty, the port is set to a value of z (high impedance). module child_mod(In1, In2, Out1, Out2) module parent_mod(…….) input In1; input In2; child_mod mod(A, ,Y1, Y2); output Out1; //Empty Input output Out2; endmodule //behavior relating In1 and In2 to Out1 endmodule If an output port of an instantiated module is left empty, the port is considered to be unused. module parent_mod(…….) child_mod mod(A, B, Y1, ); //Empty Output

Test Bench Test Bench `timescale 1ns/100ps module Top; reg PA, PB; wire PSum, PCarry; HalfAdder G1(PA, PB, PSum, PCarry); initial begin: LABEL reg [2:0] i; for (i=0; i<4; i=i+1) begin {PA, PB} = i; #5 $display (“PA=%b PB=%b PSum=%b PCarry=%b”, PA, PB, PSum, PCarry); end // for end // initial endmodule Test Bench Apply Inputs Design Module Observe Outputs

Test Bench - Generating Stimulus Example: A sequence of values initial begin Clock = 0; #50 Clock = 1; #30 Clock = 0; #20 Clock = 1; end

Test Bench - Generating Clock Repetitive Signals (clock) Clock A Simple Solution: wire Clock; assign #10 Clock = ~ Clock Caution: Initial value of Clock (wire data type) = z ~z = x and ~x = x

Test Bench - Generating Clock (cont.) Initialize the Clock signal initial begin Clock = 0; end Caution: Clock is of data type wire, cannot be used in an initial statement Solution: reg Clock; … always begin #10 Clock = ~ Clock; forever loop can also be used to generate clock