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 179

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 179 arniml
-- $Id: int.vhd,v 1.4 2005-06-11 10:08:43 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
    clk_mstate_i      : in  mstate_t;
59
    jtf_executed_i    : in  boolean;
60
    tim_overflow_i    : in  boolean;
61
    tf_o              : out std_logic;
62
    en_tcnti_i        : in  boolean;
63
    dis_tcnti_i       : in  boolean;
64
    int_n_i           : in  std_logic;
65
    ale_i             : in  boolean;
66
    last_cycle_i      : in  boolean;
67
    en_i_i            : in  boolean;
68
    dis_i_i           : in  boolean;
69
    ext_int_o         : out boolean;
70
    tim_int_o         : out boolean;
71
    retr_executed_i   : in  boolean;
72
    int_executed_i    : in  boolean;
73
    int_pending_o     : out boolean;
74
    int_in_progress_o : out boolean
75 4 arniml
  );
76
 
77 179 arniml
end t48_int;
78 4 arniml
 
79
 
80
use work.t48_pack.all;
81
 
82 179 arniml
architecture rtl of t48_int is
83 4 arniml
 
84
  constant tim_int_c : std_logic := '0';
85
  constant ext_int_c : std_logic := '1';
86
 
87
  type int_state_t is (IDLE, PENDING, INT);
88
 
89
  signal int_state_s,
90
         int_state_q  : int_state_t;
91
 
92
  signal timer_flag_q       : boolean;
93
  signal timer_overflow_q   : boolean;
94
  signal timer_int_enable_q : boolean;
95
  signal int_q              : boolean;
96
  signal int_enable_q       : boolean;
97
  signal ale_q              : boolean;
98
  signal int_type_q         : std_logic;
99
  signal int_in_progress_q  : boolean;
100
 
101
begin
102
 
103
  -----------------------------------------------------------------------------
104
  -- Process nstate
105
  --
106
  -- Purpose:
107
  --   Determines the next state of the Interrupt controller FSM.
108
  --
109
  nstate: process (int_state_q,
110
                   int_type_q,
111
                   int_in_progress_q,
112
                   int_executed_i,
113
                   retr_executed_i,
114
                   clk_mstate_i,
115
                   last_cycle_i)
116
  begin
117
    int_state_s <= int_state_q;
118
 
119
    case int_state_q is
120
      when IDLE =>
121
        if int_in_progress_q and
122
           last_cycle_i and clk_mstate_i = MSTATE5 then
123
          int_state_s <= PENDING;
124
        end if;
125
 
126
      when PENDING =>
127
        if int_executed_i then
128
          int_state_s <= INT;
129
        end if;
130
 
131
      when INT =>
132
        if retr_executed_i then
133
          int_state_s <= IDLE;
134
        end if;
135
 
136
      when others =>
137
        int_state_s <= IDLE;
138
 
139
    end case;
140
 
141
  end process nstate;
142
  --
143
  -----------------------------------------------------------------------------
144
 
145
 
146
  -----------------------------------------------------------------------------
147
  -- Process regs
148
  --
149
  -- Purpose:
150
  --   Implement the various registers.
151 120 arniml
  --   They are designed according Figure "Interrupt Logic" of
152
  --   "The Single Component MCS-48 System".
153 4 arniml
  --
154
  regs: process (res_i, clk_i)
155
  begin
156
    if res_i = res_active_c then
157
      timer_flag_q       <= false;
158
      timer_overflow_q   <= false;
159
      timer_int_enable_q <= false;
160
      int_q              <= false;
161
      int_enable_q       <= false;
162
      ale_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
        ale_q       <= ale_i;
171
 
172
        int_state_q <= int_state_s;
173
 
174
        if jtf_executed_i then
175
          timer_flag_q <= false;
176
        elsif tim_overflow_i then
177
          timer_flag_q <= true;
178
        end if;
179
 
180
        if (int_type_q = tim_int_c and int_executed_i) or
181
          not timer_int_enable_q then
182
          timer_overflow_q <= false;
183
        elsif tim_overflow_i then
184
          timer_overflow_q <= true;
185
        end if;
186
 
187
        if dis_tcnti_i then
188
          timer_int_enable_q <= false;
189
        elsif en_tcnti_i then
190
          timer_int_enable_q <= true;
191
        end if;
192
 
193
        if last_cycle_i and
194
          ale_q  and not ale_i  then
195
          int_q <= not to_boolean(int_n_i);
196
        end if;
197
 
198
        if dis_i_i then
199
          int_enable_q <= false;
200
        elsif en_i_i then
201
          int_enable_q <= true;
202
        end if;
203
 
204
        if retr_executed_i then
205
          int_in_progress_q <= false;
206
        elsif (int_q and int_enable_q) or
207
          timer_overflow_q then
208
          int_in_progress_q <= true;
209
          if not int_in_progress_q then
210
            int_type_q <= to_stdLogic(int_q and int_enable_q);
211
          end if;
212
        end if;
213
 
214
      end if;
215
 
216
    end if;
217
 
218
  end process regs;
219
  --
220
  -----------------------------------------------------------------------------
221
 
222
 
223
  -----------------------------------------------------------------------------
224
  -- Output Mapping.
225
  -----------------------------------------------------------------------------
226 120 arniml
  tf_o              <= to_stdLogic(timer_flag_q);
227
  ext_int_o         <= int_type_q = ext_int_c;
228
  tim_int_o         <= int_type_q = tim_int_c;
229
  int_pending_o     <= int_state_q = PENDING;
230
  int_in_progress_o <= int_in_progress_q;
231 4 arniml
 
232
end rtl;
233
 
234
 
235
-------------------------------------------------------------------------------
236
-- File History:
237
--
238
-- $Log: not supported by cvs2svn $
239 179 arniml
-- Revision 1.3  2004/07/11 16:51:33  arniml
240
-- cleanup copyright notice
241
--
242 129 arniml
-- Revision 1.2  2004/06/30 21:18:28  arniml
243
-- Fix bug report:
244
-- "Program Memory bank can be switched during interrupt"
245
-- int module emits int_in_progress signal that is used inside the decoder
246
-- to hold mb low for JMP and CALL during interrupts
247
--
248 120 arniml
-- Revision 1.1  2004/03/23 21:31:52  arniml
249
-- initial check-in
250 4 arniml
--
251
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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