code: def resolve_addresses(self, node):
          prop_alignment = self.alignment_stack[-1]
          if prop_alignment is None:
              prop_alignment = 1
          prev_node = None
          for child_node in node.children(skip_not_present=False):
              if not isinstance(child_node, AddressableNode):
                  continue
              if child_node.inst.addr_offset is not None:
                  prev_node = child_node
                  continue
              if node.env.chk_implicit_addr:
                  node.env.msg.message(
                      node.env.chk_implicit_addr,
                      "Address offset of component '%s' is not explicitly set" % child_node.inst.inst_name,
                      child_node.inst.inst_src_ref
                  )
              alloc_alignment = child_node.inst.addr_align
              if alloc_alignment is None:
                  alloc_alignment = 1
              if self.addressing_mode_stack[-1] == rdltypes.AddressingType.compact:
                  if isinstance(child_node, RegNode):
                      mode_alignment = child_node.get_property('accesswidth') // 8
                  else:
                      mode_alignment = 1
              elif self.addressing_mode_stack[-1] == rdltypes.AddressingType.regalign:
                  mode_alignment = child_node.size
                  mode_alignment = roundup_pow2(mode_alignment)
              elif self.addressing_mode_stack[-1] == rdltypes.AddressingType.fullalign:
                  mode_alignment = child_node.total_size
                  mode_alignment = roundup_pow2(mode_alignment)
              else:
                  raise RuntimeError
              alignment = max(prop_alignment, alloc_alignment, mode_alignment)
              if prev_node is None:
                  next_offset = 0
              else:
                  next_offset = prev_node.inst.addr_offset + prev_node.total_size
              child_node.inst.addr_offset = roundup_to(next_offset, alignment)
              prev_node = child_node
          def get_child_sort_key(inst):
              if not isinstance(inst, comp.AddressableComponent):
                  return -1
              else:
                  return inst.addr_offset
          node.inst.children.sort(key=get_child_sort_key)