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

Subversion Repositories gamepads

[/] [gamepads/] [trunk/] [snespad/] [rtl/] [vhdl/] [snespad_pad.vhd] - Blame information for rev 41

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 arniml
-------------------------------------------------------------------------------
2
--
3
-- SNESpad controller core
4
--
5 41 arniml
-- $Id: snespad_pad.vhd 41 2009-04-01 19:58:04Z arniml $
6 3 arniml
--
7
-- Copyright (c) 2004, Arnim Laeuger (arniml@opencores.org)
8
--
9
-- All rights reserved
10
--
11
-- Redistribution and use in source and synthezised forms, with or without
12
-- modification, are permitted provided that the following conditions are met:
13
--
14
-- Redistributions of source code must retain the above copyright notice,
15
-- this list of conditions and the following disclaimer.
16
--
17
-- Redistributions in synthesized form must reproduce the above copyright
18
-- notice, this list of conditions and the following disclaimer in the
19
-- documentation and/or other materials provided with the distribution.
20
--
21
-- Neither the name of the author nor the names of other contributors may
22
-- be used to endorse or promote products derived from this software without
23
-- specific prior written permission.
24
--
25
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
27
-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28
-- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
29
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35
-- POSSIBILITY OF SUCH DAMAGE.
36
--
37
-- Please report bugs to the author, but before you do so, please
38
-- make sure that this is not a derivative work and that
39
-- you have the latest version of this file.
40
--
41
-- The latest version of this file can be found at:
42
--      http://www.opencores.org/cvsweb.shtml/gamepads/
43
--
44
-- The project homepage is located at:
45
--      http://www.opencores.org/projects.cgi/web/gamepads/overview
46
--
47
-------------------------------------------------------------------------------
48
 
49
library ieee;
50
use ieee.std_logic_1164.all;
51
 
52
entity snespad_pad is
53
 
54
  generic (
55
    reset_level_g   :     natural := 0;
56
    button_level_g  :     natural := 0
57
  );
58
  port (
59
    -- System Interface -------------------------------------------------------
60
    clk_i           : in  std_logic;
61
    reset_i         : in  std_logic;
62
    clk_en_i        : in  boolean;
63
    -- Control Interface ------------------------------------------------------
64
    shift_buttons_i : in  boolean;
65
    save_buttons_i  : in  boolean;
66
    -- Pad Interface ----------------------------------------------------------
67
    pad_data_i      : in  std_logic;
68
    -- Buttons Interface ------------------------------------------------------
69
    but_a_o         : out std_logic;
70
    but_b_o         : out std_logic;
71
    but_x_o         : out std_logic;
72
    but_y_o         : out std_logic;
73
    but_start_o     : out std_logic;
74
    but_sel_o       : out std_logic;
75
    but_tl_o        : out std_logic;
76
    but_tr_o        : out std_logic;
77
    but_up_o        : out std_logic;
78
    but_down_o      : out std_logic;
79
    but_left_o      : out std_logic;
80
    but_right_o     : out std_logic
81
  );
82
 
83
end snespad_pad;
84
 
85
 
86
use work.snespad_pack.all;
87
 
88
architecture rtl of snespad_pad is
89
 
90
  signal buttons_q,
91
         shift_buttons_q : buttons_t;
92
 
93
begin
94
 
95
  -- pragma translate_off
96
  -----------------------------------------------------------------------------
97
  -- Check generics
98
  -----------------------------------------------------------------------------
99
  assert (reset_level_g = 0) or (reset_level_g = 1)
100
    report "reset_level_g must be either 0 or 1!"
101
    severity failure;
102
 
103
  assert (button_level_g = 0) or (button_level_g = 1)
104
    report "button_level_g must be either 0 or 1!"
105
    severity failure;
106
  -- pragma translate_on
107
 
108
  seq: process (reset_i, clk_i)
109
  begin
110
    if reset_i = reset_level_g then
111
      for i in buttons_t'range loop
112
        buttons_q(i)       <= button_reset_f(button_level_g);
113
        shift_buttons_q(i) <= button_reset_f(button_level_g);
114
      end loop;
115
 
116
    elsif clk_i'event and clk_i = '1' then
117
      if save_buttons_i then
118
        buttons_q <= shift_buttons_q;
119
      end if;
120
 
121
      if clk_en_i and shift_buttons_i then
122
        shift_buttons_q(buttons_t'high downto 1) <= shift_buttons_q(buttons_t'high-1 downto 0);
123
        shift_buttons_q(0)                       <= button_active_f(pad_data_i, button_level_g);
124
      end if;
125
 
126
    end if;
127
  end process;
128
 
129
 
130
  -----------------------------------------------------------------------------
131
  -- Output Mapping
132
  -----------------------------------------------------------------------------
133
  but_a_o     <= buttons_q(but_pos_a_c);
134
  but_b_o     <= buttons_q(but_pos_b_c);
135
  but_x_o     <= buttons_q(but_pos_x_c);
136
  but_y_o     <= buttons_q(but_pos_y_c);
137
  but_start_o <= buttons_q(but_pos_start_c);
138
  but_sel_o   <= buttons_q(but_pos_sel_c);
139
  but_tl_o    <= buttons_q(but_pos_tl_c);
140
  but_tr_o    <= buttons_q(but_pos_tr_c);
141
  but_up_o    <= buttons_q(but_pos_up_c);
142
  but_down_o  <= buttons_q(but_pos_down_c);
143
  but_left_o  <= buttons_q(but_pos_left_c);
144
  but_right_o <= buttons_q(but_pos_right_c);
145
 
146
end rtl;

powered by: WebSVN 2.1.0

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