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

Subversion Repositories v65c816

[/] [v65c816/] [trunk/] [xr.vhd] - Blame information for rev 2

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 index register "X"
7
entity xr is
8
  port(       clk:  in STD_LOGIC;
9
            fwait:  in STD_LOGIC;
10
                       size:  in STD_LOGIC;
11
           ld_lsb:  in STD_LOGIC;
12
           ld_msb:  in STD_LOGIC;
13
            ld_mul_msb:  in STD_LOGIC;
14
                     u:  in STD_LOGIC;
15
                          d:  in STD_LOGIC;
16
              din:  in STD_LOGIC_VECTOR(15 downto 0);
17
                         mul_msb:  in STD_LOGIC_VECTOR(15 downto 0);
18
             dout: out STD_LOGIC_VECTOR(15 downto 0)
19
      );
20
end xr;
21
 
22
architecture rtl of xr is
23
signal reg: STD_LOGIC_VECTOR(15 downto 0);
24
signal op:  STD_LOGIC_VECTOR(4 downto 0);
25
begin
26
  op <= ld_mul_msb & u & d & ld_msb & ld_lsb;
27
  process(clk)
28
    begin
29
      if (clk'event and clk = '1') then
30
        if fwait = '1' then
31
          reg <= reg;
32
        else
33
                                 case op is
34
                                        when   "00001" => reg(7 downto 0) <= din(7 downto 0);              -- load lsb
35
                                                                                reg(15 downto 8) <= reg(15 downto 8);
36
                                        when   "00010" => reg(15 downto 8) <= din(7 downto 0);             -- load msb
37
                                                                                reg(7 downto 0) <= reg(7 downto 0);
38
                                        when   "00011" => reg <= din;                                      -- load msb & lsb                                            
39
                                        when   "00100" => reg <= reg - "0000000000000001";                 -- decrement
40
                                        when   "01000" => reg <= reg + "0000000000000001";                 -- increment
41
                                        when   "10000" => reg <= mul_msb;                                  -- load multiplication msb result
42
                                        when others    => reg <= reg;
43
                                 end case;
44
                                 if size = '1' then
45
                                   reg(15 downto 8) <= (others => '0');                               -- with size = '1' (X = '1') the msb of index register is always zero
46
                                 end if;
47
                  end if;
48
      end if;
49
  end process;
50
  dout <= reg;
51
end rtl;
52
 
53
 

powered by: WebSVN 2.1.0

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