def get_region_for_chip(x, y, level=3):
    """Get the region word for the given chip co-ordinates.

    Parameters
    ----------
    x : int
        x co-ordinate
    y : int
        y co-ordinate
    level : int
        Level of region to build. 0 is the most coarse and 3 is the finest.
        When 3 is used the specified region will ONLY select the given chip,
        for other regions surrounding chips will also be selected.

    Returns
    -------
    int
        A 32-bit value representing the co-ordinates of the chunk of SpiNNaker
        chips that should be selected and the blocks within this chunk that are
        selected.  As long as bits (31:16) are the same these values may be
        OR-ed together to increase the number of sub-blocks selected.
    """
    shift = 6 - 2*level

    bit = ((x >> shift) & 3) + 4*((y >> shift) & 3)  # bit in bits 15:0 to set

    mask = 0xffff ^ ((4 << shift) - 1)  # in {0xfffc, 0xfff0, 0xffc0, 0xff00}
    nx = x & mask  # The mask guarantees that bits 1:0 will be cleared
    ny = y & mask  # The mask guarantees that bits 1:0 will be cleared

    #        sig bits x | sig bits y |  2-bit level  | region select bits
    region = (nx << 24) | (ny << 16) | (level << 16) | (1 << bit)
    return region