M
Mohammed A khader
Guest
Hi ,
I have to design a clock divider. Clock Division Factor is an
unsigned number as an input port(NOT CONSTANT). I could able to think
of an architecture which can divide the clk by even numbers. Here is
the code ....
entity Ad_Clk_Div is
port(
Div_Fac : in unsigned(3 downto 0);-- Division Factor
Clk : in std_logic; -- Global Clk
Reset : in std_logic; -- Global Reset
DClk : out std_logic -- Divided Clk Out
);
end entity Ad_Clk_Div;
architecture Ad_Clk_Div_Arch of Ad_Clk_Div is
signal count : unsigned(3 downto 0);
begin
-- Sequential Process
-- Programmable Load counter and Toggle FiFo
process(Clk,Reset)
begin
if(Reset = '0')then
count <= (others => '0');
DClk <= '0';
elsif(RISING_EDGE(Clk))then
if(count = Div_Fac)then
count <= (others => '0');
DClk <= not DClk ;
else
count <= count + 1 ;
end if;
end if;
end process;
end architecture Ad_Clk_Div_Arch;
How can I make it to divide by odd numbers too... To make it so I
must to detect the falling edges also. Is there any sequential element
/ counter which would work on both the edges .... OR how should I
think to get this funtionality..
Thanks a lot.
Mohammed A Khader.
I have to design a clock divider. Clock Division Factor is an
unsigned number as an input port(NOT CONSTANT). I could able to think
of an architecture which can divide the clk by even numbers. Here is
the code ....
entity Ad_Clk_Div is
port(
Div_Fac : in unsigned(3 downto 0);-- Division Factor
Clk : in std_logic; -- Global Clk
Reset : in std_logic; -- Global Reset
DClk : out std_logic -- Divided Clk Out
);
end entity Ad_Clk_Div;
architecture Ad_Clk_Div_Arch of Ad_Clk_Div is
signal count : unsigned(3 downto 0);
begin
-- Sequential Process
-- Programmable Load counter and Toggle FiFo
process(Clk,Reset)
begin
if(Reset = '0')then
count <= (others => '0');
DClk <= '0';
elsif(RISING_EDGE(Clk))then
if(count = Div_Fac)then
count <= (others => '0');
DClk <= not DClk ;
else
count <= count + 1 ;
end if;
end if;
end process;
end architecture Ad_Clk_Div_Arch;
How can I make it to divide by odd numbers too... To make it so I
must to detect the falling edges also. Is there any sequential element
/ counter which would work on both the edges .... OR how should I
think to get this funtionality..
Thanks a lot.
Mohammed A Khader.