Data Types - Computer Science - Lecture Slides, Slides of Computer Science

These are the Lecture Slides of Computer Science which includes Bit Adder, Code, Vector, Bcdcarryout, Architecture Behavioral, Component, Signal, Waveform, Logic etc. Key important points are: Data Types, Data Object, Type Associated, Type Defines, Set of Values, Operation, Bit, Vector, Character, Boolean

Typology: Slides

2012/2013

Uploaded on 03/23/2013

dhruv
dhruv ๐Ÿ‡ฎ๐Ÿ‡ณ

4.3

(12)

194 documents

1 / 35

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Data Types
โ€ขEach data object has a type associated with
it.
โ€ขThe type defines the set of values that the
object can have and the set of operation that
are allowed on it.
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23

Partial preview of the text

Download Data Types - Computer Science - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

Data Types

  • Each data object has a type associated with

it.

  • The type defines the set of values that the

object can have and the set of operation that

are allowed on it.

Data types defined in the

standard package

  • Predefined data type are as follows:
    • Bit
    • Bit_vector
    • Boolean
    • Character
    • File_open_kind*
    • File_open_status*
    • Integer
    • Natural
    • Positive
    • Real
    • Severity_level
    • String
    • Time* Docsity.com

Data Types

  • A type declaration defines the name of the

type and the range of the type.

  • Type declaration are allowed in package

declaration sections, entity declaration

sections, architecture declaration sections,

subprogram declaration section and process

declaration sections.

Scalar Types

  • Scalar types describe objects that can hold ,

at most, one value at a time.

  • Integer Type
    • It is same as mathematical integers.
    • All of the normal predefined mathematical function apply to integer types.
    • Minimum Range: -2,147,483,647 to 12,147,483,

Example - Integer

Architecture test of test is

Begin

Process (x) Variable a: integer; Begin a := 1; --ok a := -1 ; -- ok a := 1.0; -- error End process;

End test;

Example โ€“ Real Types

Architecture test of test is

signal a : real;

Begin

a <= 1.0; -- ok a <= 1; -- error a <= -1.0E10; -- ok a <= 1.5E-20; --ok a <= 5.3 ns; -- error

End test;

Enumerated types

  • Enumerated type is used to represent exactly the values required for a specific operation.
  • All of the values of an enumerated type are user- defined.
  • This values can be identifiers or single-character literals.
  • A typical example:

TYPE fourval IS (โ€˜xโ€™, โ€˜0โ€™, โ€˜1โ€™, โ€˜zโ€™); TYPE color IS (red,yellow, blue,green,orange);

Physical Types

  • Physical types are used to represent physical quantities such as distance,current, time and so on.
  • A physical type provides for a base unit,and successive units are then defined in terms of this unit.
  • The smallest unit represented is one base unit.
  • The largest unit is determined by the range specified in physical type declaration.
  • TIME is a predefined physical types

Example โ€“ Physical Type

Package example is

type current is range 0 to 10000000000 units na; ua = 1000 na; -- nano amp ma = 1000 ua; -- micro amp a = 1000 ma; End units; type load_factor is (small, med, big);

End example;

Predefined physical type - Time

Type TIME is Range

units fs; --femtosecond ps = 1000 fs; -- picosecond ns = 1000 ps; -- nansecond us = 1000 ns; -- microsecond ms = 1000 us; -- millisecond sec = 1000 ms; -- second min = 60 sec; -- minute hr = 60 min; -- hour

End units;

Composite Types

  • Arrays Type are groups of elements of the

same type.

  • Arrays are useful for modeling linear structure such as RAMs and ROMs.
  • Record Types allow the grouping of

elements of different types.

  • Record are useful for modeling data packets, instructions and so on.

Array slices and Ranges

  • Assignment of arrays preserves the left-to-

right ordering regardless of the direction.

  • Example

Signal x : std_logic_vector(0 to 3);--case 1 Signal y : std_logic_vector(3 downto 0); --case X <= โ€œ1010โ€; Y <= โ€œ0101โ€;

Cont..

  • The assignment x<=y is equivalent to:

X(0) <= Y(3); -- the left element X(1) <= y(2); X(2) <=Y(1); X(3) <=Y(0); -- the right elements The array range for case I in 0 to 3 loop, the elements of the array would be accessed from left to right. The array range for caseII in 3 downto 0 loop, the elements of the array would be accessed from right to left.