1 | library ieee;
|
2 | use ieee.std_logic_1164.all;
|
3 | use ieee.std_logic_arith.all;
|
4 |
|
5 | entity ioctrl is
|
6 |
|
7 | port (clk48 : in std_logic; -- 48 MHz system clock
|
8 | reset_n : in std_logic; -- asynchronous reset
|
9 | led : out std_logic_vector(6 downto 0);
|
10 | led2 : out std_logic);
|
11 |
|
12 | end ioctrl;
|
13 |
|
14 | architecture rtl of ioctrl is
|
15 |
|
16 | constant C_ENCOUNTVAL : std_logic_vector(14 downto 0):= "100101100000000";
|
17 |
|
18 | --signal s_busfsm : t_busfsm;
|
19 | --signal s_enctr : std_logic_vector(14 downto 0);
|
20 | --signal s_10khzen : std_logic;
|
21 | signal s_led : std_logic_vector(7 downto 0);
|
22 |
|
23 | begin -- rtl
|
24 |
|
25 | -----------------------------------------------------------------------------
|
26 | --
|
27 | -- Generate 10 KHz enable signal.
|
28 | --
|
29 | -----------------------------------------------------------------------------
|
30 | --p_slowen: process (clk48, reset_n)
|
31 | --begin -- process p_slowen
|
32 | -- if reset_n = '0' then -- asynchronous reset (active low)
|
33 | -- s_10khzen <= '0';
|
34 | -- s_enctr <= (others => '0');
|
35 | -- elsif clk48'event and clk48 = '1' then -- rising clock edge
|
36 | -- -- Enable signal is inactive per default.
|
37 | -- s_10khzen <= '0';
|
38 | -- if s_enctr /= C_ENCOUNTVAL then
|
39 | -- -- As long as the terminal count is not reached: increment the counter.
|
40 | -- s_enctr <= unsigned(s_enctr) + conv_unsigned(1,1);
|
41 | -- else
|
42 | -- When the terminal count is reached, set enable flag and reset the
|
43 | -- counter.
|
44 | -- s_enctr <= (others => '0');
|
45 | -- s_10khzen <= '1';
|
46 | -- end if;
|
47 | -- end if;
|
48 | --end process p_slowen;
|
49 | -----------------------------------------------------------------------------
|
50 | --
|
51 | -- Generate state machine to put out and to read in data from the bus in a
|
52 | -- loop.
|
53 | --
|
54 | -----------------------------------------------------------------------------
|
55 | p_busfsm: process (clk48, reset_n)
|
56 | begin -- process p_busfsm
|
57 | if reset_n = '0' then -- asynchronous reset (active low)
|
58 | s_led <= "10000001";
|
59 |
|
60 | elsif clk48'event and clk48 = '1' then -- rising clock edge
|
61 | --if s_10khzen = '1' then
|
62 | s_led <= "11110000";--not s_led;
|
63 | --end if;
|
64 | end if;
|
65 | end process p_busfsm;
|
66 | led <= s_led(6 downto 0);
|
67 | led2<= s_led(7);
|
68 | end rtl;
|