title: Keeping count of button clicks in verilog
body: <p>I am creating a vending machine in verilog. There is one button on the FPGA board to act as the coin inserter, every time the button is pushed it will add a 'quarter' to the total amount the user can spend, and display the total on the left and right seven segment displays.</p>
  
  <p>Ex.
  1st button push : 25 cents
  2nd button push : 50 cents
  3rd button push : 75 cents
  4th button push : $1.00 (10 on the seven segment display).
  Wont increment after the 4th button press.</p>
  
  <pre><code> input quarterIn,
   output reg [4:0] state,
   output reg [4:0] next_state,
   output reg totalChange,
  output reg [7:0] RSSD,
  output reg [7:0] LSSD
  );
  
   /***coin implementation***/
   parameter
      c0 = 0,
      c1 = 1,
      c2 = 2,
      c3 = 3,
      c4 = 4;
  </code></pre>
  
  <p><code>always @(posedge clock)
      begin
      state = next_state;
      end</code></p>
  
  <pre><code> always @ (quarterIn or totalChange)
   begin
      case(totalChange)
      0: begin if(quarterIn == 1) totalChange = 1; state = c1; end
      1: begin if(quarterIn == 1) totalChange = 2; state = c2; end
      2: begin if(quarterIn == 1) totalChange = 3; state = c3; end
      3: begin if(quarterIn == 1) totalChange = 4; state = c4; end
      4: begin if(quarterIn == 1) totalChange = 4; state = c4; end
      endcase
   end
  </code></pre>
  
  <p>I am getting stuck on how to keep count of the button clicks. I can see the first value on the seven segment display, but am unsure as to how to increment the total coins. I couldn't find any sort of information on this from trying to research on my own. </p>