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

Subversion Repositories m65c02

[/] [m65c02/] [trunk/] [Src/] [RTL/] [M65C02_IntHndlr.v] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 MichaelA
////////////////////////////////////////////////////////////////////////////////
2
//
3
//  Copyright 2013 by Michael A. Morris, dba M. A. Morris & Associates
4
//
5
//  All rights reserved. The source code contained herein is publicly released
6
//  under the terms and conditions of the GNU Lesser Public License. No part of
7
//  this source code may be reproduced or transmitted in any form or by any
8
//  means, electronic or mechanical, including photocopying, recording, or any
9
//  information storage and retrieval system in violation of the license under
10
//  which the source code is released.
11
//
12
//  The source code contained herein is free; it may be redistributed and/or
13
//  modified in accordance with the terms of the GNU Lesser General Public
14
//  License as published by the Free Software Foundation; either version 2.1 of
15
//  the GNU Lesser General Public License, or any later version.
16
//
17
//  The source code contained herein is freely released WITHOUT ANY WARRANTY;
18
//  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
19
//  PARTICULAR PURPOSE. (Refer to the GNU Lesser General Public License for
20
//  more details.)
21
//
22
//  A copy of the GNU Lesser General Public License should have been received
23
//  along with the source code contained herein; if not, a copy can be obtained
24
//  by writing to:
25
//
26
//  Free Software Foundation, Inc.
27
//  51 Franklin Street, Fifth Floor
28
//  Boston, MA  02110-1301 USA
29
//
30
//  Further, no use of this source code is permitted in any form or means
31
//  without inclusion of this banner prominently in any derived works.
32
//
33
//  Michael A. Morris
34
//  Huntsville, AL
35
//
36
////////////////////////////////////////////////////////////////////////////////
37
 
38
`timescale 1ns / 1ps
39
 
40
////////////////////////////////////////////////////////////////////////////////
41
// Company:         M. A. Morris & Associates 
42
// Engineer:        Michael A. Morris 
43
// 
44
// Create Date:     12:06:18 08/18/2013 
45
// Design Name:     M65C02 -  
46
// Module Name:     M65C02_IntHndlr.v 
47
// Project Name:    C:\XProjects\ISE10.1i\M65C02 
48
// Target Devices:  SRAM-based FPGAs: XC3S50A-xVQ100I, XC3S200A-xVQ100I 
49
// Tool versions:   Xilinx ISE 10.1i SP3
50
// 
51
// Description: 
52
//
53
//  This module implements a simple interrupt handler for the M65C02 soft-core
54
//  microprocessor. It accepts external active low inputs for Non-Maskable
55
//  Interrupt request (nNMI) and maskable Interrupt ReQuest (nIRQ). It synchro-
56
//  nizes both inputs to the internal system clock (Clk), and generates internal
57
//  signals NMI and IRQ. NMI is falling edge sensitive, and IRQ is active low
58
//  level sensitive. The module also accepts the core's mode output (Mode) and
59
//  generates an internal BReaK software trap request (BRK).
60
//
61
//  The non-maskable interrupt request, nNMI, has priority, followed by BRK, and
62
//  finally nIRQ. The core, from the I bit in the processor register, provides a
63
//  mask that prevents the generation of the internal IRQ signal.
64
//
65
//  Vectors for each of the four interrupt/trap sources are set using para-
66
//  meters. The current implementation aims to maintain compatibility with the
67
//  WDC W65C02S processor, so IRQ and BRK share the same vector. A quick edit
68
//  of the parameters allows an independent vector location to be added for BRK.
69
//  Similarly, the vectors for any of the interrupt/trap sources can be moved
70
//  to any location in the memory space, if W65C02S compatibility is not desired
71
//  or required.
72
//
73
// Dependencies:    fedet.v 
74
//
75
// Revision:
76
//
77
//  0.01    13H18   MAM     File Created 
78
// 
79
// Additional Comments: 
80
//
81
///////////////////////////////////////////////////////////////////////////////
82
 
83
module M65C02_IntHndlr #(
84
    parameter pIRQ_Vector = 16'hFFFE,
85
    parameter pBRK_Vector = 16'hFFFE,
86
    parameter pRST_Vector = 16'hFFFC,
87
    parameter pNMI_Vector = 16'hFFFA,
88
    parameter pBRK        = 3'b010
89
)(
90
    input   Rst,
91
    input   Clk,
92
 
93
    input   nNMI,
94
    input   nIRQ,
95
    input   [2:0] Mode,
96
 
97
    input   IRQ_Msk,
98
    input   IntSvc,
99
 
100
    output  reg Int,
101
    output  reg [15:0] Vector,
102
 
103
    output  reg NMI,
104
    output  reg IRQ,
105
    output  reg Brk
106
);
107
 
108
////////////////////////////////////////////////////////////////////////////////
109
//
110
//  Local Declarations
111
//
112
 
113
wire    RE_NMI;
114
wire    CE_NMI;
115
reg     nIRQ_IFD;
116
 
117
 
118
//  Perform falling edge detection on the external non-maskable interrupt input
119
 
120
fedet   FE3 (
121
            .rst(Rst),
122
            .clk(Clk),
123
            .din(nNMI),
124
            .pls(RE_NMI)
125
        );
126
 
127
//  Capture and hold the rising edge pulse for NMI in NMI FF until serviced by
128
//      the processor.
129
 
130
assign CE_NMI = (Rst | IntSvc | RE_NMI);
131
always @(posedge Clk) NMI <= #1 ((CE_NMI) ? RE_NMI : 0);
132
 
133
//  Synchronize external IRQ input to Clk
134
 
135
always @(posedge Clk or posedge Rst)
136
begin
137
    if(Rst) begin
138
        nIRQ_IFD <= #1 1;
139
        IRQ      <= #1 0;
140
    end else begin
141
        nIRQ_IFD <= #1 nIRQ;
142
        IRQ      <= #1 ~nIRQ_IFD;
143
    end
144
end
145
 
146
//assign Brk    = (Mode == pBRK);
147
//assign Int    = (NMI | (~IRQ_Msk & IRQ));
148
//
149
//always @(*) Vector = ((Int) ? ((NMI) ? pNMI_Vector
150
//                                     : pIRQ_Vector)
151
//                            : ((Brk) ? pBRK_Vector
152
//                                     : pRST_Vector));
153
 
154
always @(posedge Clk or posedge Rst)
155
begin
156
    if(Rst) begin
157
        Brk    <= #1 0;
158
        Int    <= #1 0;
159
        Vector <= #1 pRST_Vector;
160
    end else begin
161
        Brk    <= #1 (Mode == pBRK);
162
        Int    <= #1 (NMI | (~IRQ_Msk & IRQ));
163
        Vector <= #1 ((Int) ? ((NMI) ? pNMI_Vector
164
                                     : pIRQ_Vector)
165
                            : ((Brk) ? pBRK_Vector
166
                                     : pRST_Vector));
167
    end
168
end
169
 
170
endmodule

powered by: WebSVN 2.1.0

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