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

Subversion Repositories gamepads

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 arniml
-------------------------------------------------------------------------------
2
--
3
-- GCpad controller core
4
--
5
-- Copyright (c) 2004, Arnim Laeuger (arniml@opencores.org)
6
--
7 41 arniml
-- $Id: gcpad_pack-p.vhd 41 2009-04-01 19:58:04Z arniml $
8 11 arniml
--
9
-------------------------------------------------------------------------------
10
 
11
library ieee;
12
use ieee.std_logic_1164.all;
13
 
14
package gcpad_pack is
15
 
16
  subtype analog_axis_t is std_logic_vector(7 downto 0);
17
  constant num_buttons_c : natural := 64;
18
  subtype buttons_t is std_logic_vector(num_buttons_c-1 downto 0);
19
 
20
  function "=" (a : in std_logic; b : in integer) return boolean;
21
 
22
  -----------------------------------------------------------------------------
23
  -- The button positions inside a gc packet
24
  -----------------------------------------------------------------------------
25
  -- byte 7 -------------------------------------------------------------------
26
  constant pos_errstat_c  : natural := 63;
27
  constant pos_errlatch_c : natural := 62;
28
  constant pos_unknown1_c : natural := 61;
29
  constant pos_start_c    : natural := 60;
30
  constant pos_y_c        : natural := 59;
31
  constant pos_x_c        : natural := 58;
32
  constant pos_b_c        : natural := 57;
33
  constant pos_a_c        : natural := 56;
34
  -- byte 6 -------------------------------------------------------------------
35
  constant pos_unknown2_c : natural := 55;
36
  constant pos_tl_c       : natural := 54;
37
  constant pos_tr_c       : natural := 53;
38
  constant pos_z_c        : natural := 52;
39
  constant pos_up_c       : natural := 51;
40
  constant pos_down_c     : natural := 50;
41
  constant pos_right_c    : natural := 49;
42
  constant pos_left_c     : natural := 48;
43
  -- byte 5 -------------------------------------------------------------------
44
  constant joy_x_high_c   : natural := 47;
45
  constant joy_x_low_c    : natural := 40;
46
  -- byte 4 -------------------------------------------------------------------
47
  constant joy_y_high_c   : natural := 39;
48
  constant joy_y_low_c    : natural := 32;
49
  -- byte 3 -------------------------------------------------------------------
50
  constant c_x_high_c     : natural := 31;
51
  constant c_x_low_c      : natural := 24;
52
  -- byte 2 -------------------------------------------------------------------
53
  constant c_y_high_c     : natural := 23;
54
  constant c_y_low_c      : natural := 16;
55
  -- byte 1 -------------------------------------------------------------------
56
  constant l_high_c       : natural := 15;
57
  constant l_low_c        : natural :=  8;
58
  -- byte 0 -------------------------------------------------------------------
59
  constant r_high_c       : natural :=  7;
60
  constant r_low_c        : natural :=  0;
61
 
62
end gcpad_pack;
63
 
64
 
65
package body gcpad_pack is
66
 
67
  -----------------------------------------------------------------------------
68
  -- Function =
69
  --
70
  -- Compares a std_logic with an integer.
71
  --
72
  function "=" (a : in std_logic; b : in integer) return boolean is
73
    variable result_v : boolean;
74
  begin
75
    result_v := false;
76
 
77
    case a is
78
      when '0' =>
79
        if b = 0 then
80
          result_v := true;
81
        end if;
82
 
83
      when '1' =>
84
        if b = 1 then
85
          result_v := true;
86
        end if;
87
 
88
      when others =>
89
        null;
90
 
91
    end case;
92
 
93
    return result_v;
94
  end;
95
  --
96
  -----------------------------------------------------------------------------
97
 
98
end gcpad_pack;

powered by: WebSVN 2.1.0

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