It is currently Fri Sep 10, 2010 8:13 pm




Post new topic Reply to topic  [ 1 post ] 
Verilog - Simle PB Debounce Code For Spartan 3 Boards 
Author Message
Site Admin

Joined: Sat Jan 24, 2009 3:56 pm
Posts: 32
Post Verilog - Simle PB Debounce Code For Spartan 3 Boards
The following bit of verilog code is a module that can be called and used to debounce any number of pushbuttons. It works very well and is incredibly stable on the spartan 3 and nexys 2 boards

Code:
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date:    16:55:18 03/11/2009
// Design Name:
// Module Name:    DebouncePB
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------
//                  DEBOUNCE MODULE
//----------------------------------------------------------
module DebouncePB(pushbutton, clock, clean_pb);
    input pushbutton,clock;
    output reg clean_pb;
   
    reg [14:0] countbuffer;
   
    always @ (posedge clock)
        begin
            countbuffer <= countbuffer + 1;
            if(countbuffer == 15'h7FFF)
                begin
                    countbuffer <= 15'h0;
                    clean_pb = 0;
                end
       
            else if(pushbutton == 1)
                begin
                    countbuffer <= 15'd0;
                    clean_pb = 1;
                end
        end
endmodule


Thu Aug 06, 2009 6:50 am
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © phpBB Group.
Designed by Vjacheslav Trushkin for Free Forum/DivisionCore.