Frequency Divider using VHDL

Moderator (Company: Titel) #4500242
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!
#4500928
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.
Moderator (Company: Titel) #4500986
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...
#4501024
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.

Reply

Please log in before posting.

or

Log in with Google account

Registration is free and takes only a minute.

Register now