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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_0_1_beta/] [rtl/] [vhdl/] [int.vhd] - Blame information for rev 333

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 arniml
-------------------------------------------------------------------------------
2
--
3
-- The Interrupt Controller.
4
-- It collects the interrupt sources and notifies the decoder.
5
--
6
-- $Id: int.vhd,v 1.1 2004-03-23 21:31:52 arniml Exp $
7
--
8
-- All rights reserved
9
--
10
-- Redistribution and use in source and synthezised forms, with or without
11
-- modification, are permitted provided that the following conditions are met:
12
--
13
-- Redistributions of source code must retain the above copyright notice,
14
-- this list of conditions and the following disclaimer.
15
--
16
-- Redistributions in synthesized form must reproduce the above copyright
17
-- notice, this list of conditions and the following disclaimer in the
18
-- documentation and/or other materials provided with the distribution.
19
--
20
-- Neither the name of the author nor the names of other contributors may
21
-- be used to endorse or promote products derived from this software without
22
-- specific prior written permission.
23
--
24
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
26
-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27
-- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
28
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34
-- POSSIBILITY OF SUCH DAMAGE.
35
--
36
-- Please report bugs to the author, but before you do so, please
37
-- make sure that this is not a derivative work and that
38
-- you have the latest version of this file.
39
--
40
-- The latest version of this file can be found at:
41
--      http://www.opencores.org/cvsweb.shtml/t48/
42
--
43
-------------------------------------------------------------------------------
44
 
45
library ieee;
46
use ieee.std_logic_1164.all;
47
 
48
use work.t48_pack.mstate_t;
49
 
50
entity int is
51
 
52
  port (
53
    clk_i           : in  std_logic;
54
    res_i           : in  std_logic;
55
    en_clk_i        : in  boolean;
56
    clk_mstate_i    : in  mstate_t;
57
    jtf_executed_i  : in  boolean;
58
    tim_overflow_i  : in  boolean;
59
    tf_o            : out std_logic;
60
    en_tcnti_i      : in  boolean;
61
    dis_tcnti_i     : in  boolean;
62
    int_n_i         : in  std_logic;
63
    ale_i           : in  boolean;
64
    last_cycle_i    : in  boolean;
65
    en_i_i          : in  boolean;
66
    dis_i_i         : in  boolean;
67
    ext_int_o       : out boolean;
68
    tim_int_o       : out boolean;
69
    retr_executed_i : in  boolean;
70
    int_executed_i  : in  boolean;
71
    int_pending_o   : out boolean
72
  );
73
 
74
end int;
75
 
76
 
77
use work.t48_pack.all;
78
 
79
architecture rtl of int is
80
 
81
  constant tim_int_c : std_logic := '0';
82
  constant ext_int_c : std_logic := '1';
83
 
84
  type int_state_t is (IDLE, PENDING, INT);
85
 
86
  signal int_state_s,
87
         int_state_q  : int_state_t;
88
 
89
  signal timer_flag_q       : boolean;
90
  signal timer_overflow_q   : boolean;
91
  signal timer_int_enable_q : boolean;
92
  signal int_q              : boolean;
93
  signal int_enable_q       : boolean;
94
  signal ale_q              : boolean;
95
  signal int_type_q         : std_logic;
96
  signal int_in_progress_q  : boolean;
97
 
98
begin
99
 
100
  -----------------------------------------------------------------------------
101
  -- Process nstate
102
  --
103
  -- Purpose:
104
  --   Determines the next state of the Interrupt controller FSM.
105
  --
106
  nstate: process (int_state_q,
107
                   int_type_q,
108
                   int_in_progress_q,
109
                   int_executed_i,
110
                   retr_executed_i,
111
                   clk_mstate_i,
112
                   last_cycle_i)
113
  begin
114
    int_state_s <= int_state_q;
115
 
116
    case int_state_q is
117
      when IDLE =>
118
        if int_in_progress_q and
119
           last_cycle_i and clk_mstate_i = MSTATE5 then
120
          int_state_s <= PENDING;
121
        end if;
122
 
123
      when PENDING =>
124
        if int_executed_i then
125
          int_state_s <= INT;
126
        end if;
127
 
128
      when INT =>
129
        if retr_executed_i then
130
          int_state_s <= IDLE;
131
        end if;
132
 
133
      when others =>
134
        int_state_s <= IDLE;
135
 
136
    end case;
137
 
138
  end process nstate;
139
  --
140
  -----------------------------------------------------------------------------
141
 
142
 
143
  -----------------------------------------------------------------------------
144
  -- Process regs
145
  --
146
  -- Purpose:
147
  --   Implement the various registers.
148
  --
149
  regs: process (res_i, clk_i)
150
  begin
151
    if res_i = res_active_c then
152
      timer_flag_q       <= false;
153
      timer_overflow_q   <= false;
154
      timer_int_enable_q <= false;
155
      int_q              <= false;
156
      int_enable_q       <= false;
157
      ale_q              <= false;
158
      int_type_q         <= '0';
159
      int_state_q        <= IDLE;
160
      int_in_progress_q  <= false;
161
 
162
    elsif clk_i'event and clk_i = clk_active_c then
163
      if en_clk_i then
164
 
165
        ale_q       <= ale_i;
166
 
167
        int_state_q <= int_state_s;
168
 
169
        if jtf_executed_i then
170
          timer_flag_q <= false;
171
        elsif tim_overflow_i then
172
          timer_flag_q <= true;
173
        end if;
174
 
175
        if (int_type_q = tim_int_c and int_executed_i) or
176
          not timer_int_enable_q then
177
          timer_overflow_q <= false;
178
        elsif tim_overflow_i then
179
          timer_overflow_q <= true;
180
        end if;
181
 
182
        if dis_tcnti_i then
183
          timer_int_enable_q <= false;
184
        elsif en_tcnti_i then
185
          timer_int_enable_q <= true;
186
        end if;
187
 
188
        if last_cycle_i and
189
          ale_q  and not ale_i  then
190
          int_q <= not to_boolean(int_n_i);
191
        end if;
192
 
193
        if dis_i_i then
194
          int_enable_q <= false;
195
        elsif en_i_i then
196
          int_enable_q <= true;
197
        end if;
198
 
199
        if retr_executed_i then
200
          int_in_progress_q <= false;
201
        elsif (int_q and int_enable_q) or
202
          timer_overflow_q then
203
          int_in_progress_q <= true;
204
          if not int_in_progress_q then
205
            int_type_q <= to_stdLogic(int_q and int_enable_q);
206
          end if;
207
        end if;
208
 
209
      end if;
210
 
211
    end if;
212
 
213
  end process regs;
214
  --
215
  -----------------------------------------------------------------------------
216
 
217
 
218
  -----------------------------------------------------------------------------
219
  -- Output Mapping.
220
  -----------------------------------------------------------------------------
221
  tf_o           <= to_stdLogic(timer_flag_q);
222
  ext_int_o      <= int_type_q = ext_int_c;
223
  tim_int_o      <= int_type_q = tim_int_c;
224
  int_pending_o  <= int_state_q = PENDING;
225
 
226
end rtl;
227
 
228
 
229
-------------------------------------------------------------------------------
230
-- File History:
231
--
232
-- $Log: not supported by cvs2svn $
233
--
234
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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