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

Subversion Repositories next186mp3

[/] [next186mp3/] [trunk/] [HW/] [PIC_8259.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ndumitrach
//////////////////////////////////////////////////////////////////////////////////
2
//
3
// This file is part of the Next186 Soc PC project
4
// http://opencores.org/project,next186
5
//
6
// Filename: PIC_8259.v
7
// Description: Part of the Next186 SoC PC project, PIC controller
8
//      8259 simplified interrupt controller (only interrupt mask can be read, not IRR or ISR, no EOI required)
9
// Version 1.0
10
// Creation date: May2012
11
//
12
// Author: Nicolae Dumitrache 
13
// e-mail: ndumitrache@opencores.org
14
//
15
/////////////////////////////////////////////////////////////////////////////////
16
// 
17
// Copyright (C) 2012 Nicolae Dumitrache
18
// 
19
// This source file may be used and distributed without 
20
// restriction provided that this copyright statement is not 
21
// removed from the file and that any derivative work contains 
22
// the original copyright notice and the associated disclaimer.
23
// 
24
// This source file is free software; you can redistribute it 
25
// and/or modify it under the terms of the GNU Lesser General 
26
// Public License as published by the Free Software Foundation;
27
// either version 2.1 of the License, or (at your option) any 
28
// later version. 
29
// 
30
// This source is distributed in the hope that it will be 
31
// useful, but WITHOUT ANY WARRANTY; without even the implied 
32
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
33
// PURPOSE. See the GNU Lesser General Public License for more 
34
// details. 
35
// 
36
// You should have received a copy of the GNU Lesser General 
37
// Public License along with this source; if not, download it 
38
// from http://www.opencores.org/lgpl.shtml 
39
// 
40
///////////////////////////////////////////////////////////////////////////////////
41
// Additional Comments: 
42
// http://wiki.osdev.org/8259_PIC
43
//////////////////////////////////////////////////////////////////////////////////
44
 
45
`timescale 1ns / 1ps
46
 
47
module PIC_8259(
48
    input CS,
49
         input WR,
50
         input [7:0]din,
51
         output wire [7:0]dout,
52
         output reg [7:0]ivect,
53
         input clk,             // cpu CLK
54
         output reg INT = 0,
55
         input IACK,
56
         input [3:0]I    // 0:timer, 1:keyboard, 2:RTC, 3:mouse
57
    );
58
 
59
        reg [3:0]ss_I = 0;
60
        reg [3:0]s_I = 0;
61
        reg [3:0]IMR = 4'b1111;
62
        reg [3:0]IRR = 0;
63
 
64
        assign dout = {3'b000, IMR[3:2], 1'b0, IMR[1:0]};
65
 
66
        always @ (posedge clk) begin
67
                ss_I <= I;
68
                s_I <= ss_I;
69
                IRR <= (IRR | (~s_I & ss_I)) & ~IMR;    // front edge detection
70
                if(~INT) begin
71
                        if(IRR[0]) begin //timer
72
                                INT <= 1;
73
                                ivect <= 8'h08;
74
                                IRR[0] <= 0;
75
                        end else if(IRR[1]) begin  // keyboard
76
                                INT <= 1;
77
                                ivect <= 8'h09;
78
                                IRR[1] <= 0;
79
                        end else if(IRR[2]) begin  // RTC
80
                                INT <= 1;
81
                                ivect <= 8'h70;
82
                                IRR[2] <= 0;
83
                        end else if(IRR[3]) begin // mouse
84
                                INT <= 1;
85
                                ivect <= 8'h74;
86
                                IRR[3] <= 0;
87
                        end
88
                end else if(IACK) INT <= 0;      // also act as Auto EOI
89
 
90
                if(CS & WR) IMR <= {din[4:3], din[1:0]};
91
        end
92
 
93
 
94
endmodule
95
 
96
 

powered by: WebSVN 2.1.0

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