From 07cc3c5c788eff68b8d68713204613b07824fae2 Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Sat, 28 Mar 2026 16:35:19 -0700 Subject: Initial Commit --- button_sync.v | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 button_sync.v (limited to 'button_sync.v') diff --git a/button_sync.v b/button_sync.v new file mode 100644 index 0000000..5913ce5 --- /dev/null +++ b/button_sync.v @@ -0,0 +1,20 @@ +// This module is used for sycronizing the keys to the clock. +// The key input is active low, like the keys on the board. +// This module inverts the buttons so that the pressed output is active high +// button_down is high if any of the buttons are pressed +module button_sync ( + input clk, + input [7:0] key, + output button_down, + output reg [7:0] pressed +); + // used to avoid metastability + reg [7:0] key1; + + assign button_down = |pressed; + + always @(posedge clk) begin + pressed <= key1; + key1 <= key; + end +endmodule -- cgit v1.2.1