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

Reply

VHDL - Clock edge during unstable input

 
Thread Tools Search this Thread
Old 10-01-2003, 01:26 PM   #1
Default Clock edge during unstable input


Hello! I've been looking at the RTL schematic results of some synthesis and
realize that inputs aren't really synchronized with the clock, although the
process as such is completely synchronized (that is, everything takes place
inside a "if clk'event and clk = '1' then"). I am worried about what might
happen if an input is changing right at the moment of a clock rising edge -
is it possible that some receivers of the input signal will assume the new
value, while others will assume the old value?

Here is an example where the problem could arise:

Inputs:
* zeroes: std_logic_vector(1023 downto 0) -- always '0'
* ones: std_logic_vector(1023 downto 0) -- always '1'
* switch_signal: std_logic -- switches between '0' and '1'
Outputs:
* error: std_logic -- will signal this problem
Internal signals:
* buffer: std_logic_vector(1023 downto 0)

process(clk)
begin
if clk'event and clk = '1' then
if switch_signal = '1' then
buffer <= ones;
else
buffer <= zeroes;
end if;
end if;
error <= buffer(1023) xor buffer(0);
end process;

If zeroes is always an array of '0' and ones is always an array of '1'
during a simulation, then it would be impossible to get the error,
regardless of how I switch the switch_signal. But in reality, say that the
switch_signal net is changing from '0' to '1' and is not yet stable when a
positive clock edge occurs. Then some of the muxes feeding zeroes/ones to
buffer will still feed zeroes, while others will feed ones, so there may be
both zeroes and ones clocked into the buffer, and the error will occur.

Is this right, and if so, what can I do about it? Do I need to clock
switch_signal into an internal signal to get rid of the problem?

Finally, a more general question: This is an example of a problem that will
not be revealed in verification. Are there other such problems? Does anyone
know of a good book or a tutorial about all these things one should know
about?

/Jerker




Jerker Hammarberg \(DST\)
  Reply With Quote
Old 10-01-2003, 03:40 PM   #2
Egbert Molenkamp
 
Posts: n/a
Default Re: Clock edge during unstable input

"Jerker Hammarberg (DST)" <> wrote in message
news:3f7ac7f0$...
> Hello! I've been looking at the RTL schematic results of some synthesis

and
> realize that inputs aren't really synchronized with the clock, although

the
> process as such is completely synchronized (that is, everything takes

place
> inside a "if clk'event and clk = '1' then"). I am worried about what might
> happen if an input is changing right at the moment of a clock rising

edge -
> is it possible that some receivers of the input signal will assume the new
> value, while others will assume the old value?
>
> Here is an example where the problem could arise:
>
> Inputs:
> * zeroes: std_logic_vector(1023 downto 0) -- always '0'
> * ones: std_logic_vector(1023 downto 0) -- always '1'
> * switch_signal: std_logic -- switches between '0' and '1'
> Outputs:
> * error: std_logic -- will signal this problem
> Internal signals:
> * buffer: std_logic_vector(1023 downto 0)
>
> process(clk)
> begin
> if clk'event and clk = '1' then
> if switch_signal = '1' then
> buffer <= ones;
> else
> buffer <= zeroes;
> end if;
> end if;
> error <= buffer(1023) xor buffer(0);
> end process;
>
> If zeroes is always an array of '0' and ones is always an array of '1'
> during a simulation, then it would be impossible to get the error,
> regardless of how I switch the switch_signal. But in reality, say that the
> switch_signal net is changing from '0' to '1' and is not yet stable when a
> positive clock edge occurs. Then some of the muxes feeding zeroes/ones to
> buffer will still feed zeroes, while others will feed ones, so there may

be
> both zeroes and ones clocked into the buffer, and the error will occur.
>
> Is this right, and if so, what can I do about it? Do I need to clock
> switch_signal into an internal signal to get rid of the problem?


In real hardware you would indeed synchronize your asynchronous input signal
using an extra FF for switch_signal the way you describe above. Maybe you
even add two FFs in serie to reduce metastability.

Egbert Molenkamp








Egbert Molenkamp
  Reply With Quote
Old 10-02-2003, 02:52 AM   #3
Jim Wu
 
Posts: n/a
Default Re: Clock edge during unstable input
> Is this right, and if so, what can I do about it? Do I need to clock
> switch_signal into an internal signal to get rid of the problem?


Yes, you will need to synchronize switch_signal if it is asynchrous to the
clock. Normally people use two-stage FFs as the synchronizer. It will not
get rid of the problem completely, but will decrease the probability of
getting into metastability state.


Jim Wu
(remove capital letters)
http://www.geocities.com/jimwu88/chips




Jim Wu
  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
Wonderful data input with web reporting tool freezea Software 0 09-09-2009 05:30 AM
Post-Route Simulation does not give output for the first clock cycle Options velocityreviews Software 0 04-17-2007 05:47 PM
New Releases: Revelations, The Librarian & My Left Foot: Updated complete downloadable R1 DVD DB & Info lists Doug MacLean DVD Video 0 05-17-2005 06:57 AM
Hollywood Detective - The Buried Clock David Marsh DVD Video 1 09-27-2004 11:26 PM
DVD Recorder-DV input & Hard Drive ? Marion DVD Video 7 05-16-2004 06: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