Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Electronic Equipment > VHDL > What am I missi...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 6082 of 6417
Post > Topic >>

What am I missing... again?

by rickman <gnuarm@[EMAIL PROTECTED] > Jun 15, 2008 at 09:39 PM

I wrote this debounce code and it did not behave the way I expected...

(btw, 'i' was used in a loop and the 5 was used outside of the loop
for a quick test)

		if (EdgeDet(SW_D(i), SW_DD(i))) then
		  DebCntr(i)	<= to_unsigned(Deb_Max_Cnt, 19);
		  if (DebCntr(i) = 0) then
			Deb(i)		<= SW_DD(i);
		  end if;
		elsif (DebCntr(i) /= 0) then
		  DebCntr(i)	<= DebCntr(i) - 1;
		end if;

SW_D is the value of SW run through one FF.  SW_DD is the value run
through a second FF.  EdgeDet is defined to return either a boolean or
an SLV and is defined for a boolean as...

  function EdgeDet (Val, Val_D : STD_LOGIC) return Boolean is
  begin
	return (Val = '1' xor Val_D = '0');
  end EdgeDet;


The above code seems to set the counter to the max value by default
and let it count down by one when an edge is detected on SW.  It is
supposed to do the opposite.

T try to debug the issue, I pulled the edge detect function outside
and assigned it to a signal...

  SwEdge(5) <= std_logic(EdgeDet(SW_D(5), SW_DD(5)));

		if (SwEdge(i) = '1') then
		  DebCntr(i)	<= to_unsigned(Deb_Max_Cnt, 19);
		  if (DebCntr(i) = 0) then
			Deb(i)		<= SW_DD(i);
		  end if;
		elsif (DebCntr(i) /= 0) then
		  DebCntr(i)	<= DebCntr(i) - 1;
		end if;

This worked correctly!!!  Obviously there is something I am missing
here.  I am 99.9% sure I did not change the meaning of the code by
these changes.  But obviously did.

Rick
 




 3 Posts in Topic:
What am I missing... again?
rickman <gnuarm@[EMAIL  2008-06-15 21:39:24 
Re: What am I missing... again?
Thomas Stanka <usenet_  2008-06-15 22:16:48 
Re: What am I missing... again?
rickman <gnuarm@[EMAIL  2008-06-16 17:24:41 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Dec 1 15:56:52 CST 2008.