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

Subversion Repositories v6502

[/] [v6502/] [trunk/] [pcr.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
-- 16 bit program counter register "PC"
7
entity pcr is
8
  port(   clk:  in STD_LOGIC;
9
            i:  in STD_LOGIC;
10
        fwait:  in STD_LOGIC;
11
           fc:  in STD_LOGIC_VECTOR(3 downto 0);
12
         din1:  in STD_LOGIC_VECTOR(7 downto 0);
13
         din2:  in STD_LOGIC_VECTOR(7 downto 0);
14
         dout: out STD_LOGIC_VECTOR(15 downto 0)
15
      );
16
end pcr;
17
 
18
architecture rtl of pcr is
19
constant NOP_P: STD_LOGIC_VECTOR(3 downto 0) := "0000"; -- PC no operation
20
constant LSB_P: STD_LOGIC_VECTOR(3 downto 0) := "0010"; -- PC load lsb
21
constant MSB_P: STD_LOGIC_VECTOR(3 downto 0) := "0100"; -- PC load msb
22
constant INC_P: STD_LOGIC_VECTOR(3 downto 0) := "0110"; -- PC increment by 1
23
constant LOD_P: STD_LOGIC_VECTOR(3 downto 0) := "1000"; -- PC load lsb\msb
24
constant ADJ_P: STD_LOGIC_VECTOR(3 downto 0) := "1010"; -- PC msb increment by 1
25
constant ADJ_N: STD_LOGIC_VECTOR(3 downto 0) := "1011"; -- PC msb decrement by 1
26
signal op:  STD_LOGIC_VECTOR(3 downto 0);
27
signal reg: STD_LOGIC_VECTOR(15 downto 0);
28
 
29
begin
30
  process(fc)
31
  begin
32
    case fc is
33
      when ADJ_P  => op             <= ADJ_P;
34
      when ADJ_N  => op             <= ADJ_N;
35
      when others => op(3 downto 1) <= fc(3 downto 1);
36
                     op(0)          <= '0';
37
    end case;
38
  end process;
39
 
40
  process(clk)
41
    begin
42
      if (clk'event and clk = '1') then
43
        if fwait = '1' then
44
          reg <= reg;
45
        else
46
          if i = '1' then
47
            reg <= reg +1;
48
          else
49
            case op is
50
              when LSB_P  => reg(7 downto 0) <= din1; reg(15 downto 8) <= reg(15 downto 8);
51
              when MSB_P  => reg(15 downto 8) <= din1; reg(7 downto 0) <= reg(7 downto 0);
52
              when INC_P  => reg <= reg +1;
53
              when LOD_P  => reg(15 downto 8) <= din1; reg(7 downto 0) <= din2;
54
              when ADJ_P  => reg(15 downto 8) <= reg(15 downto 8) + ("00000001"); reg(7 downto 0) <= reg(7 downto 0);
55
              when ADJ_N  => reg(15 downto 8) <= reg(15 downto 8) - ("00000001"); reg(7 downto 0) <= reg(7 downto 0);
56
              when NOP_P  => reg <= reg;
57
              when others => reg <= reg;
58
            end case;
59
          end if;
60
        end if;
61
      end if;
62
  end process;
63
  dout <= reg;
64
end rtl;
65
 
66
 

powered by: WebSVN 2.1.0

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