///////////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------------
// 
// © 2022 Microchip Technology Inc. and its subsidiaries
//   All rights reserved.
//  
//   ANY USE OR REDISTRIBUTION IN PART OR IN WHOLE MUST BE HANDLED IN
//   ACCORDANCE WITH THE MICROCHIP LICENSE AGREEMENT AND MUST BE APPROVED
//   IN ADVANCE IN WRITING.
//
//-------------------------------------------------------------------------
// Title       : cnt_up.v
// Created     : November 2017
// Description : This module instantiates series of counters based on 
//                user preference
// Hierarchy    :
//                
//                Top_Level
//                 -- Fabric_LSRAM_USRAM_MACC
//                  -- fabric_logic.v              
//                   -- cnt_up_cascade.v                   
//                    -- cnt_up.v               <-- This module
//
// Target device: <Family:PolarFire> <Die:MPF300TS_ES> <Pkg:FCG1152> 
//-------------------------------------------------------------------------

module cnt_up #(parameter WIDTH = 16)
              (input CLK,                   // Input clock
               input RST,                   // Reset for logic
               input[WIDTH - 1 : 0] DIN,    // Input data for counter
               output[WIDTH - 1 : 0] DOUT   // Output data from counter
              );
  reg[WIDTH - 1 : 0] CNTVAL;
  
  //Logic for counter
  always@(posedge CLK or negedge RST)
    begin: U
      if (RST == 1'b0)
        CNTVAL <= { WIDTH { 1'b0 } };
      else
        begin
          CNTVAL <= DIN + 1'b1;
        end
    end
  assign DOUT = CNTVAL;
endmodule
