dfa_assembly.il

来自「ALLEGRO SKILL SAMPLE CODE」· IL 代码 · 共 627 行 · 第 1/3 页

IL
627
字号
                bottom_left = car(temp_line)
                top_right = cadr(temp_line)
             else
                temp_line1 = set_bBox_point(nth(i line_bBox))
               unless(axlDistance(car(temp_line1) cadr(temp_line1)) == 0.0 
                if(caar(temp_line) <= caar(temp_line1) then
                   if(cadar(temp_line) <= cadar(temp_line1) then
                      bottom_left = car(temp_line)
                    else
                      bottom_left = list(caar(temp_line) cadar(temp_line1))
                     ) ; end if
                 else
                   if(cadar(temp_line) <= cadar(temp_line1) then
                      bottom_left = list(caar(temp_line1) cadar(temp_line))
                    else
                      bottom_left = list(caar(temp_line1) cadar(temp_line1))
                     ) ; end if
                    ) ; end if
                if(caadr(temp_line) > caadr(temp_line1) then
                   if(cadadr(temp_line) >= cadadr(temp_line1) then
                      top_right = cadr(temp_line)
                    else
                      cond(
                          (cadr(bottom_left) == cadadr(temp_line1) 
                                      top_right = list(caadr(temp_line) cadadr(temp_line))  )
                          (t          top_right = list(caadr(temp_line) cadadr(temp_line1)) )  
                          ) ; end cond
                     ) ; end if
                 else
                   if(cadadr(temp_line) > cadadr(temp_line1) then
                      cond(
                          (car(bottom_left) == caadr(temp_line1) 
                                   top_right = list(caadr(temp_line) cadadr(temp_line)) )
                          (t    top_right = list(caadr(temp_line1) cadadr(temp_line)))
                          ) ; end cond
                    else
                      cond(
                          (cadr(bottom_left) == cadadr(temp_line1) 
                                   top_right = list(caadr(temp_line1) cadadr(temp_line)) )
                          (t    top_right = list(caadr(temp_line1) cadadr(temp_line1)) )
                          ) ; end cond
                     ) ; end if
                    ) ; end if
                  ); end unless
                ) ; end if
                    temp_line = list(bottom_left top_right)
                 ); end for
                 bbox_table[assem_box->parent->refdes] = temp_line
            ) ; end if
                ) ; end unless
           ) ; end foreach
             return(bbox_table)
     ); end prog
) ; end defun

;##########################################################################
;#                                                                        #
;#             clearance_check Function                                   #
;# Checks whether any component is violating the clearance                #
;##########################################################################

(defun clearance_check (refdes_c1 refdes_c2 bbox_set grid_inc dfa_check_log seg2)
 prog( ( check key2 bbox_check bbox_clear duplicate1 duplicate2 error_count dbid_key dbid_key2 seg_refdes line_width1 line_width2)
       duplicate1 = nil
       error_count = line_width1 = line_width2 = 0
       bbox_clear = makeTable("c2_table" nil)
       foreach( key refdes_c1
             foreach(key2 refdes_c2
               duplicate2 = strcat(key2 key)
               unless(key2 == key
                if(member(duplicate2 duplicate1) == nil then
                   foreach(seg_refdes seg2
                         if( seg_refdes->parent->refdes == key then
                           unless(seg_refdes->objType != "path" 
                               line_width1 = car(seg_refdes->segments)->width
                                  ); end unless
                           ) ; end if
                         if( seg_refdes->parent->refdes == key2 then 
                             unless(seg_refdes->objType != "path"
                               line_width2 = car(seg_refdes->segments)->width
                                  ) ; end unless 
                           ) ; end if
                         ) ; end foreach
                 bbox_clear = create_bBox(key grid_inc line_width1 line_width2)
                 duplicate1 = append(duplicate1 list(strcat(key key2)))
                if(axlIsPointInsideBox(car(bbox_set[ key2 ]) bbox_clear[ key ]) ||
                   axlIsPointInsideBox(cadr(bbox_set[ key2 ]) bbox_clear[ key ]) ||
                   axlIsPointInsideBox(car(bbox_clear[ key ]) bbox_set[ key2 ]) ||
                   axlIsPointInsideBox(cadr(bbox_clear[ key ]) bbox_set[ key2 ]) then
                   dbid_key = car(axlDBCreateRectangle(bbox_set[ key ] nil "Package Geometry/Soldermask_Top"))
                   dbid_key2= car(axlDBCreateRectangle(bbox_set[ key2 ] nil "Package Geometry/Soldermask_Top"))
                   airgap = cadr(cdr(axlAirGap(dbid_key dbid_key2)))
                   airgap = airgap - (line_width1/2) - (line_width2/2)
                   unless( airgap >= grid_inc
                    fprintf(dfa_check_log "ERROR (DFA_clearance_audit):\n ")
                    fprintf(dfa_check_log "Violation reported between components %s and %s\n",key key2)
                    fprintf(dfa_check_log "Clearance between components  %L\n",airgap)
                    fprintf(dfa_check_log "Minimum clearance required : %L\n\n\n",grid_inc)
                    error_count++
                         ) ; end unless
                    axlDeleteObject(list(dbid_key dbid_key2))
                     line_width1 = line_width2 = 0
                   ) ; end if
                     ) ; end unless
                    ) ; end if
                    ) ; end foreach
           remove(key bbox_check)
               ); end foreach
     return(error_count)        
  ) ; end prog
) ; end defun

;##########################################################################
;#                                                                        #
;#             set_bBox_Right  Function                                   #
;# Sets the bBox to Bottom left and Top_Right for all keys of Association #
;# table                                                                  #
;##########################################################################

(defun set_bBox_Right (bbox_table)
 prog( ( key bottom_left top_right bbox_tmp bbox_set)
     bbox_tmp = makeTable("tmp_table" nil)
     bbox_set = makeTable("s_table" nil)
     bbox_tmp = bbox_table
     foreach( key bbox_tmp
        cond(
              (caar(bbox_tmp[ key ]) > caadr(bbox_tmp[ key ]) && cadar(bbox_tmp[ key ]) < cadadr(bbox_tmp[ key ]) 
                  bottom_left = list(caadr(bbox_tmp[ key ]) cadar(bbox_tmp[ key ]))
                  top_right   = list(caar(bbox_tmp[ key ])  cadadr(bbox_tmp[ key ]))
                  bbox_set[ key ] = list(bottom_left top_right)
              )
              (caar(bbox_tmp[ key ]) > caadr(bbox_tmp[ key ]) && cadar(bbox_tmp[ key ]) > cadadr(bbox_tmp[ key ])                 
                  bottom_left = list(caadr(bbox_tmp[ key ]) cadadr(bbox_tmp[ key ]))
                  top_right   = list(caar(bbox_tmp[ key ])  cadar(bbox_tmp[ key ]))
                  bbox_set[ key ] = list(bottom_left top_right)
              )
              (caar(bbox_tmp[ key ]) < caadr(bbox_tmp[ key ]) && cadar(bbox_tmp[ key ]) > cadadr(bbox_tmp[ key ])
                  bottom_left = list(caar(bbox_tmp[ key ]) cadadr(bbox_tmp[ key ]))
                  top_right   = list(caadr(bbox_tmp[ key ])  cadar(bbox_tmp[ key ]))
                  bbox_set[ key ] = list(bottom_left top_right)
              )
              (t
                  bbox_set[ key ] =  bbox_tmp[ key ] 
              )
            ) ; end cond
           ); end foreach
      return(bbox_set)
  ) ; end prog
); end defun

;##########################################################################
;#                                                                        #
;#             set_bBox_point  Function                                   #
;# Sets the bBox to Bottom left and Top_Right a given Dbid                #
;#                                                                        #
;##########################################################################

(defun set_bBox_point (bbox_point)
 prog( ( bottom_left top_right bbox_set)
        cond(
              (caar(bbox_point) > caadr(bbox_point) && cadar(bbox_point) < cadadr(bbox_point) 
                  bottom_left = list(caadr(bbox_point) cadar(bbox_point))
                  top_right   = list(caar(bbox_point)  cadadr(bbox_point))
                  bbox_set = list(bottom_left top_right)
              )
              (caar(bbox_point) > caadr(bbox_point) && cadar(bbox_point) > cadadr(bbox_point)                 
                  bottom_left = list(caadr(bbox_point) cadadr(bbox_point))
                  top_right   = list(caar(bbox_point)  cadar(bbox_point))
                  bbox_set = list(bottom_left top_right)
              )
              (caar(bbox_point) < caadr(bbox_point) && cadar(bbox_point) > cadadr(bbox_point)
                  bottom_left = list(caar(bbox_point) cadadr(bbox_point))
                  top_right   = list(caadr(bbox_point)  cadar(bbox_point))
                  bbox_set = list(bottom_left top_right)
              )
              (t
                  bbox_set =  bbox_point 
              )
            ) ; end cond
      return(bbox_set)
  ) ; end prog
); end defun

;##########################################################################
;#                                                                        #
;#             Find Layer visibility function                             #
;# Finds the currently visible layers in the design                       #
;#                                                                        #
;##########################################################################

(defun store_layer_index ()
 prog( ( dbid_layergp _active_layers test_layer v_layer_index)
            dbid_layergp = axlGetParam("paramLayerGroup")
            foreach(layergp dbid_layergp->groupMembers
               test_layer = strcat("paramLayerGroup:" layergp)
               dbid_layer= axlGetParam(test_layer)
                     foreach(_layers dbid_layer->groupMembers
                           _active_layers = strcat(layergp "/" _layers)
                            if(axlIsVisibleLayer(_active_layers) then
                                v_layer_index = append(list(_active_layers) v_layer_index)
                               ); end if
                             ) ; end foreach
                      ) ; end foreach
     return(v_layer_index)
        ) ; end prog
 ) ; end defun
                            

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?