mirror of
https://github.com/nippur72/Apple1_MiST.git
synced 2024-06-17 06:29:30 +00:00
add debounce filter to cassette input
This commit is contained in:
parent
076e8f48c6
commit
b4d78e99e7
20
rtl/aci.v
20
rtl/aci.v
|
@ -21,7 +21,7 @@ module ACI (
|
||||||
|
|
||||||
wire io_range = addr >= 16'hC000 && addr <= 16'hC0FF;
|
wire io_range = addr >= 16'hC000 && addr <= 16'hC0FF;
|
||||||
|
|
||||||
wire [7:0] read_addr = io_range ? { addr[7:1], addr[0] & tape_in } : addr[7:0];
|
wire [7:0] read_addr = io_range ? { addr[7:1], addr[0] & debounced_tape_in } : addr[7:0];
|
||||||
|
|
||||||
always @(posedge clk) begin
|
always @(posedge clk) begin
|
||||||
|
|
||||||
|
@ -31,5 +31,23 @@ module ACI (
|
||||||
dout <= rom_data[read_addr];
|
dout <= rom_data[read_addr];
|
||||||
end
|
end
|
||||||
|
|
||||||
|
// filters tape_in with anti bounce
|
||||||
|
wire debounced_tape_in = last_tape_in;
|
||||||
|
reg last_tape_in;
|
||||||
|
reg [31:0] bounce_cnt;
|
||||||
|
localparam bounce_max = 3579; // 57272719 / 3579 = ~16 KHz max
|
||||||
|
|
||||||
|
always @(posedge clk) begin
|
||||||
|
if(tape_in != last_tape_in) begin
|
||||||
|
if(bounce_cnt < bounce_max) begin
|
||||||
|
bounce_cnt <= bounce_cnt + 1;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
bounce_cnt <= 0;
|
||||||
|
last_tape_in = tape_in;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|
Loading…
Reference in New Issue
Block a user