完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
library ieee;
use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all; entity dl_control is port ( --时钟输入 clk : in std_logic ; --安锁 lock : in std_logic ; --输入密码 start : in std_logic; --报警复位 off_al : in std_logic; --修改密码 ps_ch : in std_logic; --密码确认 enter : in std_logic; --密码脉冲 ps_i : in std_logic; -- 比较结果 cmp_r : in std_logic; --完成密码输入指示 cin : in std_logic; --密码输入使能 code_en : out std_logic; --计数器清零 cnt_clr :out std_logic; --计数器时钟 cnt_clk : out std_logic ; --寄存器读/写信号 reg_wr : out std_logic; --钥匙信号 key : out std_logic; --报警信号 warn :out std_logic ); end dl_control; architecture behave of dl_control is --常量定义 constant key_active : std_logic :='1'; --状态机定义 --共7个状态,分别是:开锁,安锁,输入密码,密码初验正确,密码初验 --错误,报警及修改密码 type state_type is (outlock,inlock,ps_input,ps_right,ps_wrong,alARM,ps_change); signal state : state_type; begin --密码麻脉冲作为计数时钟 cnt_clk <= ps_i; ---------- --状态机 ---------- process(clk) begin if rising_edge(clk) then case state is --开锁状态 when outlock => --开锁 key<='0'; if lock = key_active then state<= inlock ; elsif ps_ch = key_active then state<= ps_change; else state<= outlock ; end if; --安锁状态 when inlock => -- 关锁 key <='1'; --禁止输入密码 code_en <= '0'; --清零计数器 cnt_clr <='1'; reg_wr <='0'; warn <='0'; if start = key_active then state <= ps_input; else state <= inlock ; end if ; --输入密码状态 when ps_input => --允许输入密码 code_en <= '1'; cnt_clr <='0'; --寄存器读使能 reg_wr <='0'; --密码位数和内容均正确 if cin='1' and ps_i ='1'and cmp_r='1' then code_en <= '0'; cnt_clr <= '1'; state <= ps_right; --密码出现错误 elsif ps_i ='1'and cmp_r='0' then code_en <= '0'; cnt_clr <= '1'; state <= ps_wrong; -- 在密码位数不足时,按enter键,则直接报警 elsif enter = key_active and cin = '0' then code_en <= '0'; cnt_clr <= '1'; state <= alarm; else state <= ps_input; end if; --密码初验正确状态 when ps_right => if enter = key_active then state <= outlock; else state <=ps_right; end if ; --密码初验错误状态 when ps_wrong => if enter = key_active then state <=alarm; else state <= ps_wrong; end if ; --报警状态 when alarm => if off_al = key_active then warn <= '0'; state <= inlock; else warn <= '1'; state <= alarm; end if; --修改密码状态 when ps_change => --允许输入密码 code_en <= '1'; cnt_clr <='0'; --寄存器写使能 reg_wr <='1'; --计数满且密码正确 if cin='1' then code_en <='0'; cnt_clr <= '1'; state <= outlock; end if ; when others => state <= inlock; end case ; end if ; end process; end behave; 这是密码锁 控制模块 为什么仿真出来不对 就是不管clk 高低电平 state 都是 1 啊 求解答 |
|
相关推荐
1个回答
|
|
求大神啊 来人啊 {:2:}{:2:}{:2:}{:2:}{:2:}{:2:}{:2:}
|
|
|
|
只有小组成员才能发言,加入小组>>
1268 浏览 0 评论
2035 浏览 0 评论
7787 浏览 0 评论
写了一个用DMA读取ADC数据的程序,记录下整个过程和一点心得
3171 浏览 0 评论
3434 浏览 0 评论
1218浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-9-14 08:25 , Processed in 0.436985 second(s), Total 50, Slave 42 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号