ADS PDK Automation Part.1 Py Test Plan

'''
# Version 0.0.2
# Coder: Huang Xiao
# Target: improve quality and effeciency
    1.Pcell Code Coverage
    2.two of LVS 3 level check:PDK level
    3.Simulation QA
    4.DRC Code coverage
    5.PDK Consistency: ADS & Cadence
    6.PDK Generation Framework
# Function: 1.drc code  2.auto lvs

    Log:
        2018.12.06 Hxj: Add Setting Dict to Control performance, Function also change
        2018.12.07 Hxj: Modify Function ParseCircuitAelofPath(DocPath) extend return default value of PDK
        2018.12.07 Hxj: Add WritePDKComponentInfo2Excel to read PDK Component Info and write to excel
        2018.12.07 Hxj: Debug Function Sampling/ReadDeviceList handle type=4 parameter value expression
        2018.12.08 Hxj: Debug Function AelScriptGeneration: add symbol in PcellPath to ajust schematic generation
        2018.12.10 Hxj: Debug pop() key error
        2018.12.14 Hxj: Debug Sampling() to adjust type4 like [TV_slot_20X40, TV_circle_40]
        2018.12.14 Hxj: Debug InfoCat() to adjust error like wrong parameter name in Excel
    Topic:
        DeviceList.xlsx: if "the instance statement" is blank
        PDK: ael document contain old component that is not used
            process component do not has not symbol
        Case: P15LN cannot read SCdio:n

'''
#================================================== Section 0. Package ============================================
import re
import xlrd    
import xlwt
import os
import sys

Setting={'TableFormatHeader':['No','Device','Terminal','DeviceName','Instance Statement','Device Description (ADS explanation)','Equation'],
        'DeviceListStatementPattern':['(\d+\.{0,1}\d*){1}\s*\[\s*(\d+\.{0,1}\d*)\s*,\s*(\d+\.{0,1}\d*)\s*\]'  ,   '(\d+\.{0,1}\d*)\s*\(\s*\]'  ,   '\s*(\d+\.{0,1}\d*)\s*,{0,1}\s*'  , '(\d+\.{0,1}\d*)','(\d+\.{0,1}\d*){1}\s*\[\s*(\d+\.{0,1}\d*)\s*:\s*(\d+\.{0,1}\d*)\s*:\s*(\d+\.{0,1}\d*)\s*\]'],
        'WorkPath':'C:/Users/10000130/Desktop/Work/QA.autoQ/AutoQA/QA/Sanan_P15LN/', 
        'ScriptPath':'QA/script/',
        'DeviceListPath':'QA/PDKdevicelist.xls',
        'SheetName':'netlist_v1',
        'ComponentArtworkPath':'circuit/ael/',
}

#============================================ Section 1. Prcossing Function ============================================

def DeleteNullInList(StringList):
    Length1=len(StringList)
    Length2=0
    while(Length2<Length1):
        Length1=len(StringList)
        for item in StringList:
            if (item=='' or item==[]):
                StringList.remove(item)
        Length2=len(StringList)

def BacktraceSpaceIndex(ValueString,IndexStart):
    StringLen=len(ValueString)
    if(IndexStart>=0 & IndexStart<StringLen):
        Index=IndexStart
        while(Index>=0):
            if(ValueString[Index]==' '):
                return Index
            Index-=1
        return Index
    else:
        return 'Input IndexStart Range Error'

def Float2Str(ValueList):
    ResultList=[]
    try:
        for item in ValueList:
            ResultList.append('%.2f'%item)
        return ResultList
    except:
        return ValueList

def Str2Float(StrList):
    ResultList=[]
    try:
        for item in StrList:
            ResultList.append(float(item))
        return ResultList        
    except:
        return StrList
''' Test Code
PatternList=['prm\s*\((.+?)\)\s*' , ',\s*\"\d*\.{0,1}\d+(.*?)\"']
IndexList=[0,0]
StatementString='LENGTH_UNIT,                        prm("StdForm", "") ,     // default value                        list(dm_create_cb(PARM_MODIFIED_CB,'
StatementString1='LENGTH_UNIT,                        prm("StdForm", "20 um ") ,     // default value                        list(dm_create_cb(PARM_MODIFIED_CB,'
StatementString2='LENGTH_UNIT,                        prm("StdForm", "20") ,     // default value                        list(dm_create_cb(PARM_MODIFIED_CB,'
StatementString3='LENGTH_UNIT,                        prm("StdForm", "20.5 um ") ,     // default value                        list(dm_create_cb(PARM_MODIFIED_CB,'
StatementString4='LENGTH_UNIT,                        prm("StdForm", "vtw") ,     // default value                        list(dm_create_cb(PARM_MODIFIED_CB,' #may cause error
#expect result '',' um', ' um'
'''
def MultipleExtract(StatementString,PatternList,IndexList):
    if len(PatternList)<len(IndexList):
        return 'Input List Length Format Error !'
    ExtractedList=[]
    for i in range(len(PatternList)):
        PatternExpression=re.compile(PatternList[i])
        ExtractedList=PatternExpression.findall(StatementString) # if not found return [] empty list
        try:
            StatementString=ExtractedList[IndexList[i]]
        except:
            StatementString=''
    return StatementString
'''

StatementString='create_parm( "ne",                        "Number of fingers: Emitter --->  1 to 8 ",'

'''

def RecursionFileInDoc(PATH): 
# Fcuntion: get all files in PATH
# Setting: 
# Requirement: input is path string, should be: 1.some fixed format pattern ; 2.paht should be exist
# Package Depend on: os
    #LinuxPathStringFormat='(\/w*)(\1)+'
    #WindowsPathStrtingFormat
    if(PATH[-1]!='/'):
        PWD=PATH+'/' 
    else:
        PWD=PATH # if not / add
    Files=[]
    try:
        CurrentDir=os.listdir(PATH)
        for i in range (len(CurrentDir)):
            if(os.path.isdir(PWD+CurrentDir[i])):
                Files=Files+(recursionFile(PWD+CurrentDir[i]))
            elif(os.path.isfile(PWD+CurrentDir[i])):
                Files.append(PWD+CurrentDir[i])
        return Files    
    except FileNotFoundError as e:
        return e
 
def FilenameFilter(FileList,FilterKeyword):
# Fcuntion: Processing Files with 'xxx.yyy' format
# Setting: 
# Requirement: input is path string list and format string yyy
# Package Depend on:
    for filename in FileList:
        #tempname=re.split('.',filename) # . will be regard as regular pattern here
        tempname=filename.split('.')
        if tempname[-1]!=FilterKeyword :
            FileList.remove(filename)

#================================================== Section 2. Module ==================================================

def ReadDeviceList(ExcelPath,SheetName,Setting):
# Fcuntion: Read sheet in .xlsx , output device infomation without parsed
# Setting: TableFormatHeader
# Requirement: input .xlsx and SheetName should be fixed 
# Package Depend on: xlrd
    #define output data
    DeviceDict={}
    #Define Tabel format:
    TableFormatHeader=Setting['TableFormatHeader']
    ColumnOfTable=len(TableFormatHeader)
    #read excel and parse
    with xlrd.open_workbook(ExcelPath) as Excel:
        #SheetName= Excel.sheet_names()[0]
        #get sheet contain Device List info
        Sheet=Excel.sheet_by_name(SheetName)
        #遍历每一行,count数行数
        Nrows=Sheet.nrows #获得sheet的总行数
        Section=0
        Count=0
        while Count<Nrows:
            RowList=Sheet.row_values(Count) #RowList是一个以每一行的各个列元素组合成的list
           &nb
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值