OpenCores
URL https://opencores.org/ocsvn/funbase_ip_library/funbase_ip_library/trunk

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [TUT/] [ip.hwp.interface/] [eth_lan91c111_ctrl/] [1.0/] [vhd/] [lan91c111_interrupt_handler.vhd] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
-------------------------------------------------------------------------------
2
-- Title      : DM9000A controller, interrupt handler module
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : DM9kA_interrupt_handler.vhd
6
-- Author     : Jussi Nieminen  <niemin95@galapagosinkeiju.cs.tut.fi>
7
-- Company    : 
8
-- Last update: 2011-11-06
9
-- Platform   : 
10
-------------------------------------------------------------------------------
11
-- Description: Activates with interrupt signal and finds out the source of it.
12
-------------------------------------------------------------------------------
13
-- Revisions  :
14
-- Date        Version  Author  Description
15
-- 2009/08/26  1.0      niemin95        Created
16
-------------------------------------------------------------------------------
17
 
18
library ieee;
19
use ieee.std_logic_1164.all;
20
use work.lan91c111_ctrl_pkg.all;
21
 
22
 
23
entity lan91c111_interrupt_handler is
24
 
25
  port (
26
    clk                     : in  std_logic;
27
    rst_n                   : in  std_logic;
28
    interrupt_in            : in  std_logic;
29
    comm_req_out            : out std_logic;
30
    comm_grant_in           : in  std_logic;
31
    rx_waiting_out          : out std_logic;
32
    tx_ready_out            : out std_logic;
33
    reg_addr_out            : out std_logic_vector( real_addr_width_c-1 downto 0 );
34
    config_data_out         : out std_logic_vector( lan91_data_width_c-1 downto 0 );
35
    config_nBE_out          : out std_logic_vector( 3 downto 0 );
36
    read_not_write_out      : out std_logic;
37
    config_valid_out        : out std_logic;
38
    data_from_comm_in       : in  std_logic_vector( lan91_data_width_c-1 downto 0 );
39
    data_from_comm_valid_in : in  std_logic;
40
    comm_busy_in            : in  std_logic
41
    );
42
 
43
end lan91c111_interrupt_handler;
44
 
45
 
46
architecture rtl of lan91c111_interrupt_handler is
47
 
48
  type check_state_type is (idle, get_status, check_status, clear_isr);
49
  signal check_state_r : check_state_type;
50
 
51
  signal comm_req_r     : std_logic;
52
  signal isr_status_r   : std_logic_vector( 7 downto 0 );
53
  signal comm_working_r : std_logic;
54
 
55
-------------------------------------------------------------------------------
56
begin  -- rtl
57
-------------------------------------------------------------------------------
58
 
59
  config_nBE_out <= "1100";
60
  comm_req_out <= comm_req_r;
61
 
62
  check_int : process (clk, rst_n)
63
  begin  -- process check_int
64
    if rst_n = '0' then                 -- asynchronous reset (active low)
65
 
66
      comm_req_r         <= '0';
67
      rx_waiting_out     <= '0';
68
      tx_ready_out       <= '0';
69
      reg_addr_out       <= (others => '0');
70
      config_data_out    <= (others => '0');
71
      read_not_write_out <= '0';
72
      config_valid_out   <= '0';
73
      check_state_r      <= idle;
74
      isr_status_r       <= (others => '0');
75
      comm_working_r     <= '0';
76
 
77
    elsif clk'event and clk = '1' then  -- rising clock edge
78
 
79
      -- these are allowed to be up only one cycle
80
      tx_ready_out   <= '0';
81
      rx_waiting_out <= '0';
82
 
83
      config_valid_out <= '0';
84
 
85
      case check_state_r is
86
        when idle =>
87
 
88
          if interrupt_in = '1' then
89
            -- "We have an interrupt! What are you waiting for, magget??! Do
90
            -- something, move like you got a pair!"
91
 
92
            -- "Sir yes sir!"
93
            comm_req_r <= '1';
94
 
95
            if comm_grant_in = '1' and comm_req_r = '1' then
96
              -- our turn to act
97
              check_state_r <= get_status;
98
              reg_addr_out <= "110";
99
              read_not_write_out <= '1';
100
              config_valid_out <= '1';
101
            end if;
102
          else
103
            comm_req_r <= '0';
104
          end if;
105
 
106
        when get_status =>
107
          if data_from_comm_valid_in = '1' then
108
            isr_status_r <= data_from_comm_in( 7 downto 0 );
109
            check_state_r <= check_status;
110
          end if;
111
 
112
        when check_status =>
113
 
114
          if isr_status_r(0) = '1' then
115
            -- packet received bit
116
            rx_waiting_out <= '1';
117
          end if;
118
 
119
          if isr_status_r(1) = '1' then
120
            -- packet transmitted bit
121
            tx_ready_out <= '1';
122
          end if;
123
 
124
          -- clear the ISR
125
          read_not_write_out <= '0';
126
          -- the interrupt status bits are cleared by writing 1
127
          config_data_out    <= x"000000FF";
128
          config_valid_out   <= '1';
129
          check_state_r      <= clear_isr;
130
 
131
          comm_working_r     <= '0';
132
 
133
        when clear_isr =>
134
 
135
          if comm_busy_in = '1' then
136
            -- comm is clearing the ISR
137
            comm_working_r <= '1';
138
          elsif comm_working_r = '1' then
139
            -- comm_busy_in is down and comm has been working -> back to idle
140
            check_state_r <= idle;
141
            comm_req_r <= '0';
142
          end if;
143
 
144
        when others => null;
145
      end case;
146
 
147
    end if;
148
  end process check_int;
149
 
150
 
151
 
152
end rtl;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.