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

Subversion Repositories v6502

[/] [v6502/] [trunk/] [bcd_reg.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
-- BCD register
7
entity bcd_reg is
8
  port(    clk:  in STD_LOGIC;
9
           clr:  in STD_LOGIC;
10
         fwait:  in STD_LOGIC;
11
            en:  in STD_LOGIC;
12
        bcd_sl:  in STD_LOGIC;
13
        bcd_sh:  in STD_LOGIC;
14
        dout: out STD_LOGIC_VECTOR(7 downto 0)
15
      );
16
end bcd_reg;
17
 
18
architecture rtl of bcd_reg is
19
signal reg: STD_LOGIC_VECTOR(7 downto 0);
20
begin
21
  process(clk)
22
    begin
23
      if (clk'event and clk = '1') then
24
        if fwait = '1' then
25
          reg <= reg;
26
        else
27
          if clr = '1' or en = '0' then
28
            reg <= (others => '0');
29
          else
30
            if bcd_sl = '1' then
31
              reg(3 downto 0) <= "0110";  -- loads 0x6 to lsb
32
            else
33
              reg(3 downto 0) <= reg(3 downto 0);
34
            end if;
35
            if bcd_sh = '1' then
36
              reg(7 downto 4) <= "0110";  -- loads 0x6 to msb
37
            else
38
              reg(7 downto 4) <= reg(7 downto 4);
39
            end if;
40
          end if;
41
        end if;
42
      end if;
43
  end process;
44
  dout <= reg;
45
end rtl;
46
 
47
 

powered by: WebSVN 2.1.0

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