Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

counter problem

Status
Not open for further replies.

Kriki

Technical User
Aug 9, 2004
15
AT
I try to program a counter who counts the clock'edges between the signal changes. The problem is that when the the next change occours, the counter doesn't reset back to 0.
Can anyone help me with that ??


process(lastdata, data, cclk, test, change, clk, i, rs)
begin
change <= data xor lastdata;
if (rs = '1') then
i <= 0;
elsif(rising_edge(clk)) then
i <= i + 1;
end if;
if(rising_edge(change)) then
if( i >= 5) then
test <= '1';
else test <= '0';
end if;
end if;
if(change = '1') then
rs <= '1';
else rs <= '0';
end if;
lastdata <= data;
end process;

Regards, Kriki
 
i think that you need after the test to add i=0.
if(rising_edge(change)) then
if( i >= 5) then
test <= '1';
else test <= '0';
i=0;
end if;
this could help if you had some comments
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top