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

📄 code_p.vhd

📁 一些很好的FPGA设计实例
💻 VHD
字号:
--**                    优 先 编 码 器 						        **--

--文件名:code_p.vhd

--功  能:对数据进行优先编码

--说  明:以拨盘开关作为数据输入端,用发光二极管的后3位来表示编码后的信息;

--        datain(0)-datain(7) 分别对应拨盘开关上的1-8号键;

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

entity code_p 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 code_p;

architecture Behavioral of code_p is

begin

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

dataout(7 downto 3)<="11111";

process(datain)
begin
   if datain(0)='0' then 											--0;
	                        dataout(2 downto 0)<="000";
	elsif datain(1)='0' then										--1
	                        dataout(2 downto 0)<="001";
	elsif datain(2)='0' then										--2
	                        dataout(2 downto 0)<="010";
	elsif datain(3)='0' then										--3
	                        dataout(2 downto 0)<="011";
	elsif datain(4)='0' then										--4
	                        dataout(2 downto 0)<="100";
	elsif datain(5)='0' then										--5
	                        dataout(2 downto 0)<="101";
	elsif datain(6)='0' then										--6
	                        dataout(2 downto 0)<="110";
	elsif datain(7)='0' then										--7
	                        dataout(2 downto 0)<="111";
   else dataout(2 downto 0)<="111";
	end if;   
end process;

end Behavioral;

⌨️ 快捷键说明

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