2016-09-21 50 views
0

有人可以帮助我如何将此vhdl代码更改为使用'when'语句?如何更改为何时声明

下面是代码我写:

library IEEE; 
use IEEE.std_logic_1164.all; 

entity sel2_1 is 
    port(A, B, SEL : in std_logic; 
     outsgnl : out std_logic); 
end sel2_1; 

architecture EX1 of sel2_1 is 
begin 
    outsgnl <= (not SEL and A) or (SEL and B); 
end EX1; 

的模拟结果如下: simulation

+0

我已经编辑了上面的问题,并把模拟结果。我试图改变vhdl代码使用时声明和我期望相同的确切结果。 – HAKIM

回答

2

当关键字在不同VHDL分配被使用。假设SEL'0''1'则可以通过一个选择的信号分配 simpley取代

outsgnl <= (not SEL and A) or (SEL and B); 

,通常被称为与/选择分配

with SEL select outsgnl <= 
    A when '0', 
    B when others; 

或者,也可以使用条件信号分配常简称当/别

outsgnl <= A when SEL = '0' else B; 
+0

非常感谢你!它与我上面发布的模拟功能相同。 – HAKIM