I have been trying to write a Verilog design for a while to interface with a SNES controller and read it's button outputs, using this page as a guide: http://www.gamefaqs.com/snes/916396-super-nintendo/faqs/5395
This is what I have:
And the clock I'm using has a period of 12us (to fit the specifications described), and is divided up with this:
However, I am getting nothing but a high signal from the SNES data line. I have debugged this with both a simulator and Signal Tap and seem to be doing everything right. My logic analyzer output is attached, with data, clock, and latch from top to bottom. Just looking at this, can anyone see if I am doing something wrong? This far, I haven't been able to get anything but a high data signal from the controller.
This is what I have:
Code:
module SNES(input clock, input snes_data,
output snes_clock, output reg snes_latch,
output reg a, output reg b, output reg x, output reg y,
output reg up, output reg down, output reg left, output reg right,
output reg l, output reg r, output reg start, output reg select);
reg[3:0] btn_counter;
reg latch;
initial latch <= 1;
assign snes_clock = snes_latch ? 1 : clock;
always @ (posedge clock)
snes_latch <= latch;
always @ (negedge clock)
if (latch) latch <= 0;
else begin
case (btn_counter)
0: b <= ~snes_data;
1: y <= ~snes_data;
2: select <= ~snes_data;
3: start <= ~snes_data;
4: up <= ~snes_data;
5: down <= ~snes_data;
6: left <= ~snes_data;
7: right <= ~snes_data;
8: a <= ~snes_data;
9: x <= ~snes_data;
10: l <= ~snes_data;
11: r <= ~snes_data;
endcase
btn_counter <= btn_counter + 1;
latch <= btn_counter == 0;
end
endmodule
Code:
module clk_div(Clk_in, Clk_out);
// input ports
input Clk_in;
// output ports
output reg Clk_out;
parameter max = 300; // max-counter size
reg [8:0]counter = 0; // 9-bit counter size
always@(posedge Clk_in) begin
if (counter == max-1)
begin
counter <= 0;
Clk_out <= ~Clk_out;
end
else
begin
counter <= counter + 1'd1;
end
end
endmodule
Attachments
-
21.5 KB Views: 44