集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 963|回复: 1

VHDL遇到一点困惑,求高手指点迷津

[复制链接]
理工大小白 发表于 2012-8-19 09:37:44 | 显示全部楼层 |阅读模式
我在尝试写一个矩阵键盘的代码,当某一个按键按下时,数码管对应输出一个数值,代码如下:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity key_led is
        port(
                clk:in std_logic;
                reset:in std_logic;
                keyin:in std_logic_vector(3 downto 0);
                keyoutut std_logic_vector(3 downto 0);
                dataut std_logic_vector(7 downto 0)
                );
end key_led;

architecture rtl of key_led is
signal count:integer range 0 to 3;
signal q:std_logic;
signal key:std_logic_vector(7 downto 0);
signal keyout_rec:std_logic_vector(3 downto 0);

begin
       
        process(clk,reset)
        begin
                if(clk 'event and clk='1')then
                        if(reset='0')then
                                count<=0;
                        elsif(q='1')then
                                if(count=3)then
                                        count<=0;
                                else
                                        count<=count+1;
                                end if;
                        else
                                null;
                        end if;
                end if;
        end process;
       
        process(count)
        begin
                case count is
                        when 0=>keyout_rec<="1110";
                        when 1=>keyout_rec<="1101";
                        when 2=>keyout_rec<="1011";
                        when 3=>keyout_rec<="0111";
                        when others=>null;
                end case;
        end process;
       
        process(clk)
        begin
                if(clk 'event and clk='0')then
                        if(keyin="1111")then
                                q<='1';
                        else
                                q<='0';
                        end if;
                end if;
        end process;
       
        key<=keyout_rec&keyin;
        keyout<=keyout_rec;
       
        process(key)
        begin
                        case key is
                                when "01111110"=>data<="11110011";
                                when "01111101"=>data<="01001001";
                                when "01111011"=>data<="01100001";
                                when "01110111"=>data<="00110011";
                                when "10111110"=>data<="00100101";
                                when "10111101"=>data<="00000101";
                                when "10111011"=>data<="11110001";
                                when "10110111"=>data<="00000001";
                                when "11011110"=>data<="00100001";
                                when "11011101"=>data<="00010001";
                                when "11011011"=>data<="00000111";
                                when "11010111"=>data<="10001101";
                                when "11101110"=>data<="01000011";
                                when "11101101"=>data<="00001101";
                                when "11101011"=>data<="00011101";
                                when "11100111"=>data<="10000001";
                                when others=>null;
                        end case;
        end process;
                               
end rtl;
但是在功能仿真的时候却出现这种情况,data会输出一些case语句中没有的数据(图片附件),实在不明白问题在哪儿,求解啊~~

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?我要注册

x
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|fpga论坛|fpga设计论坛 ( 京ICP备20003123号-1 )

GMT+8, 2025-6-26 06:15 , Processed in 0.063908 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表