用VHDL语言设计2位数值比较器 要程序 急!!
真值表如下A1B1A0B0F(A>B)F(A<B)F(A=B)A1>B1X100A1<B1X010A1=B1A0>B0100A1=B1A0<B0010A1=B1A0=B0...
真值表如下
A1 B1 A0 B0 F(A>B) F(A<B) F(A=B)
A1>B1 X 1 0 0
A1<B1 X 0 1 0
A1=B1 A0>B0 1 0 0
A1=B1 A0<B0 0 1 0
A1=B1 A0=B0 0 0 1 展开
A1 B1 A0 B0 F(A>B) F(A<B) F(A=B)
A1>B1 X 1 0 0
A1<B1 X 0 1 0
A1=B1 A0>B0 1 0 0
A1=B1 A0<B0 0 1 0
A1=B1 A0=B0 0 0 1 展开
1个回答
展开全部
优点:逻辑少,关键路径少,布线方便
缺点:书写麻烦
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_ARITH.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
entity Comp is
port (
A1 : in std_logic;
B1 : in std_logic;
A0 : in std_logic;
B0 : in std_logic;
AsmallerB : out std_logic;
AgreaterB : out std_logic;
AequalB : out std_logic
);
end Comp;
architecture RTL of Comp is
signal S_TMP : std_logic_vector(3 downto 0);
begin
S_TMP <= A1 & B1 & A0 & B0;
process (S_TMP) begin
case (S_TMP) is
when "0000" => AsmallerB <= '0';AgreaterB <= '0';AequalB <= '1';
when "0001" => AsmallerB <= '1';AgreaterB <= '0';AequalB <= '0';
when "0010" => AsmallerB <= '0';AgreaterB <= '1';AequalB <= '0';
when "0011" => AsmallerB <= '0';AgreaterB <= '0';AequalB <= '1';
when "0100" => AsmallerB <= '1';AgreaterB <= '0';AequalB <= '0';
when "0101" => AsmallerB <= '1';AgreaterB <= '0';AequalB <= '0';
when "0110" => AsmallerB <= '1';AgreaterB <= '0';AequalB <= '0';
when "0111" => AsmallerB <= '1';AgreaterB <= '0';AequalB <= '0';
when "1000" => AsmallerB <= '0';AgreaterB <= '1';AequalB <= '0';
when "1001" => AsmallerB <= '0';AgreaterB <= '1';AequalB <= '0';
when "1010" => AsmallerB <= '0';AgreaterB <= '1';AequalB <= '0';
when "1011" => AsmallerB <= '0';AgreaterB <= '1';AequalB <= '0';
when "1100" => AsmallerB <= '0';AgreaterB <= '0';AequalB <= '1';
when "1101" => AsmallerB <= '1';AgreaterB <= '0';AequalB <= '0';
when "1110" => AsmallerB <= '0';AgreaterB <= '1';AequalB <= '0';
when "1111" => AsmallerB <= '0';AgreaterB <= '0';AequalB <= '1';
when others => AsmallerB <= '0';AgreaterB <= '0';AequalB <= '0';
end case;
end process;
end RTL;
缺点:书写麻烦
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_ARITH.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
entity Comp is
port (
A1 : in std_logic;
B1 : in std_logic;
A0 : in std_logic;
B0 : in std_logic;
AsmallerB : out std_logic;
AgreaterB : out std_logic;
AequalB : out std_logic
);
end Comp;
architecture RTL of Comp is
signal S_TMP : std_logic_vector(3 downto 0);
begin
S_TMP <= A1 & B1 & A0 & B0;
process (S_TMP) begin
case (S_TMP) is
when "0000" => AsmallerB <= '0';AgreaterB <= '0';AequalB <= '1';
when "0001" => AsmallerB <= '1';AgreaterB <= '0';AequalB <= '0';
when "0010" => AsmallerB <= '0';AgreaterB <= '1';AequalB <= '0';
when "0011" => AsmallerB <= '0';AgreaterB <= '0';AequalB <= '1';
when "0100" => AsmallerB <= '1';AgreaterB <= '0';AequalB <= '0';
when "0101" => AsmallerB <= '1';AgreaterB <= '0';AequalB <= '0';
when "0110" => AsmallerB <= '1';AgreaterB <= '0';AequalB <= '0';
when "0111" => AsmallerB <= '1';AgreaterB <= '0';AequalB <= '0';
when "1000" => AsmallerB <= '0';AgreaterB <= '1';AequalB <= '0';
when "1001" => AsmallerB <= '0';AgreaterB <= '1';AequalB <= '0';
when "1010" => AsmallerB <= '0';AgreaterB <= '1';AequalB <= '0';
when "1011" => AsmallerB <= '0';AgreaterB <= '1';AequalB <= '0';
when "1100" => AsmallerB <= '0';AgreaterB <= '0';AequalB <= '1';
when "1101" => AsmallerB <= '1';AgreaterB <= '0';AequalB <= '0';
when "1110" => AsmallerB <= '0';AgreaterB <= '1';AequalB <= '0';
when "1111" => AsmallerB <= '0';AgreaterB <= '0';AequalB <= '1';
when others => AsmallerB <= '0';AgreaterB <= '0';AequalB <= '0';
end case;
end process;
end RTL;
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询