///////////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------------
// © 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 : mem_cnt.v
// Description : This module used to generate and control a memory depth parameter (MEM_DEPTH) based on the state of a DIP switch .  <-- This module
//-------------------------------------------------------------------------

//`timescale <time_units> / <precision>

module mem_cnt( CLK, RESETN, dip_conf, MEM_DEPTH );
input CLK, RESETN;
input   dip_conf;
output	reg [24:0]   MEM_DEPTH;

reg [24:0]   MEM_DEPTH_int;
reg  dip_conf_q;
//defining memory with switching
always @(posedge CLK or negedge RESETN)
begin
    if (!RESETN) begin
        dip_conf_q <= 1'b0;
        MEM_DEPTH_int <= 0;
        MEM_DEPTH <= 0;
    end
    else
        begin
        MEM_DEPTH <= MEM_DEPTH_int;
        dip_conf_q <= dip_conf;
        case (dip_conf_q)
            1'b0    : begin MEM_DEPTH_int <= 25'h0000020; end /// 32k (16x2k)	
            1'b1    : begin MEM_DEPTH_int <= 25'h000FFFF; end	
            default : MEM_DEPTH_int <= 25'h3FFFFF; 
        endcase
    end 
end
//<statements>

endmodule

