Rev 20 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
20 | reyssat | 1 | #! /bin/sh |
2 | # |
||
3 | # Regeneration of index files. |
||
4 | |||
5 | if [ -z "$1" ]; then |
||
6 | cat <<@ |
||
7 | This script transforms a WIMS circuit data file into a ps file |
||
8 | recognizable by xcircuit. You can then modify the latter and |
||
9 | transform back using ps2data. |
||
10 | |||
11 | Usage: ./data2ps inputfile |
||
12 | |||
13 | @ |
||
14 | exit |
||
15 | fi |
||
16 | |||
17 | if [ -n "$w_module" ]; then |
||
18 | echo "This script is to be used manually. It should not be run by WIMS." |
||
19 | exit |
||
20 | fi |
||
21 | |||
22 | inp=$1 |
||
23 | [ -f "$inp" ] || inp=$1.data |
||
24 | [ -f "$inp" ] || exit |
||
25 | |||
26 | current=`pwd` |
||
27 | cd `dirname $0` |
||
28 | homedir=`pwd` |
||
29 | header=$homedir/circ-header.ps1 |
||
30 | tail=$homedir/circ-tail.ps1 |
||
31 | cd $current |
||
32 | |||
33 | # Translation size factor |
||
34 | sf=64 |
||
35 | |||
36 | desc=`awk 'BEGIN {rec=0}; |
||
37 | /^:/ {rec++}; |
||
38 | rec>1 {exit}; |
||
39 | rec==1 {if(substr($0,1,1)==":") print substr($0,2); else print};' $inp` |
||
40 | range=`awk 'BEGIN {rec=0}; |
||
41 | /^:/ {rec++}; |
||
42 | rec>2 {exit}; |
||
43 | rec==2 {if(substr($0,1,1)==":") print substr($0,2); else print};' $inp` |
||
44 | pos=`awk 'BEGIN {rec=0}; |
||
45 | /^:/ {rec++}; |
||
46 | rec>3 {exit}; |
||
47 | rec==3 {if(substr($0,1,1)==":") print substr($0,2); else print};' $inp` |
||
48 | wire=`awk 'BEGIN {rec=0}; |
||
49 | /^:/ {rec++}; |
||
50 | rec>4 {exit}; |
||
51 | rec==4 {if(substr($0,1,1)==":") print substr($0,2); else print};' $inp` |
||
52 | dots=`awk 'BEGIN {rec=0}; |
||
53 | /^:/ {rec++}; |
||
54 | rec>5 {exit}; |
||
55 | rec==5 {if(substr($0,1,1)==":") print substr($0,2); else print};' $inp` |
||
56 | pairs=`echo "$range" | tr '()[]' '@@@@' | cut -s -d@ -f2 | tr ',' ' '` |
||
57 | if [ -z "$pairs" ]; then |
||
58 | pairs=`echo "$range" | cut -s -d, -f4 | tr ',' ' '` |
||
59 | fi |
||
60 | |||
61 | cat $header |
||
62 | echo |
||
63 | echo "(DESC: $desc) {/Helvetica cf} 2 16 0 1.00 0 -160 label" |
||
64 | echo "$range" |\ |
||
65 | awk -F, '{ |
||
66 | texthd="{/Helvetica cf} 2 16 0 1.00"; sf='$sf'; |
||
67 | for(i=0;i<=$2/2;i++) { |
||
68 | printf "0.8 0.8 0.8 scb\n1 1.00 0 %d %d %d 2 polygon\nsce\n", |
||
69 | i*2*sf, $1*sf, i*2*sf; |
||
70 | printf "1.00 0 0 %d tap\n",i*2*sf; |
||
71 | printf "(%d) %s -64 %d label\n",i*2,texthd,i*2*sf-16; |
||
72 | } |
||
73 | if($2%2 == 1) { |
||
74 | printf "1.00 0 0 %d tap\n",$2*sf; |
||
75 | printf "(%d) %s -64 %d label\n",$2,texthd,$2*sf-16; |
||
76 | } |
||
77 | printf "0.8 0.8 0.8 scb\n1 1.00 0 0 0 %d 2 polygon\nsce\n", $2*sf; |
||
78 | for(i=1;i<=$1/2;i++) { |
||
79 | printf "0.8 0.8 0.8 scb\n1 1.00 %d 0 %d %d 2 polygon\nsce\n", |
||
80 | i*2*sf, i*2*sf, $2*sf; |
||
81 | printf "1.00 270 %d 0 tap\n",i*2*sf; |
||
82 | printf "(%d) %s %d -48 label\n",i*2,texthd,i*2*sf-16; |
||
83 | } |
||
84 | if($1%2 == 1) { |
||
85 | printf "1.00 270 %d 0 tap\n",$1*sf; |
||
86 | printf "(%d) %s %d -48 label\n",$1,texthd,$1*sf-16; |
||
87 | } |
||
88 | exit}' |
||
89 | echo "$pos" |\ |
||
90 | awk -F, '{sf='$sf'; |
||
91 | texthd="{/Helvetica cf} 2 16 0 1.00"; |
||
92 | printf "1.00 %d %d %d acsource\n",(1-$5)*270,$1*sf,$2*sf; |
||
93 | if($3>=0 && $4>=0) printf "(XXX) %s %d %d label\n", |
||
94 | texthd,int($3*4)*sf/4,int($4*4)*sf/4-32; |
||
95 | for(i=6;i<=NF;i++) { |
||
96 | if($i>-1 && $i<1) continue; |
||
97 | if($i<0) t=-0.25; else t=0.25; |
||
98 | if($5==0) printf("1 1.50 %d %d %d %d 2 polygon\n", |
||
99 | int(($1+$i)*4)*sf/4, int($2*4)*sf/4, |
||
100 | int(($1+t)*4)*sf/4, int($2*4)*sf/4); |
||
101 | else printf("1 1.50 %d %d %d %d 2 polygon\n", |
||
102 | int($1*4)*sf/4, int(($2+$i)*4)*sf/4, |
||
103 | int($1*4)*sf/4, int(($2+t)*4)*sf/4); |
||
104 | } |
||
105 | }' |
||
106 | echo "$dots" |\ |
||
107 | awk -F, '{sf='$sf'; |
||
108 | for(i=2;i<=NF;i+=2) printf "1.00 0 %d %d dot\n",$(i-1)*sf,$i*sf; |
||
109 | }' |
||
15531 | bpr | 110 | echo "$wire" | awk '$1=="polyline" {print}' | sed 's/polyline//;s/_color_//' |\ |
20 | reyssat | 111 | awk -F, '{sf='$sf'; |
112 | printf "1 3.00 "; |
||
113 | for(i=2;i<=NF;i++) printf "%d ",$i*sf; |
||
114 | printf "%d polygon\n",(i-1)/2; |
||
115 | }' |
||
15531 | bpr | 116 | echo "$wire" | awk '$1=="polyline" {print}' | sed 's/polyline//;s/_color_//' |\ |
20 | reyssat | 117 | awk -F, '{sf='$sf'; |
118 | printf "1 3.00 %d %d %d %d 2 polygon\n", |
||
119 | $1*sf,$2*sf,$3*sf,$4*sf; |
||
120 | }' |
||
121 | echo "$wire" | awk '$1=="parallel" {print}' | sed 's/parallel//;s/_color_//' |\ |
||
122 | awk -F, '{sf='$sf'; |
||
123 | for(i=0;i<$7;i++) { |
||
124 | printf "1 3.00 %d %d %d %d 2 polygon\n", |
||
125 | ($1+i*$5)*sf,($2+i*$6)*sf, |
||
126 | ($3+i*$5)*sf,($4+i*$6)*sf; |
||
127 | } |
||
128 | }' |
||
129 | echo "$wire" | awk '$1 == "text" || $1 == "string" {print}' |\ |
||
130 | awk -F, 'BEGIN {texthd="{/Helvetica cf} 2 16 0 1.00"; sf='$sf'}; |
||
131 | {printf "(%s) %s %d %d label\n",$5,texthd,$2*sf,$3*sf-32}' |
||
132 | for p in $pairs; do |
||
133 | echo "$pos" | awk -F, 'FNR == '$p' { |
||
134 | sf='$sf'; |
||
135 | if($5==0) {x1=$1+1;x2=$1+2;y1=y2=$2;} |
||
136 | else {x1=x2=$1;y1=$2-1;y2=$2-2;}; |
||
137 | printf "1.0 0.0 0.0 scb\n1 3.00 %d %d %d %d 2 polygon\nsce\n", |
||
138 | x1*sf,y1*sf,x2*sf,y2*sf; |
||
139 | exit; |
||
140 | }' |
||
141 | done |
||
142 | cat $tail |
||
143 |