Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - clock divider by 2

 
Thread Tools Search this Thread
Old 08-15-2006, 03:43 AM   #1
Default clock divider by 2


this may be the simplest question..
I want to write a clock divider by 2 using DFF...but I just want to use
1 DFF when /Q is connected to the data_in

so the inputs are clock and data_in and outputs are Q and /Q
and /Q is connected to data_in.

how can I write this in VHDL or Can I?

Thank you,
Martin



martstev@gmail.com
  Reply With Quote
Old 08-15-2006, 08:26 AM   #2
Thomas Stanka
 
Posts: n/a
Default Re: clock divider by 2

schrieb:

> this may be the simplest question..
> I want to write a clock divider by 2 using DFF...but I just want to use
> 1 DFF when /Q is connected to the data_in
>
> so the inputs are clock and data_in and outputs are Q and /Q
> and /Q is connected to data_in.
>
> how can I write this in VHDL or Can I?


To get exactly what your are describing might require some more effort
(as synthesis will more likely use a D-FF with inverter), but following
lines inside your clocked process template will do a simple clk/2
divider.

if rising_edge(clk) then
data<=not data;
end if;

You should be aware that data is not phase alligned to clk, so if you
use data as a clock, you have to consider all parts clocked with data
as asynchronous to clk.

bye Thomas



Thomas Stanka
  Reply With Quote
Old 08-15-2006, 01:50 PM   #3
backhus
 
Posts: n/a
Default Re: clock divider by 2
schrieb:
> this may be the simplest question..
> I want to write a clock divider by 2 using DFF...but I just want to use
> 1 DFF when /Q is connected to the data_in
>
> so the inputs are clock and data_in and outputs are Q and /Q
> and /Q is connected to data_in.
>
> how can I write this in VHDL or Can I?
>
> Thank you,
> Martin
>

Hi Martin,
If you know exactly what you are doing, you can instantiate the dff
directly from your tech library.

e.g. (using direct instantiation from techlib)

clockdivider: entity techlib.DFF
port map(c => clock,
d => feedback,
q => divided_clock,
qn => feedback);

....something like this.

If you are not really familiar with the elements of your technology
library, or if you need a generic solution do it the way as shown by
Thomas. If the synthesis tool generates an Inverter, but you are sure
that the FF has a notQ output, then try some constrainting the area or
whatever your tool offers.

have a nice synthesis
Eilert


backhus
  Reply With Quote
Old 08-16-2006, 06:06 AM   #4
arant
 
Posts: n/a
Default Re: clock divider by 2
Hey Martin.

you can use the following code snippet
-------------------------RTL----------------------------
library ieee;
use ieee.std_logic_1164.all;

library divby2;
use divby2.all;

entity divby2 is
port (
clk : in std_logic;
reset : in std_logic;
clk_div2 : out std_logic
);
end divby2 ;

architecture rtl of divby2 is
signal clk_s : std_logic;

begin

p_divby2 : process(clk,reset)
begin
if (reset = '0') then
clk_s <= '0';
elsif (clk'event and clk = '1') then
clk_s <= not (clk_s);
end if;
end process p_divby2;

clk_div2 <= clk_s;

end rtl;
-----------------------------
-------------TESTBENCH--------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;

library pattern;
use pattern.all;

entity test_divby2 is
end test_divby2;

architecture tb of test_divby2 is

signal logic0 : std_logic := '0';
signal logic1 : std_logic := '1';
signal clk_s : std_logic := '0';
signal reset_s : std_logic := '0';
signal clk_div2_s : std_logic;

component divby2
port (
clk : in std_logic;
reset : in std_logic;
clk_div2 : out std_logic
);
end component;

begin
reset_s <= '1' after 3 ns;

process (reset_s,clk_s)
begin
if reset_s ='1' then
clk_s <= not(clk_s) after 10 ns;
else
clk_s <= '0';
end if;
end process;

i_divby2 : divby2
port map (
clk => clk_s ,
reset => reset_s,
clk_div2 => clk_div2_s
);
end tb;
--------------------------

I think DC will put in a structure with the D flop output connected to
an inverter (in case Qn is not available ) and fed back to the input of
the D flop

Regards,
Arant


backhus wrote:
> schrieb:
> > this may be the simplest question..
> > I want to write a clock divider by 2 using DFF...but I just want to use
> > 1 DFF when /Q is connected to the data_in
> >
> > so the inputs are clock and data_in and outputs are Q and /Q
> > and /Q is connected to data_in.
> >
> > how can I write this in VHDL or Can I?
> >
> > Thank you,
> > Martin
> >

> Hi Martin,
> If you know exactly what you are doing, you can instantiate the dff
> directly from your tech library.
>
> e.g. (using direct instantiation from techlib)
>
> clockdivider: entity techlib.DFF
> port map(c => clock,
> d => feedback,
> q => divided_clock,
> qn => feedback);
>
> ...something like this.
>
> If you are not really familiar with the elements of your technology
> library, or if you need a generic solution do it the way as shown by
> Thomas. If the synthesis tool generates an Inverter, but you are sure
> that the FF has a notQ output, then try some constrainting the area or
> whatever your tool offers.
>
> have a nice synthesis
> Eilert




arant
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Clock Modelling using VHDL rtl.engineer Hardware 0 07-31-2008 11:50 AM
Computer Clock GoneBeforeMyTime A+ Certification 5 04-21-2007 05:31 PM
Post-Route Simulation does not give output for the first clock cycle Options velocityreviews Software 0 04-17-2007 05:47 PM
New Releases: Revelations, The Librarian & My Left Foot: Updated complete downloadable R1 DVD DB & Info lists Doug MacLean DVD Video 0 05-17-2005 06:57 AM
Hollywood Detective - The Buried Clock David Marsh DVD Video 1 09-27-2004 11:26 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

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