⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 compare.vhd

📁 基础性试验 实践性试验 综合性试验 提升性试验 交通灯设计
💻 VHD
字号:
--**                       比 较 器 						        **--

--文件名:compare.vhd

--功  能:比较两组数据的大小

--说  明:以拨盘开关作为数据输入端,用发光二极管来表示两组数据的大小,

--        当左边的数据>右边的数据时左边的四位发光二极管亮;

--	     当右边的数据>左边的数据时右边的四位发光二极管亮;

--        当左边的数据=右边的数据时发光二极管全亮;

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity compare is
    Port (datain : in std_logic_vector(7 downto 0);   --高四位和低四位比较
	       cs     : out std_logic_vector(1 downto 0);	--数码管、发光二极管片选信号;
			 dataout: out std_logic_vector(7 downto 0));
end compare;

architecture Behavioral of compare is

begin

cs<="01";     --选通发光二极管;

process(datain)
begin
   if datain(3 downto 0)>datain(7 downto 4) then
	   dataout<="00001111";

   elsif datain(3 downto 0)=datain(7 downto 4) then
	   dataout<="00000000";

   else dataout<="11110000";
	end if;
end process;
end Behavioral;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -