def generate_peripheral(peripheral, **kwargs):
    """ Generates definition of a peripheral.

    Args:
        peripheral (dict): peripheral description
        kwargs (dict): additional parameters, including 'model' and 'properties'

    Returns:
        string: repl definition of the peripheral
    """
    result = '\n{}: {} @ sysbus {}\n'.format(
        peripheral['name'],
        kwargs['model'],
        peripheral['address'])

    for constant, val in peripheral['constants'].items():
        if constant == 'interrupt':
            result += '    -> cpu@{}\n'.format(val)
        else:
            result += '    {}: {}\n'.format(constant, val)

    if 'properties' in kwargs:
        for prop, val in kwargs['properties'].items():
            result += '    {}: {}\n'.format(prop, val())

    return result