1 |
11 |
arniml |
-------------------------------------------------------------------------------
|
2 |
|
|
--
|
3 |
|
|
-- GCpad controller core
|
4 |
|
|
--
|
5 |
12 |
arniml |
-- $Id: gcpad_basic.vhd,v 1.2 2004-10-08 20:51:59 arniml Exp $
|
6 |
11 |
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 gcpad_basic is
|
53 |
|
|
|
54 |
|
|
generic (
|
55 |
|
|
reset_level_g : integer := 0;
|
56 |
|
|
clocks_per_1us_g : integer := 2
|
57 |
|
|
);
|
58 |
|
|
port (
|
59 |
|
|
-- System Interface -------------------------------------------------------
|
60 |
|
|
clk_i : in std_logic;
|
61 |
|
|
reset_i : in std_logic;
|
62 |
|
|
pad_request_i : in std_logic;
|
63 |
|
|
pad_avail_o : out std_logic;
|
64 |
|
|
-- Gamepad Interface ------------------------------------------------------
|
65 |
|
|
pad_data_io : inout std_logic;
|
66 |
|
|
-- Buttons Interface ------------------------------------------------------
|
67 |
|
|
but_a_o : out std_logic;
|
68 |
|
|
but_b_o : out std_logic;
|
69 |
|
|
but_x_o : out std_logic;
|
70 |
|
|
but_y_o : out std_logic;
|
71 |
|
|
but_z_o : out std_logic;
|
72 |
|
|
but_start_o : out std_logic;
|
73 |
|
|
but_tl_o : out std_logic;
|
74 |
|
|
but_tr_o : out std_logic;
|
75 |
|
|
but_left_o : out std_logic;
|
76 |
|
|
but_right_o : out std_logic;
|
77 |
|
|
but_up_o : out std_logic;
|
78 |
|
|
but_down_o : out std_logic;
|
79 |
|
|
ana_joy_x_o : out std_logic_vector(7 downto 0);
|
80 |
|
|
ana_joy_y_o : out std_logic_vector(7 downto 0);
|
81 |
|
|
ana_c_x_o : out std_logic_vector(7 downto 0);
|
82 |
|
|
ana_c_y_o : out std_logic_vector(7 downto 0);
|
83 |
|
|
ana_l_o : out std_logic_vector(7 downto 0);
|
84 |
|
|
ana_r_o : out std_logic_vector(7 downto 0)
|
85 |
|
|
);
|
86 |
|
|
|
87 |
|
|
end gcpad_basic;
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
use work.gcpad_pack.analog_axis_t;
|
91 |
|
|
|
92 |
|
|
architecture struct of gcpad_basic is
|
93 |
|
|
|
94 |
|
|
component gcpad_ctrl
|
95 |
|
|
generic (
|
96 |
|
|
reset_level_g : integer := 0
|
97 |
|
|
);
|
98 |
|
|
port (
|
99 |
|
|
clk_i : in std_logic;
|
100 |
|
|
reset_i : in std_logic;
|
101 |
|
|
pad_request_i : in std_logic;
|
102 |
|
|
pad_avail_o : out std_logic;
|
103 |
|
|
tx_start_o : out boolean;
|
104 |
|
|
tx_finished_i : in boolean;
|
105 |
|
|
rx_en_o : out boolean;
|
106 |
|
|
rx_done_i : in boolean
|
107 |
|
|
);
|
108 |
|
|
end component;
|
109 |
|
|
|
110 |
|
|
component gcpad_tx
|
111 |
|
|
generic (
|
112 |
|
|
reset_level_g : natural := 0;
|
113 |
|
|
clocks_per_1us_g : natural := 2
|
114 |
|
|
);
|
115 |
|
|
port (
|
116 |
|
|
clk_i : in std_logic;
|
117 |
|
|
reset_i : in std_logic;
|
118 |
|
|
pad_data_o : out std_logic;
|
119 |
|
|
tx_start_i : in boolean;
|
120 |
|
|
tx_finished_o : out boolean;
|
121 |
12 |
arniml |
tx_size_i : in std_logic_vector( 1 downto 0);
|
122 |
11 |
arniml |
tx_command_i : in std_logic_vector(23 downto 0)
|
123 |
|
|
);
|
124 |
|
|
end component;
|
125 |
|
|
|
126 |
|
|
component gcpad_rx
|
127 |
|
|
generic (
|
128 |
|
|
reset_level_g : integer := 0;
|
129 |
|
|
clocks_per_1us_g : integer := 2
|
130 |
|
|
);
|
131 |
|
|
port (
|
132 |
|
|
clk_i : in std_logic;
|
133 |
|
|
reset_i : in std_logic;
|
134 |
|
|
rx_en_i : in boolean;
|
135 |
|
|
rx_done_o : out boolean;
|
136 |
12 |
arniml |
rx_size_i : in std_logic_vector(3 downto 0);
|
137 |
11 |
arniml |
pad_data_i : in std_logic;
|
138 |
|
|
but_a_o : out std_logic;
|
139 |
|
|
but_b_o : out std_logic;
|
140 |
|
|
but_x_o : out std_logic;
|
141 |
|
|
but_y_o : out std_logic;
|
142 |
|
|
but_z_o : out std_logic;
|
143 |
|
|
but_start_o : out std_logic;
|
144 |
|
|
but_tl_o : out std_logic;
|
145 |
|
|
but_tr_o : out std_logic;
|
146 |
|
|
but_left_o : out std_logic;
|
147 |
|
|
but_right_o : out std_logic;
|
148 |
|
|
but_up_o : out std_logic;
|
149 |
|
|
but_down_o : out std_logic;
|
150 |
|
|
ana_joy_x_o : out analog_axis_t;
|
151 |
|
|
ana_joy_y_o : out analog_axis_t;
|
152 |
|
|
ana_c_x_o : out analog_axis_t;
|
153 |
|
|
ana_c_y_o : out analog_axis_t;
|
154 |
|
|
ana_l_o : out analog_axis_t;
|
155 |
|
|
ana_r_o : out analog_axis_t
|
156 |
|
|
);
|
157 |
|
|
end component;
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
-----------------------------------------------------------------------------
|
161 |
|
|
-- constants for standard status polling
|
162 |
12 |
arniml |
constant rx_size_c : std_logic_vector( 3 downto 0) := "1000";
|
163 |
|
|
signal rx_size_s : std_logic_vector( 3 downto 0);
|
164 |
11 |
arniml |
--
|
165 |
12 |
arniml |
constant tx_size_c : std_logic_vector( 1 downto 0) := "11";
|
166 |
|
|
signal tx_size_s : std_logic_vector( 1 downto 0);
|
167 |
11 |
arniml |
--
|
168 |
|
|
constant tx_command_c : std_logic_vector(23 downto 0) := "010000000000001100000010";
|
169 |
|
|
signal tx_command_s : std_logic_vector(23 downto 0);
|
170 |
|
|
--
|
171 |
|
|
-----------------------------------------------------------------------------
|
172 |
|
|
|
173 |
|
|
signal pad_data_tx_s : std_logic;
|
174 |
|
|
|
175 |
|
|
signal tx_start_s : boolean;
|
176 |
|
|
signal tx_finished_s : boolean;
|
177 |
|
|
|
178 |
|
|
signal rx_en_s,
|
179 |
|
|
rx_done_s : boolean;
|
180 |
|
|
|
181 |
|
|
begin
|
182 |
|
|
|
183 |
|
|
rx_size_s <= rx_size_c;
|
184 |
|
|
tx_size_s <= tx_size_c;
|
185 |
|
|
tx_command_s <= tx_command_c;
|
186 |
|
|
|
187 |
|
|
ctrl_b : gcpad_ctrl
|
188 |
|
|
generic map (
|
189 |
|
|
reset_level_g => reset_level_g
|
190 |
|
|
)
|
191 |
|
|
port map (
|
192 |
|
|
clk_i => clk_i,
|
193 |
|
|
reset_i => reset_i,
|
194 |
|
|
pad_request_i => pad_request_i,
|
195 |
|
|
pad_avail_o => pad_avail_o,
|
196 |
|
|
tx_start_o => tx_start_s,
|
197 |
|
|
tx_finished_i => tx_finished_s,
|
198 |
|
|
rx_en_o => rx_en_s,
|
199 |
|
|
rx_done_i => rx_done_s
|
200 |
|
|
);
|
201 |
|
|
|
202 |
|
|
tx_b : gcpad_tx
|
203 |
|
|
generic map (
|
204 |
|
|
reset_level_g => reset_level_g,
|
205 |
|
|
clocks_per_1us_g => clocks_per_1us_g
|
206 |
|
|
)
|
207 |
|
|
port map (
|
208 |
|
|
clk_i => clk_i,
|
209 |
|
|
reset_i => reset_i,
|
210 |
|
|
pad_data_o => pad_data_tx_s,
|
211 |
|
|
tx_start_i => tx_start_s,
|
212 |
|
|
tx_finished_o => tx_finished_s,
|
213 |
|
|
tx_size_i => tx_size_s,
|
214 |
|
|
tx_command_i => tx_command_s
|
215 |
|
|
);
|
216 |
|
|
|
217 |
|
|
rx_b : gcpad_rx
|
218 |
|
|
generic map (
|
219 |
|
|
reset_level_g => reset_level_g,
|
220 |
|
|
clocks_per_1us_g => clocks_per_1us_g
|
221 |
|
|
)
|
222 |
|
|
port map (
|
223 |
|
|
clk_i => clk_i,
|
224 |
|
|
reset_i => reset_i,
|
225 |
|
|
rx_en_i => rx_en_s,
|
226 |
|
|
rx_done_o => rx_done_s,
|
227 |
|
|
rx_size_i => rx_size_s,
|
228 |
|
|
pad_data_i => pad_data_io,
|
229 |
|
|
but_a_o => but_a_o,
|
230 |
|
|
but_b_o => but_b_o,
|
231 |
|
|
but_x_o => but_x_o,
|
232 |
|
|
but_y_o => but_y_o,
|
233 |
|
|
but_z_o => but_z_o,
|
234 |
|
|
but_start_o => but_start_o,
|
235 |
|
|
but_tl_o => but_tl_o,
|
236 |
|
|
but_tr_o => but_tr_o,
|
237 |
|
|
but_left_o => but_left_o,
|
238 |
|
|
but_right_o => but_right_o,
|
239 |
|
|
but_up_o => but_up_o,
|
240 |
|
|
but_down_o => but_down_o,
|
241 |
|
|
ana_joy_x_o => ana_joy_x_o,
|
242 |
|
|
ana_joy_y_o => ana_joy_y_o,
|
243 |
|
|
ana_c_x_o => ana_c_x_o,
|
244 |
|
|
ana_c_y_o => ana_c_y_o,
|
245 |
|
|
ana_l_o => ana_l_o,
|
246 |
|
|
ana_r_o => ana_r_o
|
247 |
|
|
);
|
248 |
|
|
|
249 |
|
|
|
250 |
|
|
-----------------------------------------------------------------------------
|
251 |
|
|
-- Open collector driver to pad data
|
252 |
|
|
-----------------------------------------------------------------------------
|
253 |
|
|
pad_data_io <= '0'
|
254 |
|
|
when pad_data_tx_s = '0' else
|
255 |
|
|
'Z';
|
256 |
|
|
|
257 |
|
|
end struct;
|
258 |
|
|
|
259 |
|
|
|
260 |
|
|
-------------------------------------------------------------------------------
|
261 |
|
|
-- File History:
|
262 |
|
|
--
|
263 |
|
|
-- $Log: not supported by cvs2svn $
|
264 |
12 |
arniml |
-- Revision 1.1 2004/10/07 21:23:10 arniml
|
265 |
|
|
-- initial check-in
|
266 |
|
|
--
|
267 |
11 |
arniml |
-------------------------------------------------------------------------------
|