VHDL上的多路复用器

时间:2014-10-13 16:05:03

标签: vhdl fpga hdl intel-fpga quartus

我尝试创建多路复用器:

LIBRARY ieee;
USE ieee.std_logic_1164.all;


--  Entity Declaration

ENTITY multiplekser IS
-- {{ALTERA_IO_BEGIN}} DO NOT REMOVE THIS LINE!
PORT
(
U : IN STD_LOGIC_VECTOR(2 downto 0);
V : IN STD_LOGIC_VECTOR(2 downto 0);
W : IN STD_LOGIC_VECTOR(2 downto 0);
X : IN STD_LOGIC_VECTOR(2 downto 0);
Y : IN STD_LOGIC_VECTOR(2 downto 0);
S : IN STD_LOGIC_VECTOR(2 downto 0);
CS : IN STD_LOGIC;
M : OUT STD_LOGIC_VECTOR(2 downto 0)
);
-- {{ALTERA_IO_END}} DO NOT REMOVE THIS LINE!

END multiplekser;


--  Architecture Body

ARCHITECTURE multiplekser_architecture OF multiplekser IS


BEGIN
    PROCESS(CS)
    BEGIN
    if (CS = '1') then
        with S select
            M<=U when "000",
                V when "001",
                W when "010",
                X when "011",
                Y when others;
    else 
        M<="ZZZ";
    end if;
    END PROCESS;
END multiplekser_architecture;

但发生了一些错误: errors

我在Quartus II 64位上做过。这是我的框图: block diagram

CS是启用信号。当CS为0时,M(输出)必须具有高阻抗。

1 个答案:

答案 0 :(得分:1)

您正在使用并发声明,其中需要顺序声明

您应该使用案例陈述或一组if陈述。例如:

architecture multiplekser_architecture of multiplekser is
begin
    process(cs, s, u, v, w, x, y)
    begin
        if cs = '1' then
            case S is
                when "000"  => m <= u;
                when "001"  => m <= v;
                when "010"  => m <= w;
                when "011"  => m <= x;
                when others => m <= y;
            end case;
        else
            m <= "ZZZ";
        end if;
    end process;
end architecture;