.. _add_register:

		Adds the Register_ ``register`` to the interface.

		Will raise a SetupError_ if the interface is locked (because it is running) or if
		there is already a Register with the name of the new Register or if
		the number of Registers would exceed the size of the interface.

		Returns the index of the new Register

def add_register(self, register):
		"""
		.. _add_register:

		Adds the Register_ ``register`` to the interface.

		Will raise a SetupError_ if the interface is locked (because it is running) or if
		there is already a Register with the name of the new Register or if
		the number of Registers would exceed the size of the interface.

		Returns the index of the new Register
		"""
		if(self._lock):
			raise SetupError("RegisterInterface is already running, no changes to the register layout can be performed")
		if(len(self.registers_by_index) >= self.size):
			raise SetupError("Number of Registers would exceed the address space({})".format(self.size))
		if(register.name in self.registers_by_name):
			raise SetupError("Register with name '{}' already added.".format(register.name))
		self.registers_by_name[register.name] = register
		self.registers_by_index.append(register)
		return len(self.registers_by_index) - 1