]> rtime.felk.cvut.cz Git - fpga/virtex2/msp_motion.git/blob - mcu_periph/gpio.vhd
Makefile - save xst report in xst.log file.
[fpga/virtex2/msp_motion.git] / mcu_periph / gpio.vhd
1 library ieee;
2 use ieee.std_logic_1164.all;
3 use ieee.std_logic_arith.all;
4
5 --------------------------------------------------------------------------------
6
7 entity gpio is
8   generic (
9     W : integer := 8);                  -- GPIO port width (pin count)
10   port (
11     -- Peripheral bus interface
12     ACK_O  : out std_logic;
13     ADR_I  : in  std_logic_vector (1 downto 0);
14     CLK_I  : in  std_logic;
15     DAT_I  : in  std_logic_vector (W-1 downto 0);
16     DAT_O  : out std_logic_vector (W-1 downto 0);
17     RST_I  : in  std_logic;
18     SEL_I  : in  std_logic;
19     STB_I  : in  std_logic;
20     WE_I   : in  std_logic;
21     -- GPIO port pins
22     GPIO_I : in  std_logic_vector (W-1 downto 0);
23     GPIO_O : out std_logic_vector (W-1 downto 0));
24 end gpio;
25
26 --------------------------------------------------------------------------------
27
28 architecture behavioral of gpio is
29
30   signal gpio_output     : std_logic_vector (W-1 downto 0) := (others => '0');
31   signal gpio_output_new : std_logic_vector (W-1 downto 0);
32   signal write_en        : std_logic;
33   
34 begin
35   
36   ACK_O <= SEL_I and STB_I;
37
38   with ADR_I select
39     DAT_O <=
40     GPIO_I          when "00",
41     gpio_output     when "01",
42     (others => '-') when others;
43
44   
45   with ADR_I select
46     gpio_output_new <=
47     DAT_I                     when "01",
48     gpio_output or DAT_I      when "10",
49     gpio_output and not DAT_I when "11",
50     gpio_output               when others;
51   
52   write_en  <= SEL_I and STB_I and WE_I;
53   
54   process (CLK_I, RST_I) is
55   begin
56     if rising_edge(CLK_I) then
57       if RST_I = '1' then
58         gpio_output <= (others => '0');
59       else
60         if write_en = '1' then
61           gpio_output <= gpio_output_new;
62         end if;        
63       end if;
64     end if;
65   end process;
66
67 end behavioral;
68