完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}这个程序是实现四位数码显示灯亮的选择及数据的加减,不过我能力有限,还请大家帮我看看,优化一下在下感激不尽!!
{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:}{:soso_e100:} ---------------------------------------------------------------------------------- library IEEE; use IEEE.STD_LOGIC_1164.ALL; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; -- Uncomment the following library declaration if using -- arithmetic functions with Signed or Unsigned values --use IEEE.NUMERIC_STD.ALL; -- Uncomment the following library declaration if instantiating -- any Xilinx primitives in this code. --library UNISIM; --use UNISIM.VComponents.all; entity shuma is port (clk: in std_logic; btn : in std_logic_vector(4 downto 0); sel : out std_logic_vector(3 downto 0); led : out std_logic_vector(7 downto 0) --doutU,doutD, doutL,doutR : out std_logic ); end shuma; architecture Behavioral of shuma is signal count: std_logic_vector(50 downto 0); signal num1,num2,num3,num4,code :integer range -10 to 10; --signal btnUB,btnDB,btnLB:std_logic; signal dout: std_logic; signal btn_num :integer range 1 to 4; begin process(clk) begin if (clk'event and clk='1') then count<=count+1; end if; end process; process(count(16),btn) variable temp:integer range 0 to 110; begin if count(16)'event and count(16)='1' then temp:=temp+1; if(btn="00000") then --键未按下不开始计数,计数一直归零 temp:=0; end if; if temp>100 then --延迟100个周期再判断 dout<='1'; else dout<='0'; end if; end if; end process; process(dout) begin if dout'event and dout='1' then case btn is when"00100"=>num1<=num1+1; if num1>=9 then num1<=0; end if; when"00010"=>num1<=num1-1; if num1<=0 then num1<=9; end if; when others=> end case; end if; end process; process(dout) begin if dout'event and dout='1' then case btn is when "00001" => btn_num <= btn_num+1; when "01000" => btn_num <= btn_num-1; when others=> end case; end if; end process; process(btn_num) begin case btn_num is when 1=>sel<="1110"; when 2=>sel<="1101"; when 3=>sel<="1011"; when 4=>sel<="0111"; when others=> end case; end process; process(count) begin if (count(25)'event and count(25)='1') then code<=code+1; end if; end process; process( num1) begin case num1 is when 0 => led <="11000000"; --0 when 1 => led <="11111001"; --1 when 2 => led <="10100100"; --2 when 3 => led <="10110000"; --3 when 4 => led <="10011001"; --4 when 5 => led <="10010010"; --5 when 6 => led <="10000010"; --6 when 7 => led <="11111000"; --7 when 8 => led <="10000000"; --8 when 9 => led <="10010000"; --9 when others => end case; end process; end Behavioral; |
|
相关推荐
1 个讨论
|
|
你正在撰写讨论
如果你是对讨论或其他讨论精选点评或询问,请使用“评论”功能。
NVMe高速传输之摆脱XDMA设计50:主要功能测试结果与分析2 nvmePCIe高速存储
252 浏览 0 评论
NVMe高速传输之摆脱XDMA设计49:主要功能测试结果与分析1
1501 浏览 0 评论
907 浏览 0 评论
855 浏览 0 评论
658 浏览 0 评论
4427 浏览 63 评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 09:04 , Processed in 1.059967 second(s), Total 62, Slave 46 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1910