VHDL组合设计实例详解
1. 32位模式依赖比较器
在进行32位输入比较时,单个比较器的速度可能有快有慢,但在本示例中暂不考虑速度问题。一种更高效的方法是仅对输入的30个高位进行一次比较,并使用依赖于模式的额外逻辑,必要时结合低位给出最终结果。
以下是32位模式依赖比较器的VHDL行为架构代码:
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
entity Vmodecmp is
port ( M: in STD_LOGIC_VECTOR (1 downto 0); -- mode
A, B: in STD_LOGIC_VECTOR (31 downto 0); -- unsigned integers
EQ, GT: out STD_LOGIC ); -- comparison results
end Vmodecmp;
architecture Vmodecmp_arch of Vmodecmp is
begin
process (M, A, B)
begin
case M is
when "00" =>
if A = B then EQ <= '1'; else EQ <= '0'; end if;
if A > B then GT <= '1'; else GT <= '0'; end if;
when "01"
超级会员免费看
订阅专栏 解锁全文
44

被折叠的 条评论
为什么被折叠?



