LANGUAGE CONSTRUCTS AND CONVENTIONS IN VERILOG

Similar documents
P-1/74. Samir Palnitkar. Prentice-Hall, Inc. INSTRUCTOR : CHING-LUNG SU.

Verilog HDL Introduction

Computer Aided Design Basic Syntax Gate Level Modeling Behavioral Modeling. Verilog

Verilog Design Principles

Programming in C++ 4. The lexical basis of C++

LECTURE 02 INTRODUCTION TO C++

Lecture #2: Verilog HDL

Chapter 2: Introduction to C++

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen

Advanced Digital Design Using FPGA. Dr. Shahrokh Abadi

Chapter 3: Dataflow Modeling

MATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL. John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards

Verilog Design Principles

PYTHON- AN INNOVATION

Chapter 2 Bits, Data Types, and Operations

Number System. Introduction. Decimal Numbers

Numbering Systems. Number Representations Part 1

Chap 3. Modeling structure & basic concept of Verilog HDL

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

Chapter 2 Bits, Data Types, and Operations

Verilog Language Concepts

Review of Data Representation & Binary Operations Dhananjai M. Rao CSA Department Miami University

Chapter 2. Lexical Elements & Operators

The C++ Language. Arizona State University 1

Verilog Dataflow Modeling

Chapter 2 Bits, Data Types, and Operations

Java Notes. 10th ICSE. Saravanan Ganesh

Lexical Considerations

Standard 11. Lesson 9. Introduction to C++( Up to Operators) 2. List any two benefits of learning C++?(Any two points)

Microcomputers. Outline. Number Systems and Digital Logic Review

1 Lexical Considerations

ADVANCED DIGITAL IC DESIGN. Verilog Simulation Techniques (I)

Introduction To Verilog Design. Chun-Hung Chou

CHW 261: Logic Design

VHDL Lexical Elements

Lexical Considerations

14:332:231 DIGITAL LOGIC DESIGN. Hardware Description Languages

VERILOG 2: LANGUAGE BASICS

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:

Number Systems. Decimal numbers. Binary numbers. Chapter 1 <1> 8's column. 1000's column. 2's column. 4's column

Verilog. Like VHDL, Verilog HDL is like a programming language but:

Number Systems and Binary Arithmetic. Quantitative Analysis II Professor Bob Orr

IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1

Digital Fundamentals

Chapter 2 Bits, Data Types, and Operations

Introduction. Why Use HDL? Simulation output. Explanation

ENGIN 241 Digital Systems with Lab

MACHINE LEVEL REPRESENTATION OF DATA

Computer Organization

Variable and Data Type I

The type of all data used in a C++ program must be specified

EDIABAS BEST/2 LANGUAGE DESCRIPTION. VERSION 6b. Electronic Diagnostic Basic System EDIABAS - BEST/2 LANGUAGE DESCRIPTION

M1 Computers and Data

Homework 1 graded and returned in class today. Solutions posted online. Request regrades by next class period. Question 10 treated as extra credit

Spring 2017 EE 3613: Computer Organization Chapter 5: Processor: Datapath & Control - 2 Verilog Tutorial

Microprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming)

CMPE223/CMSE222 Digital Logic Design. Positional representation

Number Systems Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur Number Representation

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9

Chapter 7. Basic Types

Number Systems CHAPTER Positional Number Systems

Number representations

These are reserved words of the C language. For example int, float, if, else, for, while etc.

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

UNIT - I: COMPUTER ARITHMETIC, REGISTER TRANSFER LANGUAGE & MICROOPERATIONS

EEL 4783: Hardware/Software Co-design with FPGAs

CHAPTER 3 BASIC INSTRUCTION OF C++

Verilog Coding Guideline

Inf2C - Computer Systems Lecture 2 Data Representation

JAVA Programming Fundamentals

CSE241 VLSI Digital Circuits Winter Recitation 1: RTL Coding in Verilog

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation

Chapter 4: Computer Codes. In this chapter you will learn about:

BSM540 Basics of C Language

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

PART I. Part II Answer to all the questions 1. What is meant by a token? Name the token available in C++.

C++ Basics. Lecture 2 COP 3014 Spring January 8, 2018

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual

Reserved Words and Identifiers

CMPSCI 145 MIDTERM #1 Solution Key. SPRING 2017 March 3, 2017 Professor William T. Verts

Verilog HDL [As per Choice Based Credit System (CBCS) scheme]

DECLARATIONS. Character Set, Keywords, Identifiers, Constants, Variables. Designed by Parul Khurana, LIECA.

COMP Overview of Tutorial #2

CS 101: Computer Programming and Utilization

Introduction to Verilog/System Verilog

Operations On Data CHAPTER 4. (Solutions to Odd-Numbered Problems) Review Questions

Engineering Computing I

Data Types and Variables in C language

Full file at

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

Fundamentals of Programming

Time: 8:30-10:00 pm (Arrive at 8:15 pm) Location What to bring:

Octal and Hexadecimal Integers

C++ character set Letters:- A-Z, a-z Digits:- 0 to 9 Special Symbols:- space + - / ( ) [ ] =! = < >, $ # ; :? & White Spaces:- Blank Space, Horizontal

Number Systems Standard positional representation of numbers: An unsigned number with whole and fraction portions is represented as:

Chapter 2 Bits, Data Types, and Operations

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

UNIT 7A Data Representation: Numbers and Text. Digital Data

Transcription:

LANGUAGE CONSTRUCTS AND CONVENTIONS IN VERILOG Dr.K.Sivasankaran Associate Professor, VLSI Division School of Electronics Engineering, VIT University

Outline White Space Operators Comments Identifiers Keywords Number Specification Strings FPGA BASED SYSTEM DESIGN 2

White Space In any design description the white space characters are included to improve readability. Blank spaces ---> \b Tabs ---> \t New lines ---> \n White space is not ignored in strings. Example: $display( The value of a=%b, b=%b, y=%b \n, a,b,y); FPGA BASED SYSTEM DESIGN 3

Operators unary operators. operates on a single operand. Example: out = ~ a; binary operators. operates on two operands. Example: out = a & b; ternary operators. operates on three operands. Example: out = s? a : b; FPGA BASED SYSTEM DESIGN 4

Comments Improve readability and helps good documentation. Two comment structures are available in verilog: single / one line comment Example: module d_ff (Q, dp, clk); //This is the design description of a D flip-flop. //Here Q is the output. // dp is the input and clk is the clock. multiple line / block comment Example: /* this logic performs the reversal of bits */ Multiple line comments cannot be nested. /* This is /* a wrong comment */ structure */ FPGA BASED SYSTEM DESIGN 5

Identifiers Identifiers are used to define language constructs. Identifiers refer objects to be referenced in the design. Identifiers are made of alphabets (both cases), numbers, the underscore _ and the dollar sign $. They start with an alphabetic character or underscore. They cannot start with a number or with $ which is reserved for system tasks. Identifiers are case sensitive i.e., identifiers differing in their case are distinct. An identifier say count is different from COUNT, count and count. FPGA BASED SYSTEM DESIGN 6

Identifiers name, _name. Name, name1, name_$,... all these are allowed as identifiers name aa not allowed as an identifier because of the blank ( name and aa are interpreted as two different identifiers) $name not allowed as an identifier because of the presence of $ as the first character. 1_name not allowed as an identifier, since the numeral 1 is the first character @name not allowed as an identifier because of the presence of the character @. A+b not allowed as an identifier because of the presence of the character +. FPGA BASED SYSTEM DESIGN 7

Examples for Identifiers Count COUNT _R2_D2 R56_68 FIVE$ module and_gate input a,b; output y; assign y= a & b; endmodule (a,b,y); Identifier used during simulation $count 12six_b Illegal Illegal module and_gate Input a,b ; output y; assign y= a & b; endmodule (a,b,y); Identifier used in ports FPGA BASED SYSTEM DESIGN 8

Keywords The keywords define the language constructs. A keyword signifies an activity to be carried out, initiated, or terminated. As such, a programmer cannot use a keyword for any purpose other than that it is intended for. All keywords in Verilog are in small letters and require to be used as such. Examples module signifies the beginning of a module definition. endmodule signifies the end of a module definition. begin signifies the beginning of a block of statements. end signifies the end of a block of statements. if signifies a conditional activity to be checked while signifies a conditional activity to be carried out. FPGA BASED SYSTEM DESIGN 9

Format Verilog HDL is case-sensitive. All the keywords in Verilog must be in lower case. Verilog constructs may be written across multiple lines, or on one line. FPGA BASED SYSTEM DESIGN 10

Number Specification Sized numbers. <size> <base format> <number> Unsized numbers. <base format> <number> <size> in decimal <base format> can be b or B, d or D, o or O and h or H. Numbers without <base format> are decimal by default. FPGA BASED SYSTEM DESIGN 11

FPGA BASED SYSTEM DESIGN 12

Number Specification -Example Sized numbers : 4'b1111 // This is a 4-bit binary number 12'habc // This is a 12-bit hexadecimal number 16'd255 // This is a 16-bit decimal number. Unsized numbers : 23456 // This is a 32-bit decimal number by default 'hc3 // This is a 32-bit hexadecimal number 'o21 // This is a 32-bit octal number FPGA BASED SYSTEM DESIGN 13

Unknown and High Impedance Values Unknown & high impedance values X or x for unknown values. Z or z for high impedance values. X or Z at the MSB has the self padding property. Examples: 32 B z // this is a 32-bit high impedance number 6 h X // this is a 6-bit hex number 12 H 13x // this is a 12-bit hex number FPGA BASED SYSTEM DESIGN 14

Number Specification-Example 5 037 5-bit octal 4 D2 4-bit decimal 9 b11011x01 x signifies the concerned bit to be of unknown value. 9 o12z equivalent to 001 010 zzz 7 Hx 7-bit x (x extended), i.e. xxxxxxx 4 hz 4-bit z (z extended), i.e zzzz 4 d-4 Not legal -4 d7 Its value in 2 s complement form is 7. 8 h 2A Spaces allowed between size & character & between base and value 3 b001 Not legal: no space allowed between and base b 10 b10 Padded with 0 to the left, 0000000010 11 hb0 equivalent value is 000 1011 0000. 5 hza A 5-bit hex number. Its value is taken as z 1010. 3 b1001_0011 is same as 3 b011 FPGA BASED SYSTEM DESIGN 15

FPGA BASED SYSTEM DESIGN 16

Integers It is a decimal number signed or unsigned; an unsigned number is automatically taken as a positive number. Example: 2 25 253 253 The following are invalid since nondecimal representations are not permissible. 2a B8 2a B8 FPGA BASED SYSTEM DESIGN 17

Real Numbers Real numbers can be specified in decimal or scientific notation. The decimal notation has the form 3.2 A number can be specified in scientific notation as 4.3e2 where 4.3 is the mantissa and 2 the exponent. The decimal equivalent of this number is 430. Examples: 4.3e2, 4.3e 2, and 4.3e 2. FPGA BASED SYSTEM DESIGN 18

Strings A string is a sequence of characters that are enclosed by double quotes. Verilog classes are very interesting??? Spaces are not ignored in strings. Strings cannot be on multiple lines. FPGA BASED SYSTEM DESIGN 19

Strings in expressions When a string of ASCII characters as above is an operand in an expression, it is treated as a binary number. Example: P = numb assigns the binary value 0110 1110 0111 0101 0110 1101 0110 0010 to P (0110 1110, 0111 0101, 0110 1101 and 0110 0010 are the 8-bit equivalents of the letters n, u, m, and b, respectively). FPGA BASED SYSTEM DESIGN 20

Review Multiple line comments can be nested True/False List out rules for choosing an identifier name Verilog code is case insensitive True/False Identify the valid number specification a. 1 b0 b. -4 b10 c. 3 b101 d. 3 bx e. 4 b10 Strings can be given in multiple lines FPGA BASED SYSTEM DESIGN 21