|
--
declaration with formal parameters i and length and data type of return
value
FUNCTION i2bv (i: INTEGER; length: INTEGER) RETURN BIT_VECTOR
IS
VARIABLE bv: BIT_VECTOR(length-1 DOWNTO 0);
VARIABLE temp: INTEGER;
BEGIN -- start of sequential procedure statements
temp := i;
FOR j IN 0 TO (bv'LENGTH-1) LOOP
IF (temp mod 2 = 1) THEN
bv(j) := '1';
ELSE
bv(j) := '0';
END
IF;
temp := temp/2;
END
LOOP;
return bv;
END i2bv; -- end of sequential procedure statements
…
ARCHITECTURE bench OF entity_name IS
SIGNAL in_var: INTEGER;
SIGNAL out_vec: BIT_VECTOR (1 to 8);
…
BEGIN
in_var <= 10;
-- function call with actual
parameters in_var and value 8
out_vec <= i2bv (in_var,8)
AFTER
1ms;
END ARCHITECTURE bench;
|