Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 2: Introduction.

Slides:



Advertisements
Similar presentations
Verilog HDL -Introduction
Advertisements

Simulation executable (simv)
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.
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.
CSE 341 Verilog HDL An Introduction. Hardware Specification Languages Verilog  Similar syntax to C  Commonly used in  Industry (USA & Japan) VHDL 
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 8: Sequential Design Spring 2009 W. Rhett.
Introduction to C Programming
Spring 20067W. Rhett Davis with minor modifications by Dean Brock ECE 406 at UNASlide 1 ECE 406 Design of Complex Digital Systems Lecture 10: 9: State.
ECE 353 Computer Systems Lab I Verilog Hardware Description Language.
Verilog Lab This presentation includes some material that is selected from BUCKNELL VERILOG HANDBOOK. Instructor: Dr. Charles Liu Prepared by John Ren.
CSE241 R1 Verilog.1Kahng & Cichy, UCSD ©2003 CSE241 VLSI Digital Circuits Winter 2003 Recitation 1: Verilog Introduction.
Reconfigurable Computing (EN2911X, Fall07) Lecture 05: Verilog (1/3) Prof. Sherief Reda Division of Engineering, Brown University
University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
B. RAMAMURTHY Hardware Description Language 8/2/
Hardware Description Language(HDL). Verilog simulator was first used beginning in 1985 and was extended substantially through The implementation.
Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 7: Design Example,
Chap. 3 Basic Concepts. 2 Basic Concepts Lexical Conventions Data Types System Tasks and Compiler Directives Summary.
Lecture Note on Verilog, Course # , EE, NTU, C.H Tsai Basic Logic Design with Verilog TA: Chen-han Tsai.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Spring 2007W. Rhett Davis with slight modification by Dean Brock UNCA ECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 11: Memories,
ECE 2372 Modern Digital System Design
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 2: Introduction to Verilog Syntax Spring.
Workshop Topics - Outline
Verilog HDL: A solution for Everybody By, Anil Kumar Ram Rakhyani
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.
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 3: Structural Modeling Spring 2009 W. Rhett.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Digital System Design Introduction to Verilog ® HDL Maziar Goudarzi.
RTL Hardware Design by P. Chu Chapter Basic VHDL program 2. Lexical elements and program format 3. Objects 4. Data type and operators RTL Hardware.
Module 1.3 Verilog Basics UNIT 1 : Introduction to Verilog Data Types.
EEE2243 Digital System Design Chapter 3: Verilog HDL (Combinational) by Muhazam Mustapha, January 2011.
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.
Spring 2007 W. Rhett Davis with minor editing by J. Dean Brock UNCA ECE Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 1: Introduction.
Slide 1 2. Verilog Elements. Slide 2 Why (V)HDL? (VHDL, Verilog etc.), Karen Parnell, Nick Mehta, “Programmable Logic Design Quick Start Handbook”, Xilinx.
1 Hardware description languages: introduction intellectual property (IP) introduction to VHDL and Verilog entities and architectural bodies behavioral,
1 Verilog Digital System Design Z. Navabi, 2006 Verilog Language Concepts.
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
BASIC VHDL LANGUAGE ELEMENTS Digital Design for Instrumentation with VHDL 1.
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 4: Testing, Dataflow Modeling Spring 2009.
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 6: Procedural Modeling Spring 2009 W. Rhett.
Spring 20067W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 1 ECE 406 Design of Complex Digital Systems Lecture 11: Data Converter,
© 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.
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.
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 10: Data-Converter Example Spring 2009 W.
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.
Structural Description
Hardware Description Languages: Verilog
Hardware Description Language
Discussion 2: More to discuss
Verilog-HDL-1 by Dr. Amin Danial Asham.
KARTHIK.S Lecturer/ECE S.N.G.C.E
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® HDL
Introduction to Digital System and Microprocessor Design
Introduction to Verilog® HDL
COE 202 Introduction to Verilog
Reconfigurable Computing (EN2911X, Fall07)
Presentation transcript:

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 2: Introduction to Verilog Syntax Spring 2007 W. Rhett Davis NC State University with significant material from Paul Franzon, Bill Allen, & Xun Liu

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 2 Summary of Last Lecture l Explain the differences between the following terms: » Schematic vs. Block Diagram » Port vs. Net » Symbol vs. Instance » System vs. Module » HDL vs. RTL

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 3 Today’s Lecture l Verilog Introduction l Conventions, Identifiers, Numbers, & Operators l Data Types l Modules l Test Benches

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 4 History of Verilog l 1984 – Developed by Gateway Design Automation l 1995 – Became an IEEE Standard (IEEE ) l 2001 – Revised (IEEE ) l 2003 – Accelera released the System Verilog 3.1 specification l We’ll use both the IEEE and IEEE versions of the language. (Either will be accepted on your assignments).

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 5 Comparison of HDLs l Verilog » Most commonly used HDL in USA » Based on the C programming language » Least verbose » Fastest simulation l VHDL » Used by US Government, Europe, ASIA » Based on the ADA programming language » More general than Verilog l SystemC SystemC » Emerging Standard, used more for Electronic System Level (ESL) Descriptions » C++ class library that mimics VHDL, plus allows greater abstraction » Allows co-simulation of Hardware and Software

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 6 Today’s Lecture l Verilog Introduction l Conventions, Identifiers, Numbers, & Operators l Data Types l Modules l Test Benches

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 7 Example: Data Selector Route input data to one of two outputs. Specification: When a new data word arrives at the input, the module inspects the state of the most significant bit and routes the data to output A if the bit is true and to B if the bit is false. The last value sent to either output is retained until replaced. Data A-data B-data here new-A new-B A B

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 8 Example: Stimulus l How to describe the module? l How to describe the stimulus? Data A-data B-data here new-A new-B A B

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 9 Verilog Language Conventions l Case sensitive l Whitespace ignored (except in strings) l Comments (just like C++ and Java) » Single Line: a = b && c; // The rest of this line is a comment » Multi-Line (cannot be nested): /* This is a multiple line comment*/

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 10 Identifiers l Can contain » Letters (a-z,A-Z) » Digits (0-9) » Underscore (_) » Dollar-sign ($) l Must start with a letter » Except for weird things like \reset* l Cannot be a keyword (see Sutherland, section 3.0 for a full list)

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 11 Operators l Unary - single operand » ~in l Binary - two operands » in1 && in2 l Ternary - three operands » select ? in1 : in2 l Nearly all Verilog statements end with a semicolon (don’t forget it on your homework)

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 12 Values l Write the following: » Binary , 6 bits » Hex 7FFE, 16 bits » Decimal 133, 8 bits l Omitting gives an “unsized” value (32 bits) Sized numbers: ’ : specifies number of bits in number (in decimal) : decimal (‘d, ‘D); hexadecimal (‘h, ‘H); binary (‘b, ‘B); octal (‘o, ‘O) : digits (in base format) of the numeric value

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 13 Special Values Language conventions: Numbers & Values In addition to normal numeric values, Verilog provides two special values, x and z. x denotes an unknown or undefined value. unknown by the simulator z denotes a “high impedance” value “isolated from from other regions of the circuit by open switches” l Write the following: » 16-bit hex, low order 4 bits unknown » 8-bit binary, high order 2 bits unknown » 8-bit value, all bits high impedance

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 14 Physical Meaning of Values Draw a circuit to represent the following values: 0 and 1 x

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 15 Physical Meaning of Values Draw a circuit to represent the following values: z

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 16 Values: Special Cases Zero fill / extension: If a numeric value does not contain enough digits to fill the specified number of bits, the high order bits are filled with zeros. If the most significant bit specified is an x or z, the x/z is left extended to fill the bit field. 16’h39  8’hz  Negative numbers: Specified by preceding the with a minus (negative) symbol. Values will be stored as the two’s complement of the given value.

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 17 Verilog 2001 Syntax l Signed Values: ’s l The “s” denotes that a value is signed (all other values are assumed unsigned) l This does not change the value, but it does change how certain operators deal with the value (namely, whether or not it will be sign-extended) l Examples: » 4’hF =1111 in binary » 4’shF = 1111 in binary (but will sometimes be interpreted as -1)

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 18 Example: Stimulus l How would you write the values for Data and here? (assume Data is 4 bits)

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 19 Today’s Lecture l Verilog Introduction l Conventions, Identifiers, Numbers, & Operators l Data Types l Modules l Test Benches

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 20 Net Variables Nets are usually declared by the keyword wire. Nets represent connections between hardware components. wire d;// declare output as net d. wire b, c;// declare two wires in same statement a, b, c, & d are nets. abab c d

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 21 Register Variables Registers are variables that can hold a value. not necessarily the same as a hardware register Registers can be assigned values multiple times during a simulation, but Nets can be assigned only at the beginning of a simulation. Would you use a Net or a Register variable for the Data and here signals in the Data Selector example? Registers are declared by the keyword reg. The default value for a reg data type is x. reg start; // declares register “start” reg reset, clock; // declares registers reset & clock

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 22 Bitvectors l Left bit is considered the most significant l By convention, use [ : ] Bitvectors can be specified by declaring the range of bit numbers with the variable name. The form of the declaration is: [ : ] ; or [ : ] ; // declare 8-bit data named BYTE // declare 16-bit register named INFO // declare 12-bit register named DATA

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 23 Specifying Parts of Vectors Given vector declarations, it is possible to reference parts of a register (down to a single bit). The format of the reference follows the pattern [ ]. // bit 5 of INFO // bits 11-8 of INFO (bits 11-8) // least significant byte of DATA

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 24 Other Types l Integer l Real l Time (accessed w/ system function $time) l Rarely used in the description of a hardware module but are frequently useful in the Test Bench. l See Sutherland, section 7.0 for details

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 25 Arrays Arrays can be declared for both scalar and vector data. An array is simply an ordered group of elements. All arrays are single dimensioned in Verilog. Arrays are declared with the syntax: [ ] or [ ] reg bool [31:0];// 32 1-bit boolean register values integer count [0:9];// array of 10 count variables reg [7:0] PID [0:5];// array of 6 bytes

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 26 Memories reg bitmem [0:1023]// 1K x 1 (bit) memory reg [7:0] MEM [0:16383]// 16K x 8 or 16K bytes Note that the addressing range is usually specified as [ : ] and for physical reasons, the address range starts at 0. Memories are defined by the syntax: [ ]

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 27 Symbolic Constants (Parameters) The parameter keyword allows definition of a symbolic label with a constant value. Anytime that label is used in the Verilog code, it is replaced with its constant value. parameter size = 16;// defines a constant called // size with a value of 16 For example, if size is defined with a value of 16, the memory declaration: reg [size-1 : 0] MEM [0 : 4095] gives the same result as writing: reg [15:0] MEM [0:4095]

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 28 Verilog 2001 Syntax l Signed Variables can be declared with the keyword signed l As with signed values, declaring a variable as signed does not change its value, but rather how certain operators deal with the value (namely, whether or not it will be sign-extended) reg signed [7:0] mybyte; wire signed [5:0] myvar;

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 29 Today’s Lecture l Verilog Introduction l Conventions, Identifiers, Numbers, & Operators l Data Types l Modules l Test Benches

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 30 Module Descriptions in Verilog The Verilog description of a digital module follows a prescribed structure as follows: Header Parameters Port declarations Variable declarations Instantiation of lower-level modules Functionality description - Gate-level - Data Flow - Behavioral Terminator Let’s write a module description for the Data Selector:

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 31 Header & Port Declarations Module header: names the module and lists ports. module ( ); Port declarations: specify the input and output port characteristics. (like variable declarations, but use the keywords input and output)

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 32 Variable Declarations Variable declarations: specify module’s nets & registers. reg [15:0] A, B;// A & B are 16-bit registers wire [15:0] Data, A_data, B_data; wire here, new_A, new_B; Note: The wire declarations could be omitted since port declarations imply the associated nets.

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 33 Verilog 2001 Syntax l Verilog 2001 allows port declarations within the port-list module data_selector (Data, here, A_data, new_A, B_data, new_B); input [15:0] Data; input here; output [15:0] A_data, B_data; output new_A, new_B; module data_selector ( input [15:0] Data, input here, output [15:0] A_data, B_data, output new_A, new_B ); 1995 Syntax 2001 Syntax

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 34 Instantiation, Functionality, Terminator Terminator marks the end of the Verilog module description. It is simply endmodule (without a trailing semicolon). Instantiation of lower-level modules: creates a unique named instance for each of the low-level modules. ( ); Functionality description: specifies the internal organization and operation of the module. There are three levels of abstraction that will be studied:

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 35 Data Selector’s Module Description module data_selector (Data, here, A_data, new_A, B_data, new_B); input [15:0] Data; input here; output [15:0] A_data, B_data; output new_A, new_B; reg [15:0] A, B; wire [15:0] DATA, A_data, B_data;// these 2 lines can wire here, new_A, new_B;// be omitted // No modules to instantiate for this design // Description of functionality would go here endmodule 1995 Syntax

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 36 Data Selector’s Module Description module data_selector (input [15:0] Data, input here, output [15:0] A_data, B_data, output new_A, new_B); reg [15:0] A, B; // No modules to instantiate for this design // Description of functionality would go here endmodule 2001 Syntax

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 37 Today’s Lecture l Verilog Introduction l Conventions, Identifiers, Numbers, & Operators l Data Types l Modules l Test Benches

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 38 Creating the Stimulus l We know how to describe the Data-Selector, but how do we describe its stimulus? l Need to specify a behavior that has a beginning and an end.

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 39 Initial Blocks l Use an initial block to specify a behavior for a module that executes once at the beginning of the simulation. initial begin myvar = 4’d9; myvar = 4’d7; … end l begin and end are needed only if there is more than one statement in the initial block (like “{“ and “}” in C) » Looks a bit like Pascal and Ada l Note that there is no semicolon after initial, begin, end l In the example above, is myvar declared as wire or reg?

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 40 Displaying Values l Use the system task $display to print out values l $display is like printf() in C (see Sutherland, section 18.0 for details) module hello; initial $display(“Hello World!\n”); endmodule //hello

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 41 Representation of Stimulus module test; reg [3:0] Data; initial begin Data = 4'h2; $display("Data = %h",Data); Data = 4'hA; $display("Data = %h",Data); Data = 4'h7; $display("Data = %h",Data); end endmodule //test

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 42 Summary l What characters are allowed in identifiers? l What kinds of circuits would generate the values 0, 1, x, and z? l What is the difference between wire and reg variables? l What parts of the module description do you need to create a test-bench?

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 43 Homework #1 Tips l Problem 2 (a) and (b) » Please convert to binary manually l Problem 7 » See Sutherland, section 19.0 for an example of the `define compiler directive