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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_0_6__beta/] [rtl/] [vhdl/] [int.vhd] - Blame information for rev 120

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 120 arniml
-- $Id: int.vhd,v 1.2 2004-06-30 21:18:28 arniml Exp $
7 4 arniml
--
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 120 arniml
    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
    int_in_progress_o : out boolean
73 4 arniml
  );
74
 
75
end int;
76
 
77
 
78
use work.t48_pack.all;
79
 
80
architecture rtl of int is
81
 
82
  constant tim_int_c : std_logic := '0';
83
  constant ext_int_c : std_logic := '1';
84
 
85
  type int_state_t is (IDLE, PENDING, INT);
86
 
87
  signal int_state_s,
88
         int_state_q  : int_state_t;
89
 
90
  signal timer_flag_q       : boolean;
91
  signal timer_overflow_q   : boolean;
92
  signal timer_int_enable_q : boolean;
93
  signal int_q              : boolean;
94
  signal int_enable_q       : boolean;
95
  signal ale_q              : boolean;
96
  signal int_type_q         : std_logic;
97
  signal int_in_progress_q  : boolean;
98
 
99
begin
100
 
101
  -----------------------------------------------------------------------------
102
  -- Process nstate
103
  --
104
  -- Purpose:
105
  --   Determines the next state of the Interrupt controller FSM.
106
  --
107
  nstate: process (int_state_q,
108
                   int_type_q,
109
                   int_in_progress_q,
110
                   int_executed_i,
111
                   retr_executed_i,
112
                   clk_mstate_i,
113
                   last_cycle_i)
114
  begin
115
    int_state_s <= int_state_q;
116
 
117
    case int_state_q is
118
      when IDLE =>
119
        if int_in_progress_q and
120
           last_cycle_i and clk_mstate_i = MSTATE5 then
121
          int_state_s <= PENDING;
122
        end if;
123
 
124
      when PENDING =>
125
        if int_executed_i then
126
          int_state_s <= INT;
127
        end if;
128
 
129
      when INT =>
130
        if retr_executed_i then
131
          int_state_s <= IDLE;
132
        end if;
133
 
134
      when others =>
135
        int_state_s <= IDLE;
136
 
137
    end case;
138
 
139
  end process nstate;
140
  --
141
  -----------------------------------------------------------------------------
142
 
143
 
144
  -----------------------------------------------------------------------------
145
  -- Process regs
146
  --
147
  -- Purpose:
148
  --   Implement the various registers.
149 120 arniml
  --   They are designed according Figure "Interrupt Logic" of
150
  --   "The Single Component MCS-48 System".
151 4 arniml
  --
152
  regs: process (res_i, clk_i)
153
  begin
154
    if res_i = res_active_c then
155
      timer_flag_q       <= false;
156
      timer_overflow_q   <= false;
157
      timer_int_enable_q <= false;
158
      int_q              <= false;
159
      int_enable_q       <= false;
160
      ale_q              <= false;
161
      int_type_q         <= '0';
162
      int_state_q        <= IDLE;
163
      int_in_progress_q  <= false;
164
 
165
    elsif clk_i'event and clk_i = clk_active_c then
166
      if en_clk_i then
167
 
168
        ale_q       <= ale_i;
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 last_cycle_i and
192
          ale_q  and not ale_i  then
193
          int_q <= not to_boolean(int_n_i);
194
        end if;
195
 
196
        if dis_i_i then
197
          int_enable_q <= false;
198
        elsif en_i_i then
199
          int_enable_q <= true;
200
        end if;
201
 
202
        if retr_executed_i then
203
          int_in_progress_q <= false;
204
        elsif (int_q and int_enable_q) or
205
          timer_overflow_q then
206
          int_in_progress_q <= true;
207
          if not int_in_progress_q then
208
            int_type_q <= to_stdLogic(int_q and int_enable_q);
209
          end if;
210
        end if;
211
 
212
      end if;
213
 
214
    end if;
215
 
216
  end process regs;
217
  --
218
  -----------------------------------------------------------------------------
219
 
220
 
221
  -----------------------------------------------------------------------------
222
  -- Output Mapping.
223
  -----------------------------------------------------------------------------
224 120 arniml
  tf_o              <= to_stdLogic(timer_flag_q);
225
  ext_int_o         <= int_type_q = ext_int_c;
226
  tim_int_o         <= int_type_q = tim_int_c;
227
  int_pending_o     <= int_state_q = PENDING;
228
  int_in_progress_o <= int_in_progress_q;
229 4 arniml
 
230
end rtl;
231
 
232
 
233
-------------------------------------------------------------------------------
234
-- File History:
235
--
236
-- $Log: not supported by cvs2svn $
237 120 arniml
-- Revision 1.1  2004/03/23 21:31:52  arniml
238
-- initial check-in
239 4 arniml
--
240 120 arniml
--
241 4 arniml
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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