如何更改为 when 语句
How to change to when statement
有人可以帮助我如何将此 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
在不同的 VHDL 分配中使用关键字时。假设 SEL
只是 '0'
或 '1'
你可以简单地替换
outsgnl <= (not SEL and A) or (SEL and B);
通过选定的信号分配,通常称为with/select分配
with SEL select outsgnl <=
A when '0',
B when others;
或者您可以使用 条件信号分配 通常称为 when/else
outsgnl <= A when SEL = '0' else B;
有人可以帮助我如何将此 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
在不同的 VHDL 分配中使用关键字时。假设 SEL
只是 '0'
或 '1'
你可以简单地替换
outsgnl <= (not SEL and A) or (SEL and B);
通过选定的信号分配,通常称为with/select分配
with SEL select outsgnl <=
A when '0',
B when others;
或者您可以使用 条件信号分配 通常称为 when/else
outsgnl <= A when SEL = '0' else B;