Tuesday, July 1, 2008

Introduction To VHDL: Arrays, Operator, Functions, Procedures, Packages and Library

Arrays

type SHORT_WORD is array (15 downto 0) of bit
signal DATA_WORD: SHORT_WORD;
variable ALT_WORD: SHORT_WORD:= “01010101…”;
constant ONE_WORD: SHORT_WORD:= (others => ‘1’);

type matrix4x3 is array (1 to 4, 1 to 3) of integer;
variable matrixA: matrix4x3 := ((1, 2, 3), (4, 5, 6),
(7, 8, 9), (10, 11, 12));

type intvec is array (natural range <>) of integer;
signal intvec5: intvec (1 to 5) := (3, 2, 6, 8, 1);

---------------------------------------------------------
Operator

  • Binary logical operatoors: and or nand nor xor xnor
  • Relational operator: = /= < <= > >=
  • Shift operator: sll srl sla sra rol ror
  • Adding operators: + - &(concatenation)
  • Unary sign operators: + -
  • Multiplying operator: * / mod rem
  • Miscellaneous operators: not abs **
---------------------------------------------------------
Functions

function function_name (formal-parameter-list)
return return-type is [declaration]
begin
sequential statements – must include return return-value;
end function-name;
The general form of a function call is
function_name (actual-parameter-list)

[loop-label:] for loop-index in range loop
sequential statements
end loop [loop-label];

---------------------------------------------------------
Procedures

procedure procedure_name (formal-parameter-list) is [declaration]
begin
sequential statements
end procedure-name;

procedure_name (actual-parameter-list);

---------------------------------------------------------
Packages And Library

package package_name is
package declarations
end [package][package_name];

package body package_name is
package body declarations
end [package body][package_name];

library, use
example: library BITLIB;
use BITLIB.bit_pack.all;

*identifiers in bold type denotes a VHDL keyword

0 comments: