正在加载图片...
if布尔表达式1then顺序语句1 elseif布尔表达式2then顺序语句2 else顺序语句3 nd if 当布尔表达式1为true时,执行顺序语句1 布尔表达式2为true时,执行顺序语句2; 所有布尔表达式都为 false时,执行顺序语句3; 例 表458 质数检测器的行为设计(采用i语句) 并进行数据类型转换 library ieee use ieee std logic 1164. all; use ieee std logic unsigned. all entity prime is port(n: in std logic vector(3 downto 0); f: out std logic); architecture beh of prime is process(n) variable ni: integer ni:=conv integer(n); if ni=l or ni=2 then f<='1' elsif ni=3 or ni=5 or ni=7 or ni=ll or ni=13 then f<='1 else f<=0t end ifif 布尔表达式 1 then 顺序语句 1 elseif 布尔表达式 2 then 顺序语句 2 else 顺序语句 3 end if; 当布尔表达式 1 为 true 时,执行顺序语句 1; 布尔表达式 2 为 true 时,执行顺序语句 2; 所有布尔表达式都为 false 时,执行顺序语句 3; 例:p.292 表 4-58 质数检测器的行为设计(采用 if 语句) 并进行数据类型转换 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity prime7 is port (n: in std_logic_vector (3 downto 0); f: out std_logic); end prime7; architecture beh of prime7 is begin process(n) variable ni : integer; begin ni := conv_integer(n); if ni=1 or ni=2 then f<= '1'; elsif ni=3 or ni=5 or ni=7 or ni=11 or ni=13 then f<='1'; else f<= '0'; end if; end process;
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有