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

Subversion Repositories v6502

[/] [v6502/] [trunk/] [opr.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
-- 8 bit opcode hold register
7
entity opr is
8
  port(   clk:  in STD_LOGIC;
9
          clr:  in STD_LOGIC;
10
        fwait:  in STD_LOGIC;
11
           ld:  in STD_LOGIC;
12
          din:  in STD_LOGIC_VECTOR(7 downto 0);
13
            b: out STD_LOGIC;
14
         dout: out STD_LOGIC_VECTOR(7 downto 0)
15
      );
16
end opr;
17
 
18
architecture rtl of opr is
19
constant BRK_OP: STD_LOGIC_VECTOR(7 downto 0) := "00000000"; -- 0x00 BRK/IRQ/NMI/RES
20
signal      reg: STD_LOGIC_VECTOR(7 downto 0);
21
signal       bf: STD_LOGIC;
22
begin
23
  process(clk)
24
  begin
25
    if(clk'event and clk = '1')then
26
      if fwait = '1' then
27
        reg <= reg;
28
      else
29
        if clr = '1' then                  -- clr serves to force an "BRK" opcode on RES-NMI-IRQ interrupt
30
          reg <= BRK_OP;
31
          bf <= '0';
32
        else
33
          if ld = '1' then
34
            reg <= din;
35
            if din = BRK_OP then           -- check if the opcode "BRK" was loaded as normal instruction or it was forced 
36
              bf <= '1';                   -- by an interrupt request, thus in order to set properly the flag "B" of status register     
37
            else
38
              bf <= '0';
39
            end if;
40
          else
41
            reg <= reg;
42
            bf <= bf;
43
          end if;
44
        end if;
45
      end if;
46
    end if;
47
  end process;
48
  b <= bf;
49
  dout <= reg;
50
end rtl;
51
 
52
 

powered by: WebSVN 2.1.0

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