When I make the counter with DLL, I used the below two code, but when clock goes higher, the second code didn't work. Can anyone tell me why?
thank you
first ,
process (clk, rst)
begin
if rst ='1' then
counter <= (others => '0);
elsif clk'event and clk='1' then
counter <= counter +1;
end if;
end process;
second,
process (clk, rst)
begin
if rising_edge(clk) then
if rst ='1' then
counter <= (others =>'0');
else
counter <= counter +1;
end if;
end process;
Yes, as ankit said, first code has Asynchronous reset whereas the second one has Synchronous reset. Both the schemes are ok and both are supposed to work. When you say the second code didn't work, does it mean it didn't work in simulation or it didn't work on board?
Well, one small thing...... the reset pulse width should be more than the clock period for the second code.
process (clk, rst)
begin
if rising_edge(clk) then
if rst ='1' then
counter <= (others =>'0');
else
counter <= counter +1;
end if;
end if; --<---- added line
end process;
and remember that it uses synchronous reset. it will be better if you keep "rst" in the sensitivity list.