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

Subversion Repositories v65c816

[/] [v65c816/] [trunk/] [opr.vhd] - Blame information for rev 4

Go to most recent revision | 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
-- 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
        brk_f: out STD_LOGIC;
14
        cop_f: out STD_LOGIC;
15
         dout: out STD_LOGIC_VECTOR(7 downto 0)
16
      );
17
end opr;
18
 
19
architecture rtl of opr is
20
constant BRK_OP: STD_LOGIC_VECTOR(7 downto 0) := "00000000"; -- 0x00 BRK/IRQ/NMI/RES
21
constant COP_OP: STD_LOGIC_VECTOR(7 downto 0) := "00000010"; -- 0x02 COP
22
signal      reg: STD_LOGIC_VECTOR(7 downto 0);
23
signal       bf: STD_LOGIC;
24
signal       cf: STD_LOGIC;
25
begin
26
  process(clk)
27
  begin
28
    if(clk'event and clk = '1')then
29
      if fwait = '1' then
30
        reg <= reg;
31
      else
32
        if clr = '1' then                  -- clr serves to force an "BRK" opcode on RES-NMI-IRQ interrupt
33
          reg <= BRK_OP;
34
          bf <= '0';
35
        else
36
          if ld = '1' then
37
            reg <= din;
38
            if din = BRK_OP then           -- check if the opcode "BRK" was loaded as normal instruction or it was forced 
39
              bf <= '1';                   -- by an interrupt request, thus in order to set properly the flag "B" of status register     
40
                                  cf <= '0';
41
            else
42
                                  if din = COP_OP THEN
43
                                     cf <= '1';
44
                                  else
45
                                     cf <= '0';
46
                                  end if;
47
              bf <= '0';
48
            end if;
49
          else
50
            reg <= reg;
51
            bf <= bf;
52
          end if;
53
        end if;
54
      end if;
55
    end if;
56
  end process;
57
  brk_f <= bf;
58
  cop_f <= cf;
59
  dout <= reg;
60
end rtl;
61
 
62
 

powered by: WebSVN 2.1.0

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