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

Reply

VHDL - Passing a signal from slow to fast clock

 
Thread Tools Search this Thread
Old 05-18-2005, 05:07 PM   #1
Default Passing a signal from slow to fast clock


Hi,
I've looked over the discussion in the forum on passing signal between
clock domains and read Clifford Cummings paper on asynchronous clock
design and coded a synchronizer circuit.

The problem is the I have a pulse coming in from a slow clock and this
has to be sampled by the fast clk which could lead to the signal being
active for more than 1 clk cycle in the fast clk.
So I've added edge detection in the synchronizer circuit. I think this
should do the trick. Can I get some expert opinion if this is correct
since it seems there is no way to thoroughly test a sync circuit
(easily).

port(
pCLK : in std_logic;
NEWLINE_v : in std_logic;
NEWLINE_p : out std_logic
);
end sync_v2p;

architecture RTL of sync_v2p is
signal stage1fifo,
stage2fifo,
pulsefifo : std_logic;

begin
process(pCLK) is
begin
if (pCLK = '1' and pCLK'event) then

-- perform two stage synchronization
-- as in SNUG2001 paper by Clifford Cummings
stage1fifo <= NEWLINE_v;
stage2fifo <= stage2fifo;

-- add third stage for edge detection
pulsefifo <= stage2fifo;

-- detect edge and assign output
if (stage2fifo = '1' and pulsefifo = '0') then
NEWLINE_p <= '1';
else
NEWLINE_p <= '0';
end if;

end if;
end process;
end RTL;

Also if I don't do edge detection in the sync circuit but use the
following piece of code in my block will it work and synthesize? (just
curious)

if (pCLK = '1 and pCLK'event) then
-- assume synchronizer is only 2 stage
-- and no edge detection is done in synchronizer
-- detect edge here
if (NEWLINE_p = '1' and NEWLINE_P'event) then

...

end if;

I have never seen 'event being used anywhere except for the clk which
is why I am asking this.

Thanks,
Divyang M



Divyang M
  Reply With Quote
Old 05-18-2005, 06:38 PM   #2
Divyang M
 
Posts: n/a
Default Re: Passing a signal from slow to fast clock
Just a correction above in a typo..
it should be

stage1fifo <= NEWLINE_v;
stage2fifo <= stage1fifo;



Divyang M
  Reply With Quote
Old 05-19-2005, 07:44 AM   #3
Neo
 
Posts: n/a
Default Re: Passing a signal from slow to fast clock
divyang,
You are just checking for the rising edge of the data but not the
duration. so your output will always be one clock cycle in faster
domain even if the data remains high for multiple clock cycles in the
slower domain. This modification should check for that:
if ((stage2fifo = '1' and pulsefifo = '0') or stage1fifo = '1') then
---
---
However I am not very sure if its good idea to take the 'OR' of
stage1fifo or to put one more FF in faster domain and take its value
for ORING.



Neo
  Reply With Quote
Old 05-19-2005, 04:33 PM   #4
Jim Lewis
 
Posts: n/a
Default Re: Passing a signal from slow to fast clock
Divyang,
> > if (NEWLINE_p = '1' and NEWLINE_P'event) then

Use 'event only with clocks. They imply connection
to the clock input of a flip-flop.

Better yet if all your clock signals are std_logic, use
the rising_edge function:

if rising_edge(Clk) then

Cheers,
Jim

> I've looked over the discussion in the forum on passing signal between
> clock domains and read Clifford Cummings paper on asynchronous clock
> design and coded a synchronizer circuit.
>
> The problem is the I have a pulse coming in from a slow clock and this
> has to be sampled by the fast clk which could lead to the signal being
> active for more than 1 clk cycle in the fast clk.
> So I've added edge detection in the synchronizer circuit. I think this
> should do the trick. Can I get some expert opinion if this is correct
> since it seems there is no way to thoroughly test a sync circuit
> (easily).
>
> port(
> pCLK : in std_logic;
> NEWLINE_v : in std_logic;
> NEWLINE_p : out std_logic
> );
> end sync_v2p;
>
> architecture RTL of sync_v2p is
> signal stage1fifo,
> stage2fifo,
> pulsefifo : std_logic;
>
> begin
> process(pCLK) is
> begin
> if (pCLK = '1' and pCLK'event) then
>
> -- perform two stage synchronization
> -- as in SNUG2001 paper by Clifford Cummings
> stage1fifo <= NEWLINE_v;
> stage2fifo <= stage2fifo;
>
> -- add third stage for edge detection
> pulsefifo <= stage2fifo;
>
> -- detect edge and assign output
> if (stage2fifo = '1' and pulsefifo = '0') then
> NEWLINE_p <= '1';
> else
> NEWLINE_p <= '0';
> end if;
>
> end if;
> end process;
> end RTL;
>
> Also if I don't do edge detection in the sync circuit but use the
> following piece of code in my block will it work and synthesize? (just
> curious)
>
> if (pCLK = '1 and pCLK'event) then
> -- assume synchronizer is only 2 stage
> -- and no edge detection is done in synchronizer
> -- detect edge here
> if (NEWLINE_p = '1' and NEWLINE_P'event) then
>
> ...
>
> end if;
>
> I have never seen 'event being used anywhere except for the clk which
> is why I am asking this.
>
> Thanks,
> Divyang M
>



--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~
Jim Lewis
Director of Training private.php?do=newpm&u=
SynthWorks Design Inc. http://www.SynthWorks.com
1-503-590-4787

Expert VHDL Training for Hardware Design and Verification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~


Jim Lewis
  Reply With Quote
Old 05-19-2005, 04:39 PM   #5
Jim Lewis
 
Posts: n/a
Default Re: Passing a signal from slow to fast clock
Neo,
I would not recommend using the stage1fifo for anything.
It is intended for metastable resolution.

If you need glitch suppression, you may need additional
registers in the term like you suggested. When crossing
clock domains, I would not expect need to do this. The
control signal crossing the clock domain needs to come
directly from the output of a register of the other clock
and directly into the registers of this clock domain.

Cheers,
Jim


> divyang,
> You are just checking for the rising edge of the data but not the
> duration. so your output will always be one clock cycle in faster
> domain even if the data remains high for multiple clock cycles in the
> slower domain. This modification should check for that:
> if ((stage2fifo = '1' and pulsefifo = '0') or stage1fifo = '1') then
> ---
> ---
> However I am not very sure if its good idea to take the 'OR' of
> stage1fifo or to put one more FF in faster domain and take its value
> for ORING.
>



--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~
Jim Lewis
Director of Training private.php?do=newpm&u=
SynthWorks Design Inc. http://www.SynthWorks.com
1-503-590-4787

Expert VHDL Training for Hardware Design and Verification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~


Jim Lewis
  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: 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




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