ADS PDK Automation Part.2 CallBack Function

/*
    Type: ADS AEL Code
    
    Functions for QA script generation

    Requirement
    1.function name is protected and should be keepe onece been created;

    Log:
    2018.11.15 Hxj New
    2018.11.15 Hxj Add:DeviceLayoutGeneration
    2018.11.30 Hxj Add:DeviceSchematicGernation_Based_On_DeviceLayoutGeneration
    2018.12.01 Hxj Add:AddPinSchematic,AddPinLayout
    2018.12.03 Hxj Modify:DeviceLayoutGeneration,DeviceSchemaaticGeneration
    2018.12.07 Hxj Modify:DeviceLayoutGeneration now can got item Bbox and ajust layout space

*/

defun DeviceLayoutGeneration(PcellPath,LayoutPath,ParameterNameList,ParameterValueList,LocationList)
// LocationList=((case1 x,y),(case2 x,y)....)
{    //generate 1 kind of device with n instance
    //2018.12.03 Hxj:Create Layout View if not exist
    decl Lib=nth(0,LayoutPath);
    decl Cell=nth(1,LayoutPath);
    decl Layout= nth(2,LayoutPath);
    decl DesignName=strcat(Lib,":",Cell,":",Layout);
    decl context = de_find_design_context_from_name(DesignName);
    if (context == NULL){
        context = db_oa_create_empty_design(Lib,Cell,Layout, 2);
    }
    de_show_context_in_new_window(context); //symbol or layout cannot be placed if the context is not showed
    //Place Device on Layout
    decl PcellLib=nth(0,PcellPath);
    decl PcellCell=nth(1,PcellPath);
    decl PcellLayout= nth(2,PcellPath);
    decl Component=strcat(PcellLib,":",PcellCell,":",PcellLayout);
    
    decl ItemInfo = de_init_item(Component);
    
    decl Num=listlen(ParameterValueList);
    decl ParaNum=listlen(ParameterNameList);    
    decl dX=0;
    decl dY=0;
    decl X=0;
    decl Y=0;
    decl SpaceX=nth(0,nth(0,LocationList))+30; // 10 prevent inter SpaceX=0 which will cause 2 layout connected 
    decl SpaceY=nth(1,nth(0,LocationList))+30;
    decl i=0;
    for(i=0;i<Num;i=i+1)
    {
        // 1. SET LOCATION
        //dX = nth(0,nth(i,LocationList));
        //dY = nth(1,nth(i,LocationList));
        X=X+dX+SpaceX;
        Y=Y;
        // 2. CREATE PARAMETER
        decl ItemInfo = de_create_iteminfo_for_new_instance(context, PcellLib, PcellCell,PcellLayout);
        decl newInst = de_create_new_instance_from_iteminfo(ItemInfo, X, Y);
        decl InstName = db_get_instance_name(newInst);
        // 3. SET PARAMETERS
        decl ParameterValue=nth(i,ParameterValueList);
        decl j=0;
        for(j=0;j<ParaNum;j=j+1)
        {
            decl ParameterName=nth(j,ParameterNameList);
            decl Value=nth(j,ParameterValue);
            db_update_parameters_ex(context, list(InstName, ParameterName, Value));
        }
        
        // 4. AFTER PARAMETER CHANGE, GET BBOX
        decl InstName = db_get_instance_name(newInst);
        decl instHandle=db_find_instance_ex(context, InstName);
        decl bbox = db_get_instance_bbox(instHandle, 0);
        decl x1 = db_get_bbox_x1(bbox);
        decl y1 = db_get_bbox_y1(bbox);
        decl x2 = db_get_bbox_x2(bbox);
        decl y2 = db_get_bbox_y2(bbox);    
        dX=(x2-x1)/1000;
        dY=(y2-y1)/1000;
    
    }
    decl DesignName=strcat(Lib,":", Cell,":", Layout);
    de_save_oa_design(DesignName);
    de_close_window();
}


defun DeviceSchematicGeneration(PcellPath,SchematicPath,ParameterNameList,ParameterValueList,LocationList)
// LocationList=((case1 x,y),(case2 x,y)....)
{    //generate 1 kind of device with n instance
    //2018.12.03 Hxj: Create View if not existed
    decl Lib=nth(0,SchematicPath);
    decl Cell=nth(1,SchematicPath);
    decl Schematic= nth(2,SchematicPath);
    decl DesignName=strcat(Lib,":",Cell,":",Schematic);
    decl context = de_find_design_context_from_name(DesignName);
    if (context == NULL){
        context = db_oa_create_empty_design(Lib,Cell,Schematic, 1);   // design tyep =1 means schematic
    }
    de_show_context_in_new_window(context); //symbol or layout cannot be placed if the context is not showed
    //Place Device on Layout
    decl PcellLib=nth(0,PcellPath);
    decl PcellCell=nth(1,PcellPath);
    decl PcellSymbol= nth(3,PcellPath);  // should = symbol cause viewname is symbol in PDK,its value is ='symbol'
    decl Component=strcat(PcellLib,":",PcellCell,":",PcellSymbol);
    
    //decl ItemInfo = de_init_item(Component);
    
    decl Num=listlen(ParameterValueList);
    decl ParaNum=listlen(ParameterNameList);    
    decl dX,dY;
    decl X=0;
    decl Y=0;
    decl i=0;
    for(i=0;i<Num;i=i+1)
    {    
        // 1.Set Location
        X = nth(0,nth(i,LocationList));
        Y = nth(1,nth(i,LocationList));
        // 2.Create Item
        decl ItemInfo = de_create_iteminfo_for_new_instance(context, PcellLib, PcellCell,PcellSymbol);
        decl newInst = de_create_new_instance_from_iteminfo(ItemInfo, X, Y);
        decl InstName = db_get_instance_name(newInst);
        // 3.Set Parameters
        decl ParameterValue=nth(i,ParameterValueList);
        decl j=0;
        for(j=0;j<ParaNum;j=j+1)
        {
            decl ParameterName=nth(j,ParameterNameList);
            decl Value=nth(j,ParameterValue);
            db_update_parameters_ex(context, list(InstName, ParameterName, Value));
        }
        // 4.Set Location Next
        

    }
    decl DesignName=strcat(Lib,":", Cell,":", Schematic);
    de_save_oa_design(DesignName);
    de_close_window();
}


 
 
 defun AddPinSchematic()
 {
     decl context = de_get_current_design_context();
     decl scale=160.0; //.0 will make scale not int
    decl instIter = db_create_inst_iter(context);
    for(;db_inst_iter_is_valid(instIter);instIter=db_inst_iter_get_next(instIter))
        {    
            decl iter = db_inst_iter_get_instance(instIter);
            decl instPinIter = db_create_inst_pin_iter(iter);
            for(;db_inst_pin_iter_is_valid(instPinIter);instPinIter = db_inst_pin_iter_get_next(instPinIter))
            {
                decl snapCoordH = db_get_inst_pin_snap_point(instPinIter);
                decl snapX = db_get_x(snapCoordH);
                decl snapY = db_get_y(snapCoordH);
                de_place_port(snapX/scale, snapY/scale);
              }
        } 

}


 defun AddPinLayout()
 {
    decl context = de_get_current_design_context();
    decl scale=1000.0; //.0 will make scale not int
    decl instIter = db_create_inst_iter(context);
    for(;db_inst_iter_is_valid(instIter);instIter=db_inst_iter_get_next(instIter))
    {  
          decl iter = db_inst_iter_get_instance(instIter);
          decl instPinIter = db_create_inst_pin_iter(iter);
          for(;db_inst_pin_iter_is_valid(instPinIter);instPinIter = db_inst_pin_iter_get_next(instPinIter))
          {
            decl snapCoordH = db_get_inst_pin_snap_point(instPinIter);
            decl snapX = db_get_x(snapCoordH);
            decl snapY = db_get_y(snapCoordH);
    
            decl layerId = db_get_inst_pin_snap_layerid(instPinIter);
            decl layername = db_get_layerid_name(context, layerId);
            decl layerindex = db_get_layerid_index(context, layerId);
            //de_info(layerindex);
            //de_info(layername);
            decl layerIdText=db_get_layerid(context, "M2P", "drawing");
            if (layername=="M1:drawing"){
                layerIdText=db_get_layerid(context, "M1P", "drawing");
            }
            if (layername=="M2:drawing"){
                layerIdText=db_get_layerid(context, "M2P", "drawing");
            }
            if (layername=="TV:drawing"){
                layerIdText=db_get_layerid(context, "TV", "drawing");
            }
            if (layerindex==9){
                layerIdText=db_get_layerid(context, "M1P", "drawing");
            }
            if (layerindex==12){
                layerIdText=db_get_layerid(context, "M2P", "drawing");
            }
            if (layerindex==30){
                layerIdText=db_get_layerid(context, "TV", "drawing");
            }
            db_set_entry_layerid(context, layerIdText);
            decl termNum = db_get_inst_pin_term_number(instPinIter);
            db_add_text(context,snapX/scale,snapY/scale,strcat("P",termNum));
          }
    } 
}

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值