Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a procedure with a signal parameter.
VHDL
procedure set_signal(signal sig : out std_logic) is
begin
sig <= [1];
end procedure;Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' instead of '<=' for signal assignment.
Assigning a value without single quotes.
Using a variable assignment style.
✗ Incorrect
The procedure assigns the value '1' to the signal parameter sig.
2fill in blank
mediumComplete the procedure call to pass a signal named 'clk' as an argument.
VHDL
begin
set_signal([1] => clk);
end;Attempts:
3 left
💡 Hint
Common Mistakes
Using ':' instead of '=>'.
Omitting the parameter name.
Using '=' instead of '=>'.
✗ Incorrect
The correct syntax for named association in VHDL is 'sig => clk'.
3fill in blank
hardFix the error in the procedure header to correctly declare a signal parameter named 'data'.
VHDL
procedure update_data([1] : in std_logic_vector(7 downto 0)) is begin -- procedure body end procedure;
Attempts:
3 left
💡 Hint
Common Mistakes
Placing 'signal' after the parameter name.
Using 'variable' instead of 'signal'.
Omitting the 'signal' keyword.
✗ Incorrect
In VHDL, signal parameters are declared with 'signal' before the parameter name.
4fill in blank
hardFill both blanks to complete the procedure that sets a signal 'out_sig' to '0'.
VHDL
procedure reset_signal(signal [1] : out std_logic) is begin [2] <= '0'; end procedure;
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names in the header and body.
Using a variable name instead of the signal parameter.
Omitting the 'signal' keyword in the header.
✗ Incorrect
The parameter name and the signal used inside the procedure must match.
5fill in blank
hardFill all three blanks to create a procedure that toggles a signal 'sig' from '0' to '1'.
VHDL
procedure toggle_signal(signal [1] : inout std_logic) is begin if [2] = '0' then [3] <= '1'; else [3] <= '0'; end if; end procedure;
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names for the signal parameter and inside the procedure.
Using a variable instead of a signal parameter.
Omitting the 'signal' keyword in the parameter declaration.
✗ Incorrect
The signal parameter name must be consistent in the header and body for reading and assigning.
