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

Subversion Repositories v65c816

[/] [v65c816/] [trunk/] [intlog.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 Valerio63
library IEEE;
2
use IEEE.std_logic_1164.all;  -- defines std_logic types
3
use IEEE.STD_LOGIC_unsigned.all;
4
use IEEE.STD_LOGIC_arith.all;
5
 
6
-- interrupt request logic
7
entity intlog is
8
  port(    clk:  in STD_LOGIC;
9
          iack:  in STD_LOGIC;                    -- interrupt acknowledge by microcode 
10
             r:  in STD_LOGIC;                    -- RESET request
11
             n:  in STD_LOGIC;                    -- NMI request
12
             i:  in STD_LOGIC;                    -- IRQ request
13
           brk:  in STD_LOGIC;                    -- BRK opcode
14
                          cop:  in STD_LOGIC;                    -- COP opcode
15
                            e:  in STD_LOGIC;                    -- native\emulation mode
16
                        gmask:  in STD_LOGIC;                    -- global interrupt mask valid for IRQ and NMI (used by two byte instruction)   
17
         imask:  in STD_LOGIC;                    -- interrupt mask (valid only for IRQ)
18
         ioffs:  in STD_LOGIC_VECTOR(7 downto 0); -- interrupt servicing offset
19
          ireq: out STD_LOGIC;                    -- global interrupt requestb (IRQ/NMI)
20
         voffs: out STD_LOGIC_VECTOR(7 downto 0)  -- interrupt vector offset 
21
        );
22
end intlog;
23
 
24
architecture rtl of intlog is
25
signal irq_sync:   STD_LOGIC_VECTOR(1 downto 0);
26
signal nmi_sync:   STD_LOGIC_VECTOR(1 downto 0);
27
signal res_sync:   STD_LOGIC_VECTOR(1 downto 0);
28
signal irq_req:    STD_LOGIC;
29
signal i_nmi_req:  STD_LOGIC;
30
signal nmi_req:    STD_LOGIC;
31
signal res_req:    STD_LOGIC;
32
signal nmi_clr:    STD_LOGIC;
33
signal res_clr:    STD_LOGIC;
34
 
35
begin
36
  process(clk)                                                           -- IRQ/NMI synchronization
37
  begin
38
    if(clk'event and clk = '1')then
39
      res_sync <= res_sync(res_sync'left-1 downto res_sync'right) & r;   -- RES sampling
40
      nmi_sync <= nmi_sync(nmi_sync'left-1 downto nmi_sync'right) & n;   -- NMI sampling
41
      irq_sync <= irq_sync(irq_sync'left-1 downto irq_sync'right) & i;   -- IRQ sampling
42
      if res_clr = '1' then                                              -- RES ack
43
        res_req <= '0';
44
      else
45
        if res_sync = "11" then                                          -- level detection for RES
46
          res_req <= '1';
47
        else
48
          res_req <= res_req;
49
        end if;
50
      end if;
51
      if nmi_clr = '1' then                                              -- NMI ack
52
         i_nmi_req <= '0';
53
      else
54
        if nmi_sync = "01" then                                          -- edge detection for NMI
55
           i_nmi_req <= '1';
56
        else
57
           i_nmi_req <= i_nmi_req;
58
        end if;
59
      end if;
60
    end if;
61
  end process;
62
  nmi_req <= '1' when gmask = '0' and i_nmi_req = '1' else '0';
63
 
64
 
65
  process(gmask, imask, irq_sync)
66
  begin
67
    if gmask = '0' and imask = '0' then
68
      if irq_sync = "11" then
69
        irq_req <= '1';
70
      else
71
        irq_req <= '0';
72
      end if;
73
    else
74
      irq_req <= '0';
75
    end if;
76
  end process;
77
 
78
  -- priority encoder and vector offset generation (vector bits 7..0)
79
  process(e, res_req, nmi_req, irq_req, brk, cop)
80
  begin
81
          if e = '0' then                                                     -- native mode
82
        if res_req = '1' then
83
                voffs <= x"FC";                                               -- RESET 0x00FFFC 
84
                  else
85
           if nmi_req = '1' then
86
                   voffs <= x"EA";                                            -- NMI   0x00FFEA
87
                     else
88
                   if irq_req = '1' then
89
                           voffs <= x"EE";                                         -- IRQ   0x00FFEE 
90
                             else
91
                           if brk = '1' then
92
                                   voffs <= x"E6";                                      -- BRK   0x00FFE6
93
                                     else
94
                                   if cop = '1' then
95
                                      voffs <= x"E4";                                   -- COP   0x00FFE4 
96
                                                  else
97
                                                voffs <= "XXXXXXXX";
98
                                                  end if;
99
                                     end if;
100
                             end if;
101
                     end if;
102
             end if;
103
     else                                                                         -- emulation mode
104
        if res_req = '1' then
105
                voffs <= x"FC";                                               -- RESET 0x00FFFC
106
                  else
107
           if nmi_req = '1' then                                         -- NMI   0x00FFFA
108
                   voffs <= x"FA";
109
                     else
110
                   if irq_req = '1' then                                      -- IRQ   0x00FFFE
111
                           voffs <= x"FE";
112
                             else
113
                           if brk = '1' then                                       -- BRK   0x00FFFE 
114
                                   voffs <= x"FE";
115
                                     else
116
                                   if cop = '1' then                                    -- COP   0x00FFF4
117
                                      voffs <= x"F4";
118
                                                  else
119
                                                voffs <= "XXXXXXXX";
120
                                                  end if;
121
                                     end if;
122
                             end if;
123
                     end if;
124
             end if;
125
          end if;
126
 
127
  end process;
128
 
129
  process(iack,ioffs)                                                    -- interrupt acknowledge and flags clear
130
  begin
131
    if iack = '1' then
132
      case ioffs is
133
        when x"FC"  => res_clr <= '1';                                   -- RESET acknowledge
134
                       nmi_clr <= '1';                                   -- also NMI acknowledge
135
        when x"EA"  => nmi_clr <= '1';                                   -- NMI acknowledge (native mode)
136
                       res_clr <= '0';
137
        when x"FA"  => nmi_clr <= '1';                                   -- NMI acknowledge (emulation mode)
138
                       res_clr <= '0';
139
        when others => res_clr <= '0';
140
                       nmi_clr <= '0';
141
      end case;
142
    else
143
      res_clr <= '0';
144
      nmi_clr <= '0';
145
    end if;
146
  end process;
147
 
148
  ireq <= res_req or nmi_req or irq_req;
149
end rtl;
150
 
151
 

powered by: WebSVN 2.1.0

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