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

Subversion Repositories gamepads

[/] [gamepads/] [trunk/] [gcpad/] [rtl/] [vhdl/] [gcpad_full.vhd] - Blame information for rev 41

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 25 arniml
-------------------------------------------------------------------------------
2
--
3
-- GCpad controller core
4
--
5 41 arniml
-- $Id: gcpad_full.vhd 41 2009-04-01 19:58:04Z arniml $
6 25 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_full is
53
 
54
  generic (
55
    -- active level of reset_i
56
    reset_level_g    :       integer := 0;
57
    -- number of clk_i periods during 1us
58
    clocks_per_1us_g :       integer := 2
59
  );
60
  port (
61
    -- System Interface -------------------------------------------------------
62
    clk_i            : in    std_logic;
63
    reset_i          : in    std_logic;
64
    -- Pad Communication Interface --------------------------------------------
65
    pad_request_i    : in    std_logic;
66
    pad_avail_o      : out   std_logic;
67
    pad_timeout_o    : out   std_logic;
68
    tx_size_i        : in    std_logic_vector( 1 downto 0);
69
    tx_command_i     : in    std_logic_vector(23 downto 0);
70
    rx_size_i        : in    std_logic_vector( 3 downto 0);
71
    rx_data_o        : out   std_logic_vector(63 downto 0);
72
    -- Gamepad Interface ------------------------------------------------------
73
    pad_data_io      : inout std_logic
74
  );
75
 
76
end gcpad_full;
77
 
78
 
79
use work.gcpad_pack.all;
80
 
81
architecture struct of gcpad_full is
82
 
83
  component gcpad_ctrl
84
    generic (
85
      reset_level_g :     integer := 0
86
    );
87
    port (
88
      clk_i         : in  std_logic;
89
      reset_i       : in  std_logic;
90
      pad_request_i : in  std_logic;
91
      pad_avail_o   : out std_logic;
92
      rx_timeout_o  : out std_logic;
93
      tx_start_o    : out boolean;
94
      tx_finished_i : in  boolean;
95
      rx_en_o       : out boolean;
96
      rx_done_i     : in  boolean;
97
      rx_data_ok_i  : in  boolean
98
    );
99
  end component;
100
 
101
  component gcpad_tx
102
    generic (
103
      reset_level_g    :     natural := 0;
104
      clocks_per_1us_g :     natural := 2
105
    );
106
    port (
107
      clk_i            : in  std_logic;
108
      reset_i          : in  std_logic;
109
      pad_data_o       : out std_logic;
110
      tx_start_i       : in  boolean;
111
      tx_finished_o    : out boolean;
112
      tx_size_i        : in  std_logic_vector( 1 downto 0);
113
      tx_command_i     : in  std_logic_vector(23 downto 0)
114
    );
115
  end component;
116
 
117
  component gcpad_rx
118
    generic (
119
      reset_level_g    :     integer := 0;
120
      clocks_per_1us_g :     integer := 2
121
    );
122
    port (
123
      clk_i            : in  std_logic;
124
      reset_i          : in  std_logic;
125
      rx_en_i          : in  boolean;
126
      rx_done_o        : out boolean;
127
      rx_data_ok_o     : out boolean;
128
      rx_size_i        : in  std_logic_vector(3 downto 0);
129
      pad_data_i       : in  std_logic;
130
      rx_data_o        : out buttons_t
131
    );
132
  end component;
133
 
134
 
135
  signal pad_data_tx_s : std_logic;
136
 
137
  signal tx_start_s    : boolean;
138
  signal tx_finished_s : boolean;
139
 
140
  signal rx_en_s,
141
         rx_done_s,
142
         rx_data_ok_s : boolean;
143
 
144
begin
145
 
146
  ctrl_b : gcpad_ctrl
147
    generic map (
148
      reset_level_g => reset_level_g
149
    )
150
    port map (
151
      clk_i         => clk_i,
152
      reset_i       => reset_i,
153
      pad_request_i => pad_request_i,
154
      pad_avail_o   => pad_avail_o,
155
      rx_timeout_o  => pad_timeout_o,
156
      tx_start_o    => tx_start_s,
157
      tx_finished_i => tx_finished_s,
158
      rx_en_o       => rx_en_s,
159
      rx_done_i     => rx_done_s,
160
      rx_data_ok_i  => rx_data_ok_s
161
    );
162
 
163
  tx_b : gcpad_tx
164
    generic map (
165
      reset_level_g    => reset_level_g,
166
      clocks_per_1us_g => clocks_per_1us_g
167
    )
168
    port map (
169
      clk_i            => clk_i,
170
      reset_i          => reset_i,
171
      pad_data_o       => pad_data_tx_s,
172
      tx_start_i       => tx_start_s,
173
      tx_finished_o    => tx_finished_s,
174
      tx_size_i        => tx_size_i,
175
      tx_command_i     => tx_command_i
176
    );
177
 
178
  rx_b : gcpad_rx
179
    generic map (
180
      reset_level_g    => reset_level_g,
181
      clocks_per_1us_g => clocks_per_1us_g
182
    )
183
    port map (
184
      clk_i            => clk_i,
185
      reset_i          => reset_i,
186
      rx_en_i          => rx_en_s,
187
      rx_done_o        => rx_done_s,
188
      rx_data_ok_o     => rx_data_ok_s,
189
      rx_size_i        => rx_size_i,
190
      pad_data_i       => pad_data_io,
191
      rx_data_o        => rx_data_o
192
  );
193
 
194
 
195
  -----------------------------------------------------------------------------
196
  -- Open collector driver to pad data
197
  -----------------------------------------------------------------------------
198
  pad_data_io <=   '0'
199
                 when pad_data_tx_s = '0' else
200
                   'Z';
201
 
202
end struct;

powered by: WebSVN 2.1.0

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