def extractLagunaAnchorRoutes(slot_name):
  """
  record the ROUTE property of the nets to/from laguna anchors.
  Will reuse them later in the final stitch
  """
  script = []
  script.append(f'set target {slot_name}_ctrl_U0')
  script.append(
r'''
set laguna_anchors [get_cells -hierarchical -regexp -filter { LOC =~  ".*LAGUNA.*" } ]
set laguna_anchor_nets [get_nets  -regexp -top_net_of_hierarchical_group -filter { TYPE != "GROUND" && TYPE != "POWER" && NAME !~  ".*ap_clk.*" && ROUTE_STATUS != "HIERPORT" }  -of_objects ${laguna_anchors} ]
set file [open "add_${target}_laguna_route.tcl" "w"]
foreach net ${laguna_anchor_nets} {
  # check if the net connects to a laguna anchor
  set laguna_anchor [get_cells -of_objects [get_nets -segment $net] -filter {LOC =~ LAGUNA*}]
  if {$laguna_anchor != [] } {
    set net_route [get_property ROUTE $net]
    puts $file "set_property ROUTE ${net_route} \[get_nets ${net} \]"
  }
}
close $file
''')

  return script