]> rtime.felk.cvut.cz Git - fpga/virtex2/msp_motion.git/blob - mcu_periph/event_rwc.vhd
Merge branch 'master' of rtime.felk.cvut.cz:/fpga/virtex2/msp_motion
[fpga/virtex2/msp_motion.git] / mcu_periph / event_rwc.vhd
1 library ieee;
2 use ieee.std_logic_1164.all;
3 use ieee.std_logic_arith.all;
4
5 --------------------------------------------------------------------------------
6
7 entity event_rwc is
8   generic (
9     W : integer := 16);                  -- Event port width (pin count)
10   port (
11     -- Peripheral bus interface
12     ACK_O  : out std_logic;
13     CLK_I  : in  std_logic;
14     DAT_I  : in  std_logic_vector (W-1 downto 0);
15     DAT_O  : out std_logic_vector (W-1 downto 0);
16     RST_I  : in  std_logic;
17     SEL_I  : in  std_logic;
18     STB_I  : in  std_logic;
19     WE_I   : in  std_logic;
20     -- Event port pins
21     EVENT_I : in  std_logic_vector (W-1 downto 0);
22     EVENT_O : out std_logic_vector (W-1 downto 0));
23 end event_rwc;
24
25 --------------------------------------------------------------------------------
26
27 architecture behavioral of event_rwc is
28
29   signal status         : std_logic_vector (W-1 downto 0) := (others => '0');
30   signal write_en   : std_logic;
31   
32 begin
33   
34   ACK_O <= SEL_I and STB_I;
35   DAT_O <= status;
36
37   EVENT_O <= status;
38   
39   write_en  <= SEL_I and STB_I and WE_I;
40   
41   process (CLK_I, RST_I) is
42   begin
43     if rising_edge(CLK_I) then
44       if RST_I = '1' then
45         status <= (others => '0');
46       else
47         if write_en = '1' then
48           status <= (status and not DAT_I) or EVENT_I;
49         else
50           status <= status or EVENT_I;
51         end if;        
52       end if;
53     end if;
54   end process;
55
56 end behavioral;
57