Hello arunkannan,
You can do this using the System Device Identification Register (SIM_SDID) of your device.
This Read-Only register contains every information you need to identify the Part-Number of your chip.

For exemple, for your device you can do something like this :
- Read the register
- Check if FAMID is equal to 1. (KL1x Family (basic))
- Check if SUBFAMID is equal to 0b0110 (KLx6 Subfamily)
- Check if SRAMSIZE is equal to 0b0101 (16 KB)
- Check if PINID is equal to 0b0100 (48-pin)
You can find the specifications of this register in the reference manual :
12.2.6 System Device Identification Register (SIM_SDID).
You can also do a sort of "if-tree" to identify your specific configuration.


Hope it will help you, feel free to ask if you need anything else.
Devyy
PS: I forgot it but you can also identify the flash size of your device using the Flash Configuration Register 1 (SIM_FCFG1).


So, for your device you must read 0b111 for 128 KB.