Chap 6 - Introduction to HDL (b)

Similar documents
ECEN 468 Advanced Logic Design

Introduction to Digital VLSI Design מבוא לתכנון VLSI ספרתי

Arithmetic Operators There are two types of operators: binary and unary Binary operators:

ECE Digital System Design & Synthesis Exercise 1 - Logic Values, Data Types & Operators - With Answers

Course Topics - Outline

GO - OPERATORS. This tutorial will explain the arithmetic, relational, logical, bitwise, assignment and other operators one by one.

Verilog Dataflow Modeling

Lab 4: Arithmetic Logic Unit (ALU)

Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition

Chapter 3: Dataflow Modeling

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

JAVA OPERATORS GENERAL

Lab 5: Arithmetic Logic Unit (ALU)

ECE 4514 Digital Design II. Spring Lecture 7: Dataflow Modeling

Chap 6 Introduction to HDL (d)

Introduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands

Design Using Verilog

Prof. Navrati Saxena TA: Rochak Sachan

Lecture #2: Verilog HDL

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

Why Should I Learn This Language? VLSI HDL. Verilog-2

IT T35 Digital system desigm y - ii /s - iii

The Arithmetic Operators. Unary Operators. Relational Operators. Examples of use of ++ and

The Arithmetic Operators

Introduction to Verilog. Garrison W. Greenwood, Ph.D, P.E.

Lecture 3: Modeling in VHDL. EE 3610 Digital Systems

SECTION II: LANGUAGE BASICS

Chapter 7: Programming in MATLAB

A Verilog Primer. An Overview of Verilog for Digital Design and Simulation

Speaker: Kayting Adviser: Prof. An-Yeu Wu Date: 2009/11/23

Le L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators

Verilog Design Principles

This Lecture. Some components (useful for the homework) Verilog HDL (will continue next lecture)

Operators & Expressions

Verilog HDL Introduction

Verilog HDL:Digital Design and Modeling. Chapter 4. Expressions

Introduction To Verilog Design. Chun-Hung Chou

Verilog Design Principles

RUBY OPERATORS. Ruby Arithmetic Operators: Ruby Comparison Operators:

VERILOG 2: LANGUAGE BASICS

CMPE 415 Working with Operands and Variables Prof. Ryan Robucci

CSE140L: Components and Design Techniques for Digital Systems Lab. Verilog HDL. Instructor: Mohsen Imani UC San Diego. Source: Eric Crabill, Xilinx

Informatics Ingeniería en Electrónica y Automática Industrial

Unit 3. Operators. School of Science and Technology INTRODUCTION

Brief Introduction to Verilog HDL (Part 1)

Unit-2 (Operators) ANAND KR.SRIVASTAVA

Relational and Logical Statements

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

Operators. Java operators are classified into three categories:

Verilog Tutorial. Introduction. T. A.: Hsueh-Yi Lin. 2008/3/12 VLSI Digital Signal Processing 2

Chapter 3: Operators, Expressions and Type Conversion

Abi Farsoni, Department of Nuclear Engineering and Radiation Health Physics, Oregon State University

Schematic design. Gate level design. 0 EDA (Electronic Design Assistance) 0 Classical design. 0 Computer based language

Hardware Description Language VHDL (1) Introduction

Fundamentals of Programming CS-110. Lecture 3

Lecture 1: VHDL Quick Start. Digital Systems Design. Fall 10, Dec 17 Lecture 1 1

ESCI 386 IDL Programming for Advanced Earth Science Applications Lesson 1 IDL Operators

In Delphi script, when values are assigned to variables, the colon-equal operator is used; :=

yamin/

9/10/10. Arithmetic Operators. Today. Assigning floats to ints. Arithmetic Operators & Expressions. What do you think is the output?

Contents. Appendix D Verilog Summary Page 1 of 16

N-input EX-NOR gate. N-output inverter. N-input NOR gate

Operators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur

Verilog Coding Guideline

LAB K Basic Verilog Programming

Arithmetic and Bitwise Operations on Binary Data

Will introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators

Department of Computer Science and Electrical Engineering. Intro to Verilog II

Digital Design with FPGAs. By Neeraj Kulkarni

ECOM4311 Digital Systems Design

Perl: Arithmetic, Operator Precedence and other operators. Perl has five basic kinds of arithmetic:

Operators And Expressions

Arithmetic and Logic Blocks

Department of Computer Science

Module 2 - Part 2 DATA TYPES AND EXPRESSIONS 1/15/19 CSE 1321 MODULE 2 1

Lecture 3. More About C

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

Structures, Operators

Verilog Language Concepts

CT 229. Java Syntax 26/09/2006 CT229

Expressions and Assignment Statements

Introduction. Why Use HDL? Simulation output. Explanation

CSC 1214: Object-Oriented Programming

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following g roups:

Verilog Fundamentals. Shubham Singh. Junior Undergrad. Electrical Engineering

Digital Design (VIMIAA01) Introduction to the Verilog HDL

Under-Graduate Project Logic Design with Behavioral Models

Gate level or structural modeling

ELCT 501: Digital System Design

Chapter 7. Expressions and Assignment Statements (updated edition 11) ISBN

Operators in C. Staff Incharge: S.Sasirekha

EN2911X: Reconfigurable Computing Lecture 05: Verilog (2)

Advanced Digital Design Using FPGA. Dr. Shahrokh Abadi

Chapter 4: Basic C Operators

CS Programming I: Branches

Prefix/Infix/Postfix Notation

Fundamentals of Programming

In this lecture, we will go beyond the basic Verilog syntax and examine how flipflops and other clocked circuits are specified.

Outline. Performing Computations. Outline (cont) Expressions in C. Some Expression Formats. Types for Operands

Verilog introduction. Embedded and Ambient Systems Lab

Transcription:

Design with Verilog Chap 6 - Introduction to HDL (b) Credit to: MD Rizal Othman Faculty of Electrical & Electronics Engineering Universiti Malaysia Pahang Ext: 6036

Language Elements 1. Operators There are three types of operators: unary, binary, and ternary, which have one, two, and three operands respectively. Unary : Single operand, which precede the operand. Ex: x = ~y ~ is a unary operator y is the operand binary : Comes between two operands. Ex: x = y z is a binary operator y and z are the operands ternary : Ternary operators have two separate operators that separate three operands. Ex: p = x? y : z? : is a ternary operator x, y, and z are the operands

3.1 Gate level Primitives

3.2 Operator Bit-Wise Operator

3.2. Operators Arithmetic Operators These perform arithmetic operations. The + and - can be used as either unary (-z) or binary (x-y) operators. Operators + (addition) - (subtraction) * (multiplication) / (division) % (modulus) Examples:

Relational Operators Relational operators compare two operands and return a single bit 1 or 0. example a < b 0 if the relation is false (a is bigger then b) 1 if the relation is true ( a is smaller then b) x if any of the operands has unknown x bits (if a or b contains X) These operators synthesize into comparators. Operators < (less than) <= (less than or equal to) > (greater than) >= (greater than or equal to) == (equal to)!= (not equal to)

Example //a=5 b=10, a <= b 1 // a=5 b=10 a>= b 0 // a=x b=10 a<=b x // a=z b=10 a<=b x

Equality Operators There are two types of Equality operators. Case Equality and Logical Equality. Operator a === b a!== b a == b a!= b Description a equal to b, including x and z (Case equality) a not equal to b, including x and z (Case inequality) a equal to b, result may be unknown (logical equality) a not equal to b, result may be unknown (logical equality) Operands are compared bit by bit, with zero filling if the two operands do not have the same length Result is 0 (false) or 1 (true) For the == and!= operators, the result is x, if either operand contains an x or a z For the === and!== operators, bits with x and z are included in the comparison and must match for the result to be true. The result is always 0 or 1.

4'bx001 === 4'bx001 = 1 4'bx0x1 === 4'bx001 = 0 4'bz0x1 === 4'bz0x1 = 1 4'bz0x1 === 4'bz001 = 0 4'bx0x1!== 4'bx001 = 1 4'bz0x1!== 4'bz001 = 1 5 == 10 = 0 5 == 5 = 1 5!= 5 = 0 5!= 6 = 1

Logical Operators Logical operators return a single bit 1 or 0. They are the same as bit-wise operators only for single bit operands. They can work on expressions, integers or groups of bits, and treat all values that are nonzero as 1. Expressions connected by && and are evaluated from left to right The result is a scalar value: 0 if the relation is false 1 if the relation is true x if any of the operands has x (unknown) bits Logical operators are typically used in conditional (if... else) statements since they work with expressions. Operators! (logical NOT) && (logical AND) (logical OR)

1'b1 && 1'b1 = 1 1'b1 && 1'b0 = 0 1'b1 && 1'bx = x 1'b1 1'b0 = 1 1'b0 1'b0 = 0 1'b0 1'bx = x! 1'b1 = 0! 1'b0 = 1

Reduction Operators Reduction operators operate on all the bits of an operand vector and return a single-bit value. These are the unary (one argument) form of the bit-wise operators above. Operators & (reduction AND) (reduction OR) ~& (reduction NAND) ~ (reduction NOR) ^ (reduction XOR) ~^ or ^~(reduction XNOR)

& 4'b1001 = 0 & 4'bx111 = x ~& 4'b1001 = 1 ~& 4'bx001 = 1 ~& 4'bz001 = 1 4'b1001 = 1 4'bx000 = x ~ 4'b1001 = 0 ~ 4'bx001 = 0 ~ 4'bz001 = 0 ^ 4'b1001 = 0 ^ 4'bx001 = x ~^ 4'b1001 = 1 ~^ 4'bx001 = x

Shift Operators Shift operators shift the first operand by the number of bits specified by the second operand. Vacated positions are filled with zeros for both left and right shifts (There is no sign extension). Operators << (shift left) >> (shift right)

4'b1001 << 1 = 0010 4'b10x1 << 1 = 4'b10z1 << 1 = 4'b1001 >> 1 = 0100 4'b10x1 >> 1 = 4'b10z1 >> 1 =

4'b1001 << 1 = 0010 4'b10x1 << 1 = 0x10 4'b10z1 << 1 = 0z10 4'b1001 >> 1 = 0100 4'b10x1 >> 1 = 010x 4'b10z1 >> 1 = 010z

Concatenation Operator The concatenation operator combines two or more operands to form a larger vector. Operators {}(concatenation)

Replication Operator The replication operator makes multiple copies of an item. Operators {n{item}} (n fold replication of an item)

Conditional Operator:? Conditional operator is like those in C/C++. They evaluate one of the two expressions based on a condition. It will synthesize to a multiplexer (MUX). Operators (cond)? (result if cond true): (result if cond false)

5.10. Operator Precedence Table 5.1 shows the precedence of operators from highest to lowest. Operators on the same level evaluate from left to right. It is strongly recommended to use parentheses to define order of precedence and improve the readability of your code.