library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity mux is
port (sel: in std_logic;
s0,s1: in std_logic_vector (3 downto 0) ;
sout : out std_logic_vector (3 downto 0));
end mux;
architecture Behavioral of mux is
begin
if sel = '0' then
sout <= s0;
else
sout <= s1;
end if;
end Behavioral;
- 我正在尝试为四位串行加法器输出制作多路复用器。如果cin是0那么它将采取 - 来自第一个加法器的总和,其中cin为0,如果cin为1,那么它将从第二个 - 加法器中得到cin 1的总和。但是如果某个地方我不能错误弄清楚。编译器说if else附近的错误,并结束if语句
答案 0 :(得分:2)
在具有适当灵敏度列表的进程中使用if-else构造。
`
process(sel)
begin
(
if sel = '0' then
sout <= s0;
else
sout <= s1;
end if;
);
end process;
否则使用When Else
构造
答案 1 :(得分:1)
if
是一个顺序语句,所以它只在process
内。将if
替换为when
,因为这是一个并发语句,因此可以直接在架构中使用:
sout <= s0 when (sel = '0') else s1;