;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; File: fixhash.il ; Author: Shiv Sikand <sikand@users.sourceforge.net> ; Created: Aug 18 17:55 00 ; Modified: Aug 18 18:00 00 2314 sikand ; Language: Skill ; Package: nil ; MainFun: N/A ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright (c) 2000, S.S. Sikand, All rights reserved ; ; Redistribution and use in source and binary forms, with or ; without modification, are permitted provided that the following ; conditions are met: ; ; Redistributions of source code must retain the above copyright notice, ; this list of conditions and the following disclaimer. ; ; Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in the ; documentation and/or other materials provided with the distribution. ; ; The names of the contributors may not be used to endorse or promote ; products derived from this software without specific prior written ; permission. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ; ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR ; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR ; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;; code to re-name files with # in them ;; ie Cadence namespace mapping and Perforce ;; don't go well together ;; Synchronicity converters: please note, all others ignore this ;; section ;; you must get rid of the Sync artefact files first ;; find . -name .\*sync\* -print -exec rm {} \; ;; expects the filename passed to fixhash ;; to have entries like this ; SSTL_DLL_lay/inv_dll_slow#2binv#2bnmos ; rx_schem/Interp_Logic#2ecell ; Digital/test#2dschem ;; generate them using find ;;find . -name \*#\* -print | sed 's/\.\///g' > ~/hashlog ;; then run ;; fixhash("~/hashlog") ;; renames the bad cells ;; uses _ as the default replacement character ;; AND fixes the cell references in all cells in the library ;; attempts to perform collision detection ;; BACKUP your LIBS first ;; before running this code ;; since it may trash your instance headers ;; if it hits some condition I have not computed CDSP4_NMHex = makeTable("alias" nil) CDSP4_NMHex["1"]=1 CDSP4_NMHex["2"]=2 CDSP4_NMHex["3"]=3 CDSP4_NMHex["4"]=4 CDSP4_NMHex["5"]=5 CDSP4_NMHex["6"]=6 CDSP4_NMHex["7"]=7 CDSP4_NMHex["8"]=8 CDSP4_NMHex["9"]=9 CDSP4_NMHex["a"]=10 CDSP4_NMHex["b"]=11 CDSP4_NMHex["c"]=12 CDSP4_NMHex["d"]=13 CDSP4_NMHex["e"]=14 CDSP4_NMHex["f"]=15 CDSP4_NM= makeTable("nmap" nil) CDSP4_NM["#2f"] = "/" CDSP4_NM["#3c"] = "<" CDSP4_NM["#3e"] = ">" CDSP4_NM["#2e"] = "." CDSP4_NM["#21"] = "!" CDSP4_NM["#7c"] = "|" CDSP4_NM["#5c"] = "\\" CDSP4_NM["#2d"] = "-" CDSP4_NM["#28"]="(" CDSP4_NM["#29"]=")" CDSP4_NM["#5b"]="[" CDSP4_NM["#5d"]="]" CDSP4_NM["#24"]="$" CDSP4_NM["#40"]="@" CDSP4_NM["#7b"]="{" CDSP4_NM["#7d"]="}" CDSP4_NM["#5f"]="_" CDSP4_NM["#7e"]="~" CDSP4_NM["#3a"]=":" CDSP4_NM["#3d"]="=" CDSP4_NM["#3b"]=";" CDSP4_NM["#22"] = "\"" CDSP4_NM["#23"]="#" CDSP4_NM["#25"]="%" CDSP4_NM["#26"]="&" CDSP4_NM["#27"]="'" CDSP4_NM["#2a"]="*" CDSP4_NM["#2b"]="+" CDSP4_NM["#2c"]="," CDSP4_NM["#60"]="`" CDSP4_NM["#5e"]="^" CDSP4_NM["#3f"] = "?" procedure(unmapcdsTable(string) ;_Apr 10 00 sikand 0 let((ind pat org rep) org=string while(ind=nindex(string "#") pat=substring(string ind 3) unless(CDSP4_NM[pat] error("Could not map %s in string: %s\n" pat org)) rexCompile(pat) rep = strcat("\\" CDSP4_NM[pat]) string = rexReplace(string rep 0) when( string == org error("Failed!") ) ) ; ** while ind ** string ) ; ** let ** ) ; ** procedure unmapcdsTable ** procedure(fixhash(filename) ;_Aug 18 00 sikand 3377 let((hf data lib cell cellm fxtable cellu hashcells libid xim xbads cellr repcells x xcollisions fxtable2 celltable fpath celltable2 xrepcell repfpath cmd dontmap fxtable3 uhashcells xcheckneedreplace fxglobal fxglobaltable fixlist) fxtable=makeTable("fx" list()) fxtable2=makeTable("fx2" list()) fxtable3=makeTable("fx3" list()) celltable = makeTable("ct" nil) celltable2 = makeTable("ct2" nil) fxglobaltable=makeTable("fxg" nil) hf=infile(filename) unless(hf error("Couldn't open!") ) println("Fixhash running....") while(gets(lin hf) data=parseString(lin "\n") data=parseString(car(data) "/") lib=car(data) ;; unmapped name cellu = cadr(data) ;; mapped name cellm=unmapcdsTable(cellu) ;; replacement name ;; possibility of a collision with a real name ;; detect it later rexCompile("#[0-9a-f][0-9a-f]") cellr = rexReplace(cellu "_" 0) celltable[cellm] = cellr celltable2[cellm] = cellu ;;printf("lib: %s cell: %s\n" lib cell) fxtable[lib]=cons(cellm fxtable[lib]) fxtable2[lib]=cons(cellr fxtable2[lib]) fxtable3[lib]=cons(cellu fxtable3[lib]) fxglobal=cons(cellm fxglobal) fxglobaltable[cellm]=cellr ) ; ** while gets ** foreach(libkey fxtable ;; get the cells in each library ;; open them up ;; fix any instances printf("Checking %s\n" libkey) hashcells=fxtable[libkey] repcells = fxtable2[libkey] uhashcells = fxtable3[libkey] ;;println(repcells) libid=ddGetObj(libkey) foreach( libcell libid~>cells ;; the cells themselves need to be name mapped ;; as well as the instance headers ;; cell foo.bar contains an instance of bar.foo xrepcell = celltable[libcell~>name] when( xrepcell ;; detected a bad un ;; make sure that the replacement doesn't already ;; exist in the library when( member(xrepcell libid~>cells~>name) error("Collision detect, replacement name hits an existing cell name %s!\n" xrepcell) ) ;; clone it in Unix, delete the original fpath = libcell~>writePath println(fpath) ;; need the unmodified name ;; because that's the real filename ;; and regexp replace it with the replacement name rexCompile(celltable2[libcell~>name]) repfpath = rexReplace(fpath xrepcell 1) println(repfpath) sprintf(cmd "mv %s %s" fpath repfpath) printf("executing %s\n" cmd) sh(cmd) ) ; ** when xrepcell ** ) ; ** foreach libcell ** ;; run the loop again ;; since we've modified the data libid=ddGetObj(libkey) foreach( libcell libid~>cells foreach(viewcell libcell~>views x=dbOpenCellView(libkey libcell~>name viewcell~>name nil "a" nil) unless( x println(libkey) println(libcell~>name) println(viewcell~>name) error("Failed to open cellview, check your input data!!") ) xim=x~>instHeaders when(xim xcheckneedreplace = setof(xx xim member(xx~>cellName uhashcells)) xcollisions = setof(xx xcheckneedreplace member(xx~>cellName repcells)) when( xcollisions println(xcollisions~>cellName) printf("%s %s %s\n" libkey libcell~>name viewcell~>name) warn("Collision detect, replacement name hits an existing instance name!\n") ) xbads=setof(xx xim member(xx~>cellName hashcells)) when(xbads printf("\nLib %s Cell %s View %s\n" libkey libcell~>name viewcell~>name) println(xbads~>cellName) ;; now do the replacement foreach( insth xbads printf("rep %s %s %s\n" libkey celltable[insth~>cellName] insth~>viewName) dbSetInstHeaderMasterName(insth libkey celltable[insth~>cellName] insth~>viewName) dbSave(x) ) dbClose(x) ) ; ** when xbads ** ) ; ** when xim ** ) ; ** foreach viewcell ** ) ; ** foreach libcell ** ) ; ** foreach libkey ** ;; now check all the instance headers in every library foreach(libid ddGetLibList() unless(libid~>name=="sample" printf("P2: Checking %s\n" libid~>name) foreach( libcell libid~>cells foreach(viewcell libcell~>views x=dbOpenCellView(libid libcell~>name viewcell~>name nil "r" nil) if( !x then println(libid~>name) println(libcell~>name) println(viewcell~>name) warn("Failed to open cellview, check your input data!!") else xim=x~>instHeaders when(xim xbads=setof(xx xim member(xx~>cellName fxglobal)) when(xbads ;;printf("\nLib %s Cell %s View %s\n" libid~>name libcell~>name viewcell~>name) fixlist=append(list(list(libid libcell~>name viewcell~>name xbads~>cellName)) fixlist) ;;println(xbads~>cellName) ;; now do the replacement ;;foreach( insth xbads ;; printf("rep %s %s %s\n" libkey celltable[insth~>cellName] insth~>viewName) ;; dbSetInstHeaderMasterName(insth libkey celltable[insth~>cellName] insth~>viewName) ;; dbSave(x) ;;) dbClose(x) ) ; ** when xbads ** ) ; ** when xim ** ) ; ** foreach viewcell ** ) ) ) ) foreach(el fixlist lib=car(el) cell=cadr(el) view=caddr(el) bad=car(cadddr(el)) x=dbOpenCellView(lib cell view nil "a" nil) if( !x then println(lib~>name) println(cell) println(view) warn("Failed to open cellview, check your input data!!") else xim=x~>instHeaders when(xim xbads=setof(xx xim member(xx~>cellName fxglobal)) when(xbads foreach( insth xbads printf("rep {%s %s %s} " insth~>libName fxglobaltable[insth~>cellName] insth~>viewName) printf("in [%s %s %s]\n" lib~>name cell view) dbSetInstHeaderMasterName(insth insth~>libName celltable[insth~>cellName] insth~>viewName) dbSave(x) ) ) ) ) dbClose(x) ) t );; let ) ; ** procedure fixhash **
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 5093 | Hari Krishna Dara |
Populating perforce branch. I will be adding p4admin files to it. |
||
//guest/perforce_software/cdsp4/release/2.2/Skill/Toolbox/fixhash.il | |||||
#1 | 1675 | Shiv Sikand | New 2.2 tree |