don't care値を使う

pp.184-186
don't care値を利用するとブール式が簡単化されるためハードウェアが少なくて済む。

下のコードはLEを1個消費した。

library ieee;
use ieee.std_logic_1164.all;

entity circuit_with_dontcare is
    port(
        a : in  std_logic_vector(2 downto 0);
        b : out std_logic_vector(1 downto 0)
    );
end entity;

architecture rtl of circuit_with_dontcare is
/*
'-'がdon't care値。
合成する場合は'X' (forcing unknown)もdon't careに解釈される。
ただし'0', '1', 'Z', '-'以外は使わないことが望ましい(p.163)。
*/
begin
    with a select
        b <= "-0" when "000",
             "10" when "001",
              "-1" when "010",
              "--" when "011",
              "0-" when "100" | "110",
              "00" when "101",
              "01" when others;
end architecture;

ためしにdon't careを'0'にしてみた。LEを3個消費した。

library ieee;
use ieee.std_logic_1164.all;

entity circuit_with_dontcare is
    port(
        a : in  std_logic_vector(2 downto 0);
        b : out std_logic_vector(1 downto 0)
    );
end entity;

architecture rtl of circuit_with_dontcare is
/*
'-'がdon't care値。
合成する場合は'X' (forcing unknown)もdon't careに解釈される。
ただし'0', '1', 'Z', '-'以外は使わないことが望ましい(p.163)。
*/
begin
    with a select
        b <= "00" when "000",
             "10" when "001",
              "01" when "010",
              "00" when "011",
              "00" when "100" | "110",
              "00" when "101",
              "01" when others;
end architecture;