def format_write_request(address, value):
    """ Format a write request based on an address and the value to write to
    the FPGA.

    :param address: address at which to write date.
    :param value: data to write to the address.
    :return: formatted request.
    """
    if address >= 2**(4 * 8):
        raise ValueError(f'Address {address} is too large (max 4 bytes).')
    if address < 0:
        raise ValueError(f'Address {address} cannot be negative.')

    if value >= 2**(4 * 8):
        raise ValueError(f'Value {value} is too large (max 4 bytes).')
    if value < 0:
        raise ValueError(f'Address {address} cannot be negative.')

    buff = bytearray(9)

    buff[0] = 1 << 7
    buff[1:] = int.to_bytes(address, length=4, byteorder="little")
    buff[5:] = int.to_bytes(value, length=4, byteorder="little")

    return buff