p.27
同じ条件で今度はマルチプレクサとディマルチプレクサとを作る。
mux
:
library ieee; use ieee.std_logic_1164.all; -- a, bのどちらかを出力する。 entity mux is port ( a, b, sel: in std_logic; outp: out std_logic ); end entity; architecture behavior of mux is signal not_sel: std_logic; signal and_1, and_2: std_logic; begin not_sel <= sel nand '1'; and_1 <= (a nand not_sel) nand '1'; and_2 <= (b nand sel) nand '1'; outp <= (and_1 nand '1') nand (and_2 nand '1'); end architecture;
ところどころ最適化される。
dmux
:
library ieee; use ieee.std_logic_1164.all; -- a, bのどちらかへ出力する。 entity dmux is port ( inp, sel: in std_logic; a, b: out std_logic ); end entity; architecture behavior of dmux is signal not_sel: std_logic; begin not_sel <= sel nand '1'; a <= (not_sel nand inp) nand '1'; b <= (sel nand inp) nand '1'; end architecture;
これも最適化される。