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!

glitch

Status
Not open for further replies.

meganwhite

Technical User
Nov 6, 2003
16
US
Hi guys I am using a code and getting glitch for the signal clrcntr, how can I remove the glitch?

The program is

lib...

..
...


process(clk, rst, clrcntr, count, cntr, cntr_en, etr, clr_32)
begin
if (rst = '1' or clrcntr = '1') then
cntr <= &quot;0000&quot;;
clrcntr <= '0';
etr <= '0';
elsif (clk'event and (clk = '1')) then
if (cntr_en = '1') then
cntr <= cntr + 1;
end if;

if (count = &quot;00&quot; and cntr = &quot;1111&quot;) then
etr <= '1';
elsif (count = &quot;01&quot; and cntr>= &quot;0111&quot;) then
etr <= '1';
elsif (count = &quot;10&quot; and cntr>= &quot;0011&quot;) then
etr <= '1';

end if;

if (etr = '1') then
eofr <= '0';

clrcntr <= '1';



end if;
end process;
 
Well for the moment there are two &quot;end if&quot; missing.

Anyway I would suggest a little redesign. First removing frome the sensistivity list anything but clk and rst, these two are enough for the clocked process indeed.

Then not mixing the reset with any other action. In this particular case presumably you want the clrcntr to operate in synchronous mode, whilst for this code it is asynchronous. And this one, together with clrcntr in the sensitivity list could be the reason for glitch indeed.

Please try this (plus add the two &quot;end if&quot;s !)

process(clk, rst)
begin
if (rst = '1') then
cntr <= &quot;0000&quot;;
clrcntr <= '0';
etr <= '0';
eofr <= '0'; --- or what ?

elsif (clk'event and clk = '1') then
if (clrcntr = '1') then
cntr <= &quot;0000&quot;;
clrcntr <= '0';
etr <= '0';

else
if (cntr_en = '1') then
cntr <= cntr + 1;
end if;

if (count = &quot;00&quot; and cntr = &quot;1111&quot;) then
etr <= '1';
elsif (count = &quot;01&quot; and cntr>= &quot;0111&quot;) then
etr <= '1';
elsif (count = &quot;10&quot; and cntr>= &quot;0011&quot;) then
etr <= '1';
end if; -- BTW it is all the same !!!
-- IF ... OR ... OR ... OR ... THEN
if (etr = '1') then
eofr <= '0';

clrcntr <= '1';


end if;
end if;
end process;


have fun ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top