import random


def generate_int(data_format):
    """
    Generate an integer based on the given data width and sign.
    """
    is_signed = data_format['is_signed']
    width = data_format['width']

    if is_signed:
        result = random.randrange(-2 ** (width - 1) + 1, 2 ** (width - 1) - 1)
    else:
        result = random.randrange(0, 2 ** width - 1)
    return result