]> git.zerfleddert.de Git - fpga-games/blob - galaxian/src/fpga_arcade_if.v
clocks...
[fpga-games] / galaxian / src / fpga_arcade_if.v
1 //-------------------------------------------------------------------
2 //
3 // PLAYSTATION CONTROLLER-FPGA ARCADE GAME INTERFACE TOP
4 //
5 // Version : 2.01
6 //
7 // Copyright(c) 2003 - 2004 Katsumi Degawa , All rights reserved
8 //
9 // Important !
10 //
11 // This program is freeware for non-commercial use.
12 // An author does no guarantee about this program.
13 // You can use this under your own risk.
14 //
15 // 2004-4-29 fpga mooncrst use k .degawa
16 //-------------------------------------------------------------------
17
18 `timescale 100ps/10ps
19 `include "src/mc_conf.v"
20
21 module fpga_arcade_if(
22
23 CLK_18M432,
24 I_RSTn,
25 psCLK,
26 psSEL,
27 psTXD,
28 psRXD,
29 ps_PSW,
30 I_VIB_SW
31
32 );
33
34 input CLK_18M432,I_RSTn;
35 input I_VIB_SW;
36 input psRXD;
37 output psCLK,psSEL,psTXD;
38 output [8:0]ps_PSW;
39
40 reg [5:0]clk_reg;
41 wire CLK_288K;
42
43 assign CLK_288K = clk_reg[5];
44 always@(posedge CLK_18M432) clk_reg <= clk_reg+1;
45
46 wire [7:0]RX_DATA_1,RX_DATA_2;
47 wire [7:0]RX_DATA_3,RX_DATA_4;
48 //wire [7:0]RX_DATA_5,RX_DATA_6;
49
50 reg [1:0]XY_pos;
51
52 assign ps_PSW[0] = 1'b1; // UP
53 assign ps_PSW[1] = 1'b1; // DOWN
54 assign ps_PSW[2] = XY_pos[0]; // LEFT
55 assign ps_PSW[3] = XY_pos[1]; // RIGHT
56 assign ps_PSW[4] = RX_DATA_2[5]; // CREDIT1 (MARU-BOTAN)
57 assign ps_PSW[5] = RX_DATA_2[4]; // CREDIT2 (SANKAKU-BOTAN)
58 assign ps_PSW[6] = RX_DATA_1[3]; // START 1P (START-BOTAN)
59 assign ps_PSW[7] = RX_DATA_1[0]; // START 2P (SELCT-BOTAN)
60 assign ps_PSW[8] = RX_DATA_1[6];
61
62 always@(posedge CLK_288K)
63 begin
64 if(RX_DATA_3<=8'h5F&&RX_DATA_3>=8'h00)
65 XY_pos <= 2'b10;
66 else if(RX_DATA_3<=8'hFF&&RX_DATA_3>=8'hA0)
67 XY_pos <= 2'b01;
68 else
69 XY_pos <= 2'b11;
70 end
71
72 // Dualshock
73 `ifdef Dualshock
74 psPAD_top pspad(
75
76 .I_CLK250K(CLK_288K),
77 .I_RSTn(I_RSTn),
78 .I_VIB_SW({I_VIB_SW,1'b0}),
79 .O_psCLK(psCLK),
80 .O_psSEL(psSEL),
81 .O_psTXD(psTXD),
82 .I_psRXD(psRXD),
83 .O_RXD_1(RX_DATA_1),
84 .O_RXD_2(RX_DATA_2),
85 .O_RXD_3(RX_DATA_3),
86 .O_RXD_4(RX_DATA_4),
87 .O_RXD_5(),
88 .O_RXD_6(),
89 .I_CONF_SW(),
90 .I_MODE_SW(),
91 .I_MODE_EN(),
92 .I_VIB_DAT(8'hFF)
93 );
94 `else
95 psPAD_top pspad(
96
97 .I_CLK250K(CLK_288K),
98 .I_RSTn(I_RSTn),
99 .I_VIB_SW(I_VIB_SW),
100 .O_psCLK(psCLK),
101 .O_psSEL(psSEL),
102 .O_psTXD(psTXD),
103 .I_psRXD(psRXD),
104 .O_RXD_1(RX_DATA_1),
105 .O_RXD_2(RX_DATA_2),
106 .O_RXD_3(RX_DATA_3),
107 .O_RXD_4(RX_DATA_4),
108 .O_RXD_5(),
109 .O_RXD_6(),
110 .I_CONF_SW(),
111 .I_MODE_SW(),
112 .I_MODE_EN(),
113 .I_VIB_DAT()
114 );
115 `endif
116
117 endmodule
118
119
120
121
Impressum, Datenschutz