Hi Evan and all, On Sunday 01 July 2007 00:41, evan foss wrote: > It would seem many people adding symbols have > interest in drafting symbols only not maintaining them. Who ever did > the xilinx stuff for example did a wonderful job of drafting all the > chips with all of there pins but didn't define any of the pin > attributes properly (ex. pinseq=, pin=, pinnumber=, pinlabel=). > A large chunk can probably be done by fixing those gsymcheck issues > and say writing a few through away scripts to fix things like the > unnamed pins in the xilinx chips. Helper scripts can help, but you always have to take care of the result. Fixing sybmols is a time-consuming task, nevertheless. I've attached the two scripts I've used to fix some symbols. The file b is a shell script, it describes the workflow. The script nice_sym.py adds missing pinattributes and symbol attributes. The script doesn't support the current gschem file format (pin whichend and multiline text missing). Regards Werner
Attachment:
b
Description: application/shellscript
#!/usr/bin/python
import string,re,sys
################# constants ####################################################
#LIBRARY_PATH="/mnt/hda5/store/src/gedacvs2/geda/devel/symbols/"
CENTER=600
################ functions #####################################################
def makenice(filename):
f=open(filename)
file=f.readlines()
pintype=['in','out','io','oc','oe','pas','tp','tri','clk','pwr']
pins=[]
attr={}
graphical_text=[]
errors=[]
version=""
nr =len(file)
i = 0
while i < nr:
if file[i][0] == 'v':
print "v 20020825"
i = i + 1
elif file[i][0] == 'T':
if len(string.split(file[i+1],"=")) == 2:
if re.match('^refdes=',file[i+1]):
t=string.split(string.strip(file[i])," ")
print string.join(t[0:3]," ") + ' 8 10 1 1 ' \
+ string.join(t[7:9])
attr["refdes"]=1
else:
t=string.split(string.strip(file[i])," ")
print string.join(t[0:3]," ") + ' 5 10 0 0 ' \
+ string.join(t[7:9])
attr[string.split(file[i+1],"=")[0]]=1
print string.strip(file[i+1])
else:
graphical_text.append(string.strip(file[i]))
graphical_text.append(string.strip(file[i+1]))
i=i+2
continue
elif file[i][0] == "P":
pin=["","","","",""] ## Pin[pin,pinnumber,pinseq,pinlabel,pintype]
pin[0]=string.strip(file[i])
print pin[0]
i = i + 1
if string.strip(file[i][0]) != "{":
print "FEHLER: PIN OHNE ATTRIBUTE"
escape=1
else:
escape=0
i = i + 1
print '{'
x,y,pos = getpinpos(pin[0])
while string.strip(file[i][0]) != '}' and escape == 0:
if re.match("^pinnumber=",file[i+1]) \
and file[i][0] == 'T':
t=string.split(string.strip(file[i])," ")
if pos == "left":
pin[1] = 'T %i' %(x+200) + ' %i' %(y+50) + ' 5 8 1 1 0 6'
elif pos == "right":
pin[1] = 'T %i' %(x-200) + ' %i' %(y+50) + ' 5 8 1 1 0 0'
elif pos == "top":
pin[1] = 'T %i' %(x+50) + ' %i' %(y-200) + ' 5 8 1 1 0 0'
if ROTATE == 1:
pin[1] = 'T %i' %(x-50) + ' %i' %(y-200) + ' 5 8 1 1 90 0'
elif pos == "bottom":
pin[1] = 'T %i' %(x+50) + ' %i' %(y+100) + ' 5 8 1 1 0 0'
if ROTATE == 1:
pin[1] = 'T %i' %(x-50) + ' %i' %(y+200) + ' 5 8 1 1 90 6'
print pin[1]
print string.strip(file[i+1])
elif re.match("^pinseq=",file[i+1]) \
and file[i][0] == 'T':
t=string.split(string.strip(file[i])," ")
if pos == "left":
pin[2] = 'T %i' %(x+200) + ' %i' %(y-50) + ' 5 8 0 1 0 8'
elif pos == "right":
pin[2] = 'T %i' %(x-200) + ' %i' %(y-50) + ' 5 8 0 1 0 2'
elif pos == "top":
pin[2] = 'T %i' %(x+50) + ' %i' %(y-200) + ' 5 8 0 1 0 2'
if ROTATE == 1:
pin[2] = 'T %i' %(x+50) + ' %i' %(y-200) + ' 5 8 0 1 90 2'
elif pos == "bottom":
pin[2] = 'T %i' %(x+50) + ' %i' %(y+100) + ' 5 8 0 1 0 2'
if ROTATE == 1:
pin[2] = 'T %i' %(x+50) + ' %i' %(y+200) + ' 5 8 0 1 90 8'
print pin[2]
print string.strip(file[i+1])
elif re.match("^pinlabel=",file[i+1]) \
and file[i][0] == 'T':
t=string.split(string.strip(file[i])," ")
if pos == "left":
pin[3] = 'T %i' %(x+350) + ' %i' %y + ' 9 8 1 1 0 0'
elif pos == "right":
pin[3] = 'T %i' %(x-350) + ' %i' %y + ' 9 8 1 1 0 6'
elif pos == "top":
pin[3] = 'T %i' %x + ' %i' %(y-350) + ' 9 8 1 1 0 5'
if ROTATE == 1:
pin[3] = 'T %i' %x + ' %i' %(y-350) + ' 9 8 1 1 90 6'
elif pos == "bottom":
pin[3] = 'T %i' %x + ' %i' %(y+350) + ' 9 8 1 1 0 3'
if ROTATE == 1:
pin[3] = 'T %i' %x + ' %i' %(y+350) + ' 9 8 1 1 90 0'
print pin[3]
print string.strip(file[i+1])
elif (re.match("^pintype=",file[i+1]) \
or re.match("^type=",file[i+1])) \
and file[i][0] == 'T':
t=string.split(string.strip(file[i])," ")
if pos == "left":
pin[4] = 'T %i' %(x+350) + ' %i' %y + ' 5 8 0 1 0 2'
elif pos == "right":
pin[4] = 'T %i' %(x-350) + ' %i' %y + ' 5 8 0 1 0 8'
elif pos == "top":
pin[4] = 'T %i' %x + ' %i' %(y-500) + ' 5 8 0 1 0 5'
if ROTATE == 1:
pin[4] = 'T %i' %x + ' %i' %(y-350) + ' 5 8 0 1 90 8'
elif pos == "bottom":
pin[4] = 'T %i' %x + ' %i' %(y+500) + ' 5 8 0 1 0 3'
if ROTATE == 1:
pin[4] = 'T %i' %x + ' %i' %(y+350) + ' 5 8 0 1 90 2'
print pin[4]
print string.strip(file[i+1])
else:
print "FEHLER IN DER PINSEKTION"
i = i + 2
if pin[1] == "":
if pos == "left":
pin[1] = 'T %i' %(x+200) + ' %i' %(y+50) + ' 5 8 1 1 0 6'
elif pos == "right":
pin[1] = 'T %i' %(x-200) + ' %i' %(y+50) + ' 5 8 1 1 0 0'
elif pos == "top":
pin[1] = 'T %i' %(x+50) + ' %i' %(y-200) + ' 5 8 1 1 0 0'
if ROTATE == 1:
pin[1] = 'T %i' %(x-50) + ' %i' %(y-200) + ' 5 8 1 1 90 0'
elif pos == "bottom":
pin[1] = 'T %i' %(x+50) + ' %i' %(y+100) + ' 5 8 1 1 0 0'
if ROTATE == 1:
pin[1] = 'T %i' %(x-50) + ' %i' %(y+200) + ' 5 8 1 1 90 6'
print pin[1]
print "pinnumber=X"
if pin[2] == "":
if pos == "left":
pin[2] = 'T %i' %(x+200) + ' %i' %(y-50) + ' 5 8 0 1 0 8'
elif pos == "right":
pin[2] = 'T %i' %(x-200) + ' %i' %(y-50) + ' 5 8 0 1 0 2'
elif pos == "top":
pin[2] = 'T %i' %(x+50) + ' %i' %(y-200) + ' 5 8 0 1 0 2'
if ROTATE == 1:
pin[2] = 'T %i' %(x+50) + ' %i' %(y-200) + ' 5 8 0 1 90 2'
elif pos == "bottom":
pin[2] = 'T %i' %(x+50) + ' %i' %(y+100) + ' 5 8 0 1 0 2'
if ROTATE == 1:
pin[2] = 'T %i' %(x+50) + ' %i' %(y+200) + ' 5 8 0 1 90 8'
print pin[2]
print "pinseq=X"
if pin[3] == "":
if pos == "left":
pin[3] = 'T %i' %(x+350) + ' %i' %y + ' 9 8 1 1 0 0'
elif pos == "right":
pin[3] = 'T %i' %(x-350) + ' %i' %y + ' 9 8 1 1 0 6'
elif pos == "top":
pin[3] = 'T %i' %x + ' %i' %(y-350) + ' 9 8 1 1 0 5'
if ROTATE == 1:
pin[3] = 'T %i' %x + ' %i' %(y-350) + ' 9 8 1 1 90 6'
elif pos == "bottom":
pin[3] = 'T %i' %x + ' %i' %(y+350) + ' 9 8 1 1 0 3'
if ROTATE == 1:
pin[3] = 'T %i' %x + ' %i' %(y+350) + ' 9 8 1 1 90 0'
print pin[3]
print "pinlabel=X"
if pin[4] == "":
if pos == "left":
pin[4] = 'T %i' %(x+350) + ' %i' %y + ' 5 8 0 1 0 2'
elif pos == "right":
pin[4] = 'T %i' %(x-350) + ' %i' %y + ' 5 8 0 1 0 8'
elif pos == "top":
pin[4] = 'T %i' %x + ' %i' %(y-500) + ' 5 8 0 1 0 5'
if ROTATE == 1:
pin[4] = 'T %i' %x + ' %i' %(y-350) + ' 5 8 0 1 90 8'
elif pos == "bottom":
pin[4] = 'T %i' %x + ' %i' %(y+500) + ' 5 8 0 1 0 3'
if ROTATE == 1:
pin[4] = 'T %i' %x + ' %i' %(y+350) + ' 5 8 0 1 90 2'
print pin[4]
print "pintype=X"
if string.strip(file[i][0]) == "}":
i = i + 1
print "}"
elif file[i][0] in "ABLV":
print string.strip(file[i])
i = i+ 1
else:
print "FEHLER IN DER EINGANGSDATEI"
i = i + 1
if not attr.has_key("footprint"):
print "T 4000 650 5 10 0 0 0 0"
print "footprint=X"
if not attr.has_key("description"):
print "T 4000 850 5 10 0 0 0 0"
print "description=X"
if not attr.has_key("numslots"):
print "T 4000 450 5 10 0 0 0 0"
print "numslots=0"
if not attr.has_key("symversion"):
print "T 4000 250 5 10 0 0 0 0"
print "symversion=X"
if not attr.has_key("net"):
print "T 4000 1050 5 10 0 0 0 0"
print "net=X"
print "T 4000 1250 5 10 0 0 0 0"
print "net=X"
if not attr.has_key("documentation"):
print "T 4000 1450 5 10 0 0 0 0"
print "documentation="
for line in graphical_text: ## print all graphical text at the end of file
print line
def getpinpos(pinstring):
p=string.split(pinstring)
x1=string.atoi(p[1])
x2=string.atoi(p[3])
y1=string.atoi(p[2])
y2=string.atoi(p[4])
y = y1
x = x1
if x1 == x2: ## top or bottom pin
if (y1 + y2) < CENTER*2: ## bottom pin
pos = "bottom"
if y1 > y2:
y = y2
else: ## top pin
pos = "top"
if y1 < y2:
y = y2
else: ## left or right pin
if (x1 + x2) < CENTER*2: ## left pin
pos ="left"
if x1 > x2:
x = x2
else: ## right pin
pos = "right"
if x1 < x2:
x = x2
return x, y, pos
########################## MAIN ################################################
try:
file_in=sys.argv[1]
except:
print "nice_sym:"
print "Bad arguments, usage is: ", sys.argv[0] ,"infile [ROTATE]"
sys.exit()
try:
rot=sys.argv[2]
if rot == "ROTATE":
ROTATE=1
else:
ROTATE=0
except:
ROTATE=0
makenice(file_in)
_______________________________________________ geda-dev mailing list geda-dev@xxxxxxxxxxxxxx http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev