1 Verilog Digital System Design Z. Navabi, 2006 Verilog Language Concepts.

Slides:



Advertisements
Similar presentations
Simulation executable (simv)
Advertisements

Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Chapter 11 Verilog HDL Application-Specific Integrated Circuits Michael John Sebastian Smith Addison Wesley, 1997.
Verilog Intro: Part 1.
Hardware Description Language (HDL)
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.
Logic Values 0:logic 0 / false 1:logic 1 / true X:unknown logic value Z:high-impedance.
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.
ENEE 408C Lab Capstone Project: Digital System Design Spring 2006 Class Web Site:
Verilog Sequential Circuits Ibrahim Korpeoglu. Verilog can be used to describe storage elements and sequential circuits as well. So far continuous assignment.
CS 3850 Lecture 5 Operators. 5.1 Binary Arithmetic Operators Binary arithmetic operators operate on two operands. Register and net (wire) operands are.
Reconfigurable Computing (EN2911X, Fall07) Lecture 05: Verilog (1/3) Prof. Sherief Reda Division of Engineering, Brown University
VHDL. What is VHDL? VHDL: VHSIC Hardware Description Language  VHSIC: Very High Speed Integrated Circuit 7/2/ R.H.Khade.
Introduction to C Programming
University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Hardware Description Language(HDL). Verilog simulator was first used beginning in 1985 and was extended substantially through The implementation.
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
Verilog Basics Nattha Jindapetch November Agenda Logic design review Verilog HDL basics LABs.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
1 Verilog Digital System Design Z. Navabi, 2006 Digital Design Flow  Digital Design Flow begins with specification of the design at various levels of.
ECE 2372 Modern Digital System Design
Workshop Topics - Outline
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Verilog Language Concepts
IAY 0600 Digital Systems Design
CS 3850 Lecture 3 The Verilog Language. 3.1 Lexical Conventions The lexical conventions are close to the programming language C++. Comments are designated.
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.
Module 1.3 Verilog Basics UNIT 1 : Introduction to Verilog Data Types.
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.
January Verilog Digital System Design Copyright Z. Navabi, 2006 Verilog Digital System Design Z. Navabi, McGraw-Hill, 2005 Chapter 2 Register Transfer.
Data TypestMyn1 Data Types The type of a variable is not set by the programmer; rather, it is decided at runtime by PHP depending on the context in which.
Fall 2004EE 3563 Digital Systems Design EE 3563 VHDL – Basic Language Elements  Identifiers: –basic identifier: composed of a sequence of one or more.
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 7: Design Example, Modeling Flip-Flops Spring.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
3/4/20031 ECE 551: Digital System Design * & Synthesis Lecture Set 3 3.1: Verilog - User-Defined Primitives (UDPs) (In separate file) 3.2: Verilog – Operators,
Behavioral Modelling - 1. Verilog Behavioral Modelling Behavioral Models represent functionality of the digital hardware. It describes how the circuit.
Chapter 5 Introduction to VHDL. 2 Hardware Description Language A computer language used to design circuits with text-based descriptions of the circuits.
Introduction to ASIC flow and Verilog HDL
04/26/20031 ECE 551: Digital System Design & Synthesis Lecture Set : Introduction to VHDL 12.2: VHDL versus Verilog (Separate File)
VHDL Discussion Subprograms IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology 1.
Introduction to Verilog. Data Types A wire specifies a combinational signal. – Think of it as an actual wire. A reg (register) holds a value. – A reg.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Logic Design Dr. Oliver Faust.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
Chapter 3: Dataflow Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 3-1 Chapter 3: Dataflow Modeling.
Verilog Intro: Part 1. Hardware Description Languages A Hardware Description Language (HDL) is a language used to describe a digital system, for example,
Introduction to Verilog. Structure of a Verilog Program A Verilog program is structured as a set of modules, which may represent anything from a collection.
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.
Structural Description
Hardware Description Languages: Verilog
Definition of the Programming Language CPRL
Verilog Introduction Fall
Verilog Digital System Design Z. Navabi, McGraw-Hill, 2005
Verilog-HDL-3 by Dr. Amin Danial Asham.
Hardware Description Languages: Verilog
Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-I]
Introduction to Verilog
Behavioral Modeling in Verilog
Chapter 3: Dataflow Modeling
VHDL Discussion Subprograms
Introduction to Digital System and Microprocessor Design
VHDL Discussion Subprograms
Supplement on Verilog adder examples
COE 202 Introduction to Verilog
Reconfigurable Computing (EN2911X, Fall07)
Presentation transcript:

1 Verilog Digital System Design Z. Navabi, 2006 Verilog Language Concepts

2 Verilog Digital System Design Z. Navabi, 2006  Now we are going to see:  How modules are developed  How names, numbers and operators are used Module Basics

3 Verilog Digital System Design Z. Navabi, 2006 Module Basics ModuleBasics Wires and VariablesModulesModulePorts ArraysVerilogOperatorsVerilog Data Types ArrayIndexing NamesNumbers CodeFormat Logic Value System

4 Verilog Digital System Design Z. Navabi, 2006 Code Format CodeFormat

5 Verilog Digital System Design Z. Navabi, 2006 Code Format  Verilog code is free format.  Spaces and new lines are served as separators.  It is case sensitive.  Language keywords use lowercase characters.  A comment designator start with // makes the rest of line comment.  The symbols /* … */ bracket the section of code which is in between as a comment.

6 Verilog Digital System Design Z. Navabi, 2006 Logic Value System Logic Value System

7 Verilog Digital System Design Z. Navabi, 2006  Bit type, or bits of vectors or arrays, of Verilog wires and variables take the 4-value logic value system.  Values in this system are 0, 1, Z and X.  The values 0 and 1 logic low and high.  The Z value represents an undriven, high impedance value.  The X value represent a conflict in multiple driving values, an unknown or value of a variable not initialized. Logic Value System

8 Verilog Digital System Design Z. Navabi, 2006  Logic Values and Examples Logic Value System

9 Verilog Digital System Design Z. Navabi, 2006 Wires and Variables Wires and Variables

10 Verilog Digital System Design Z. Navabi, 2006  Wires and Variables:  net: represents a wire driven by a hardware structure or output of a gate.  reg: represents a variable that can be assigned values in behavior description of a component in a Verilog procedural block. Wires and Variables

11 Verilog Digital System Design Z. Navabi, 2006 Modules Modules

12 Verilog Digital System Design Z. Navabi, 2006  Module is the main structure of definition of hardware components and testbenchs.  Begins with module keyword and end with endmodule.  Immediately following the module keyword, port list of the module appears enclosed in parenthesis. Modules

13 Verilog Digital System Design Z. Navabi, 2006 `timescale 1ns/100ps module FlipFlop (preset, reset, din, clk, qout); input preset, reset, din, clk; output qout; reg qout; (posedge clk) begin if (reset) qout <= #7 0; else if (preset) qout <= #7 1; else qout <= #8 din; endendmodule Ports are only listed in the port list and declared as separate input and output ports inside the body of the Flip-Flop module. Modules  Separate Port Declarations Statements

14 Verilog Digital System Design Z. Navabi, 2006 Module Ports ModulePorts

15 Verilog Digital System Design Z. Navabi, 2006  Inputs and outputs of a model must be declared as:  input  output  inout  By default, all declared ports are regarded as nets and the default net type is used for the ports.  Ports declared as output may be declared as reg. This way they can be assigned values in procedural blocks.  An inout port can be used only as a net. Transfers signal from and to module. Module Ports

16 Verilog Digital System Design Z. Navabi, 2006 Names Names

17 Verilog Digital System Design Z. Navabi, 2006  A stream of characters starting with a letter or an underscore forms a Verilog identifier.  The $ character and underscore are allowed in an identifier.  Verilog uses keywords that are all formed by streams of lowercase characters.  The names of system tasks and functions begin with a $ character.  Compiler directive names are preceded by the ` (back single quote) character. Example: `timescale Names

18 Verilog Digital System Design Z. Navabi, 2006  The following are valid names for identifiers: a_name, name1, _name, Name, Name$, name55, _55name, setup, _$name.  The following are Verilog keywords or system tasks. $display, default, $setup, begin Names

19 Verilog Digital System Design Z. Navabi, 2006 Numbers Numbers

20 Verilog Digital System Design Z. Navabi, 2006  Constants in Verilog are integer or real.  Specification of integers can include X and Z in addition to the standard 0 and 1 logic values.  Integers may be  Sized: Begins with the number of equivalent bits  Unsized: Without the number of bits specification  The general format for a sized integers is: number_of_bits ‘ base_identifier digits example: 6’b example: 6’b The base specifier is a single lower or uppercase character b, d, o or h which respectively stand for binary, decimal, octal and hexadecimal bases. Numbers

21 Verilog Digital System Design Z. Navabi, 2006  Optionally, the base-identifier can be preceded by the single character s (or S) to indicate a signed quantity.  A plus or minus operator can be used on the left of the number specification to change the sign of the number.  The underscore character (_) can be used anywhere in a number for grouping its bits or digits for readability purposes.  Real constants in Verilog use the standard format as described by IEEE std , the IEEE standard for double precision floating- point numbers. Examples: 1.9, 2.6E9, 0.1e-6, Numbers

22 Verilog Digital System Design Z. Navabi, 2006 Arrays Arrays

23 Verilog Digital System Design Z. Navabi, 2006  Verilog allows declaration and usage of multidimensional arrays for nets or regs.  Range specifications are enclosed in square brackets.  The size and range specification of the elements of an array come after the net type (e.g., wire) or reg keyword.  In the absence of a range specification before the name of the array, an element size of one bit is assumed. Arrays

24 Verilog Digital System Design Z. Navabi, 2006 Arrays  Array Structures

25 Verilog Digital System Design Z. Navabi, 2006 Arrays  Array Structures (Continued)

26 Verilog Digital System Design Z. Navabi, 2006 Arrays  Array Structures

27 Verilog Digital System Design Z. Navabi, 2006 Verilog Operators VerilogOperators

28 Verilog Digital System Design Z. Navabi, 2006 Verilog Operators VerilogOperators BasicOperatorsEqualityOperators BooleanOperatorsShiftOperators ConcatenationOperatorsConditionalOperators

29 Verilog Digital System Design Z. Navabi, 2006 Basic Operators Basic Operators

30 Verilog Digital System Design Z. Navabi, 2006  Arithmetic Operations in Verilog take bit, vector, integer and real operands.  Basic operators of Verilog are +, -, *, / and **.  An X or a Z value in a bit of either of the operands of a multiplication causes the entire result of the multiply operation to become X.  If any of the operands of a relational operator contain an X or a Z, then the result becomes X. Basic Operators

31 Verilog Digital System Design Z. Navabi, 2006 Basic Operators  Examples of Basic Operations

32 Verilog Digital System Design Z. Navabi, 2006 Equality Operators Equality Operators

33 Verilog Digital System Design Z. Navabi, 2006  Equality operators are categorized into two groups:  Logical: Compare their operands for equality (==) or inequality (!=) Return a one-bit result, 0, 1, or Z Return a one-bit result, 0, 1, or Z  An X ambiguity arises when an X or a Z occurs in one of the operands. Equality Operators

34 Verilog Digital System Design Z. Navabi, 2006 Equality Operators  Examples of Equality Operations

35 Verilog Digital System Design Z. Navabi, 2006 Boolean Operators Boolean Operators

36 Verilog Digital System Design Z. Navabi, 2006 Boolean Operators  If an X or a Z appears in an operand of a logical operator, an X will result.  The complement operator ~ results in 1 and 0 for 0 and 1 inputs and X for X and Z inputs.

37 Verilog Digital System Design Z. Navabi, 2006 Shift Operators Shift Operators

38 Verilog Digital System Design Z. Navabi, 2006 Shift Operators  Logical shift operators (>> and > and << for shift right and left) fill the vacated bit positions with zeros.  Shift Operators

39 Verilog Digital System Design Z. Navabi, 2006 Concatenation Operators VerilogOperators BasicOperatorsEqualityOperators BooleanOperatorsShiftOperators ConcatenationOperatorsConditionalOperators Concatenation Operators

40 Verilog Digital System Design Z. Navabi, 2006 Concatenation Operators  The notation used for this operator is a pair of curly brackets ({...}) enclosing all scalars and vectors that are being concatenated.  If a is a 4-bit reg and aa is a 6-bit reg, the following assignment places 1101 in a and in aa: {a, aa} = 10’b

41 Verilog Digital System Design Z. Navabi, 2006 Concatenation Operators  If the a and aa registers have the values assigned to them above, and aaa is a 16-bit reg data type, then the assignment, aaa = {aa, {2{a}}, 2’b11} puts _1101_1101_11 in aaa.  {a, 2{b,c}, 3{d}} is equivalent to: {a, b, c, b, c, d, d, d}  {2’b00, 3{2’01}, 2’b11} results in: 10 ’ b

42 Verilog Digital System Design Z. Navabi, 2006 Conditional Operators VerilogOperators BasicOperatorsEqualityOperators BooleanOperatorsShiftOperators ConcatenationOperatorsConditionalOperators Conditional Operators

43 Verilog Digital System Design Z. Navabi, 2006 Conditional Operators  expression1 ? expression2 : expression3 If expression1 is true, then expression2 is selected as the result of the operation; otherwise expression3 is selected. … assign a = (b == c)? 1 : 0; …

44 Verilog Digital System Design Z. Navabi, 2006 Verilog Data Types Verilog Data Types NetDeclarationsRegDeclarations SignedDataParameters

45 Verilog Digital System Design Z. Navabi, 2006 Net Declarations Net Declarations

46 Verilog Digital System Design Z. Navabi, 2006 Net Declarations  This statement declares wires used between gates or Boolean expressions representing logic structures. wire w, n, m, p;  By default, ports of a module are net of wire type.

47 Verilog Digital System Design Z. Navabi, 2006 Reg Declarations Reg Declarations

48 Verilog Digital System Design Z. Navabi, 2006 Reg Declarations  reg is a variable for holding intermediate signal values or nonhardware parameters and function values.  The reg declaration shown below declares a, b and ci as reg types with 0 initial values. reg a=0, b=0, ci=0;  The default initial value of a declared reg is (X).

49 Verilog Digital System Design Z. Navabi, 2006 Signed Data Signed Data

50 Verilog Digital System Design Z. Navabi, 2006 Signed Data  Verilog net and reg types can be declared as signed. In below example areg is declared as a signed reg. reg signed [15:0] areg;  A signed reg that is shifted right by the >>> operator is sign filled, whereas an unsigned reg shifted by this operator is zero-filled.

51 Verilog Digital System Design Z. Navabi, 2006 Parameters Parameters

52 Verilog Digital System Design Z. Navabi, 2006 Parameters  Parameters in Verilog do not belong to either the variable or the net group. Parameters are constants and cannot be changed at runtime. Parameters can be declared as signed, real, integer, time or realtime.  Parameter Examples

53 Verilog Digital System Design Z. Navabi, 2006 Verilog Simulation Model VerilogSimulationModel ContinuousAssignmentsProceduralAssignments

54 Verilog Digital System Design Z. Navabi, 2006 Continuous Assignments Continuous Assignments

55 Verilog Digital System Design Z. Navabi, 2006 Continuous Assignments ContinuousAssignments MultipleDrives SimpleAssignmentsDelaySpecification StrengthSpecification Net Declaration Assignments

56 Verilog Digital System Design Z. Navabi, 2006 Simple Assignments ContinuousAssignments MultipleDrives SimpleAssignmentsDelaySpecification StrengthSpecification Net Declaration AssignmentsSimpleAssignments

57 Verilog Digital System Design Z. Navabi, 2006 Simple Assignments  A continuous assignment in Verilog is used only in concurrent Verilog bodies.  This assignment represents a net driven by a gate output or a logic function. assign w = m | p; assign w = m | p;

58 Verilog Digital System Design Z. Navabi, 2006 Delay Specification ContinuousAssignments MultipleDrives SimpleAssignmentsDelaySpecification StrengthSpecification Net Declaration AssignmentsDelaySpecification

59 Verilog Digital System Design Z. Navabi, 2006 Delay Specification  assign #2 w = m | p; This assignment becomes active when m or p changes. At this time, the new value of the m | p expression is evaluated, and after a wait time of 2 time units, this new value is assigned to w.

60 Verilog Digital System Design Z. Navabi, 2006 Delay Specification `timescale 1ns/100ps module Mux2to1 (input a, b, c, output w); wire n, m, p; wire n, m, p; assign #3 m = a & b; assign #3 m = a & b; assign #3 p = n & c; assign #3 p = n & c; assign #6 n = ~b; assign #6 n = ~b; assign #2 w = m | p; assign #2 w = m | p;endmodule Regardless of position in the code, each assignment waits for a right-hand-side variable to change for it to execute.  Concurrent Continuous Assignments

61 Verilog Digital System Design Z. Navabi, 2006 Delay Specification  Simulation Run Showing a Glitch The simulation of the previous circuit results in a glitch due to a 1-hazard on w. The event driven simulation of concurrent statements makes this simulation to correspond to events in the actual circuit.

62 Verilog Digital System Design Z. Navabi, 2006 Strength Specification ContinuousAssignments MultipleDrives SimpleAssignmentsDelaySpecification StrengthSpecification Net Declaration AssignmentsStrengthSpecification

63 Verilog Digital System Design Z. Navabi, 2006 Simple Assignments  Net strengths are specified by a pair of strength values bracketed by a set of parenthesis, as shown below. assign (strong0, strong1) w = m | p;  One strength value is for logic 1 and one is for logic 0, and the order in which the strength values appear in the set of parenthesis is not important.

64 Verilog Digital System Design Z. Navabi, 2006 Net Declaration Assignments ContinuousAssignments MultipleDrives SimpleAssignmentsDelaySpecification StrengthSpecification Net Declaration Assignments Assignments

65 Verilog Digital System Design Z. Navabi, 2006 Net Declaration Assignments `timescale 1ns/100ps module Mux2to1 (input a, b, c, output w); wire #3 wire #3 m = a & b, m = a & b, p = n & c, p = n & c, n = ~b, n = ~b, w = m | p; w = m | p;endmodule  Using net_declaration_assignment

66 Verilog Digital System Design Z. Navabi, 2006 Procedural Assignments Procedural Assignments

67 Verilog Digital System Design Z. Navabi, 2006 Procedural Assignments  Procedural assignments in Verilog take place in the initial and always procedural constructs, which are regarded as procedural bodies.

68 Verilog Digital System Design Z. Navabi, 2006 Procedural Flow Control  Statements in a procedural body are executed when program flow reaches them.  Flow control statements are classified as delay control and event control.  An event or delay control statement in a procedural body causes program flow to be put on hold temporarily.

69 Verilog Digital System Design Z. Navabi, 2006  A blocking assignment uses a reg data type on the left-hand side and an expression on the right-hand side of an equal sign. Procedural Blocking Assignments

70 Verilog Digital System Design Z. Navabi, 2006 Procedural Blocking Assignments initial begin : Blocking_Assignment_to_b b = 1; b = 1; #100 #100 b = #80 0; b = #120 1; b = #80 0; b = #120 1; #100 #100 $display ("Initial Block with Blocking Assignment to b Ends at:", $time); $display ("Initial Block with Blocking Assignment to b Ends at:", $time);end The $display statement displays 400  Blocking Procedural Assignments

71 Verilog Digital System Design Z. Navabi, 2006 Procedural Non-blocking Assignments  A non-blocking assignment uses the left arrow notation <= (left angular bracket followed by the equal sign) instead of the equal sign used in blocking assignments.  When flow reaches a non-blocking assignment, the right-hand side of the assignment is evaluated and will be scheduled for the left-hand side reg to take place when the intra-assignment control is satisfied.

72 Verilog Digital System Design Z. Navabi, 2006 Procedural Non-blocking Assignments initial begin : Non_blocking_Assignment_to_a a = 1; a = 1; #100 #100 a <= #80 0; a <= #120 1; a <= #80 0; a <= #120 1; #100 #100 $display ("Initial Block with Non-blocking Assignment to a Ends at:", $time); $display ("Initial Block with Non-blocking Assignment to a Ends at:", $time);end The $display statement displays 200  Non-blocking Procedural Assignments

73 Verilog Digital System Design Z. Navabi, 2006 Procedural Non-blocking Assignments  Comparing Blocking and Non-blocking Procedural Assignments

January Verilog Digital System Design Copyright Z. Navabi, 2006

January Verilog Digital System Design Copyright Z. Navabi, 2006

January Verilog Digital System Design Copyright Z. Navabi, 2006

January Verilog Digital System Design Copyright Z. Navabi, 2006

January Verilog Digital System Design Copyright Z. Navabi, 2006