题解 | #四选一多路器#
https://www.nowcoder.com/practice/cba4617e1ef64e9ea52cbb400a0725a3
VHDL选手报道。
library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity MUX4_1 is Port (d1 : in std_logic_vector(1 downto 0); d2 : in std_logic_vector(1 downto 0); d3 : in std_logic_vector(1 downto 0); d0 : in std_logic_vector(1 downto 0); sel : in std_logic_vector(1 downto 0); mux_out : out std_logic_vector(1 downto 0)); end MUX4_1; architecture Behavioral of MUX4_1 is begin process(sel) begin case sel is when "00" => mux_out <= d3; when "01" => mux_out <= d2; when "10" => mux_out <= d1; when "11" => mux_out <= d0; when others => mux_out <= d3; end case; end process; end Behavioral;