Factor out common code from Nexys2