Given the following VHDL code snippet, what will be the value of signal_out after the procedure call?
library ieee; use ieee.std_logic_1164.all; entity test_proc is port( signal_in : in std_logic_vector(3 downto 0); signal_out : out std_logic_vector(3 downto 0) ); end test_proc; architecture behavior of test_proc is procedure invert_signal(signal s_in : in std_logic_vector(3 downto 0); signal s_out : out std_logic_vector(3 downto 0)) is begin for i in s_in'range loop s_out(i) <= not s_in(i); end loop; end procedure; begin process(signal_in) begin invert_signal(signal_in, signal_out); end process; end behavior;
Remember that not inverts each bit in std_logic_vector.
The procedure invert_signal inverts each bit of signal_in and assigns it to signal_out. For input 0101, the output is 1010.
Consider signal parameters in VHDL procedures. Which of the following statements is true?
Think about how signals are passed and updated in VHDL procedures.
Signal parameters in VHDL procedures allow passing signals by reference, so the procedure can modify the signal's value directly.
What error will this VHDL code produce?
procedure update_signal(signal s : in std_logic_vector(3 downto 0)) is begin s <= "1111"; end procedure;
Check the mode of the signal parameter and whether it can be assigned inside the procedure.
Signal parameters declared as in mode cannot be assigned new values inside the procedure, causing a compilation error.
Choose the correct syntax for a procedure that takes one in and one out signal parameter of type std_logic_vector(7 downto 0).
Remember to specify signal keyword and modes for signal parameters.
Signal parameters must be declared with the signal keyword and their mode (in, out, or inout).
Consider the following VHDL code snippet:
signal a, b : std_logic_vector(1 downto 0); procedure swap_signals(signal x : inout std_logic_vector(1 downto 0); signal y : inout std_logic_vector(1 downto 0)) is variable temp : std_logic_vector(1 downto 0); begin temp := x; x <= y; y <= temp; end procedure; -- In a process: swap_signals(a, b);
How many signal assignments are scheduled after the procedure call?
Count the number of signal assignments inside the procedure.
The procedure assigns to x and y signals once each, so two signal assignments are scheduled.
