Ticker

6/recent/ticker-posts

Header Ads Widget


 

Language Elements

Language Elements


Identifiers

An identifier in VHDL is composed of a sequence of one or more characters. A legal character is an upper-case letter (A... Z), or a lower-case letter (a. .. z), or a digit (0 . . . 9) or the underscore ( _ ) character. The first character in an identifier must be a letter and the last character may not be an underscore. Lower-case and upper-case letters are considered to be identical when used in an identifier

 

Data Objects

A data object holds a value of a specified type. It is created by means of an object declaration. An example is

variable COUNT: INTEGER;

This results in the creation of a data object called COUNT which can hold integer values. The object COUNT is also declared to be of variable class.

Every data object belongs to one of the following three classes: 

 

1. Constant: An object of constant class can hold a single value of a given type. This value is assigned to the object before simulation starts and the value cannot be changed during the course of the simulation. 

 

2. Variable: An object of variable class can also hold a single value of a given type. However in this case, different values can be assigned to the object at different times using a variable assignment statement. 

 

3. Signal: An object belonging to the signal class has a past history of values, a current value, and a set of future values. Future values can be assigned to a signal object using a signal assignment statement.

 

  • Constant Declarations

Examples of constant declarations are

constant RISE_TIME: TIME := 10ns;

                        constant BUS_WIDTH: INTEGER := 8:

  • Variable Declarations 

Examples of variable declarations are

variable CTRL_STATUS: BIT_VECTOR(10 downto 0);

variable SUM: INTEGER range Oto 100 := 10;

                        variable FOUND, DONE: BOOLEAN;

  • Signal Declarations

Here are some examples of signal declarations.

signal CLOCK: BIT;

signal DATA_BUS: BIT_VECTOR(0 to 7);

signal GATE_DELAY: TIME := 10 ns;

The interpretation for these signal declarations is very similar to that of the variable declarations.

Not all objects in a VHDL description are created using object declarations. These other objects are declared as

 1. ports of an entity. All ports are signal objects.

    2. generics of an entity . These are constant objects.

    3. formal parameters of functions and procedures . Function parameters are constant objects or signal objects while procedure parameters can belong to any object class,

    4. a file declared by a file declaration .

There are two other types of objects that are implicitly declared. These are the indices of a for. . . loop statement and the generate statement . An example of such an implicit declaration for the loop index in a for. . . loop statement is shown.

for COUNT in 1 to 10 loop

SUM := SUM + COUNT;

end loop;

In this for . . . loop statement, object COUNT has an implicit declaration of type INTEGER with range I to 10, and therefore, need not be explicitly declared.

 

Data Types

Every data object in VHDL can hold a value that belongs to a set of values. This set of values is specified by using a type declaration   

 1. Scalar types: Values belonging to these types appear in a sequential order

. 2. Composite types: These are composed of elements of a single type (an array type) or elements of different types (a record type). 

 3. Access types: These provide access to objects of a given type (via pointers). 

 4. File types: These provides access to objects that contain a sequence of values of a given type.

Subtypes A subtype is a type with a constraint. The constraint specifies the subset of values for the type. The type is called the base type of the subtype.

subtype MY_INTEGER is INTEGER range 48 to 156 ;

type DIGIT is ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9') ;

                        subtype MIDDLE is DIGIT range '3' to '7' ;

 

  • Scalar Types

There are four different kinds of scalar types. These types are

1. enumeration,

2. integer,

3. physical,

                      4. floating point.

Enumeration Types

An enumeration type declaration defines a type that has a set of user-defined values consisting of identifiers and character literals. Examples are

Type MVL is ('U','0','1','Z);

                 type MICRO_OP is (LOAD, STORE, ADD, SUB, MUL, DIV);

                                 subtype ARITH_OP is MICRO_OP range ADD to DIV;

Examples of objects defined for these types are

signal CONTROL_A: MVL;

                signal CLOCK: MVL range '0' to '1'; -- Implicit subtype declaration.

                variable IC: MICRO_OP := STORE; -- STORE is the initial value for IC.

                                variable ALU: ARITH_OP;

Integer Types

An integer type defines a type whose set of values fall within a specified integer range. Examples of integer type declarations are

type INDEX is range 0 to 15;

                        type WORD_LENGTH is range 31 downto 0;

Some object declarations using these types are

constant MUX_ADDRESS: INDEX := 5;

                        signal DATA_BUS: DATA_WORD;

Values belonging to an integer type are called integer literals. Examples of integer literals are

56349 6E2 0 98_71_28

Literal 6E2 refers to the decimal value 6 * (10^) = 600. The underscore ( _ ) character can be used freely in writing integer literals and has no impact on the value of the literal; 98_71_28 is same as 987128.

INTEGER is the only predefined integer type of the language. The range of the INTEGER type is implementation dependent but must at least cover the range -(2^ 31 - 1) to +(2^31 - 1).

Floating Point Types

A floating point type has a set of values in a given range of real numbers. Examples of floating point type declarations are

type TTL_VOLTAGE is range -5.5 to -1.4;

type REAL_DATA is range 0.0 to 31.9;

An example of an object declaration is

variable LENGTH: REAL_DATA range 0.0 to 15.9;

. . .

                        variable LI, L2, L3: REAL_DATA range 0.0 to 15.9;

Integer and floating point literals can also be written in a base other than 10 (decimal). The base can be any value between 2 and 16. Such literals are called based literals. In this case, the exponent represents a power of the specified base. The syntax for a based literal is

base # based-value # -- form 1

base # based-value # E exponent -- form 2

Examples are

2#101_101_000# represents (101101000)2 = (360) in decimal,

16#FA# represents (FA)16= (11111010)2 = (250) in decimal,

16#E#E1 represents (E)16* (16^1) = 14* 16= (224) in decimal,

            2#110.01 # represents (110.01)2 = (6.25) in decimal.

Physical Types

A physical type contains values that represent measurement of some physical quantity, like time, length, voltage, and current. Values of this type are expressed as integer multiples of a base unit. An example of a physical type declaration is

type CURRENT is range 0 to 1 E9

units

                                                   nA;                        -- (base unit) nano-ampere

                                                   uA = 1000 nA;      -- micro-ampere

              mA = 1000 μA;       --milli-ampere

              Amp = 1000 mA;    -- ampere

end units;

                                 subtype FILTER_CURRENT is CURRENT range 10 μA to 5 mA;

  • Composite Types

A composite type represents a collection of values. There are two composite types: an array type and a record type. An array type represents a collection of values all belonging to a single type; on the other hand, a record type represents a collection of values that may belong to same or different types.

Array Types

An object of an array type consists of elements that have the same type. Examples of array type declarations are

type ADDRESS_WORD is array (0 to 63) of BIT;

type DATA_WORD is array (7 downto 0) of MVL;

type ROM is array (0 to 125) of DATA_WORD;

                type DECODE_MATRIX is array (POSITIVE range 15 downto 1,

NATURAL range 3 downto 0) of MVL;

                                                 --POSITIVE and NATURAL are predefined subtypes; these are:

                  subtype NATURAL is INTEGER range 0 to INTEGER'HIGH;

                  subtype POSITIVE is INTEGER range 1 to INTEGER'HIGH;

                                                        -- The HIGH attribute gives the highest value belonging to the type.

Examples of object declarations using these types are

variable ROM_ADDR: ROM;

signal ADDRESS.BUS: ADDRESS_WORD;

            constant DECODER: DECODE_MATRIX; - A deferred constant.

variable DECODE_VALUE: DECODE_MATRIX;

ADDRESS_BUS is a one-dimensional array object that consists of 64 elements of type BIT. ROM_ADDR is a one-dimensional array object that consists of 126 elements, each element being another array object consisting of 8 elements of type MVL. We have thus created an array of arrays.

Record Types

An object of a record type is composed of elements of same or different types. It is analogous to the record data type in Pascal and the struct declaration in C. An example of a record type declaration is

type PIN_TYPE is range 0 to 10;

type MODULE is

record

SIZE: INTEGER range 20 to 200;

CRITICAL_DLY: TIME;

NO_INPUTS: PIN_TYPE:

NO_OUTPUTS: PIN_TYPE;

end record;

Values can be assigned to a record type object using aggregates. For example,

variable NAND.COMP: MODULE;

-- NAND_COMP is an object of record type MODULE.

                                     NAND_COMP := (50, 20 ns, 3,2);

  • Access Types

Values belonging to an access type are pointers to a dynamically allocated object of some other type. They are similar to pointers in Pascal and C languages. Examples of access type declarations are

-- MODULE is a record type declared in the previous sub-section.

type PTR is access MODULE;

type FIFO is array (0 to 63, 0 to 7) of BIT;

type FIFO_PTR is access FIFO;

PTR is an access type whose values are addresses that point to objects of type MODULE. Every access type may also have the value null, which means that it does not point to any object. Objects of an access type can only belong to the variable class. When an object of an access type is declared, the default value of this object is null. For example,

variable MOD1PTR, MOD2PTR: PTR; - Default value is null.

  • File Types

Objects of file types represent files in the host environment. They provide a mechanism by which a VHDL design communicates with the host environment. The syntax of a file type declaration is

type file-type-name Is file of type-name,

The type-name is the type of values contained in the file. Here are two examples.

type VECTORS is file of BIT_VECTOR;

type NAMES is file of STRING;

A file of type VECTORS has a sequence of values of type BIT_VECTOR; a file of type NAMES has a sequence of strings as values in it.

A file is declared using a file declaration. The syntax of a file declaration is:

file file-name: file-type-name is mode string-expression ',

The string-expression is interpreted by the host environment as the physical name of the file. The mode of a file, in or out, specifies whether it is an input or an output file, respectively. Input files can only be read while output files can only be written to.

Here are two examples of declaring files.

file VEC_FILE: VECTORS is in "/usr/home/jb/uart/div.vec";

            file OUTPUT: NAMES is out "stdout";

 


 

Post a Comment

0 Comments