IRVS VLSI IDEA INNOVATORS

IRVS VLSI IDEA INNOVATORS
VLSI Project, Embedded Project, Matlab Projects and courses with 100% Placements

Tuesday, October 19, 2010

Operators

• VHDL provides several kinds of pre- defined operators
– Assignment operators
– Logical operators
– Arithmetic operators
– Relational operators
– Shift operators
– Concatenation operators

Assignment operators

• Are used to assign values to signals, variables, and constants.





Then the following assignments are legal:

x <= '1'; -- '1' is assigned to SIGNAL x using "<="
y := "0000"; -- "0000" is assigned to VARIABLE y using --":="
w <= "10000000"; -- LSB is '1', the others are '0'
w <= (0 =>'1', OTHERS =>'0'); -- LSB is '1', the others -- are '0'


Logical operators

• Used to perform logical operations.

• The data must be of type:
– BIT, STD_LOGIC
– STD_ULOGIC
– BIT_VECTOR
– STD_LOGIC_VECTOR
– STD_ULOGIC_VECTOR




Arithmetic operators

• Used to perform arithmetic operations. The data can be of type INTEGER, SIGNED, UNSIGNED, or REAL (the last cannot be synthesized directly).

• Also, if the std_logic_signed or the std_logic_unsigned package of the ieee library is used, then STD_LOGIC_VECTOR can also be employed directly in addition and subtraction operations.



• There are no synthesis restrictions regarding addition and subtraction, and the same is generally true for multiplication.

• For division, only power of two dividers (shift operation) are allowed.

• For exponentiation, only static values of base and exponent
are accepted.

• Regarding the mod and rem operators, y mod x returns the remainder of y/x with the signal of x, while y rem x returns the remainder of y/x with the signal of y.

• Finally, abs returns the absolute value.

information shared by www.irvs.info

Thursday, October 14, 2010

Categories of data types (VHDL)

User defined data types

• VHDL allows user defined data types.

• Two categories of this data type are:

– Integer
– Enumerated

• User defined integer type

TYPE my_integer IS RANGE -32 to +32 ;
TYPE student_grade IS RANGE 0 to 100 ;


• User defined enumerated type


TYPE my_logic IS (‘0’, ‘1’, ‘Z’);
TYPE my_state IS ( idle, forward, backward, stop) ;




• The encoding of enumerated types is done sequentially and automatically.

• Since here there are 4 states only two bits are required hence “00” is assigned to first state ( idle), “01” to second state (forward) and so on.

Subtypes

• A SUBTYPE is a TYPE with a constraint.

• Though operations between data of different types are not allowed, they are allowed between the subtype and its corresponding base type.
SUBTYPE sub_state IS my_state RANGE idle to backward ;

This means that the subtype
sub_state =(idle, forward, backward)

Arrays

• Arrays are collections of objects of same type.

• Can be 1-dimensional, 2-dimensional or
1D X 1D.

• Higher dimensional arrays are possible but not synthesize.



Array syntax

To specify an array :
TYPE type_name IS ARRAY (specification) OF data_type ;

To use an array :
SIGNAL signal_name : type_name [:= initial_value]

Example : 1D x 1D array
– We want to build an array containing 4 vectors, each of size 8 bits.
– we will call each vector as row and the complete array as matrix.



Example : 2D array
– This array will be created with scalars only.



Port Arrays

• In the specification of the input or output pins (PORTS) of a circuit (which is made in the ENTITY), we might need to specify the ports as arrays of vectors.

• Since TYPE declarations are not allowed in an ENTITY, the solution is to declare user-defined data types in a PACKAGE, which will then be visible to the whole design (thus including the ENTITY)



• As can be seen in the example above, a user- defined data type, called vector_array,was created, which can contain an indefinite number of vectors of size eight bits each (NATURAL RANGE <> signifies that the range is not fixed, with the only restriction that it must fall within the NATURAL range, which goes from 0 to +2,147,483,647)

• The data type was saved in a PACKAGE called my_data_types, and later used in an ENTITY to specify a PORT called inp.

• Notice in the main code the inclusion of an additional USE clause to make the user-defined package my_data_types visible to the design.

Records

• Records are similar to arrays, with the only difference that they contain objects of different types.



Signed and Unsigned data types

• These types are defined in the std_logic_arith package of the ieee library.



• An UNSIGNED value is a number never lower than zero. For example, ‘‘0101’’
represents the decimal 5, while ‘‘1101’’ signifies 13.

• If type SIGNED is used instead, the value can be positive or negative (in two’s complement format). Therefore,‘‘0101’’ would represent the decimal 5, while ‘‘1101’’ would mean 3.

• To use SIGNED or UNSIGNED data types, the std_logic_arith package, of the ieee library, must be declared.

information shared by www.irvs.info