导航菜单
首页 >  » 正文

利用IF语言设计一个3位二进制A[2:0]、B[2:0]比较电路,输出是D、E、F

利用IF语言设计一个3位二进制A[2:0]、B[2:0]比较电路,输出是D、E、F

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity comparator is
port ( a,b:in std_logic_vector(2 downto 0);
d,e,f:out std_logic);
end comparator;
architecture behavioral of comparator is
begin
process(a,b)
begin
if a>b then
d <= 0;e <= 1;f <= 0;
elsif a<b then
d <= 0;e <= 0;f <= 1;
else
d <= 1;e <= 0;f <= 0;
end if;
end process;
end behavioral;
题目有点儿BUG,应当是“当A<B时F=1”。

相关推荐: