基于fpga的密码锁设计_第1页
基于fpga的密码锁设计_第2页
基于fpga的密码锁设计_第3页
基于fpga的密码锁设计_第4页
基于fpga的密码锁设计_第5页
已阅读5页,还剩1页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity fen_pin isport( clk:in std_logic; clk_1ms:out std_logic; clk_10ms:out std_logic);end fen_pin;architecture FF2 of fen_pin issignal Q0:std_logic_vector(16 downto 0);signal Q1:std_logic_vector(17 downto 0);signal c0:std_log

2、ic;signal c1:std_logic;beginprocess(clk) begin if clk'event and clk='1' then if Q0=50000 then -1ms Q0<="00000000000000000" c0<=not c0; else Q0<=Q0+1; end if; if Q1=250000 then c1<=not c1; -10ms Q1<="000000000000000000" else Q1<=Q1+1; end if; end if;

3、end process;clk_1ms<=c0;clk_10ms<=c1;end FF2;-FEN PINlibrary ieee;use ieee.std_logic_1164.all;entity an_jian isport(clk_10ms:in std_logic;-时钟 col:in std_logic_vector(3 downto 0);-列扫描输入 row:out std_logic_vector(3 downto 0);-行扫描输出 keyout:out std_logic_vector(3 downto 0);-编码输出end an_jian;architec

4、ture FF1 of an_jian issignal rowreg: std_logic_vector(3 downto 0);signal con : std_logic_vector(7 downto 0);beginprocess(clk_10ms) begin if clk_10ms'event and clk_10ms= '1' then case rowreg is when "0111" => rowreg<= "1011" when "1011" => rowreg<

5、= "1101" when "1101" => rowreg<= "1110" when "1110" => rowreg<= "0111" when others => rowreg<= "0111" end case; end if;end process;row <= rowreg; -输出行扫描信号con <= rowreg & col;-合并行列信号process(clk_10ms) begin if clk_

6、10ms'event and clk_10ms= '1' then case con is when "11100111" => keyout<= "0001"-1 when "11101011" => keyout<= "0010"-2 when "11101101" => keyout<= "0011"-3 when "11101110" => keyout<= "010

7、0" -4 when "11010111" => keyout<= "0101"-5 when "11011011" => keyout<= "0110"-6 when "11011101" => keyout<= "0111"-7 when "11011110" => keyout<= "1000"-8 when "10110111" => keyou

8、t<= "1001"-9 when "10111011" => keyout<= "0000"-0 when "10111101" => keyout<= "1010"-10 when "10111110" => keyout<= "1011" -11 when "01110111" => keyout<= "1100"-12 when others =>

9、keyout<="1111"end case; end if; end process;end FF1;-AN JIANlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity an_jian_chu_li2 isport( clk_1ms:in std_logic; keyin:in std_logic_vector(3 downto 0); clk_key:out std_logic);end an_jian_chu_li2;architecture FF3 of

10、 an_jian_chu_li2 is signal key_temp:std_logic_vector(3 downto 0);signal count:std_logic_vector(9 downto 0);signal qq:std_logic;begin process(clk_1ms,count,key_temp,keyin) begin if keyin/="1111" then if clk_1ms'event and clk_1ms='0' then if key_temp=keyin then if count<1000 t

11、hen count<=count+1; else key_temp<="1111" end if; else key_temp<=keyin; count<="0000000000" end if; end if; end if; end process;qq<='1' when count>15 and count <30 else '0'clk_key<=qq;end FF3;-AN JIAN CHU LIlibrary ieee;use ieee.std_logic_1

12、164.all;use ieee.std_logic_unsigned.all;entity bi_jiao isport(clk_key:in std_logic; keyin:in std_logic_vector(3 downto 0); led_r,led_b:out std_logic);end bi_jiao;architecture FF4 of bi_jiao issignal key_temp:std_logic_vector(3 downto 0);signal count:std_logic_vector(1 downto 0);signal mi:std_logic_v

13、ector(11 downto 0);signal reg:std_logic_vector(11 downto 0);begin process(clk_key,keyin) begin if keyin/="1111" then if clk_key'event and clk_key='1' then if keyin=12 then count<="00"mi<="000000000000" led_r<='1'led_b<='1' else if

14、 count=0 then mi(11 downto 8)<=keyin; count<=count+1; elsif count=1 then mi(7 downto 4)<=keyin; count<=count+1; elsif count=2 then mi(3 downto 0)<=keyin; count<=count+1;else null; if count=3 and keyin=10 then reg<=mi; led_r<='0'led_b<='0' elsif keyin=11 the

15、n if reg=mi then led_r<='0'led_b<='1' else led_r<='1'led_b<='0' if mi="001100010100" then -密码314 led_r<='0'led_b<='1' end if; end if;end if; end if;end if;end if;end if; end process;end FF4;-BI JIAOlibrary IEEE;use IEEE.std_

16、logic_1164.all;use IEEE.std_logic_unsigned.all; entity MMS isport( clk:in std_logic; col:in std_logic_vector(3 downto 0);-列扫描输入 row:out std_logic_vector(3 downto 0);-行扫描输出 led_b,led_r:out std_logic);end MMS;architecture one of MMS iscomponent fen_pinport( clk:in std_logic; clk_1ms:out std_logic; clk

17、_10ms:out std_logic);end component;component an_jian port(clk_10ms:in std_logic;-时钟 col:in std_logic_vector(3 downto 0);-列扫描输入 row:out std_logic_vector(3 downto 0);-行扫描输出 keyout:out std_logic_vector(3 downto 0);-编码输出end component;component an_jian_chu_li2port(clk_1ms:in std_logic; keyin:in std_logic_vector(3 downto 0); clk_key:out std_logic);end component;component bi_jiao port(clk_key:in std_logic; keyin:in std_logic_vector(3 downto 0); led_r,led_b:out std_logic);end component;signal a,b,d:std_logic;signal c,f:std_logic_vector(3 downto 0);beginG1:fen_pin port map(clk

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论