INNOVUS批量摆放cell array的脚本

发布时间 2023-07-26 23:45:58作者: Siligence

说明:invs_place_cell_array -prefix $prefix -libcell $libcell -hornum $hornum -vernum $vernum -startX $startX -startY $startY -spaceX $spaceX -spaceY $spaceY -orientation $orientation, 类似于ICC2中create_cell_array的用法

proc invs_place_cell_array { args } {
  parse_proc_arguments -args $args ARGS
  set prefix $ARGS(-prefix)
  set libcell $ARGS(-libcell)
  set hornum $ARGS(-hornum)
  set vernum $ARGS(-vernum)
  set startX $ARGS(-startX)
  set startY $ARGS(-startY)
  set spaceX $ARGS(-spaceX)
  set spaceY $ARGS(-spaceY)
  set orientation $ARGS(-orientation)
  set n 0
  set x $startX
  set y $startY
  if { ($hornum != 0) && ($vernum != 0) } {
    for { set i 1 } { $i <= $hornum } { incr i } {
      for { set j 1 } { $j <= $vernum } { incr j } {
        addInst -inst ${prefix}_${i}_${j} -cell $libcell
        set insts [dbGet top.insts.name ${prefix}_*]
        set instX [dbGet [dbGet top.insts.name [lindex $insts 0] -p].box_sizex]
        set instY [dbGet [dbGet top.insts.name [lindex $insts 0] -p].box_sizey]
        set x [expr $x + ($i - 1) * $instX + ($i - 1) * $spaceX]
        set y [expr $y + ($j - 1) * $instY + ($j - 1) * $spaceY]
        placeInstance ${prefix}_${i}_${j} $x $y -fixed $orientation
        set x $startX
        set y $startY
      }
    }
  } elseif {($hornum == 0) && ($vernum != 0)} {
    for { set i 1 } { $i <= $vernum } { incr i } {
      addInst -inst ${prefix}_${i} -cell $libcell
    }
    set insts [dbGet top.insts.name ${prefix}_*]
    set instX [dbGet [dbGet top.insts.name [lindex $insts 0] -p].box_sizex]
    set instY [dbGet [dbGet top.insts.name [lindex $insts 0] -p].box_sizey]
    foreach inst $insts {
      placeInstance $inst $x $y -fixed $orientation
      incr n
      if { $n % $vernum == 0} {
        set x $startX
        set y $startY
      } else {
        set x $startX
        set y [expr $y + $instX + $spaceY]
      }
    }
  } elseif {($hornum != 0) && ($vernum == 0)} {
    for { set i 1 } { $i <= $hornum } { incr i } {
      addInst -inst ${prefix}_${i} -cell $libcell
    }
    set insts [dbGet top.insts.name ${prefix}_*]
    set instX [dbGet [dbGet top.insts.name [lindex $insts 0] -p].box_sizex]
    set instY [dbGet [dbGet top.insts.name [lindex $insts 0] -p].box_sizey]
    foreach inst $insts {
      placeInstance $inst $x $y $orientation -fixed
      incr n
      if { $n % $hornum == 0 } {
        set x $startX
        set y $startY
      } else {
        set x [expr $x + $instX + $spaceX]
        set y $startY
      }
    }
  } else {
    puts "impossible case!"
  }
}

define_proc_arguments batch_place_inst \
  -info "batch place array cells" \
  -define_args {
    {-prefix "create inst name prefix." string string required}
    {-libcell "lib cell to be created." string string required}
    {-hornum "horizontal lib cell numbers." string string required}
    {-vernum "vertical lib cell numbers." string string required}
    {-startX "first placed inst horizontal coordinate." string string required}
    {-startY "first placed inst horizontal coordinate." string string required}
    {-spaceX "spacing between two adjacent horizontally placed insts." string string required}
    {-spaceY "spacing between two adjacent vertically placed insts." string string required}
    {-orientation "orientation of first placed inst." string string required}
}