完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
library ieee;
use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity huxi is port(system_clk : in std_logic; -- clk_myself : out std_logic; led : out std_logic); end entity huxi; architecture asd of huxi is signal first_3125 : std_logic_vector(11 downto 0):="000000000000"; --first 3125000fen signal div_3125,div_625,div_125,div_25,div_50,div_100, clk_1,clk_2,clk_3,clk_4,clk_5,clk_6,clk_ms,led_ms:std_logic; signal clk_1ms : std_logic_vector(5 downto 0):="000000"; signal pwm:std_logic_vector(9 downto 0):="0000000000"; signal led_temp:integer range 0 to 9:=5; begin first_div:process(system_clk) is begin if(system_clk'event and system_clk='1')then if(first_3125="110000110101")then first_3125<="000000000000"; clk_1<=not clk_1; else first_3125<=first_3125+1; end if; end if; end process; second_div:process(div_3125) is --div to 6250 begin if(div_3125'event and div_3125='1')then clk_2<=not clk_2; end if; end process; third_div:process(div_625) is --div to 12500 begin if(div_625'event and div_625='1')then clk_3<=not clk_3; end if; end process; forth_div:process(div_125) is --div to 25000 begin if(div_125'event and div_125='1')then clk_4<=not clk_4; end if; end process; fifth_div:process(div_25) is --div to 50000 begin if(div_25'event and div_25='1')then clk_5<=not clk_5; end if; end process; sixth_div:process(div_50) is --div to 100000 begin if(div_50'event and div_50='1')then clk_6<=not clk_6; end if; end process; div_1ms:process(div_50) is begin if(div_50'event and div_50='1')then if(clk_1ms="110010")then clk_1ms<="000000"; clk_ms<=not clk_ms; else clk_1ms<=clk_1ms+1; end if; end if; end process; div_3125<=clk_1; div_625<=clk_2; div_125<=clk_3; div_25<=clk_4; div_50<=clk_5; div_100<=clk_6; led_ms<=clk_ms; pwm(4)<=div_100 and div_50; pwm(3)<=div_25 and pwm(4); pwm(2)<=div_125 and pwm(3); pwm(1)<=div_625 and pwm(2); pwm(0)<=div_3125 and pwm(1); pwm(9)<=not pwm(0); pwm(8)<=not pwm(1); pwm(7)<=not pwm(2); pwm(6)<=not pwm(3); led_huxi : process(led_ms) is begin if(led_temp=9)then led_temp<=0; else led_temp<=led_temp+1; end if; end process; led<=pwm(led_temp); end architecture asd; 分别将PWM(i)烧进板子里时灯的明暗程度是不同,但是加上循环就不行,要不就是灯一闪一闪要不就干脆不亮、、、新人求助啊、、、谢谢大家了! |
|
相关推荐 |
|
只有小组成员才能发言,加入小组>>
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-9-14 06:22 , Processed in 1.154787 second(s), Total 64, Slave 47 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号