0
0
VHDLprogramming~10 mins

Priority encoder in VHDL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a 4-bit input vector named 'data'.

VHDL
signal data : std_logic_vector([1] downto 0);
Drag options to blanks, or click blank then click option'
A3
B4
C7
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using 4 as the highest index instead of 3.
Confusing the direction of the vector range.
2fill in blank
medium

Complete the code to assign the output 'pos' with the highest priority bit index when 'data' is not zero.

VHDL
if data /= "0000" then
    pos <= [1];
end if;
Drag options to blanks, or click blank then click option'
A"11"
B"00"
C"01"
D"10"
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning the wrong binary value for the bit position.
Confusing the bit pattern with the index.
3fill in blank
hard

Fix the error in the process sensitivity list to include all inputs.

VHDL
process([1])
begin
    -- priority encoder logic
end process;
Drag options to blanks, or click blank then click option'
Adata
Bpos
Cclk
Dreset
Attempts:
3 left
💡 Hint
Common Mistakes
Including clock or reset signals unnecessarily.
Omitting the input signal 'data' from the sensitivity list.
4fill in blank
hard

Fill both blanks to complete the priority encoder output assignment and default case.

VHDL
with data select
    pos <= [1] when "1000",
           [2] when others;
Drag options to blanks, or click blank then click option'
A"11"
B"00"
C"10"
D"01"
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the binary values for the bit positions.
Not providing a default case for 'when others'.
5fill in blank
hard

Fill all three blanks to complete the priority encoder logic with multiple conditions.

VHDL
if data(3) = '1' then
    pos <= [1];
elsif data(2) = '1' then
    pos <= [2];
else
    pos <= [3];
end if;
Drag options to blanks, or click blank then click option'
A"11"
B"10"
C"00"
D"01"
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning incorrect binary values for bit positions.
Not covering all conditions properly.