1 | library IEEE;
|
2 | use IEEE.STD_LOGIC_1164.ALL;
|
3 | use IEEE.STD_LOGIC_ARITH.ALL;
|
4 | use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
5 |
|
6 | -- Uncomment the following lines to use the declarations that are
|
7 | -- provided for instantiating Xilinx primitive components.
|
8 | --library UNISIM;
|
9 | --use UNISIM.VComponents.all;
|
10 |
|
11 | entity clock is
|
12 | port( clk: in std_logic;
|
13 | reset:in std_logic;
|
14 | sel : in std_logic;
|
15 | a: out std_logic);
|
16 |
|
17 | end clock;
|
18 |
|
19 | architecture Behavioral of clock is
|
20 |
|
21 | signal cnt:std_logic_vector(1 downto 0);
|
22 |
|
23 | begin
|
24 |
|
25 | counter: process (reset,clk)
|
26 | begin
|
27 | if reset='1' then
|
28 | cnt<=(others=>'0');
|
29 | elsif rising_edge(clk) then
|
30 | cnt<=cnt+1;
|
31 | end if;
|
32 | end process;
|
33 |
|
34 | mux: process (sel,clk,cnt)
|
35 | begin
|
36 | a<=cnt(0);
|
37 |
|
38 | if (sel='1') then
|
39 | a<=clk;
|
40 | end if;
|
41 |
|
42 | end process;
|
43 |
|
44 | end Behavioral;
|