Complete the code to declare a function inside a package.
package math_pkg is function add(a : integer; b : integer) return [1]; end package math_pkg;
The function add returns an integer value, so the return type must be integer.
Complete the code to declare a procedure inside a package.
package control_pkg is
[1] reset(signal flag : out std_logic); -- procedure declaration
end package control_pkg;The keyword procedure is used to declare a procedure in a package.
Fix the error in the function implementation inside the package body.
package body math_pkg is function multiply(a : integer; b : integer) return integer is begin return a [1] b; end function multiply; end package body math_pkg;
The function multiply should return the product of a and b, so the operator must be *.
Fill both blanks to complete the procedure implementation that sets a flag to '1'.
package body control_pkg is
procedure reset(signal flag : out std_logic) is
begin
flag [1] '[2]';
end procedure reset;
end package body control_pkg;In VHDL, signals are assigned using the <= operator. To set the flag to logic high, use '1'.
Fill all three blanks to complete a function that returns true if input is positive.
package body check_pkg is function is_positive(x : integer) return boolean is begin if x [1] 0 then return [2]; else return [3]; end if; end function is_positive; end package body check_pkg;
The function checks if x is greater than zero. If yes, it returns true, otherwise false.
