完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
entity led_water is
port( clk : in std_logic; rst : in std_logic; led : out std_logic_vector(7 downto 0) ); end led_water; architecture Behavioral of led_water is signal clk1 : std_logic; --建立中间时钟信号 begin P1: process(clk,rst) --进程1 对时钟信号进行N分频 variable count : integer range 0 to 50000000 := 0; variable count1 : std_logic := '0'; begin if (rst = '1') then --如果有复位信号 count := 0; elsif(clk'event and clk = '1') then --如果clk上升沿到来 count := count + 1; if(count = 50000000) then count := 0; end if; count1 := not count1; --时钟信号翻转 clk1 <= count1; end if; end process; P2: process(clk1) --对分频信号进行计数,进而控制LED灯亮灭 variable count2 : integer range 0 to 8 := 0; begin if(clk1'event and clk1 = '1') then count2 := count2 + 1; if (count2 = 8) then count2 := 0; end if; end if; case count2 is when 0 => led <= "00000001"; when 1 => led <= "00000010"; when 2 => led <= "00000100"; when 3 => led <= "00001000"; when 4 => led <= "00010000"; when 5 => led <= "00100000"; when 6 => led <= "01000000"; when 7 => led <= "10000000"; when others => led <= (others => 'Z'); end case; end process; end Behavioral; 请大神们帮我看看错误 |
|
相关推荐
7个回答
|
|
仿真? 你仿真有40000000个周期吗? 如果仿真,不妨先暂时把分频改成很小。
最佳答案
|
|
|
|
最近才开始学习,有不懂的地方希望大神们帮助一下
|
|
|
|
你这是二分频;clk1频率太高。
if(count = 50000000) then count := 0; count1 := not count1; --时钟信号翻转 end if; |
|
|
|
麻烦您能帮我看看嘛?我改过之后,仿真有输入,输出不变化了,有问题,谢谢您 entity led_water is port( clk : in std_logic; led : out std_logic_vector(7 downto 0) ); end led_water; architecture Behavioral of led_water is signal clk1 : std_logic; --建立中间时钟信号 begin process(clk) --进程1 对时钟信号进行N分频 variable count : natural range 0 to 40000000 := 0; variable count1 : std_logic := '0'; begin if(clk'event and clk = '1') then --如果clk上升沿到来 if(count = 40000000) then count := 0; clk1 <= clk1; else count := count + 1; end if; end if; end process; process(clk1) --对分频信号进行计数,进而控制LED灯亮灭 variable count2 : integer range 0 to 8 := 0; begin if(clk1'event and clk1 = '1') then count2 := count2 + 1; if (count2 = 8) then count2 := 0; end if; end if; case count2 is when 0 => led <= "00000001"; when 1 => led <= "00000010"; when 2 => led <= "00000100"; when 3 => led <= "00001000"; when 4 => led <= "00010000"; when 5 => led <= "00100000"; when 6 => led <= "01000000"; when 7 => led <= "10000000"; when others => led <= (others => 'Z'); end case; end process; end Behavioral; |
|
|
|
利用计数来产生延时
|
|
|
|
|
|
|
|
50000000周期,也够你亮一阵了,会暗的,等着吧…
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
169 浏览 0 评论
1397 浏览 1 评论
469 浏览 0 评论
求FPGA 驱动控制ltc2271 或者 ltc2180 或者 ltc2190或者 ltc2202 的代码
2090 浏览 0 评论
530 浏览 0 评论
4945 浏览 111 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-9-12 07:17 , Processed in 0.556138 second(s), Total 53, Slave 46 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191