Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a package named Utils.
VHDL
package [1] is end package [1];
Attempts:
3 left
💡 Hint
Common Mistakes
Using a package name that does not match the declaration.
✗ Incorrect
The package name must be Utils to match the declaration.
2fill in blank
mediumComplete the code to declare a constant inside the package.
VHDL
package Utils is
constant MAX_VALUE : integer := [1];
end package Utils;Attempts:
3 left
💡 Hint
Common Mistakes
Using a string or identifier instead of a numeric value.
✗ Incorrect
Constants must be assigned a valid value like 100, not a name or string.
3fill in blank
hardFix the error in the package body declaration.
VHDL
package body Utils is function add(a, b : integer) return integer is begin return a [1] b; end function; end package body Utils;
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction or multiplication instead of addition.
✗ Incorrect
The function add must return the sum, so use the plus operator +.
4fill in blank
hardFill both blanks to declare and use a type inside the package.
VHDL
package Utils is type [1] is array (0 to 3) of integer; end package Utils; use Utils.all; architecture Behavioral of Test is signal data : [2]; begin null; end Behavioral;
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names for type declaration and usage.
✗ Incorrect
The type is declared as IntArray and used with the same name for the signal.
5fill in blank
hardFill all three blanks to declare a package with a function and use it.
VHDL
package Utils is function [1](x : integer) return integer; end package Utils; package body Utils is function [2](x : integer) return integer is begin return x [3] 1; end function; end package body Utils;
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatched function names or wrong operator.
✗ Incorrect
The function name increment is declared and defined, and it adds 1 to x using +.
