Complete the code to declare a 4-bit input vector named 'data'.
signal data : std_logic_vector([1] downto 0);
The input vector 'data' is 4 bits wide, so the highest index is 3 (0 to 3).
Complete the code to assign the output 'pos' with the highest priority bit index when 'data' is not zero.
if data /= "0000" then pos <= [1]; end if;
The output 'pos' should be assigned the binary index of the highest priority bit set. Here, "01" represents index 1.
Fix the error in the process sensitivity list to include all inputs.
process([1])
begin
-- priority encoder logic
end process;The process sensitivity list must include 'data' because the output depends on changes in 'data'.
Fill both blanks to complete the priority encoder output assignment and default case.
with data select pos <= [1] when "1000", [2] when others;
When the highest bit (bit 3) is set, 'pos' is "11" (binary 3). For all other cases, default to "00".
Fill all three blanks to complete the priority encoder logic with multiple conditions.
if data(3) = '1' then pos <= [1]; elsif data(2) = '1' then pos <= [2]; else pos <= [3]; end if;
The priority encoder checks bits from highest to lowest. If bit 3 is set, output "11" (3). Else if bit 2 is set, output "10" (2). Otherwise, output "00" (0).