def dec_to_bin(dec_val, num_bits):
    """
        Helper function convert decimal value to signed 2's complement binary value.
    """
    mod_fac = (1 << num_bits)
    format_str = '0{}b'.format(num_bits)
    return format((dec_val + mod_fac) % mod_fac, format_str)