library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
use IEEE.NUMERIC_STD.ALL;
entity final is
port( clk_in_for_fixed,clk_in_for_programmable,a,b: in std_logic;
fixed_clk_out,clk_out_programmable,qa,qb: out std_logic;
programmable_divide_value : in std_logic_vector (10 downto 0)
);
end final;
architecture Behavioral of final is
component d2 port
( inpu_c, d_in,reset:in std_logic ;
q_out :buffer std_logic
);
end component d2;
signal fixed_divide,counter_programmable,counter_fixed,programmable_divide : integer := 0;
signal set_high, qa_int, qb_int,res :std_logic;
begin
fixed_divide <= 2000;
[COLOR=#ff0000][B]programmable_divide <= to_integer(unsigned(programmable_divide_value(10 downto 0)));[/B][/COLOR]
process(clk_in_for_fixed)
begin
if( rising_edge(clk_in_for_fixed) ) then
if(counter_fixed < fixed_divide/2-1) then
counter_fixed <= counter_fixed + 1;
fixed_clk_out <= '0';
elsif(counter_fixed < fixed_divide-1) then
counter_fixed <= counter_fixed + 1;
fixed_clk_out <= '1';
else
fixed_clk_out <= '0';
counter_fixed <= 0;
end if;
end if;
end process;
process(clk_in_for_programmable)
begin
if( rising_edge (clk_in_for_programmable))then
if(counter_programmable< programmable_divide/2-1) then
counter_programmable <= counter_programmable+ 1;
clk_out_programmable <= '0';
elsif(counter_programmable < programmable_divide-1) then
counter_programmable <= counter_programmable+ 1;
clk_out_programmable<= '1';
else
clk_out_programmable <= '0';
counter_programmable <= 0;
end if;
end if;
end process;
set_high <= '1';
d0: d2 port map (
inpu_c => a,
reset => res,
d_in => set_high,
q_out => qa_int
);
d1: d2 port map (
inpu_c => b,
reset => res,
d_in => set_high,
q_out => qb_int
);
res <= qb_int and qa_int;
qa <= qa_int;
qb <= qb_int;
end Behavioral;