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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_1_0/] [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 220 arniml
-- $Id: int.vhd,v 1.7 2006-06-20 00:46:03 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 220 arniml
    xtal_en_i         : in  boolean;
60 120 arniml
    clk_mstate_i      : in  mstate_t;
61
    jtf_executed_i    : in  boolean;
62
    tim_overflow_i    : in  boolean;
63
    tf_o              : out std_logic;
64
    en_tcnti_i        : in  boolean;
65
    dis_tcnti_i       : in  boolean;
66
    int_n_i           : in  std_logic;
67
    ale_i             : in  boolean;
68
    last_cycle_i      : in  boolean;
69
    en_i_i            : in  boolean;
70
    dis_i_i           : in  boolean;
71
    ext_int_o         : out boolean;
72
    tim_int_o         : out boolean;
73
    retr_executed_i   : in  boolean;
74
    int_executed_i    : in  boolean;
75
    int_pending_o     : out boolean;
76
    int_in_progress_o : out boolean
77 4 arniml
  );
78
 
79 179 arniml
end t48_int;
80 4 arniml
 
81
 
82
use work.t48_pack.all;
83
 
84 179 arniml
architecture rtl of t48_int is
85 4 arniml
 
86
  constant tim_int_c : std_logic := '0';
87
  constant ext_int_c : std_logic := '1';
88
 
89
  type int_state_t is (IDLE, PENDING, INT);
90
 
91
  signal int_state_s,
92
         int_state_q  : int_state_t;
93
 
94
  signal timer_flag_q       : boolean;
95
  signal timer_overflow_q   : boolean;
96
  signal timer_int_enable_q : boolean;
97
  signal int_q              : boolean;
98
  signal int_enable_q       : boolean;
99
  signal ale_q              : boolean;
100
  signal int_type_q         : std_logic;
101
  signal int_in_progress_q  : boolean;
102
 
103
begin
104
 
105
  -----------------------------------------------------------------------------
106
  -- Process nstate
107
  --
108
  -- Purpose:
109
  --   Determines the next state of the Interrupt controller FSM.
110
  --
111
  nstate: process (int_state_q,
112
                   int_type_q,
113
                   int_in_progress_q,
114
                   int_executed_i,
115
                   retr_executed_i,
116
                   clk_mstate_i,
117
                   last_cycle_i)
118
  begin
119
    int_state_s <= int_state_q;
120
 
121
    case int_state_q is
122
      when IDLE =>
123
        if int_in_progress_q and
124
           last_cycle_i and clk_mstate_i = MSTATE5 then
125
          int_state_s <= PENDING;
126
        end if;
127
 
128
      when PENDING =>
129
        if int_executed_i then
130
          int_state_s <= INT;
131
        end if;
132
 
133
      when INT =>
134
        if retr_executed_i then
135
          int_state_s <= IDLE;
136
        end if;
137
 
138
      when others =>
139
        int_state_s <= IDLE;
140
 
141
    end case;
142
 
143
  end process nstate;
144
  --
145
  -----------------------------------------------------------------------------
146
 
147
 
148
  -----------------------------------------------------------------------------
149
  -- Process regs
150
  --
151
  -- Purpose:
152
  --   Implement the various registers.
153 120 arniml
  --   They are designed according Figure "Interrupt Logic" of
154
  --   "The Single Component MCS-48 System".
155 4 arniml
  --
156
  regs: process (res_i, clk_i)
157
  begin
158
    if res_i = res_active_c then
159
      timer_flag_q       <= false;
160
      timer_overflow_q   <= false;
161
      timer_int_enable_q <= false;
162
      int_enable_q       <= false;
163
      int_type_q         <= '0';
164
      int_state_q        <= IDLE;
165
      int_in_progress_q  <= false;
166
 
167
    elsif clk_i'event and clk_i = clk_active_c then
168
      if en_clk_i then
169
 
170
        int_state_q <= int_state_s;
171
 
172
        if jtf_executed_i then
173
          timer_flag_q <= false;
174
        elsif tim_overflow_i then
175
          timer_flag_q <= true;
176
        end if;
177
 
178
        if (int_type_q = tim_int_c and int_executed_i) or
179
          not timer_int_enable_q then
180
          timer_overflow_q <= false;
181
        elsif tim_overflow_i then
182
          timer_overflow_q <= true;
183
        end if;
184
 
185
        if dis_tcnti_i then
186
          timer_int_enable_q <= false;
187
        elsif en_tcnti_i then
188
          timer_int_enable_q <= true;
189
        end if;
190
 
191
        if dis_i_i then
192
          int_enable_q <= false;
193
        elsif en_i_i then
194
          int_enable_q <= true;
195
        end if;
196
 
197
        if retr_executed_i then
198
          int_in_progress_q <= false;
199
        elsif (int_q and int_enable_q) or
200
          timer_overflow_q then
201
          int_in_progress_q <= true;
202
          if not int_in_progress_q then
203
            int_type_q <= to_stdLogic(int_q and int_enable_q);
204
          end if;
205
        end if;
206
 
207
      end if;
208
 
209
    end if;
210
 
211
  end process regs;
212
  --
213
  -----------------------------------------------------------------------------
214
 
215
 
216
  -----------------------------------------------------------------------------
217 205 arniml
  -- Process xtal_regs
218
  --
219
  -- Purpose:
220
  --   Implements the sequential registers clocked with XTAL.
221
  --
222
  xtal_regs: process (res_i, xtal_i)
223
  begin
224
    if res_i = res_active_c then
225
      int_q <= false;
226
      ale_q <= false;
227
 
228
    elsif xtal_i'event and xtal_i = clk_active_c then
229 220 arniml
      if xtal_en_i then
230
        ale_q   <= ale_i;
231 205 arniml
 
232 220 arniml
        if last_cycle_i and
233
          ale_q  and not ale_i  then
234
          int_q <= not to_boolean(int_n_i);
235
        end if;
236
 
237 205 arniml
      end if;
238
    end if;
239
  end process xtal_regs;
240
  --
241
  -----------------------------------------------------------------------------
242
 
243
 
244
  -----------------------------------------------------------------------------
245 4 arniml
  -- Output Mapping.
246
  -----------------------------------------------------------------------------
247 120 arniml
  tf_o              <= to_stdLogic(timer_flag_q);
248
  ext_int_o         <= int_type_q = ext_int_c;
249
  tim_int_o         <= int_type_q = tim_int_c;
250
  int_pending_o     <= int_state_q = PENDING;
251 187 arniml
  int_in_progress_o <= int_in_progress_q and int_state_q /= IDLE;
252 4 arniml
 
253
end rtl;
254
 
255
 
256
-------------------------------------------------------------------------------
257
-- File History:
258
--
259
-- $Log: not supported by cvs2svn $
260 220 arniml
-- Revision 1.6  2005/11/01 21:26:24  arniml
261
-- operate ale_q and int_q with xtal_i after shift of ALE assertion to XTAL3
262
--
263 205 arniml
-- Revision 1.5  2005/09/13 21:00:16  arniml
264
-- Fix bug reports:
265
-- "Target address of JMP to Program Memory Bank 1 corrupted by interrupt"
266
-- "Return address of CALL to Program Memory Bank 1 corrupted by interrupt"
267
-- int_in_progress_o was active one cycle before int_pending_o is
268
-- asserted. this confused the mb multiplexer which determines the state of
269
-- the memory bank selection flag
270
--
271 187 arniml
-- Revision 1.4  2005/06/11 10:08:43  arniml
272
-- introduce prefix 't48_' for all packages, entities and configurations
273
--
274 179 arniml
-- Revision 1.3  2004/07/11 16:51:33  arniml
275
-- cleanup copyright notice
276
--
277 129 arniml
-- Revision 1.2  2004/06/30 21:18:28  arniml
278
-- Fix bug report:
279
-- "Program Memory bank can be switched during interrupt"
280
-- int module emits int_in_progress signal that is used inside the decoder
281
-- to hold mb low for JMP and CALL during interrupts
282
--
283 120 arniml
-- Revision 1.1  2004/03/23 21:31:52  arniml
284
-- initial check-in
285 4 arniml
--
286
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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