mirror of
https://github.com/pConst/basic_verilog.git
synced 2025-01-14 06:42:54 +08:00
36 lines
1.0 KiB
Coq
36 lines
1.0 KiB
Coq
|
//--------------------------------------------------------------------------------
|
|||
|
// DeBounce.v
|
|||
|
// Konstantin Pavlov, pavlovconst@gmail.com
|
|||
|
//--------------------------------------------------------------------------------
|
|||
|
|
|||
|
// INFO --------------------------------------------------------------------------------
|
|||
|
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> (<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
module DeBounce(clk,nrst,in,out);
|
|||
|
|
|||
|
input wire clk;
|
|||
|
input wire nrst;
|
|||
|
input wire [(WIDTH-1):0] in;
|
|||
|
output wire [(WIDTH-1):0] out; // also "present state"
|
|||
|
|
|||
|
parameter WIDTH = 1;
|
|||
|
|
|||
|
reg [(WIDTH-1):0] prev = 0;
|
|||
|
|
|||
|
always @ (posedge clk) begin
|
|||
|
if (~nrst) begin
|
|||
|
prev <= 0;
|
|||
|
end
|
|||
|
else begin
|
|||
|
prev[(WIDTH-1):0] <= in[(WIDTH-1):0];
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
wire [(WIDTH-1):0] switch_hi = (prev[(WIDTH-1):0] & in[(WIDTH-1):0]);
|
|||
|
wire [(WIDTH-1):0] n_switch_lo = (prev[(WIDTH-1):0] | in[(WIDTH-1):0]);
|
|||
|
|
|||
|
SetReset SR(clk,nrst,switch_hi[(WIDTH-1):0],~n_switch_lo[(WIDTH-1):0],out[(WIDTH-1):0]);
|
|||
|
defparam SR.WIDTH = WIDTH;
|
|||
|
|
|||
|
endmodule
|