完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
刚开始学,突然不太清楚数码管动态显示问题了,写的程序不能同时显示4位数码管,时间还是听精确的
晶振50M LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; USE IEEE.STD_LOGIC_ARITH.ALL; USE IEEE.STD_LOGIC_UNSIGNED.ALL; ENtiTY CLOCK1 IS PORT(CLK:IN STD_LOGIC; DATAOUT:OUT STD_LOGIC_VECTOR(7 DOWNTO 0); EN_COM:OUT STD_LOGIC_VECTOR(3 DOWNTO 0)); END ENTITY; ARCHITECTURE BEHAVIORAL OF CLOCK1 IS SIGNAL CLK1,CLK2:STD_LOGIC; SIGNAL DATA:STD_LOGIC_VECTOR(7 DOWNTO 0); signal EN:STD_LOGIC_VECTOR(3 DOWNTO 0); SIGNAL COUNTER:INTEGER RANGE 0 TO 9; signal counter1:integer range 0 to 9; signal counter2:integer range 0 to 5; signal counter3:integer range 0 to 9; signal counter4:integer range 0 to 5; SIGNAL FIRST,SECOND,THIRD,LAST:STD_LOGIC:='0'; SIGNAL SEG:STD_LOGIC_VECTOR(3 DOWNTO 0); BEGIN DATAOUT<=DATA; EN_COM<=EN; seg<=third & second & first & LAST; PROCESS(CLK) VARIABLE X:INTEGER RANGE 0 TO 24999999; BEGIN IF clk'event and clk='1' THEN IF X<24999999 THEN X:=X+1; ELSE X:=0; CLK1<=NOT CLK1; END IF; END IF; END PROCESS; process(clk) VARIABLE y:INTEGER RANGE 0 TO 2000000; BEGIN IF clk'event and clk='1' THEN IF y<2000000 THEN y:=y+1; ELSE y:=0; CLK2<=NOT CLK2; END IF; END IF; END PROCESS; PROCESS(CLK1,LAST) BEGIN IF RISING_EDGE(CLK1)THEN IF(counter1=9 OR LAST='1')THEN COUNTER1<=0; FIRST<='1'; ELSE FIRST<='0'; counter1<=counter1+1; END IF; END IF; END PROCESS; PROCESS(FIRST) BEGIN IF first='1' THEN IF counter2=5 THEN counter2<=0; SECOND<='1'; ELSE SECOND<='0'; counter2<=counter2+1; END IF; END IF; END PROCESS; PROCESS(SECOND) BEGIN IF second='1' THEN IF counter3=9 THEN counter3<=0; THIRD<='1'; ELSE THIRD<='0'; counter3<=counter3+1; END IF; END IF; END PROCESS; PROCESS(THIRD) BEGIN IF third='1' THEN IF counter4=5 THEN counter4<=0; LAST<='1'; ELSE LAST<='0'; counter4<=counter4+1; END IF; END IF; END PROCESS; process(clk2,seg) begin if rising_edge(clk2) then case seg is when "0001" => en <= "1110"; when "0010" => en <= "1101"; when "0100" => en <= "1011"; when "1000" => en <= "0111"; when others => en <= "1110"; end case; end if; end process; PROCESS(EN) BEGIN CASE EN IS WHEN "1110"=> COUNTER <=COUNTER1; WHEN "1101"=> COUNTER <=COUNTER2; WHEN "1011"=> COUNTER <=COUNTER3; WHEN "0111"=> COUNTER <=COUNTER4; when others=> counter <=0; END CASE; end process; PROCESS(counter) BEGIN CASE COUNTER IS WHEN 0=> DATA <="01000000"; -- 0 WHEN 1=> DATA <="01111001"; -- 1 WHEN 2=> DATA <="00100100"; -- 2 WHEN 3=> DATA <="00110000"; -- 3 WHEN 4=> DATA <="00011001"; WHEN 5=> DATA <="00010010"; WHEN 6=> DATA <="00000010"; WHEN 7=> DATA <="01111000"; WHEN 8=> DATA <="00000000"; WHEN 9=> DATA <="00010000"; END CASE; end process; END BEHAVIORAL; |
|
相关推荐
2个回答
|
|
没事了,会了。位选扫描没写好
|
|
|
|
才女就是才女,一看就会
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
1368 浏览 1 评论
1167 浏览 0 评论
矩阵4x4个按键,如何把识别结果按编号01-16(十进制)显示在两个七段数码管上?
1374 浏览 0 评论
909 浏览 0 评论
2187 浏览 0 评论
1414 浏览 33 评论
5604 浏览 113 评论
浏览过的版块 |
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-21 00:25 , Processed in 0.551282 second(s), Total 74, Slave 57 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号