summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2010-10-25 19:23:07 -0700
committerH. Peter Anvin <hpa@zytor.com>2014-02-10 18:07:48 -0800
commitd9b68b7d37c6bedd36890960ee179dc5be16847d (patch)
tree0e9c0c388d66567b65e209cbc263720823725ef4
parente9c349d6b0e4f123a3767864cdd606e972e47f28 (diff)
downloadabc8000-d9b68b7d37c6bedd36890960ee179dc5be16847d.tar.gz
abc8000-d9b68b7d37c6bedd36890960ee179dc5be16847d.tar.xz
abc8000-d9b68b7d37c6bedd36890960ee179dc5be16847d.zip
serial: use debounce module
Use the debounce module instead of open-coding the debounce.
-rw-r--r--serial.v34
1 files changed, 8 insertions, 26 deletions
diff --git a/serial.v b/serial.v
index 76abceb..5cc2321 100644
--- a/serial.v
+++ b/serial.v
@@ -118,34 +118,16 @@ module serial (
end // always @ (negedge rst_n or posedge clk)
// Deglitch for the input
- reg [3:0] rx_deglitch;
reg rx_deglitched;
- reg tty_rxd_q;
- always @(negedge rst_n or posedge clk)
- if ( ~rst_n )
- begin
- rx_deglitch <= 4'b1111;
- tty_rxd_q <= 1'b1;
- end
- else
- begin
- tty_rxd_q <= tty_rxd;
- if ( tty_rxd_q )
- begin
- if ( ~&rx_deglitch )
- rx_deglitch <= rx_deglitch + 1;
- else
- rx_deglitched <= 1'b1;
- end
- else
- begin
- if ( |rx_deglitch )
- rx_deglitch <= rx_deglitch - 1;
- else
- rx_deglitched <= 1'b0;
- end // else: !if( tty_rxd_q )
- end // else: !if( ~rst_n )
+ debounce #(.width(1), .count(4)) rx_deglitch
+ (
+ .clk ( clk ),
+ .reset_n ( rst_n ),
+ .in ( tty_rxd ),
+ .out ( rx_deglitched ),
+ .strobe ( )
+ );
// Receive logic
reg [3:0] rx_bit_ctr;