EmbDev.net

Forum: FPGA, VHDL & Verilog Frequency Divider using VHDL


von _Jaiko 0. (jaiko)


Rate this post
useful
not useful
Hello,

I need to do a code for frequency divider from 20MHz to 10kHz of PWM 
using Xilinx. I want to know how doing it. I try my best to do the code, 
but I still can't get the output. So, I need your help because I'm still 
new with FPGA.

Thanks.

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
Syu H. wrote:
> I try my best to do the code, but I still can't get the output.
Show what you have and what you tried. And say what you expected and 
waht you get istead. Then someone can help you.

I could simply give you a link to such a code, but then YOU won't learn 
nothing at all. Got the point?


> I need to do a code for frequency divider from 20MHz to 10kHz
BTW: you MUST NOT generate a 10kHz "clock" to be used inside a FPGA as a 
real clock. A beginners design has exactly 1 clock in whole. All the 
rest is done by clock enables!

von Dima U. (ustinoff)


Rate this post
useful
not useful
A simple way to create a clock divider is a counter.

How we can implement a counter in VHDL?
1
signal count : std_logic_vector (data_width-1 downto 0) := (others=>'0');
2
3
process(clk)
4
begin
5
if rising_edge(clk) then
6
if unsigned(count) = YOUR_COUNT_VALUE then
7
count <= (others=>'0');
8
else
9
count <= std_logic_vector (unsigned(count)+1);
10
end if;
11
end if;
12
end process;

You need to add one more signal in this code and you will get your 
divider.

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
Dima U. wrote:
> How we can implement a counter in VHDL?
You are in a very, very lucky condition: you are not the first on world 
to solve that problem.

> You need to add one more signal in this code and you will get your
> divider.
I don't think the target of this simple exercise is to ask in a forum. 
Instead YOU should (at least) try to solve that homework on your OWN.

And thats the way we gonna do it: YOU try it and when you have a 
specific problem, dne you tell what YOU tried, what you expected, why 
you expected it and what you got instead.

Be sure it would have cost me less time to solve your exercise than to 
write this short manual for your homework. But maybe its worth the 
time...

: Edited by Moderator
von Dima U. (ustinoff)


Rate this post
useful
not useful
Lothar M. wrote:
> Dima U. wrote:
>> How we can implement a counter in VHDL?
> You are in a very, very lucky condition: you are not the first on world
> to solve that problem.
>
>> You need to add one more signal in this code and you will get your
>> divider.
> I don't think the target of this simple exercise is to ask in a forum.
> Instead YOU should (at least) try to solve that homework on your OWN.
>
> And thats the way we gonna do it: YOU try it and when you have a
> specific problem, dne you tell what YOU tried, what you expected, why
> you expected it and what you got instead.
>
> Be sure it would have cost me less time to solve your exercise than to
> write this short manual for your homework. But maybe its worth the
> time...


I understand. I did not write the final version of divider. The counter 
is only first step.

: Edited by User
von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
Dima U. wrote:
> The counter is only first step.
Always the first step is the biggest in mankind. Do it.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.