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

Subversion Repositories gamepads

[/] [gamepads/] [trunk/] [snespad/] [rtl/] [vhdl/] [snespad.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.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 is
53
 
54
  generic (
55 7 arniml
    -- number of pads connected to this core
56 3 arniml
    num_pads_g       :     natural := 1;
57 7 arniml
    -- active level of reset_i
58 3 arniml
    reset_level_g    :     natural := 0;
59 7 arniml
    -- active level of the button outputs
60 3 arniml
    button_level_g   :     natural := 0;
61 7 arniml
    -- number of clk_i periods during 6us
62 3 arniml
    clocks_per_6us_g :     natural := 6
63
  );
64
  port (
65
    -- System Interface -------------------------------------------------------
66
    clk_i            : in  std_logic;
67
    reset_i          : in  std_logic;
68
    -- Gamepad Interface ------------------------------------------------------
69
    pad_clk_o        : out std_logic;
70
    pad_latch_o      : out std_logic;
71
    pad_data_i       : in  std_logic_vector(num_pads_g-1 downto 0);
72
    -- Buttons Interface ------------------------------------------------------
73
    but_a_o          : out std_logic_vector(num_pads_g-1 downto 0);
74
    but_b_o          : out std_logic_vector(num_pads_g-1 downto 0);
75
    but_x_o          : out std_logic_vector(num_pads_g-1 downto 0);
76
    but_y_o          : out std_logic_vector(num_pads_g-1 downto 0);
77
    but_start_o      : out std_logic_vector(num_pads_g-1 downto 0);
78
    but_sel_o        : out std_logic_vector(num_pads_g-1 downto 0);
79
    but_tl_o         : out std_logic_vector(num_pads_g-1 downto 0);
80
    but_tr_o         : out std_logic_vector(num_pads_g-1 downto 0);
81
    but_up_o         : out std_logic_vector(num_pads_g-1 downto 0);
82
    but_down_o       : out std_logic_vector(num_pads_g-1 downto 0);
83
    but_left_o       : out std_logic_vector(num_pads_g-1 downto 0);
84
    but_right_o      : out std_logic_vector(num_pads_g-1 downto 0)
85
  );
86
 
87
end snespad;
88
 
89
 
90
architecture struct of snespad is
91
 
92
  component snespad_ctrl
93
    generic (
94
      reset_level_g    :     natural := 0;
95
      clocks_per_6us_g :     natural := 6
96
    );
97
    port (
98
      clk_i            : in  std_logic;
99
      reset_i          : in  std_logic;
100
      clk_en_o         : out boolean;
101
      shift_buttons_o  : out boolean;
102
      save_buttons_o   : out boolean;
103
      pad_clk_o        : out std_logic;
104
      pad_latch_o      : out std_logic
105
    );
106
  end component snespad_ctrl;
107
 
108
  component snespad_pad
109
    generic (
110
      reset_level_g   :     natural := 0;
111
      button_level_g  :     natural := 0
112
    );
113
    port (
114
      clk_i           : in  std_logic;
115
      reset_i         : in  std_logic;
116
      clk_en_i        : in  boolean;
117
      shift_buttons_i : in  boolean;
118
      save_buttons_i  : in  boolean;
119
      pad_data_i      : in  std_logic;
120
      but_a_o         : out std_logic;
121
      but_b_o         : out std_logic;
122
      but_x_o         : out std_logic;
123
      but_y_o         : out std_logic;
124
      but_start_o     : out std_logic;
125
      but_sel_o       : out std_logic;
126
      but_tl_o        : out std_logic;
127
      but_tr_o        : out std_logic;
128
      but_up_o        : out std_logic;
129
      but_down_o      : out std_logic;
130
      but_left_o      : out std_logic;
131
      but_right_o     : out std_logic
132
    );
133
  end component snespad_pad;
134
 
135
 
136
  signal clk_en_s : boolean;
137
  signal shift_buttons_s : boolean;
138
  signal save_buttons_s : boolean;
139
 
140
begin
141
 
142
  ctrl_b : snespad_ctrl
143
    generic map (
144
      reset_level_g    => reset_level_g,
145
      clocks_per_6us_g => clocks_per_6us_g
146
    )
147
    port map (
148
      clk_i            => clk_i,
149
      reset_i          => reset_i,
150
      clk_en_o         => clk_en_s,
151
      shift_buttons_o  => shift_buttons_s,
152
      save_buttons_o   => save_buttons_s,
153
      pad_clk_o        => pad_clk_o,
154
      pad_latch_o      => pad_latch_o
155
    );
156
 
157
 
158
  pads: for i in 0 to num_pads_g-1 generate
159
    pad_b : snespad_pad
160
      generic map (
161
        reset_level_g   => reset_level_g,
162
        button_level_g  => button_level_g
163
      )
164
      port map (
165
        clk_i           => clk_i,
166
        reset_i         => reset_i,
167
        clk_en_i        => clk_en_s,
168
        shift_buttons_i => shift_buttons_s,
169
        save_buttons_i  => save_buttons_s,
170
        pad_data_i      => pad_data_i(i),
171
        but_a_o         => but_a_o(i),
172
        but_b_o         => but_b_o(i),
173
        but_x_o         => but_x_o(i),
174
        but_y_o         => but_y_o(i),
175
        but_start_o     => but_start_o(i),
176
        but_sel_o       => but_sel_o(i),
177
        but_tl_o        => but_tl_o(i),
178
        but_tr_o        => but_tr_o(i),
179
        but_up_o        => but_up_o(i),
180
        but_down_o      => but_down_o(i),
181
        but_left_o      => but_left_o(i),
182
        but_right_o     => but_right_o(i)
183
      );
184
  end generate;
185
 
186
end struct;

powered by: WebSVN 2.1.0

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