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

Subversion Repositories v6502

[/] [v6502/] [trunk/] [intlog.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 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
             b:  in STD_LOGIC;                    -- BRK opcode
14
             s:  in STD_LOGIC;                    -- SO
15
         imask:  in STD_LOGIC;                    -- interrupt mask (valid only for IRQ)
16
         ioffs:  in STD_LOGIC_VECTOR(1 downto 0); -- interrupt servicing offset
17
          ireq: out STD_LOGIC;                    -- global interrupt requestb (IRQ/NMI)
18
          vset: out STD_LOGIC;                    -- SO output
19
         voffs: out STD_LOGIC_VECTOR(2 downto 0)  -- interrupt vector offset 
20
        );
21
end intlog;
22
 
23
architecture rtl of intlog is
24
signal irq_sync: STD_LOGIC_VECTOR(1 downto 0);
25
signal nmi_sync: STD_LOGIC_VECTOR(1 downto 0);
26
signal res_sync: STD_LOGIC_VECTOR(1 downto 0);
27
signal irq_req:  STD_LOGIC;
28
signal nmi_req:  STD_LOGIC;
29
signal res_req:  STD_LOGIC;
30
signal nmi_clr:  STD_LOGIC;
31
signal res_clr:  STD_LOGIC;
32
signal irq_brk:  STD_LOGIC;
33
signal so_sync:  STD_LOGIC_VECTOR(1 downto 0);
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
        nmi_req <= '0';
53
      else
54
        if nmi_sync = "01" then                                          -- edge detection for NMI
55
          nmi_req <= '1';
56
        else
57
          nmi_req <= nmi_req;
58
        end if;
59
      end if;
60
    end if;
61
  end process;
62
 
63
  process(imask, irq_sync)
64
  begin
65
    if imask = '0' then
66
      if irq_sync = "11" then
67
        irq_req <= '1';
68
      else
69
        irq_req <= '0';
70
      end if;
71
    else
72
      irq_req <= '0';
73
    end if;
74
  end process;
75
 
76
  irq_brk <= irq_req or b;                                               -- IRQ | BRK (opcode)
77
 
78
  -- priority encoder and vector offset generation (vector bits 2..0)
79
  voffs <= "100" when res_req = '1' else                                 -- RESET VECTOR:    0xFFFC - 0xFFFD   
80
           "010" when nmi_req = '1' else                                 -- NMI VECTOR:      0xFFFA - 0xFFFB
81
           "110" when irq_brk = '1' else "XXX";                          -- IRQ/BRK VECTOR:  0xFFFE - 0xFFFF
82
 
83
  process(iack,ioffs)                                                    -- interrupt acknowledge and flags clear
84
  begin
85
    if iack = '1' then
86
      case ioffs is
87
        when "10"   => res_clr <= '1';                                   -- RESET acknowledge
88
                       nmi_clr <= '1';                                   -- also NMI acknowledge
89
        when "01"   => nmi_clr <= '1';                                   -- NMI acknowledge
90
                       res_clr <= '0';
91
        when others => res_clr <= '0';
92
                       nmi_clr <= '0';
93
      end case;
94
    else
95
      res_clr <= '0';
96
      nmi_clr <= '0';
97
    end if;
98
  end process;
99
 
100
  process(clk)                                                           -- SO synchronization
101
  begin
102
    if(clk'event and clk = '1')then
103
      so_sync <= so_sync(so_sync'left-1 downto so_sync'right) & s;       -- SO sampling (edge detection)
104
    end if;
105
  end process;
106
 
107
  ireq <= res_req or nmi_req or irq_req;
108
  vset <= '0' when so_sync = "10" else '1';
109
end rtl;
110
 
111
 

powered by: WebSVN 2.1.0

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