首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

[求助]

[求助]

各位答人,小弟初学乍练,想求一个计数显示电路(VHDL),键盘接口显示电路(VHDL)。 计数显示电路部分可逆计数电路(10进制)计数最大值256即可,显示电路用三个数码管。最高频率4M; 键盘接口显示电路部分3乘4键盘,0-9和两个功能键(清零,计数)。显示电路三位数码管分别致入。 如果哪位大哥肯帮忙,十分感谢。我的邮箱:BRIGHT_FW@yahoo.com.cn 我做了两个程序,但都是component调用有问题。 键盘接口显示电路: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; library altera; use altera.maxplus2.all; entity debouncing is port ( d_in,clk :in std_logic; dd1,dd0,qq1,qq0ut std_logic; d_out,d_out1ut std_logic ); end debounce; architecture a of debounce is signal vcc,inv_d:std_logic; signal d1,d0:std_logic; begin vcc<='t', inv_d<=not d_in; dff1:dff port map (d=>vcc,q=>q0,clk=>clk,clrn=>inv_d,prn=>vcc); dff2:dff port map (d=>vcc,q=>q1,clk=>clk,clrn=>inv_d,prn=>vcc); process(clk) begin if clk'event and clk='1' thn d0<=not q1; d1<=d0; end if; end process; d_out<=not(d1 and not d0); end a; ibrary ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; library altera; use altera.maxplus2.all; entity keyboard is port ( clk_4m:in std_logic; --系统原始时钟脉冲 key_in:in std_logic_vector(2 downto 0); --按键输入 clk_scanut std_logic_vector(3 downto 0); --扫描序列 out_numbut std_logic_vector(3 downto 0); --数字输出 out_funcut std_logic_vector(3 downto 0); --功能输出 flag_numbut std_logic; --数字输出标志 flag_funcut std_logic; --功能输出标志 clk_debunceut std_logic; --弹跳电路取样时钟脉冲 clk_displayut std_logic_vector(1 downto 0) --显示器扫描信号 ); end keyboard; architecture a of keyboard is component debunce port( clk :in std_logic; d_in :in std_logic; d_out ut std_logic); end component; signal clk :std_logic; --电路工作时钟脉冲(4m降频而来) signal c_keyboard:std_logic_vector(1 downto 0); signal c_debunce:std_logic; signal c_display :std_logic_vector(1 downto 0); signal c :std_logic_vector(2 downto 0); signal n :std_logic_vector(3 downto 0); signal t :std_logic_vector(3 downto 0); signal fn :std_logic; signal ff :std_logic; signal sel :std_logic_vector(3 downto 0); begin --connection 管脚信号连接 out_numb<=n; out_func<=t; flag_numb<=fn; flag_func<=ff; clk_debunce<=c_debunce; clk_display<=c_display; c_debunce<=clk; --产生不同频率的信号 counter:block signal q :std_logic_vector(19 downto 0); signal s:std_logic_vector(1 downto 0); signal sel:std_logic_vector(3 downto 0); begin process(clk_4m) begin if clk_4m'event and clk_4m='1'then q<=q+1; end if; --c_keyboard<=q(18 downto 17); --c_debunce<=q(14); --c_dispaly<=q(18 downto 17); c_keyboard<=q(5 downto 4); clk<=q(0); c_display<=q(5 downto 4); end process; sel<="1110"when c_keyboard=0 else "1101"when c_keyboard=1 else "1011"when c_keyboard=2 else "0111"when c_keyboard=3 else "1111"; clk_scan<=sel; end block counter; --debunce ckt debunce:block begin u1:debunce port map( d_in=>key_in(0), d_out=>c(0), clk=>c_debunce ); u2:debunce port map( d_in=>key_in(1), d_out=>c(1), clk=>c_debunce ); u3:debunce port map( d_in=>key_in(2), d_out=>c(2), clk=>c_debunce ); end block debunce; --key_decoder key_decoder:block signal z:std_logic_vector(4 downto 0); begin process(clk) begin z<=c_keyboard&c; --数字按键编码 if clk'event and clk='1' then case z is when"11101"=>n<="0000";--0 when"00011"=>n<="0001";--1 when"00101"=>n<="0010";--2 when"00110"=>n<="0011";--3 when"01011"=>n<="0100";--4 when"01101"=>n<="0101";--5 when"01110"=>n<="0110";--6 when"10011"=>n<="0111";--7 when"10101"=>n<="1000";--8 when"10110"=>n<="1001";--9 when others =>n<="1111"; end case; end if; --功能按键编码 if clk'event and clk='1' then case z is when"11011"=>t<="0100";--*_clear when"11110"=>t<="0001";--#_count when others=>t<="1000"; end case; end if; --out_func<=t; end process; fn<=not (n(3) and n(2) and n(1) and n(0)); --产生数字按键标志 ff<=t(2) or t(0); --产生功能按键标志 end block key_decoder; end a; 可以给我指点一下,或是给我一个例程都十分感谢。[em17]
返回列表