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

Reply

VHDL - Why is the last value used to detect the rising edge

 
Thread Tools Search this Thread
Old 09-04-2008, 01:43 AM   #1
Default Why is the last value used to detect the rising edge


Hi,
I see the following in a VHDL book and some web tutorial. It is used
to detect clk rising edge.
-----------------
if clk'event and clk'value='1' and clk'last_value='0'
then ...
-- to detect setup time
------------------
I think if clk'event(true) and clk'value='1', then clk'last_value will
be '0' unconditionally. That is, "clk'last_value='0'" is redundant. Is
it?








My question is a lot of process only uses the following to write clk
rising edge:


process (clk)
begin
if clk'event and clk='1'

end process;

I am confused with the above two usage.
Could you explain it for me? Thanks a lot.


fl
  Reply With Quote
Old 09-04-2008, 02:14 AM   #2
kennheinrich@sympatico.ca
 
Posts: n/a
Default Re: Why is the last value used to detect the rising edge
On Sep 3, 8:43 pm, fl <rxjw...@gmail.com> wrote:
> Hi,
> I see the following in a VHDL book and some web tutorial. It is used
> to detect clk rising edge.
> -----------------
> if clk'event and clk'value='1' and clk'last_value='0'
> then ...
> -- to detect setup time
> ------------------
> I think if clk'event(true) and clk'value='1', then clk'last_value will
> be '0' unconditionally. That is, "clk'last_value='0'" is redundant. Is
> it?
>
> My question is a lot of process only uses the following to write clk
> rising edge:
>
> process (clk)
> begin
> if clk'event and clk='1'
>
> end process;
>
> I am confused with the above two usage.
> Could you explain it for me? Thanks a lot.


Redundant? It depends on what the type of the clk signal is. If it's a
std_logic, then the check for '0' is *not* redundant. A signal of
type std_logic can have nine different values ('X', '0', '1', 'L',
'H', 'Z', etc). The check for '0' will, in simulation at least, cause
the code inside the "if" statement only to run on a clean 0-to-1
transition. It would be ignored on, for example, an 'X' to '1'
transition. On the other hand, if the signal is of type "bit", which
only has values '0' and '1', then it *is* redundant.

In a more practical sense, though, synthesizers (as opposed to
simulators) will treat the second form (clk'event and clk='1') as a
shorthand for referring to the regular rising edge clock of a real
hardware flip-flop, and ignore any nuances about nine-level
enumerations. For synthesis, I'd think of the clk'last_value='0' term
as redundant, and possibly even confusing to a dumber synthesizer.

- Kenn


kennheinrich@sympatico.ca
  Reply With Quote
Old 09-04-2008, 01:08 PM   #3
Peter
 
Posts: n/a
Default Re: Why is the last value used to detect the rising edge
On 4 Sep, 02:43, fl <rxjw...@gmail.com> wrote:
> Hi,
> I see the following in a VHDL book and some web tutorial. It is used
> to detect clk rising edge.
> -----------------
> if clk'event and clk'value='1' and clk'last_value='0'
> then ...
> -- to detect setup time
> ------------------
> I think if clk'event(true) and clk'value='1', then clk'last_value will
> be '0' unconditionally. That is, "clk'last_value='0'" is redundant. Is
> it?
>
> My question is a lot of process only uses the following to write clk
> rising edge:
>
> process (clk)
> begin
> if clk'event and clk='1'
>
> end process;
>
> I am confused with the above two usage.
> Could you explain it for me? Thanks a lot.


Use rising_edge(clk) instead.

/Peter


Peter
  Reply With Quote
Old 09-04-2008, 03:46 PM   #4
LittleAlex
 
Posts: n/a
Default Re: Why is the last value used to detect the rising edge
On Sep 3, 5:43*pm, fl <rxjw...@gmail.com> wrote:
> I think if clk'event(true) and clk'value='1', then clk'last_value will
> be '0' unconditionally. That is, "clk'last_value='0'" is redundant. Is
> it?


No. The 1st clock will have clk'last_value='U'.

There is probably some initialization that needs to occur.

Alex



LittleAlex
  Reply With Quote
Old 09-04-2008, 07:10 PM   #5
Andy
 
Posts: n/a
Default Re: Why is the last value used to detect the rising edge
On Sep 3, 7:43*pm, fl <rxjw...@gmail.com> wrote:
> I see the following in a VHDL book and some web tutorial.


Unfortunately there are a ton of books and tutorials that still use
archaic means of detecting the rising or falling edge of clocks. It
was only 15 years ago that standard functions rising_edge() and
falling_edge() were incorporated into the IEEE standard... These
functions correctly detect transitions to and from L and H also.

If, on the other hand, your example uses type bit/bit_vector, I don't
think these functions are defined for that data type, and the check
for last_value='0' is completely redundant.

Andy


Andy
  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
New releases: Hannibal Rising, Can't Hurry Love & Pan's Labyrinth: Updated complete downloadable R1 DVD DB & info lists Doug MacLean DVD Video 0 03-20-2007 04:55 AM
Last Day! FA: DTS INDEPENDENCE DAY ld, Sealed DEEP RISING dvd J Rusnak DVD Video 0 03-05-2006 12:50 AM
Last Hrs! Widescreen COLOSSUS:FORBIN PROJECT laserdisc, Sealed DEEP RISING dvd, GOOD, BAD,UGLY SE dvd J Rusnak DVD Video 0 02-19-2006 04:18 PM
FA: Widescreen COLOSSUS:FORBIN PROJECT laserdisc, Sealed DEEP RISING dvd, GOOD, BAD,UGLY SE dvd J Rusnak DVD Video 0 02-13-2006 04:43 AM
need app to detect ntsc or pal free2002 DVD Video 4 03-06-2004 09:41 AM




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