Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - What am I missing... again?

 
Thread Tools Search this Thread
Old 06-16-2008, 05:39 AM   #1
Default What am I missing... again?


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


rickman
  Reply With Quote
Old 06-16-2008, 06:16 AM   #2
Thomas Stanka
 
Posts: n/a
Default Re: What am I missing... again?
On 16 Jun., 06:39, rickman <gnu...@gmail.com> wrote:
> if (EdgeDet(SW_D(i), SW_DD(i))) then

[..]
> SwEdge(5) <= std_logic(EdgeDet(SW_D(5), SW_DD(5)));


> 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.


An obvious change of the code is that second sollution will execute
the content of the if..then..else path be at least one simulation
delta later. I suppose it is executed one clock cycle later.

bye Thomas



Thomas Stanka
  Reply With Quote
Old 06-17-2008, 01:24 AM   #3
rickman
 
Posts: n/a
Default Re: What am I missing... again?
On Jun 16, 1:16 am, Thomas Stanka <usenet_nospam_va...@stanka-web.de>
wrote:
> On 16 Jun., 06:39, rickman <gnu...@gmail.com> wrote:
>
> > if (EdgeDet(SW_D(i), SW_DD(i))) then

> [..]
> > SwEdge(5) <= std_logic(EdgeDet(SW_D(5), SW_DD(5)));
> > 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.

>
> An obvious change of the code is that second sollution will execute
> the content of the if..then..else path be at least one simulation
> delta later. I suppose it is executed one clock cycle later.


Thanks,

I don't know what I was thinking. When I read your post I thought I
must have mis-copied the code from the editor, and now I can't
recreate the problem. So I must have had a weird typo in the code and
the editing fixed it without my realizing it.

I find that the simulator will ignore some errors and synthesis will
ignore some errors, and they are not the same errors! Once I had a
bit constant of "0002" when I meant "0010" and the synthesis engine
took it! I have no idea what it created from that. But when it
didn't work I tried it in the simulator and of course it flagged the
error right away.

I guess I shouldn't code so late at night...

Rick :^)




rickman
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
please help!don't understand!! tcp/ip stack is missing or corrupted??? rainie General Help Related Topics 4 10-18-2006 10:03 PM
Missing NTLDR, etc on Win XP Pro,Tried everything, HELP! James A+ Certification 0 01-12-2005 02:12 AM
New Releases: Terminal, Missing & Forbin Project: Updated complete downloadable R1 DVD DB & info lists Doug MacLean DVD Video 1 09-22-2004 12:57 AM
Why is there Footage Missing from the Matrix DVD? Paul DVD Video 2 02-15-2004 04:07 AM
DVD rip is shorter than the original and the Divx encode is evenshorter with missing microchunks - help? gaffo DVD Video 10 09-25-2003 02:31 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46