Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a package named My_Pkg.
VHDL
package [1] is constant WIDTH : integer := 8; end package;
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different package name than declared.
Misspelling the package name.
✗ Incorrect
The package name must match the declaration name exactly. Here, 'My_Pkg' is the correct package name.
2fill in blank
mediumComplete the code to start the package body for My_Pkg.
VHDL
package body [1] is
-- package body implementation
end package body;Attempts:
3 left
💡 Hint
Common Mistakes
Using a different name in the package body than in the declaration.
Omitting the package name in the body.
✗ Incorrect
The package body must use the exact package name declared earlier, which is 'My_Pkg'.
3fill in blank
hardFix the error in the package declaration keyword.
VHDL
[1] My_Pkg is constant MAX_VAL : integer := 255; end package;
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'package body' instead of 'package' for declaration.
Using invalid keywords like 'pkg' or 'package declare'.
✗ Incorrect
The correct keyword to declare a package is 'package'. 'package body' is for the body, and others are invalid.
4fill in blank
hardFill both blanks to declare a constant and a function prototype inside the package.
VHDL
package My_Pkg is constant [1] : integer := 16; function [2] return integer; end package;
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing constant and function names.
Using invalid identifiers.
✗ Incorrect
The constant name is 'DATA_WIDTH' and the function prototype is 'get_value' as per common naming conventions.
5fill in blank
hardFill all three blanks to implement the function body returning the constant value.
VHDL
package body My_Pkg is function [1] return integer is begin return [2]; end [3]; end package body;
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatching function names in start and end.
Returning an undefined constant.
✗ Incorrect
The function name is 'get_value', it returns the constant 'DATA_WIDTH', and the function ends with 'end get_value;'.
