library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
use IEEE.numeric_std.all;
use IEEE.std_logic_arith.all;
entity TOP is
Port (
swtch:in std_logic_vector(3 downto 0);
Freq_in:in std logic;
PWM:out std_logic;);
end TOP;
architecture Behavioral of TOP is
component DIVX is
Port(Freq_in, Clr_n:in std_logic;
Div_num:in natural range 0 to 49999999;
Freq_out:out std_logic);
end component;
component CNT16 is
port(
Clk,Clr_n:in std_logic;
Q:out std_logic_vector(3 downto 0);
);
end component;
component COMP4BIT is
port(
A,B: in std_logic_vector(3 downto 0);
AGB:out std_logic;
);
end component;
signal Freq_out:std_logic;
signal cnt_out:std_logic_vector (3 downto 0);
begin
ul:DIVX port map (Freq_in=>Freq_in, Clr_n=>'1', Div_num=>26315, Freq_out=>Freq_out);
u2:CNT16 port map (Clk=>Freq_out, Clr_n=>'1', Q=>cnt_out);
u3:CMP4BIT port map (A=>cnt_out, B=>swtch, AGB=>PWM)
end Behavioral;