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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_0_6_1_beta/] [rtl/] [vhdl/] [int.vhd] - Blame information for rev 292

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 205 arniml
-- $Id: int.vhd,v 1.6 2005-11-01 21:26:24 arniml Exp $
7 4 arniml
--
8 129 arniml
-- Copyright (c) 2004, Arnim Laeuger (arniml@opencores.org)
9
--
10 4 arniml
-- All rights reserved
11
--
12
-- Redistribution and use in source and synthezised forms, with or without
13
-- modification, are permitted provided that the following conditions are met:
14
--
15
-- Redistributions of source code must retain the above copyright notice,
16
-- this list of conditions and the following disclaimer.
17
--
18
-- Redistributions in synthesized form must reproduce the above copyright
19
-- notice, this list of conditions and the following disclaimer in the
20
-- documentation and/or other materials provided with the distribution.
21
--
22
-- Neither the name of the author nor the names of other contributors may
23
-- be used to endorse or promote products derived from this software without
24
-- specific prior written permission.
25
--
26
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
28
-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29
-- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
30
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36
-- POSSIBILITY OF SUCH DAMAGE.
37
--
38
-- Please report bugs to the author, but before you do so, please
39
-- make sure that this is not a derivative work and that
40
-- you have the latest version of this file.
41
--
42
-- The latest version of this file can be found at:
43
--      http://www.opencores.org/cvsweb.shtml/t48/
44
--
45
-------------------------------------------------------------------------------
46
 
47
library ieee;
48
use ieee.std_logic_1164.all;
49
 
50
use work.t48_pack.mstate_t;
51
 
52 179 arniml
entity t48_int is
53 4 arniml
 
54
  port (
55 120 arniml
    clk_i             : in  std_logic;
56
    res_i             : in  std_logic;
57
    en_clk_i          : in  boolean;
58 205 arniml
    xtal_i            : in  std_logic;
59 120 arniml
    clk_mstate_i      : in  mstate_t;
60
    jtf_executed_i    : in  boolean;
61
    tim_overflow_i    : in  boolean;
62
    tf_o              : out std_logic;
63
    en_tcnti_i        : in  boolean;
64
    dis_tcnti_i       : in  boolean;
65
    int_n_i           : in  std_logic;
66
    ale_i             : in  boolean;
67
    last_cycle_i      : in  boolean;
68
    en_i_i            : in  boolean;
69
    dis_i_i           : in  boolean;
70
    ext_int_o         : out boolean;
71
    tim_int_o         : out boolean;
72
    retr_executed_i   : in  boolean;
73
    int_executed_i    : in  boolean;
74
    int_pending_o     : out boolean;
75
    int_in_progress_o : out boolean
76 4 arniml
  );
77
 
78 179 arniml
end t48_int;
79 4 arniml
 
80
 
81
use work.t48_pack.all;
82
 
83 179 arniml
architecture rtl of t48_int is
84 4 arniml
 
85
  constant tim_int_c : std_logic := '0';
86
  constant ext_int_c : std_logic := '1';
87
 
88
  type int_state_t is (IDLE, PENDING, INT);
89
 
90
  signal int_state_s,
91
         int_state_q  : int_state_t;
92
 
93
  signal timer_flag_q       : boolean;
94
  signal timer_overflow_q   : boolean;
95
  signal timer_int_enable_q : boolean;
96
  signal int_q              : boolean;
97
  signal int_enable_q       : boolean;
98
  signal ale_q              : boolean;
99
  signal int_type_q         : std_logic;
100
  signal int_in_progress_q  : boolean;
101
 
102
begin
103
 
104
  -----------------------------------------------------------------------------
105
  -- Process nstate
106
  --
107
  -- Purpose:
108
  --   Determines the next state of the Interrupt controller FSM.
109
  --
110
  nstate: process (int_state_q,
111
                   int_type_q,
112
                   int_in_progress_q,
113
                   int_executed_i,
114
                   retr_executed_i,
115
                   clk_mstate_i,
116
                   last_cycle_i)
117
  begin
118
    int_state_s <= int_state_q;
119
 
120
    case int_state_q is
121
      when IDLE =>
122
        if int_in_progress_q and
123
           last_cycle_i and clk_mstate_i = MSTATE5 then
124
          int_state_s <= PENDING;
125
        end if;
126
 
127
      when PENDING =>
128
        if int_executed_i then
129
          int_state_s <= INT;
130
        end if;
131
 
132
      when INT =>
133
        if retr_executed_i then
134
          int_state_s <= IDLE;
135
        end if;
136
 
137
      when others =>
138
        int_state_s <= IDLE;
139
 
140
    end case;
141
 
142
  end process nstate;
143
  --
144
  -----------------------------------------------------------------------------
145
 
146
 
147
  -----------------------------------------------------------------------------
148
  -- Process regs
149
  --
150
  -- Purpose:
151
  --   Implement the various registers.
152 120 arniml
  --   They are designed according Figure "Interrupt Logic" of
153
  --   "The Single Component MCS-48 System".
154 4 arniml
  --
155
  regs: process (res_i, clk_i)
156
  begin
157
    if res_i = res_active_c then
158
      timer_flag_q       <= false;
159
      timer_overflow_q   <= false;
160
      timer_int_enable_q <= false;
161
      int_enable_q       <= false;
162
      int_type_q         <= '0';
163
      int_state_q        <= IDLE;
164
      int_in_progress_q  <= false;
165
 
166
    elsif clk_i'event and clk_i = clk_active_c then
167
      if en_clk_i then
168
 
169
        int_state_q <= int_state_s;
170
 
171
        if jtf_executed_i then
172
          timer_flag_q <= false;
173
        elsif tim_overflow_i then
174
          timer_flag_q <= true;
175
        end if;
176
 
177
        if (int_type_q = tim_int_c and int_executed_i) or
178
          not timer_int_enable_q then
179
          timer_overflow_q <= false;
180
        elsif tim_overflow_i then
181
          timer_overflow_q <= true;
182
        end if;
183
 
184
        if dis_tcnti_i then
185
          timer_int_enable_q <= false;
186
        elsif en_tcnti_i then
187
          timer_int_enable_q <= true;
188
        end if;
189
 
190
        if dis_i_i then
191
          int_enable_q <= false;
192
        elsif en_i_i then
193
          int_enable_q <= true;
194
        end if;
195
 
196
        if retr_executed_i then
197
          int_in_progress_q <= false;
198
        elsif (int_q and int_enable_q) or
199
          timer_overflow_q then
200
          int_in_progress_q <= true;
201
          if not int_in_progress_q then
202
            int_type_q <= to_stdLogic(int_q and int_enable_q);
203
          end if;
204
        end if;
205
 
206
      end if;
207
 
208
    end if;
209
 
210
  end process regs;
211
  --
212
  -----------------------------------------------------------------------------
213
 
214
 
215
  -----------------------------------------------------------------------------
216 205 arniml
  -- Process xtal_regs
217
  --
218
  -- Purpose:
219
  --   Implements the sequential registers clocked with XTAL.
220
  --
221
  xtal_regs: process (res_i, xtal_i)
222
  begin
223
    if res_i = res_active_c then
224
      int_q <= false;
225
      ale_q <= false;
226
 
227
    elsif xtal_i'event and xtal_i = clk_active_c then
228
      ale_q       <= ale_i;
229
 
230
      if last_cycle_i and
231
        ale_q  and not ale_i  then
232
        int_q <= not to_boolean(int_n_i);
233
      end if;
234
 
235
 
236
    end if;
237
  end process xtal_regs;
238
  --
239
  -----------------------------------------------------------------------------
240
 
241
 
242
  -----------------------------------------------------------------------------
243 4 arniml
  -- Output Mapping.
244
  -----------------------------------------------------------------------------
245 120 arniml
  tf_o              <= to_stdLogic(timer_flag_q);
246
  ext_int_o         <= int_type_q = ext_int_c;
247
  tim_int_o         <= int_type_q = tim_int_c;
248
  int_pending_o     <= int_state_q = PENDING;
249 187 arniml
  int_in_progress_o <= int_in_progress_q and int_state_q /= IDLE;
250 4 arniml
 
251
end rtl;
252
 
253
 
254
-------------------------------------------------------------------------------
255
-- File History:
256
--
257
-- $Log: not supported by cvs2svn $
258 205 arniml
-- Revision 1.5  2005/09/13 21:00:16  arniml
259
-- Fix bug reports:
260
-- "Target address of JMP to Program Memory Bank 1 corrupted by interrupt"
261
-- "Return address of CALL to Program Memory Bank 1 corrupted by interrupt"
262
-- int_in_progress_o was active one cycle before int_pending_o is
263
-- asserted. this confused the mb multiplexer which determines the state of
264
-- the memory bank selection flag
265
--
266 187 arniml
-- Revision 1.4  2005/06/11 10:08:43  arniml
267
-- introduce prefix 't48_' for all packages, entities and configurations
268
--
269 179 arniml
-- Revision 1.3  2004/07/11 16:51:33  arniml
270
-- cleanup copyright notice
271
--
272 129 arniml
-- Revision 1.2  2004/06/30 21:18:28  arniml
273
-- Fix bug report:
274
-- "Program Memory bank can be switched during interrupt"
275
-- int module emits int_in_progress signal that is used inside the decoder
276
-- to hold mb low for JMP and CALL during interrupts
277
--
278 120 arniml
-- Revision 1.1  2004/03/23 21:31:52  arniml
279
-- initial check-in
280 4 arniml
--
281
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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