K
kristoff
Guest
Hi,
I know this is very much a beginners question but I did try to find the
answer online and at a couple of books but have not yet found an clear
answer.
I'll ask the question based on a practicle example: in a process, I need
to to things at two different rates: certain things at the full clock
rate and a slower clock.
I have a basic clock 12 Mhz clock, so I build a clock-divider.
But, as I know I will need that slower clock in multiple places, my idea
would be to have a seperate process for creating the 1 Khz clock and
feed that into the processes that need that.
My code is below.
I have two questions from a generic "how to design a syncrounous system"
one.
1/ Is this the right way to do this?
Does it make sence to create one clock-divider as a seperate process and
feed then then into other process? (so not to have to synthesiser to
create one per every process that needs one).
Or can I just code the clock-divider into every process that needs that.
(Perhaps the synthesier will optimise the design anyway and do all the
work for me).
2/ From a timing point of view, the div12000-clock output of the clock
divider sits after some logic and is then feed into the other processes.
I guess this will create some delay.
But in the processes that actually use that clock (processes "a" and "b"
in my example) , the vhdl code to check on that signal sits behind a
"rising_edge(clk_in)", which is -if I am correct- a very short timespan.
Will this not result in timing-issues?
Can I be sure that the "slowclock = 1" will arrive in process "a" and
"b" fast enough.
Or will the synthesiser do special things to make sure it will. (perhaps
delay clk_in in the processes "a" and "b" a little bit).
Or, in a more generic sence,
When doing an initial design of a syncrounous system, do you need to
take timing-issues like this in account?
Or can I just assume there is zero-delay in all processes and let
timing-issues be dealt with by the synthesizer?
(I did read some comments that it will at least check certain elements
concerning timing of the design).
I did a very interesting post in a forum that clock-signals in a FPGA
are special and that clock-signals pass over special "lanes" (or
whatever the correct term is) so they arrive at all places in the chip
at the same moment.
It would however be interesting to find some information on how to deal
with clock-signals (especially if you create them yourself in a
clock-divider) in a syncronous design.
--- cut here --- cut here --- cut here ---
clockdiv12000: process (clk_in) is
begin
if (rising_edge(clk_in) then
if (counter = 11999) then
counter <= 0;
slowclock <= '1';
else
counter <= counter + 1;
slowclock <= '0';
end if;
end if; -- end rising_edge
end process clockdiv8000;
a: process (clk_in, slowclock, in1, in2) is
begin
if (rising_edge(clk_in) then
(do some stuff at 8 Mhz clock)
if (slowclock = '1') then
(do some stuff at 1 Khz clock)
end if;
end if;
end process a;
b: process (clk_in, slowclock, in3, in4) is
begin
if (rising_edge(clk_in) then
(do some stuff at 8 Mhz clock)
if (slowclock = '1') then
(do some stuff at 1 Khz clock)
end if;
end if;
end process b;
--- cut here --- cut here --- cut here ---
Cheerio! Kr. Bonne.
I know this is very much a beginners question but I did try to find the
answer online and at a couple of books but have not yet found an clear
answer.
I'll ask the question based on a practicle example: in a process, I need
to to things at two different rates: certain things at the full clock
rate and a slower clock.
I have a basic clock 12 Mhz clock, so I build a clock-divider.
But, as I know I will need that slower clock in multiple places, my idea
would be to have a seperate process for creating the 1 Khz clock and
feed that into the processes that need that.
My code is below.
I have two questions from a generic "how to design a syncrounous system"
one.
1/ Is this the right way to do this?
Does it make sence to create one clock-divider as a seperate process and
feed then then into other process? (so not to have to synthesiser to
create one per every process that needs one).
Or can I just code the clock-divider into every process that needs that.
(Perhaps the synthesier will optimise the design anyway and do all the
work for me).
2/ From a timing point of view, the div12000-clock output of the clock
divider sits after some logic and is then feed into the other processes.
I guess this will create some delay.
But in the processes that actually use that clock (processes "a" and "b"
in my example) , the vhdl code to check on that signal sits behind a
"rising_edge(clk_in)", which is -if I am correct- a very short timespan.
Will this not result in timing-issues?
Can I be sure that the "slowclock = 1" will arrive in process "a" and
"b" fast enough.
Or will the synthesiser do special things to make sure it will. (perhaps
delay clk_in in the processes "a" and "b" a little bit).
Or, in a more generic sence,
When doing an initial design of a syncrounous system, do you need to
take timing-issues like this in account?
Or can I just assume there is zero-delay in all processes and let
timing-issues be dealt with by the synthesizer?
(I did read some comments that it will at least check certain elements
concerning timing of the design).
I did a very interesting post in a forum that clock-signals in a FPGA
are special and that clock-signals pass over special "lanes" (or
whatever the correct term is) so they arrive at all places in the chip
at the same moment.
It would however be interesting to find some information on how to deal
with clock-signals (especially if you create them yourself in a
clock-divider) in a syncronous design.
--- cut here --- cut here --- cut here ---
clockdiv12000: process (clk_in) is
begin
if (rising_edge(clk_in) then
if (counter = 11999) then
counter <= 0;
slowclock <= '1';
else
counter <= counter + 1;
slowclock <= '0';
end if;
end if; -- end rising_edge
end process clockdiv8000;
a: process (clk_in, slowclock, in1, in2) is
begin
if (rising_edge(clk_in) then
(do some stuff at 8 Mhz clock)
if (slowclock = '1') then
(do some stuff at 1 Khz clock)
end if;
end if;
end process a;
b: process (clk_in, slowclock, in3, in4) is
begin
if (rising_edge(clk_in) then
(do some stuff at 8 Mhz clock)
if (slowclock = '1') then
(do some stuff at 1 Khz clock)
end if;
end if;
end process b;
--- cut here --- cut here --- cut here ---
Cheerio! Kr. Bonne.