Difference between priority encoding and case example.
If we have a one hot select that can select one of four inputs a, b, c, and d, then the selects are mutually exclusive.
Code VHDL - [expand] |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| process (s0, s1, s2, s3, a, b, c, d)
begin
if (s0 = '1') then
y <= a;
elsif (s1 = '1') then
y <= b;
elsif (s2 = '1') then
y <= c;
elsif (s3 = '1') then
y <= d;
else
y <= 'x';
endif;
end process; |
This results in a priority encoder as there are 16 possible combinations of values that the s0-s3 can take.
Code VHDL - [expand] |
1
2
3
4
5
6
7
8
9
10
11
12
| process (s0, s1, s2, s3, a, b, c, d)
variable sel : std_logic_vector(3 downto 0);
begin
sel := s3 & s2 & s1 & s0;
case (sel) is
when "0001" => y <= a;
when "0010" => y <= b;
when "0100" => y <= c;
when "1000" => y <= d;
when others => y <= 'x'
end case;
end process; |
Without verifying, I believe this will result in an equation like this:
Code VHDL - [expand] |
1
| y <= (a and sel0) or (b and sel1) or (c and sel2) or (d and sel3); |
Which is a non-priority encoded circuit where sel0-3 must be mutually exclusive.l