写一个Verilog程序,用来实现按键消抖
时间: 2023-03-11 11:34:56 浏览: 104
整体程序-线性系统理论课后题答案
module debounce (input key, output reg debounced_key);
reg [23:0] cnt;
always @ (posedge key) begin
if (cnt == 24'hFFFFFF) begin
debounced_key <= 1'b1;
end else begin
cnt <= cnt + 24'h1;
end
end
always @ (negedge key) begin
cnt <= 24'h0;
debounced_key <= 1'b0;
end
endmodule
阅读全文