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

Subversion Repositories v65c816

[/] [v65c816/] [trunk/] [mpr.vhd] - Blame information for rev 3

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
-- 16 bit memory pointer address register 
7
entity mpr is
8
  port(   clk:  in STD_LOGIC;
9
        fwait:  in STD_LOGIC;
10
       dbr_ld:  in STD_LOGIC;
11
                      c:  in STD_LOGIC;
12
           fc:  in STD_LOGIC_VECTOR(4 downto 0);
13
        din_l:  in STD_LOGIC_VECTOR(7 downto 0);
14
        din_h:  in STD_LOGIC_VECTOR(7 downto 0);
15
          dbr:  in STD_LOGIC_VECTOR(7 downto 0);
16
           dr:  in STD_LOGIC_VECTOR(15 downto 0);
17
                          op:  in STD_LOGIC_VECTOR(15 downto 0);
18
                          xr:  in STD_LOGIC_VECTOR(15 downto 0);
19
                          yr:  in STD_LOGIC_VECTOR(15 downto 0);
20
                          sr:  in STD_LOGIC_VECTOR(15 downto 0);
21
            v:  in STD_LOGIC_VECTOR(7 downto 0);
22
         dout: out STD_LOGIC_VECTOR(23 downto 0)
23
      );
24
end mpr;
25
 
26
architecture rtl of mpr is
27
constant NOP_M: STD_LOGIC_VECTOR(4 downto 0) := "00000"; -- no operation
28
constant LSB_M: STD_LOGIC_VECTOR(4 downto 0) := "00001"; -- load lsb
29
constant MSB_M: STD_LOGIC_VECTOR(4 downto 0) := "00010"; -- load msb
30
constant INC_M: STD_LOGIC_VECTOR(4 downto 0) := "00011"; -- increment 
31
constant DEC_M: STD_LOGIC_VECTOR(4 downto 0) := "00100"; -- decrement
32
constant VEC_M: STD_LOGIC_VECTOR(4 downto 0) := "00101"; -- load vector
33
constant ZPL_M: STD_LOGIC_VECTOR(4 downto 0) := "00110"; -- load ZEROPAGE
34
constant ALL_M: STD_LOGIC_VECTOR(4 downto 0) := "00111"; -- load all 16 bit register
35
constant ICC_M: STD_LOGIC_VECTOR(4 downto 0) := "01000"; -- increment MSB with carry
36
constant DOX_M: STD_LOGIC_VECTOR(4 downto 0) := "01001"; -- add D + offset + X
37
constant DOY_M: STD_LOGIC_VECTOR(4 downto 0) := "01010"; -- add D + offset + Y
38
constant AOS_M: STD_LOGIC_VECTOR(4 downto 0) := "01011"; -- add S + offset
39
constant ABX_M: STD_LOGIC_VECTOR(4 downto 0) := "01100"; -- add opr+X
40
constant ABY_M: STD_LOGIC_VECTOR(4 downto 0) := "01101"; -- add opr+Y
41
constant ADX_M: STD_LOGIC_VECTOR(4 downto 0) := "01110"; -- add X
42
constant ADY_M: STD_LOGIC_VECTOR(4 downto 0) := "01111"; -- add Y
43
constant MHB_M: STD_LOGIC_VECTOR(4 downto 0) := "10000"; -- load high byte 
44
constant AOY_M: STD_LOGIC_VECTOR(4 downto 0) := "10001"; -- add opr+Y and concatenates SBR
45
 
46
signal reg: STD_LOGIC_VECTOR(23 downto 0);
47
begin
48
  process(clk)
49
  begin
50
    if (clk'event and clk = '1') then
51
      if fwait = '1' then
52
        reg <= reg;
53
      else
54
                  if dbr_ld = '1' then           -- on every opcode fetch the high byte of MPR is loaded with DBR value                                                                                                     
55
           reg(23 downto 16) <= dbr;
56
        end if;
57
        case fc is
58
          when LSB_M  => reg(7 downto 0)  <= din_l; reg(23 downto 8) <= reg(23 downto 8);                                            -- load LSB (bit 7..0)
59
          when MSB_M  => reg(15 downto 8) <= din_h; reg(7 downto 0) <= reg(7 downto 0); reg(23 downto 16) <= reg(23 downto 16);      -- load MSB (bit 15..8)
60
          when ALL_M  => reg(15 downto 8) <= din_h; reg(7 downto 0) <= din_l; reg(23 downto 16) <= reg(23 downto 16);                -- load LSB/MSB (bit 15..0)
61
          when INC_M  => reg <= reg +1;                                                                                              -- increment 24 bit
62
          when DEC_M  => reg <= reg -1;                                                                                              -- decrement 24 bit
63
          when VEC_M  => reg <= "0000000011111111" & v;                                                                              -- 0x00FFXX load vector
64
          when ZPL_M  => reg(15 downto 0) <= dr + ("00000000" & din_l);                                                              -- 0x00XXXX zeropage operation (D + 0x0000XX)
65
          when ICC_M  => reg(15 downto 8) <= reg(15 downto 8) + c;                                                                   -- increment MSB for indexed addressing mode
66
                         when DOX_M  => reg(15 downto 0) <= dr + ("00000000" & din_l) + xr;                                                         -- D+offset+X
67
                         when DOY_M  => reg(15 downto 0) <= dr + ("00000000" & din_l) + yr;                                                         -- D+offset+Y
68
                         when AOS_M  => reg(15 downto 0) <= sr + ("00000000" & din_h); reg(23 downto 16) <= "00000000";                             -- S+offset
69
                         when ABX_M  => reg(15 downto 0) <= din_h & op(7 downto 0) + xr;                                                            -- +O+X
70
                         when ABY_M  => reg(15 downto 0) <= din_h & op(7 downto 0) + yr;                                                            -- +O+Y
71
                         when ADX_M  => reg <= reg + ("00000000" & xr);                                                                             -- +X (24 bit SUM)
72
                         when ADY_M  => reg <= reg + ("00000000" & yr);                                                                             -- +Y (24 bit SUM)
73
          when MHB_M  => reg(23 downto 16) <= din_h; reg(15 downto 0) <= op;                                                         -- load high byte (bit 23..16)
74
                         when AOY_M  => reg <= (dbr & op) + ("00000000" & yr);                                                                      -- O+Y (24 bit SUM)
75
          when others => reg <= reg;
76
        end case;
77
      end if;
78
    end if;
79
  end process;
80
  dout <= reg;
81
end rtl;
82
 
83
 

powered by: WebSVN 2.1.0

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