八选一须具选择器:用CASE语句。
LIBRARY IEEEUSE IEEE.STD_LOGIC_1164.ALL
ENTITY mux_8_1 IS
PORT (A,B,C,D,E,F,G,H,En:IN STD_LOGIC
S:in STD_LOGIC_vector(2 downto 0)
Y: out STD_LOGIC)
end mux_8_1
ARCHITECTURE mux OF mux_8_1 IS
begin
process( S,A,B,C,D,E,F,G,H,En)
begin
if En='0' then
case S is
when "000" => Y<=A
when "001" => Y<=B
弯衫 when "010"埋则腔 => Y<=C
when "011" => Y<=D
when "100" => Y<=E
when "101" => Y<=F
when "110" => Y<=G
when "111" => Y<=H
盯含 end case
end if
end process
end mux
LIBRARY IEEE;USE IEEE.Std_logic_1164.ALL;
ENTITY Mux8 IS
PORT(sel:IN Std_logic_Vector(2 DOWNTO 0);
In_s:IN Std_logic_Vector(7 DOWNTO 0);
y:OUT Std_logic);
END Mux8;
ARCHITECTURE behave OF Mux8 IS
BEGIN
PROCESS(sel,In_s)
BEGIN
CASE sel IS
WHEN "111"或塌 =>y <= In_s(7);
WHEN "011" =>y <= In_s(6);
WHEN "101" =>y <= In_s(5);
WHEN "100" =>y <= In_s(4);
WHEN "011" =>y <= In_s(3);
WHEN "010" =>y <= In_s(2);
WHEN "001" =>y <= In_s(1);孝键
WHEN "000" =>y <= In_s(0);
WHEN OTHERS =>NULL;
END CASE;
END PROCESS
END behave;
将上面描述中的全巧团巧角字符改成半角字符后,就可以通过编译了。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)