Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

VHDL Help

Altera_Forum
Honored Contributor II
3,153 Views

Please help me to generate a clock in VHDL synchronised with rising edges of two external clocks. 

External clocks are: 100Mhz and 124 Hz 

Clock to be generated: 10MHz 

The 10MHz clock is to be generated using 100MHz clock startin g from rising edge of 124Hz clock.
0 Kudos
22 Replies
Altera_Forum
Honored Contributor II
2,246 Views

whats wrong with clock enables?

0 Kudos
Altera_Forum
Honored Contributor II
2,246 Views

 

--- Quote Start ---  

whats wrong with clock enables? 

--- Quote End ---  

 

clock enable is not working in this case since the 10MHz is to be synchronized with two un-synchronized clocks 100MHz and 124Hz
0 Kudos
Altera_Forum
Honored Contributor II
2,246 Views

you cant syncrhonise 100Mhz and 124 Mhz.

0 Kudos
Altera_Forum
Honored Contributor II
2,246 Views

yes because both are from separate sources...then how to generate a new clock synchronised with these two

0 Kudos
Altera_Forum
Honored Contributor II
2,246 Views

you cant. Why do you need them synchronised? are you trying to send data across the boundary? why not use a DC fifo?

0 Kudos
Altera_Forum
Honored Contributor II
2,246 Views

i am beginner in VHDL...kindly elaborate...my requirement is to generate a clock synchronised with two un-synchronised clocks

0 Kudos
Altera_Forum
Honored Contributor II
2,246 Views

you cant synchronise a clock to two completly unreleated clocks. You may be able to synchronise it every few thousand clocks. But generating clocks with logic is NOT a good idea.

0 Kudos
Altera_Forum
Honored Contributor II
2,246 Views

then what shall i do to solve the problem?

0 Kudos
Altera_Forum
Honored Contributor II
2,246 Views

Why do you need this clock? what is the ultimate aim? a clock on its own is no use to anyone. What is the system doing?

0 Kudos
Altera_Forum
Honored Contributor II
2,241 Views

Actually i need to generate a clock for a sensor....i chose 100Mhz crystal for generating this clock on my pcb...but there is an external clock 124 Hz coming to the pcb and this 10Mhz clock, generated from 100Mhz clock, shall start at the rising edge of 124Hz clock

0 Kudos
Altera_Forum
Honored Contributor II
2,246 Views

Sorry, I read 124 as Mhz, not Hz. 

 

Then yes, it should be ok, but it still doesnt really make sense unless you only want so many clock pulses - and then you might as well make it a clock enable. You would have to re-synchronise it every time you had a rising edge because it wouldnt be in sync by the time the 124Hz clock rose again.
0 Kudos
Altera_Forum
Honored Contributor II
2,246 Views

hey can you provide some coding example for this requirement

0 Kudos
Altera_Forum
Honored Contributor II
2,246 Views

that is your job. I suggest you get coding, and come back here when you have problems.

0 Kudos
Altera_Forum
Honored Contributor II
2,246 Views

i hav already tried many logics...but not getting the right one...the newly generated 10MHz clock is not getting synchronized with 124Hz clock

0 Kudos
Altera_Forum
Honored Contributor II
2,246 Views

why not post some code, and we can tell you where you're going wrong.

0 Kudos
Altera_Forum
Honored Contributor II
2,246 Views

if clk_100'event and clk_100 = '1' then 

if clk_124'event and clk_124 = '1' then 

if count <=10 then 

clk_10 = '1'; 

else 

clk_10 = '0'; 

end if; 

 

count = count + 1; 

if count > = 20 then 

count = 1; 

end if; 

 

end if; 

end if;
0 Kudos
Altera_Forum
Honored Contributor II
2,246 Views

well theres a problem - you cannot try and read two clocks in 1 bit of code. Think about it - a register (that you are infering) cannot have two clock connections. You have to run the counter in one clock domain and then syncrhonise it into the other - or sample one clock in the other clock domain (and to do that you will need at least a 248Mhz clock to sample the 124Mhz clock properly).

0 Kudos
Altera_Forum
Honored Contributor II
2,246 Views

can i do like this: 

process-1: 

 

if clk_100'event and clk_100 = '1' then 

if count <=10 then 

clk_10 = '1'; 

else 

clk_10 = '0'; 

end if; 

 

count = count + 1; 

if count > = 20 then 

count = 1; 

end if; 

 

end if; 

 

2nd process: 

if clk_124'event and clk_124 = '1' then 

clk_10_new <= clk_10; 

endif; 

 

will this work?
0 Kudos
Altera_Forum
Honored Contributor II
2,246 Views

here essentially i am generating required clock in process-1 and trying to sync it with 124Hz clock in process-2

0 Kudos
Altera_Forum
Honored Contributor II
2,195 Views

you could do that, but remember the 10Mhz clock is toggling at 10Mhz, so you dont know whether you'll sample a '1' or a '0' in the 124hz clock domain, so you may just get a load of zeros. Plus you have the potential for meta stability. 

 

I suggest you sample the 124Hz clock in the 100 Mhz clock domain.
0 Kudos
Reply