-VLOGS = 7seg.v Framebuffer.v GBZ80Core.v Interrupt.v LCDC.v Sound1.v \
+VLOGS = 7seg.v Framebuffer.v core/GBZ80Core.v Interrupt.v LCDC.v Sound1.v \
Sound2.v Soundcore.v System.v Timer.v Uart.v Buttons.v PS2Button.v
-VLOGS_ALL = $(VLOGS) insn_call-callcc.v insn_incdec16.v insn_jr-jrcc.v \
- insn_ld_reg_hl.v insn_ld_reg_reg.v insn_nop.v insn_ret-retcc.v \
- allinsns.v insn_alu8.v insn_di-ei.v insn_jp_hl.v insn_ldh_ac.v \
- insn_ld_reg_imm16.v insn_ld_sp_hl.v insn_pop_reg.v insn_rst.v \
- CPUDCM.v insn_alu_a.v insn_halt.v insn_jp-jpcc.v insn_ld_hl_reg.v \
- insn_ld_reg_imm8.v insn_ldx_ahl.v insn_push_reg.v insn_vop_intr.v \
- insn_ldm8_a.v insn_ldm16_a.v insn_ldbcde_a.v insn_alu_ext.v \
- insn_bit.v insn_two_byte.v insn_incdec_reg8.v insn_add_hl.v
+VLOGS_ALL = $(VLOGS) core/insn_call-callcc.v core/insn_incdec16.v \
+ core/insn_jr-jrcc.v core/insn_ld_reg_hl.v core/insn_ld_reg_reg.v \
+ core/insn_nop.v core/insn_ret-retcc.v core/allinsns.v \
+ core/insn_alu8.v core/insn_di-ei.v core/insn_jp_hl.v \
+ core/insn_ldh_ac.v core/insn_ld_reg_imm16.v core/insn_ld_sp_hl.v \
+ core/insn_pop_reg.v core/insn_rst.v CPUDCM.v core/insn_alu_a.v \
+ core/insn_halt.v core/insn_jp-jpcc.v core/insn_ld_hl_reg.v \
+ core/insn_ld_reg_imm8.v core/insn_ldx_ahl.v core/insn_push_reg.v \
+ core/insn_vop_intr.v core/insn_ldm8_a.v core/insn_ldm16_a.v \
+ core/insn_ldbcde_a.v core/insn_alu_ext.v core/insn_bit.v \
+ core/insn_two_byte.v core/insn_incdec_reg8.v core/insn_add_hl.v
all: CoreTop.svf
module PS2Button(
+ input clk,
input inclk,
input indata,
output wire [7:0] buttons
reg key_a = 0,key_b = 0,key_st = 0,key_sel = 0,key_up = 0,key_dn = 0,key_l = 0,key_r = 0;
assign buttons = {key_st,key_sel,key_b,key_a,key_dn,key_up,key_l,key_r};
+
+ /* Clock debouncing */
+ reg lastinclk = 0;
+ reg [5:0] debounce = 0;
+ reg fixedclk = 0;
+ reg [9:0] resetcountdown = 0;
+
+ always @(posedge clk) begin
+ if (inclk != lastinclk) begin
+ lastinclk <= inclk;
+ debounce <= 1;
+ resetcountdown <= 10'b1111111111;
+ end else if (debounce == 0) begin
+ fixedclk <= inclk;
+ resetcountdown <= resetcountdown - 1;
+ end else
+ debounce <= debounce + 1;
+ end
- always @ (negedge inclk) begin
- if(bitcount == 10) begin
+ always @(negedge fixedclk) begin
+ if (resetcountdown == 0)
+ bitcount <= 0;
+ else if (bitcount == 10) begin
bitcount <= 0;
if(parity != (^ key)) begin
if(keyarrow) begin