小白提问,在用VHDL写流水灯实验的时候,灯一直亮着,显然是没有延时的,怎么去延时呢
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 led led led led led led led led led 'Z');
end case;
end process;
end Behavioral;
请大神们帮我看看错误
仿真?
你仿真有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 led led led led led led led led led 'Z');
end case;
end process;
end Behavioral;
利用计数来产生延时
已经解决了,谢谢
50000000周期,也够你亮一阵了,会暗的,等着吧…