|
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity clk_d is
generic(N:integer:=5);
port(
clk:in std_logic;
clk_out:buffer std_logic;
count11 ut integer;
tem: out std_logic);
end clk_d;
architecture example of clk_d is
signal count1,count2:integer:=0;
signal temp:std_logic;
begin
process(clk)
begin
if clk'event and clk='1' then
if count1=N-1 then
count1<=0;
else
count1<=count1+1;
end if;
end if;
count11<=count1;
end process;
process(clk)
begin
if clk'event and clk='0' then
if count2=N-1 then
count2<=0;
else
count2<=count2+1;
end if;
end if;
end process;
process(count1,count2)
begin
if((N rem 2)=1) then
if count1=1 then
if count2=0 then
temp<='1';
else
temp<='0';
end if;
elsif count1=(N+1)/2 then
if count2=(N+1)/2 then
temp<='1';
else
temp<='0';
end if;
else
temp<='0';
end if;
else
if count1=1 then
temp<='1';
elsif(count1=(N/2+1)) THEN
temp<='1';
else
temp<='0';
end if;
end if;
end process;
process(temp,clk)
begin
if((N/=2)AND(N/=1)) then
if temp'event and temp='1' then
clk_out<=not clk_out;
end if;
elsif(N=2) then
if(clk'event and clk='1')then
clk_out<=not clk_out;
end if;
else clk_out<=clk;
end if;
tem<=temp;
end process;
end example;
这是源程序... |
|