| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2289 人关注过本帖
标题:vhdl如何实现用三个按键对数码管进行加减和移位
只看楼主 加入收藏
钟小小
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2019-5-23
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
vhdl如何实现用三个按键对数码管进行加减和移位
按第一个按键则数码管数字加一,按第二个按键则数码管数字减一,按第三个则数字左移,在最右边输入

add_outside: process(clk,reset_all)   --key1:按键加一,后半部分为当清屏信号到来时,外部输入密码置0
      begin
        if(key1'event and key1='0') then
           key1_clear <= '1';
            case location is
              when "00" => bit_one_out <= bit_one_out + 1;
                if(bit_one_out = 9) then
                   bit_one_out <= 0;
                  end if;
                when "01" => bit_two_out <= bit_two_out + 1;
                 if(bit_two_out = 9) then
                    bit_two_out <= 0;
                  end if;
                when "10" => bit_three_out <= bit_three_out + 1;
                 if(bit_three_out = 9) then
                    bit_three_out <= 0;
                  end if;
                when "11" => bit_four_out <= bit_four_out + 1;
                 if(bit_four_out = 9) then
                    bit_four_out <= 0;
                  end if;
            end case;
          end if;
          if(clear_num=0) then
            key1_clear <= '0';
          end if;
          if(reset_all='1') then
            bit_one_out <= 0;
             bit_two_out <= 0;
             bit_three_out <= 0;
             bit_four_out <= 0;
          end if;
  end process add_outside;
  
  sub_outside: process(clk,reset_all)  --key2
   begin
        if(key2'event and key2='0') then
           key2_clear <= '1';
            
            case location is
              when "00" => bit_one_out <= bit_one_out - 1;
                if(bit_one_out = 0) then
                   bit_one_out <= 9;
                  end if;
                when "01" => bit_two_out <= bit_two_out - 1;
                 if(bit_two_out = 0) then
                    bit_two_out <= 9;
                  end if;
                when "10" => bit_three_out <= bit_three_out - 1;
                 if(bit_three_out = 0) then
                    bit_three_out <= 9;
                  end if;
                when "11" => bit_four_out <= bit_four_out - 1;
                 if(bit_four_out = 0) then
                    bit_four_out <= 9;
                  end if;
            end case;
         
          end if;
          if(clear_num=0) then
            key2_clear <= '0';
          end if;
         
    end process sub_outside;
此程序出错,不可以在两个进程对同一个赋值
搜索更多相关主题的帖子: 按键 数码管 then end if 
2019-05-23 20:55
xinjie
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:19
帖 子:277
专家分:520
注 册:2007-8-11
收藏
得分:10 
走错门了。。。。。
2019-05-23 21:05
快速回复:vhdl如何实现用三个按键对数码管进行加减和移位
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016381 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved