Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Frequency divider

Reply
Thread Tools

Frequency divider

 
 
Patrick
Guest
Posts: n/a
 
      05-17-2004
i have implemented this vhdl code for divide the clock
p1 : process (clk_chip)
variable compteur : integer range 0 to 11;
begin
if (clk_chip'event )then
if reset='1' then
compteur := 1;
else if compteur >= 11 then
compteur := 1;
else
compteur := compteur + 1;
end if;
end if;
if compteur >= 6 then
clock_bit <= '0';
else
clock_bit <= '1';
end if;
end if;
end process p1;

but the counter not count the two edge !!

have you any idea ?
 
Reply With Quote
 
 
 
 
Amontec, Larry
Guest
Posts: n/a
 
      05-17-2004
Patrick wrote:
> i have implemented this vhdl code for divide the clock
> p1 : process (clk_chip)
> variable compteur : integer range 0 to 11;
> begin
> if (clk_chip'event )then
> if reset='1' then
> compteur := 1;
> else if compteur >= 11 then
> compteur := 1;
> else
> compteur := compteur + 1;
> end if;
> end if;
> if compteur >= 6 then
> clock_bit <= '0';
> else
> clock_bit <= '1';
> end if;
> end if;
> end process p1;
>
> but the counter not count the two edge !!
>
> have you any idea ?


Some VHDL rules:

- do not use variable, but use signal
- if possible use asynchronous reset
- if possible do not use >= but only = , you will save in your clock
frequency

Laurent
www.amontec.com
------------ And now a word from our sponsor ------------------
For a quality usenet news server, try DNEWS, easy to install,
fast, efficient and reliable. For home servers or carrier class
installations with millions of users it will allow you to grow!
---- See http://netwinsite.com/sponsor/sponsor_dnews.htm ----
 
Reply With Quote
 
 
 
 
Patrick
Guest
Posts: n/a
 
      05-18-2004
I have modified the process like this

p1 : process (clk_chip,reset)
variable compteur : integer range 0 to 11;
begin
if reset = '1' then
compteur := 1;
else if (clk_chip'event)then
if compteur = 11 then
compteur := 1;
else
compteur := compteur + 1;
end if;
if compteur >= 6 then
clk_bit <= '0';
else
clk_bit <= '1';
end if;
end if;
end if;
end process p1;


but when i synthesis this one on a stratix fpga, the counter count
only the rising edge and not the two rising and falling edge (use of
clk_chip'event ONLY) with Quartus II 4.0
 
Reply With Quote
 
Joerg Ritter
Guest
Posts: n/a
 
      05-18-2004
seems to be that the flipflops could react only at rising or at falling
edge, not at both

take two processes, each responsible for a clock edge typ.
j

the synthesis software should have given you a warning ?


> I have modified the process like this
>
> p1 : process (clk_chip,reset)
> variable compteur : integer range 0 to 11;
> begin
> if reset = '1' then
> compteur := 1;
> else if (clk_chip'event)then
> if compteur = 11 then
> compteur := 1;
> else
> compteur := compteur + 1;
> end if;
> if compteur >= 6 then
> clk_bit <= '0';
> else
> clk_bit <= '1';
> end if;
> end if;
> end if;
> end process p1;
>
>
> but when i synthesis this one on a stratix fpga, the counter count
> only the rising edge and not the two rising and falling edge (use of
> clk_chip'event ONLY) with Quartus II 4.0

 
Reply With Quote
 
Ralf Hildebrandt
Guest
Posts: n/a
 
      05-18-2004
Patrick wrote:
> I have modified the process like this
>
> p1 : process (clk_chip,reset)
> variable compteur : integer range 0 to 11;
> begin
> if reset = '1' then
> compteur := 1;
> else if (clk_chip'event)then
> if compteur = 11 then
> compteur := 1;
> else
> compteur := compteur + 1;
> end if;
> if compteur >= 6 then
> clk_bit <= '0';
> else
> clk_bit <= '1';
> end if;
> end if;
> end if;
> end process p1;
>
>
> but when i synthesis this one on a stratix fpga, the counter count
> only the rising edge and not the two rising and falling edge (use of
> clk_chip'event ONLY) with Quartus II 4.0


Dual-edge-behavior is not supported by VHDL at the moment. If you would
have mentioned, that your code has to be synthesized, you would have got
an answer to your 1st posting.

I am only in wonder, why your synthesis tool did not exit with an error.


Ralf

 
Reply With Quote
 
Amontec Team
Guest
Posts: n/a
 
      05-19-2004


Ralf Hildebrandt wrote:
> Patrick wrote:
>
>> I have modified the process like this
>>
>> p1 : process (clk_chip,reset)
>> variable compteur : integer range 0 to 11;
>> begin
>> if reset = '1' then
>> compteur := 1;
>> else if (clk_chip'event)then
>> if compteur = 11 then
>> compteur := 1;
>> else
>> compteur := compteur + 1;
>> end if;
>> if compteur >= 6 then
>> clk_bit <= '0';
>> else clk_bit <= '1';
>> end if;
>> end if;
>> end if;
>> end process p1;
>>
>>
>> but when i synthesis this one on a stratix fpga, the counter count
>> only the rising edge and not the two rising and falling edge (use of
>> clk_chip'event ONLY) with Quartus II 4.0

>
>
> Dual-edge-behavior is not supported by VHDL at the moment. If you would
> have mentioned, that your code has to be synthesized, you would have got
> an answer to your 1st posting.
>
> I am only in wonder, why your synthesis tool did not exit with an error.
>
>
> Ralf
>


It's WRONG !

This is depending on the architecture target only, but this is not
depending on the VHDL language.

For many projects we used the dual-edge VHDL description and it works
fine for simulation, for synthesis and for Place and Route.

Just try to place and route the code to an Xilinx CoolRunner-II and your
count will run on both edges.

It just CANNOT work for stratix FPGA, because the stratix achitechture
does not support the dual-edge !

Laurent Gauch
www.amontec.com
 
Reply With Quote
 
Charles Bailey
Guest
Posts: n/a
 
      05-21-2004

"Amontec, Larry" <> wrote in message
news:...
> Patrick wrote:
> > i have implemented this vhdl code for divide the clock
> > p1 : process (clk_chip)
> > variable compteur : integer range 0 to 11;
> > begin
> > if (clk_chip'event )then
> > if reset='1' then
> > compteur := 1;
> > else if compteur >= 11 then
> > compteur := 1;
> > else
> > compteur := compteur + 1;
> > end if;
> > end if;
> > if compteur >= 6 then
> > clock_bit <= '0';
> > else
> > clock_bit <= '1';
> > end if;
> > end if;
> > end process p1;
> >
> > but the counter not count the two edge !!
> >
> > have you any idea ?

>
> Some VHDL rules:

Huh? Where did you get these "rules"?
>
> - do not use variable, but use signal

The use of variables should be fine in this case, if your synthesis
tools can handle it.
> - if possible use asynchronous reset

In general, asynchrounous resets are problematic. I would recommend
synchronous resets wherever possible.
> - if possible do not use >= but only = , you will save in your clock

compteur is defined as having a range of 0 to 11 so the >= comparison is
unnecessary because the variable can never be > 11. Also, you defined
the range as 0 to 11 but in your code compteur never has a value of 0,
so the range should probably be 1 to 11.
> frequency
>
> Laurent
> www.amontec.com
> ------------ And now a word from our sponsor ------------------
> For a quality usenet news server, try DNEWS, easy to install,
> fast, efficient and reliable. For home servers or carrier class
> installations with millions of users it will allow you to grow!
> ---- See http://netwinsite.com/sponsor/sponsor_dnews.htm ----



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
frequency divider Gandalf VHDL 6 09-24-2008 04:32 AM
VHDL-problem with symmetrical frequency divider by 3 Winfried Salomon VHDL 12 08-29-2007 02:50 PM
frequency divider by 2,3 JenniferLin801 VHDL 0 10-16-2006 01:48 AM
Frequency Divider Simulation problem using ModelSIM Kyle H. VHDL 3 09-26-2006 03:25 PM
MCU clock divider vs. VHDL divider Matt Clement VHDL 3 04-28-2006 01:24 PM



Advertisments
 



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 47 48 49 50 51 52 53 54 55 56 57