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

Subversion Repositories copyblaze

[/] [copyblaze/] [trunk/] [copyblaze/] [rtl/] [vhdl/] [ip/] [wb_gpio/] [wb_gpio.vhd] - Blame information for rev 65

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 ameziti
-----------------------------------------------------------------------------
2
-- Wishbone GPIO ------------------------------------------------------------
3
library ieee;
4
use ieee.std_logic_1164.ALL;
5
 
6
entity wb_gpio is
7
   port (
8
      clk      : in  std_logic;
9
      reset    : in  std_logic;
10
      -- Wishbone bus
11
      wb_adr_i : in  std_logic_vector(31 downto 0);
12
      wb_dat_i : in  std_logic_vector(31 downto 0);
13
      wb_dat_o : out std_logic_vector(31 downto 0);
14
      wb_sel_i : in  std_logic_vector( 3 downto 0);
15
      wb_cyc_i : in  std_logic;
16
      wb_stb_i : in  std_logic;
17
      wb_ack_o : out std_logic;
18
      wb_we_i  : in  std_logic;
19
      -- I/O ports
20
      iport    : in  std_logic_vector(31 downto 0);
21
      oport    : out std_logic_vector(31 downto 0) );
22
end wb_gpio;
23
 
24
-----------------------------------------------------------------------------
25
-- Implementation -----------------------------------------------------------
26
architecture rtl of wb_gpio is
27
 
28
signal wbactive  : std_logic;
29
 
30
signal oport_reg : std_logic_vector(31 downto 0);
31
signal iport_reg : std_logic_vector(31 downto 0);
32
 
33
begin
34
 
35
oport <= oport_reg;
36
 
37
-- synchronize incoming signals (anti-meta-state)
38
syncproc: process(clk) is
39
begin
40
        if clk'event and clk='1' then
41
                iport_reg <= iport;
42
        end if;
43
end process;
44
 
45
-----------------------------------------------------------------------------
46
-- Wishbone handling --------------------------------------------------------
47
 
48
wb_ack_o <= wb_stb_i and wb_cyc_i;
49
 
50
wb_dat_o <= iport_reg when wb_stb_i='1' and wb_cyc_i='1' and wb_adr_i(3 downto 0)=x"0" else
51
            oport_reg when wb_stb_i='1' and wb_cyc_i='1' and wb_adr_i(3 downto 0)=x"4" else
52
            (others => '-');
53
 
54
writeproc: process (reset, clk) is
55
variable val : std_logic_vector(31 downto 0);
56
begin
57
        if reset='1' then
58
                oport_reg <= (others => '0');
59
        elsif clk'event and clk='1' then
60
                if wb_stb_i='1' and wb_cyc_i='1' and wb_we_i='1' then
61
 
62
                        -- decode WB_SEL_I --
63
                        if wb_sel_i(3)='1' then
64
                                val(31 downto 24) := wb_dat_i(31 downto 24);
65
                        end if;
66
                        if wb_sel_i(2)='1' then
67
                                val(23 downto 16) := wb_dat_i(23 downto 16);
68
                        end if;
69
                        if wb_sel_i(1)='1' then
70
                                val(15 downto  8) := wb_dat_i(15 downto  8);
71
                        end if;
72
                        if wb_sel_i(0)='1' then
73
                                val( 7 downto  0) := wb_dat_i( 7 downto  0);
74
                        end if;
75
 
76
                        -- decode WB_ADR_I --
77
                        if wb_adr_i(3 downto 0)=x"4" then
78
                                oport_reg <= val;
79
                        end if;
80
 
81
                end if;
82
        end if;
83
end process;
84
 
85
end rtl;
86
 

powered by: WebSVN 2.1.0

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