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

Subversion Repositories copyblaze

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

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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