Scalar Data Types and Operations 大同大學 資訊工程系 副教授 鄭福炯

Slides:



Advertisements
Similar presentations
INTRO TO VHDL Appendix A: page page VHDL is an IEEE and ANSI standard. VHDL stands for Very High Speed IC hardware description language.
Advertisements

Chapter 11 Verilog HDL Application-Specific Integrated Circuits Michael John Sebastian Smith Addison Wesley, 1997.
1 Lecture 13 VHDL 3/16/09. 2 VHDL VHDL is a hardware description language. The behavior of a digital system can be described (specified) by writing a.
Introduction to VHDL (Lecture #5) ECE 331 – Digital System Design The slides included herein were taken from the materials accompanying Fundamentals of.
ECE C03 Lecture 161 Lecture 16 Introduction to VHDL Prith Banerjee ECE C03 Advanced Digital Design Spring 1998.
Comprehensive VHDL Module 6 Types November Comprehensive VHDL: Types Copyright © 2000 Doulos Types Aim ©To understand the use and synthesis.
VHDL Data Types Module F3.1. VHDL Data Types Scalar Integer Enumerated Real (floating point)* Physical* Composite Array Record Access (pointers)* * Not.
Data Types. Composite Date Types n Arrays –Single and multi-dimensional –Arrays are single Type n Records –Records are mixed types.
ECE C03 Lecture 121 Lecture 12 Introduction to VHDL Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
ELEN 468 Lecture 191 ELEN 468 Advanced Logic Design Lecture 19 VHDL.
0 Chap. 2. Types, Operators, and Expressions 2.1Variable Names 2.2Data Types and Sizes 2.3Constants 2.4Declarations Imperative Programming, B. Hirsbrunner,
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie June 27, 2005.
第6章 VHDL NUMBERS, STRINGS, AND EXPRESSIONS 義守大學電機工程學系 陳慶瀚
Chapter 2: Introduction to C++.
JavaScript, Third Edition
VHDL. What is VHDL? VHDL: VHSIC Hardware Description Language  VHSIC: Very High Speed Integrated Circuit 7/2/ R.H.Khade.
Concordia University 1 Lecture #8 In this lecture we will cover the following material: The standard package, The std_logic_1164  Objects & data Types.
Reconfigurable Computing - VHDL - Types John Morris Chung-Ang University The University of Auckland.
1 Part I: VHDL CODING. 2 Design StructureData TypesOperators and AttributesConcurrent DesignSequential DesignSignals and VariablesState Machines A VHDL.
VHDL – Dataflow and Structural Modeling and Testbenches ENGIN 341 – Advanced Digital Design University of Massachusetts Boston Department of Engineering.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
A VHDL Tutorial ENG2410. ENG241/VHDL Tutorial2 Goals Introduce the students to the following: –VHDL as Hardware description language. –How to describe.
IAY 0600 Digital Systems Design
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Lecture 3 Chap 4 Types Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
Capt Michael Tanner Room 2F46A
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.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Fall 2004EE 3563 Digital Systems Design EE 3563 VHDL – Basic Language Elements  Identifiers: –basic identifier: composed of a sequence of one or more.
Introduction to VHDL Spring EENG 2920 Digital Systems Design Introduction VHDL – VHSIC (Very high speed integrated circuit) Hardware Description.
Lecture 4 Chap 5 Types Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
Lecture #8 Page 1 Lecture #8 Agenda 1.VHDL : Operators 2.VHDL : Signal Assignments Announcements 1.HW #4 assigned ECE 4110– Digital Logic Design.
VHDL Very High Speed Integrated Circuit Hardware Description Language Shiraz University of shiraz spring 2011.
CPS 506 Comparative Programming Languages Syntax Specification.
VHDL Basics. VHDL BASICS 2 OUTLINE –Component model –Code model –Entity –Architecture –Identifiers and objects –Operations for relations VHDL ET062G &
Lecture #7 Page 1 Lecture #7 Agenda 1.VHDL Data Types Announcements 1.n/a ECE 4110– Digital Logic Design.
Lecture 9 Chap 11: Subprograms Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
Chapter 5 Introduction to VHDL. 2 Hardware Description Language A computer language used to design circuits with text-based descriptions of the circuits.
IAY 0600 Digital Systems Design
Introduction to VHDL. VHDL DARPA, VHSIC (Very High Speed Integrated Circuits) program Different manufacturers Standard language to describe –Structure.
Concordia University 1 Lecture #8 In this lecture we will cover the following material: The standard package, The std_logic_1164  Objects & data Types.
CEC 220 Digital Circuit Design Introduction to VHDL Wed, February 25 CEC 220 Digital Circuit Design Slide 1 of 19.
ECOM 4311—Digital System Design with VHDL
BASIC VHDL LANGUAGE ELEMENTS Digital Design for Instrumentation with VHDL 1.
ECOM 4311—Digital System Design with VHDL
C++ for Engineers and Scientists Second Edition
VHDL Programming Fundamentals Presented By Dr. Pradyut Kumar Biswal Department of Electronics, IIIT Bhubaneswar.
CEC 220 Digital Circuit Design Introduction to VHDL Friday, February 21 CEC 220 Digital Circuit Design Slide 1 of 10.
0 Chap.2. Types, Operators, and Expressions 2.1Variable Names 2.2Data Types and Sizes 2.3Constants 2.4Declarations 2.5Arithmetic Operators 2.6Relational.
Signals & Data-typesVer 1.1, Copyright 1997, TS, Inc. VHDL S i g n a l s & D a t a T y p e s Page 1.
Lecture #8 Page 1 Lecture #8 Agenda 1.VHDL : Operators 2.VHDL : Signal Assignments Announcements 1.HW #4 assigned ECE 4110– Sequential Logic Design.
Java Programming: From Problem Analysis to Program Design, Second Edition 1 Lecture 1 Objectives  Become familiar with the basic components of a Java.
Java Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
CEC 220 Digital Circuit Design Introduction to VHDL Wed, Oct 14 CEC 220 Digital Circuit Design Slide 1 of 19.
Composite Data Types and Operations Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
13/06/59 1 Copyright  1997, KJH Introduction to VHDL Lecture 2 Prof. K. J. Hintz Department of Electrical and Computer Engineering George Mason University.
IAY 0600 Digital Systems Design
Introduction To VHDL 홍 원 의.
Subject Name: FUNDAMENTALS OF HDL Subject Code: 10EC45
Design Entry: Schematic Capture and VHDL
Operators Assignment Operators Logical Operators Relational Operators
Multiple variables can be created in one declaration
Behavioral Modeling in Verilog
CHAPTER 10 Introduction to VHDL
2.1 Parts of a C++ Program.
ECE 434 Advanced Digital System L9
ECE 434 Advanced Digital System L10
VHDL Data Types Module F3.1.
EEL4712 Digital Design (VHDL Tutorial).
Presentation transcript:

Scalar Data Types and Operations 大同大學 資訊工程系 副教授 鄭福炯

© Fu-Chiung Cheng VHDL Ch02 2 Type Type of a data object defines – the set of values that the object can assume and – the set of operations that can be performed on those values Type: scalar types, access types, file types and composite types

© Fu-Chiung Cheng VHDL Ch02 3 Lexical Elements of VHDL Lexical elements of VHDL: comments, identifiers, reserved words, special symbols, numbers, characters, strings, bit strings Comments: – A comment line in VHDL is represented by two successive dashes “--”. – A comment extends from “--” to the end of the line. – See page 192 examples

© Fu-Chiung Cheng VHDL Ch02 4 Lexical Elements of VHDL Identifiers: – Identifiers are used to name items – Use meaningful name – Identifiers can be arbitrarily long – Some Rules: must start with an alphabetic letter. can contain alphabetic letters, decimal digits and underline character “_”. can not end with “_”. can not contain successive “_”.

© Fu-Chiung Cheng VHDL Ch02 5 Lexical Elements of VHDL Legal and illegal examples: – See page 18 Extended identifiers – Can contain any sequence of characters – Is written by enclosing the characters between ‘\’ characters – Examples: \data bus\, \global.clock\, \923\

© Fu-Chiung Cheng VHDL Ch02 6 Lexical Elements of VHDL Reserved Words – Reserved words are used to denote special constructs that form a model – Can not be used as identifiers – Is listed in Figure 1-15 on page 19

© Fu-Chiung Cheng VHDL Ch02 7 Lexical Elements of VHDL Special Symbols: – Operators: +, -, &, *, /,.,, |, /=, :=, >=, – To delimit parts of language constructs and as punctuation: “, ‘, (, ), “,”, :, ;, – array indices: [] Numbers: – Integer literals: 23, 0, 146, 56E5, 1E+12, 2# #, 16#12FD”, 2#1111_1101# – Real literals: 23.1, 0.0, , 1.234E09

© Fu-Chiung Cheng VHDL Ch02 8 Lexical Elements of VHDL Characters – ‘A’~’Z’, ‘a’-’z’, ‘,’, Strings – A sequence of characters – “data bus”, “923” (use & operator) – Binary digits: B for binary, O for octal, X for hexadecimal (B” ”, X”97”)

© Fu-Chiung Cheng VHDL Ch02 9 Syntax Descriptions Extended Backus-Naur Form to describe the rules of VHDL syntax EBNF divides a language into syntactic categories: Variable assignment: – Variable_Assignment  target := Expression; – x := y + 1; Function_Call  name [( Association_Lis t) ] – zero or one

© Fu-Chiung Cheng VHDL Ch02 10 Syntax Descriptions Optional operator “{}” – process is { process_declarative_item } begin { sequential_statement } end process; – zero or more Iterative operator “{…}” – identifier_list <= identifier, {…} | identifier – one or more

© Fu-Chiung Cheng VHDL Ch02 11 Syntax Descriptions Choice operator “|” – mode <= in | out | inout – one of the many Parenthetic grouping ( ) – Term  Factor { (*|/|mod|rem) Factor)}

© Fu-Chiung Cheng VHDL Ch02 12 Constant Declaration EBNF: constant_decl  constant id {,… }: subtype_indication [:= expr ]; Examples: – constant NUMBER_OF_BYTE: integer := 4; – constant SIZE, COUNT: integer := 255;

© Fu-Chiung Cheng VHDL Ch02 13 Variable Declaration and Assignment Variables act as placeholders for quantities that change during simulation. EBNF: variable_decl  variable id {,… }: subtype_indication [:= expr ]; Examples: – variable index, sum : integer := 0; – variable_assign <= [labe l: ] i d:= exp r; Can be used in process block only – pc := 1; – index := index + 1;

© Fu-Chiung Cheng VHDL Ch02 14 Type Every name or id in VHDL has an associated “type”. The “type” determines the operations that can be applied to the name. VHDL along with its packages provides pre- defined types. Additionally the user can define new types.

© Fu-Chiung Cheng VHDL Ch02 15 Type Declarations EBNF” type_decl <= type id is type_definition ; Useful when pre-defined types are insufficient. Examples: – type apples is range 0 to 100; – type oranges is range 0 to 100; – apples may not be assigned to variable oranges Default value is left hand side of range.

© Fu-Chiung Cheng VHDL Ch02 16 Type Declarations User defined type – If we define our own types for ports, the type names must be declared in a package (similar to a header file). – Example: package int_types is type Small_Int is range 0 to 255; end package int_type

© Fu-Chiung Cheng VHDL Ch02 17 Type Declarations User defined type – Example use work.int_type.all; entity SmallAdder is Port (a,b: in small_int; s: out small_in) end enitity small_adder

© Fu-Chiung Cheng VHDL Ch02 18 Integer type “integer” is a pre-defined type used to represent whole numbers. – variable x, y : integer ; VHDL standard requires that the implementation be able to represent numbers from –2^ to 2^31 – 1. User can define new “integer” types.

© Fu-Chiung Cheng VHDL Ch02 19 Integer type EBNF: – type_decl <= type identifie r is int_type_def n; – int_type_defn <= range expr (to | downto ) expr Examples: – type month is range 1 to 12 ; – type count_down is range 10 downto 0;

© Fu-Chiung Cheng VHDL Ch02 20 Integer type : operations Addition: +, Subtraction or negation: -, Multiplication: *, Division: / Modulo: mod – a = b*n + (a mod b), sign of b, n: integer – (-5) mod 3 = 1 Remainder: rem – a = (a/b)*b + (a rem b), sign of a – (-5) rem 3 = 1 Absolute value: abs Exponentiation: ** Logical: =, /=,, =

© Fu-Chiung Cheng VHDL Ch02 21 Floating-point type “real” is a pre-defined type used to represent floating-point numbers – variable x, y : real ; Similar to integers the user can also define new real types with limited range. Examples – type temp is range –273.0 to ;

© Fu-Chiung Cheng VHDL Ch02 22 Floating point type: operations Addition: + Subtraction or negation: - Multiplication: * Division: / Absolute value: abs Exponentiation: ** Logical: =, /=,, =

© Fu-Chiung Cheng VHDL Ch02 23 Time type Predefined physical type. type time is range implementation defined units fs; ps = 1000 fs; ns = 1000 ps; us = 1000 ns; ms = 1000 us; sec = 1000 ms; min = 60 sec; hr = 60 min; end units;

© Fu-Chiung Cheng VHDL Ch02 24 Enumerated types Useful for giving names to a values of an object (variable or signal). Example: – type alu_func is (disable, pass, add, sub, mult, div); Predefined enum types – type character is ( ‘a’, ‘b’, ‘c’, ……….); Operations: =, /=,, = – type boolean is ( false,true); Operations: and, or, nand, nor, xor, xnor, not, =, /=,, =

© Fu-Chiung Cheng VHDL Ch02 25 Characters ISO 8859-Latin-1 8-bit character set – type character is ( null, soh, …. ………. ); – Example: variable command_char, terminator: character; command := ‘P’; terminator := cr;

© Fu-Chiung Cheng VHDL Ch02 26 Boolean Boolean is one of the most important predefined types in VHDL – type boolean is (false, true); – Operations and, or, nand, nor, xor, xnor, not – and, or, nand, nor are called “short-circuit” operators

© Fu-Chiung Cheng VHDL Ch02 27 Bit type Bit is also a predefined enumerated type – type bit is (‘0’, ‘1’); – Operations Logical: =, /=,, = Boolean: and, or, nand, nor, xor, xnor, not Shift:sll, srl, sla, sra, rol, ror

© Fu-Chiung Cheng VHDL Ch02 28 Standard logic Since VHDL is designed to modeling digital hardware, it is necessary to include types to represent digitally encoded values type std_logic is (’U’, -- Uninitialized ‘X’, -- Forcing Unknown ‘0’, -- Forcing zero ‘1’, -- Forcing one ‘Z’, -- High impedance ‘W’, -- Weak Unknown ‘L’, -- Weak zero ‘H’, -- Weak one ‘_’); -- don’t care

© Fu-Chiung Cheng VHDL Ch02 29 Subtypes Sub types are useful for limiting the range of base type Examples: type month is 1 to 31; subtype working_day is month range 1 to 3; variable x,y : month; variable z : working_day; y = x + z; subtype natural is integer range 0 to biggest_integer; subtype positive is integer range 1 to biggest_integer;

© Fu-Chiung Cheng VHDL Ch02 30 Type Conversion Integer to real: read(123) Real to integer: integer(3.6) See Chap 4 for more detail.

© Fu-Chiung Cheng VHDL Ch02 31 Attributes of Scalar Types T’left : first (leftmost) value of T T’right : last (rightmost) value of T T’low : least value of T T’high : highest value of T T’ascending : true if T is ascending, false otherwise T’image(x) : A string representing the value of x T’value(s) : The value in T that is represented by s.

© Fu-Chiung Cheng VHDL Ch02 32 Example type set_index is range 21 downto 11; set_index’left = 21 set_index’right = 11 set_index’low = 11 set_index’high = 21 set_index’ascending = false set_index’image(14) = “14” set_index’value(“20”) = 20 Restrictions on coding style for RTL model

© Fu-Chiung Cheng VHDL Ch02 33 Attributes of Scalar Types Discrete types are integer and all enumerated types. – T’pos(x): position of x in T – T’val(n): value in T at position n – T’succ(x): successor of x in T – T’pred(x): predecessor of x in T – T’leftof(x): value in T at position one left of x – T’rightof(x): value in T at position one right of x

© Fu-Chiung Cheng VHDL Ch02 34 Example type logic_level is (unknown, low, undriven, high); logic_level’pos(unknown) = 0 logic_level’val(3) = high logic_level’succ(unknown) = low logic_level’pred(undriven) = low

© Fu-Chiung Cheng VHDL Ch02 35 Expression and Operators Primary values that can be used in expressions: – Literal values – Identifiers representing data objects (constants, variables) – Attributes that yield values – Qualified expressions – Type-converted expressions and – Expressions in parentheses

© Fu-Chiung Cheng VHDL Ch02 36 Expression and Operators VHDL operators – See page 53~54