[ Shell ] 通過 Shell 指令碼匯出 GDSII/OASIS 檔案

YEUNGCHIE發表於2022-04-05

https://www.cnblogs.com/yeungchie/

常見的積體電路版圖資料庫檔案格式有 GDSII 和 OASIS,virtuoso 提供了下面兩個工具,可以用來通過命令列匯出版圖資料。

  • strmout (匯出為 GDSII 格式)

    strmout -help
    Usage: Usage: strmout
        -library                        <Input Library>
        -strmFile                       <Output Stream File>
        [-strmVersion]                  <Stream Version Number>
        [-runDir]                       <Run Directory>
        [-topCell]                      <Toplevel Cells to Translate>
        [-view]                         <Toplevel Cell View Name>
        [-logFile]                      <Output Log File Name>
        [-summaryFile]                  <Output Summary File>
        [-techLib]                      <Technology Library>
        [-hierDepth]                    <Hierarchical Depth to Translate to>
        [-layerMap]                     <Quoted List of Layer Map Files>
        [-translateUnmappedLPP]         <Allow undefined LPP to be translated by incrementally mapping LPP using layerMap file, SKILL hook poLayerMap, and automatic layer mapping>
        [-labelMap]                     <Input Label Map File>
        [-labelDepth]                   <Hierarchical Depth to Add Labels to>
        [-replaceBusBitChar]            <Replace "<>" With "[]">
        [-cellMap]                      <Input Cell Map File>
        [-fontMap]                      <Input Font Map File>
        [-propMap]                      <Input Property Map File>
        [-objectMap]                    <Quoted List of Object Mapping Files>
        [-viaMap]                       <Via Mapping File>
        [-viaCutArefThreshold]          <Threshold Value For Creating AREF For Cut Geometries For Via>
        [-userSkillFile]                <User Skill File>
        [-refLibList]                   <Name of The File Containing Refliblist >
        [-arrayInstToScalar]
        [-cellNamePrefix]               <Cell Name Prefix>
        [-cellNameSuffix]               <Cell Name Suffix>
        [-ignoreTopCellPrefixSuffix]    <Ignores cellName Prefix and Suffix for topCell>
        [-case]                         <upper | lower | preserve >
        [-labelCase]                    <upper | lower | preserve >
        [-ignoreLines]
        [-noOutputTextDisplays]
        [-noOutputUnplacedInst]         <Do not Output Unplaced Instances>
        [-convertDot]                   <node | polygon | ignore >
        [-convertPin]                   <geometry | text | geometryAndText | ignore >
        [-pinAttNum]                    <Stream Attribute Num (1-127) For Preserving Pins>
        [-pathToPolygon]                <Convert Paths to Polygons>
        [-diagonalPathToPolygon]        <Convert Paths with non-orthogonal segments to polygons>
        [-propValueOnly]                <Output Property Values Only>
        [-rectToBox]
        [-respectGDSIINameLimit]
        [-gdsCellNameLength]            <Truncate GDS Cell/STRUCT name length to specified value (>=10)>
        [-flattenPcells]
        [-flattenVias]
        [-outputViaShapesToViaPurp]     <Output Shapes of Via to Via Purpose>
        [-doNotPreservePcellPins]
        [-snapToGrid]
        [-dbuPerUU]                     <DB Units per user units>
        [-reportPrecisionLoss]          <Report Precision Loss Because of dbuPerUU Value>
        [-noObjectProp]
        [-ignorePcellEvalFail]
        [-mergePathSegsToPath]          <Merging pathSegs into a single PATH>
        [-noConvertHalfWidthPath]       <Do not Convert The Half Width Path to Boundary>
        [-checkPolygon]                 <Report Bad Polygons And Paths>
        [-backupGdsLogFiles]            <Backup GDSII and LOG files, if they already exist>
        [-maxVertices]                  <Maximum Limit of Vertices (5-4000) Allowed in Stream File>
        [-strmTextNS]                   <NameSpace of The TEXT Records in The Stream File>
        [-templateFile]                 <Name of The File Containing Option Names And Values>
        [-cellListFile]                 <Name of the file containing cellList>
        [-outputDir]                    <output directory>
        [-noInfo]                       <Quoted List of Info Message Ids>
        [-noWarn]                       <Quoted List of Warning Message Ids>
        [-warnToErr]                    <Quoted List of warning Message Ids>
        [-infoToWarn]                   <Quoted List of Info Message Ids>
        [-donutNumSides]                <Number of sides (4-131072) for the BOUNDARY of donut>
        [-ellipseNumSides]              <Number of sides (4-131072) for the BOUNDAR of ellipse>
        [-wildCardInCellMap]            <Wild Card in cell map file>
        [-ignoreMissingCells]           <Ignores Missing cellViews During Translation and Continue Translation>
        [-ignoreMissingVias]            <Ignores Missing standard/custom vias During Translation and Continue Translation>
        [-subMasterSeparator]           <Separator to used for sub-master naming (default: "_CDNS_")>
        [-convertPcellPin]              <geometry | text | geometryAndText | ignore (default: convertPin value)>
        [-guiHistory]                   <Use options of last successful translation from the XStream Out GUI>
        [-ignoreZeroWidthPathSeg]       <Ignores zero width PathSeg during translation>
        [-ignoreObjectMapFromTech]      <Ignores object map file from technology>
        [-ignoreCurrentTimestamp]       <Ignores current timestamp>
        [-verbose]                      <Generate detailed information in the log and summary files>ose] <Generate detailed information in the log and summary files>
    
  • oasisout (匯出為 OASIS 格式)

    oasisout -help
    Usage: oasisout
        -library                        <Input Library>
        -oasisFile                      <Output OASIS File>
        [-arrayInstToScalar]            <Convert Arrays to Scalar Instances>
        [-backupOasisLogFiles]          <Backup OASIS and LOG files, if they    already exist>
        [-case]                         <upper | lower | preserve>
        [-cellMap]                      <Input cell map file>
        [-cellListFile]                 <Name of the file containing cellList>
        [-cellNamePrefix]               <Cell name prefix>
        [-cellNameSuffix]               <Cell name suffix>
        [-checkPolygon]                 <Report bad polygons and paths>
        [-circleToPolygon]              <Convert Cricle/Ellipse object to Polygon>
        [-compress]                     <Enable CBLOCK compression>
        [-compressLevel]                <Set the compression level for CBLOCK   compression>
        [-convertDot]                   <polygon | circle | ignore>
        [-convertPcellPin]              <geometry | text | geometryAndText |    ignore (default: convertPin value)>
        [-convertPin]                   <geometry | text | geometryAndText |    ignore>
        [-dbuPerUU]                     <DB Units per user units>
        [-diagonalPathToPolygon]        <Convert Paths with non-orthogonal  segments to Polygons>
        [-doNotPreservePcellPins]       <Do not preserve the PCell Pins>
        [-donutNumSides]                <Number of sides (4-131072) for the     BOUNDARY of Donut>
        [-ellipseNumSides]              <Number of sides (4-131072) for the     BOUNDAR of Circle/Ellipse>
        [-flattenPcells]                <Flatten the PCell Instances>
        [-flattenViaShapesToViaPurp]    <Flatten Vias' Shapes to Via Purpose>
        [-flattenVias]                  <Flatten the Vias>
        [-GDSIICompatible]              <Generate the OASIS file with GDSII     specific limits>
        [-guiHistory]                   <Use options of last successful     translation from the XOasis Out GUI>
        [-hierDepth]                    <Hierarchical depth to translate to>
        [-ignoreLines]                  <Ignore Line objects>
        [-ignoreMissingCells]           <Ignore missing cellViews during    translation and continue translation>
        [-ignoreMissingVias]            <Ignore missing standard/custom vias    during translation and continue translation>
        [-ignoreObjectMapFromTech]      <Ignore object map file from technology>
        [-ignorePcellEvalFail]          <Ignore the PCell evaluation failure>
        [-ignoreRoutes]                 <Ignore Route objects>
        [-ignoreZeroWidthPathSeg]       <Ignore zero width PathSeg during   translation>
        [-infoToWarn]                   <Quoted list of Info message Ids>
        [-labelMap]                     <Input label map file>
        [-labelDepth]                   <Hierarchical depth to add labels to>
        [-layerMap]                     <Quoted list of layer map files>
        [-logFile]                      <Output log file name>
        [-mergePathSegsToPath]          <Merge pathSegs into a single PATH>
        [-noConvertHalfWidthPath]       <Do not convert the half width Path to  Boundary>
        [-noInfo]                       <Quoted list of info message Ids>
        [-noObjectProp]                 <Do not write the special object    properties>
        [-noOutputTextDisplays]         <Do not output Text Displays>
        [-noOutputUnplacedInst]         <Do not output Unplaced Instances>
        [-noWarn]                       <Quoted list of warning message Ids>
        [-objectMap]                    <Quoted list of object mapping files>
        [-outputDir]                    <output directory>
        [-pathToPolygon]                <Convert Path object to Polygon>
        [-preservePinAtt]               <Preserve Pin connectivity information>
        [-preserveTextAtt]              <Preserve Text attributes as properties>
        [-propMap]                      <Input property map file>
        [-refLibList]                   <Name of the file containing reference  libraries list>
        [-replaceBusBitChar]            <Replace "<>" with "[]">
        [-runDir]                       <Run directory>
        [-snapToGrid]                   <Snap to grid>
        [-subMasterSeparator]           <Separator to used for sub-master naming    (default: "_CDNS_")>
        [-summaryFile]                  <Output summary file>
        [-techLib]                      <Technology library>
        [-templateFile]                 <Name of the file containing option names   And values>
        [-textCase]                     <upper | lower | preserve>
        [-topCell]                      <Toplevel cells to translate>
        [-translateUnmappedLPP]         <Allow undefined LPP to be translated by    incrementally mapping LPP using layerMap file, SKILL hook poLayerMap, and  automatic layer mapping>
        [-userSkillFile]                <User skill file>
        [-verbose]                      <Generate detailed information in the log   and summary files>
        [-viaMap]                       <Via mapping file>
        [-view]                         <Toplevel cell view name>
        [-warnToErr]                    <Quoted list of warning message Ids>
        [-wildCardInCellMap]            <Wild card in cell map file>
    

OASIS 的檔案體積聲稱可以比 GDSII 小 10~50 倍,實際在我的使用中這個數字可以到 20+(以專案情況而定),當專案資料較大的情況下,檔案小了確實可以加快執行速度、節省時間(估計是硬碟讀寫環節拖累了整體執行時間)。
oasisoutstrmout 幾個常用的引數都是相同的,下面講下如何使用。

另外,命令的執行路徑必須在 virtuoso 啟動路徑(能在當前路徑下找得到 cds.lib 檔案)。

引數解釋

必要的

首先有幾個必要的執行條件和引數。

  • -library

    這個引數用來指定匯出的單元庫 (library) 名。

  • -strmFile

    當使用 strmout 時,這個引數用來指定匯出的 GDSII 檔名稱。

  • -oasisFile

    當使用 oasisout 時,這個引數用來指定匯出的 OASIS 檔名稱。

推薦的

其次還有幾個是可選的引數,但是建議也指定一下。

  • -topCell

    指定匯出單元的頂層 Cell 名稱,指定了頂層 Cell 就不會匯出該頂層沒有呼叫的單元,否則會匯出當前庫下的所有 Cell 。

  • -view

    指定匯出單元的頂層 View 名稱,預設為 layout

  • -runDir

    指定執行路徑。

    注意這裡的 執行路徑 不同於前面提到的命令的執行路徑。
    當定義了 -runDir-strmFile-oasisFile-logFile-summaryFile 等引數如果定義的是相對路徑,則會以 -runDir 為參考。

  • -logFile

    生成 log 檔案,預設生成檔名為 strmOut.logoasisOut.log

  • -summaryFile

    生成 summary 檔案,預設不生成。

  • -layerMap

    指定 layermap 檔案,預設情況是呼叫 attach tech 中的 layermap,當對層次轉換有特殊要求時可以通過這個引數來指定自定義的 layermap 。

編寫指令碼 export_layout

下面寫個指令碼優化一下這個執行方式。

點選檢視完整程式碼
#!/bin/bash
#--------------------------
# Program  : export_layout.sh
# Language : Bash
# Author   : YEUNGCHIE
# Version  : 2022.04.05
#--------------------------
HelpInfo(){
    cat <<EOF
-------------------------------------------------
Export Layout ( GDSII or OASIS ) File
-------------------------------------------------
Usage: export_layout -path cdslibDir -lib libName -cell cellName [ OPTIONS ]

    -path       Path where the cds.lib file is located
    -lib        Layout top cell libName
    -cell       Layout top cell cellName
    -view       Layout top cell viewName    ( Default: layout )
    -file       Output file name            ( Default: <cellName>.gds or <cellName>.oasis )
    -log        Log file                    ( Default: export_layout.log )
    -sum        Summary file
    -layermap   Specified the layermap file
    -oasis      Specified the file format is OASIS, and GDSII if not specified
    -h, -help   Display this help

Examples:   export_layout\\
                -path       \$project/work/
                -lib        Xeon
                -cell       X999
                -oasis

Output:     OASIS file - X999.oasis
EOF
}

viewName='layout'
logFile='export_layout.log'

# 命令列引數分析
while [[ -n $1 ]]; do
    if [[ -n $opt ]]; then
        case $opt in
            lib_opt)    libName=$1  ;;
            cell_opt)   cellName=$1 ;;
            view_opt)   viewName=$1 ;;
            file_opt)   file=$1     ;;
            path_opt)   path=$1     ;;
            log_opt)    logFile=$1  ;;
            map_opt)
                mapCmd="-layerMap $1"
            ;;
            sum_opt)
                sumCmd="-summaryFile $1"
            ;;
        esac
        unset opt
    else
        case $1 in
            -lib)       opt='lib_opt'   ;;
            -cell)      opt='cell_opt'  ;;
            -view)      opt='view_opt'  ;;
            -file)      opt='file_opt'  ;;
            -path)      opt='path_opt'  ;;
            -log)       opt='log_opt'   ;;
            -sum)       opt='sum_opt'   ;;
            -layermap)  opt='map_opt'   ;;
            -oasis)     OASIS=1         ;;
            -h|-help)
                HelpDoc >&2
                exit 1
            ;;
            *)
                echo "Invalid option - '$1'" >&2
                echo "Try -h or -help for more infomation." >&2
                exit 1
            ;;
        esac
    fi
    shift
done

# 記錄當前路徑
runDir=$(pwd -P)

# 引數檢查
if [[ ! ( $path && $libName && $cellName ) ]]; then
    # 缺少必要引數時,列印 help 並退出
    HelpInfo >&2
    exit 1
elif [[ -d $path ]]; then
    cd $path
else
    # 找不到目標路徑檔案,列印報錯
    echo "No such directory - $path" >&2
    echo "Try -h or -help for more infomation." >&2
    exit 1
fi

## 不同的檔案格式
if [[ $OASIS ]]; then
    if [[ ! $file ]]; then file="${cellName}.oasis" ; fi
    command="oasisout -oasisFile $file"
else
    if [[ ! $file ]]; then file="${cellName}.gds" ; fi
    command="strmout -strmFile $file"
fi

command="$command -runDir $runDir -library $libName -topCell $cellName -view $viewName -logFile $logFile $sumCmd $mapCmd"

# 執行
exec $command

優化後的指令碼有三個必要的引數需要指定

  • -path
    指定 cds.lib 檔案所在的資料夾路徑
  • -lib
    指定匯出單元的頂層 Library 名稱
  • -cell
    指定匯出單元的頂層 Cell 名稱

通過 -path 引數來定義 virtuoso 啟動路徑,實現在任意路徑下可執行,生成的檔案都在當前路徑下。

執行例項

例:cdslib 檔案所在路徑為 ../project

  1. 匯出版圖 verify/ad01d0/layout 單元為 GDSII 檔案。

    export_layout -path ../project -lib verify -cell ad01d0
    
  2. 匯出版圖 verify/inv0d0/layout 單元為 OASIS 檔案,指定輸出檔名 inv.oasis,指定 log 檔案為 inv.log

    export_layout -path ../project -lib verify -cell inv0d0 -file inv.oasis -oasis -log inv.log
    

相關擴充

相關文章