def conv_16upto32(val, nb):
    """ converts val (16bits) to 16+n bits (n must be comprised between 0 & 16 bits)
    :warning: conversion output shall not exceed 32bits (input shall strictly be unsigned 16bits)
    :warning: nb shall be in range 0-16 (note that using 0 doesn't change val)
    :param val: 16bit var to convert
    :param nb: nb of bit pseudo shifts to add
    :return: 16+n bit conversion result """
    return (val << nb) + (val & 65535 >> 16 - nb) & 4294967295
