Subversion Repositories OpenARM Single-board Computer

Rev

Rev 135 | Rev 142 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 135 Rev 141
Line 11... Line 11...
11
$y{labels} = -200;
11
$y{labels} = -200;
12
$labelpin = 0;
12
$labelpin = 0;
13
13
14
# Read in the file, storing information about each pin.
14
# Read in the file, storing information about each pin.
15
15
-
 
16
my $pinnumwidth = 0;
-
 
17
my $blockname;
-
 
18
16
while (<>) {
19
while (<>) {
17
    next if /^#/;
20
    next if /^#/;
18
    s/^\s+//;
21
    s/^\s+//;
19
    s/\s+$//;
22
    s/\s+$//;
20
    s/[\s\t]+/ /g;
23
    s/[\s\t]+/ /g;
Line 59... Line 62...
59
    }
62
    }
60
63
61
    # Visible labels are stored as pins because their size affects the
64
    # Visible labels are stored as pins because their size affects the
62
    # size of the symbols' box.
65
    # size of the symbols' box.
63
    if (/\S/ && $side eq "labels") {
66
    if (/\S/ && $side eq "labels") {
-
 
67
        if ($_ =~ /^block=/) {
-
 
68
                $blockname = $_;
-
 
69
                printf STDERR "Blocname %s\n", $blockname;
-
 
70
                next;
-
 
71
        }
64
        $labelpin --;
72
        $labelpin --;
65
        $pinside{$labelpin} = $side;
73
        $pinside{$labelpin} = $side;
66
        $piny{$labelpin} = $y{labels};
74
        $piny{$labelpin} = $y{labels};
67
        $pinlabel{$labelpin} = $_;
75
        $pinlabel{$labelpin} = $_;
68
        $y{labels} -= 200;
76
        $y{labels} -= 200;
Line 92... Line 100...
92
        } else {
100
        } else {
93
            $pinlabel{$pin} = $rest;
101
            $pinlabel{$pin} = $rest;
94
        }
102
        }
95
        $rlen{$pin} = &textlen($pinlabel{$pin});
103
        $rlen{$pin} = &textlen($pinlabel{$pin});
96
104
-
 
105
        if ($pinnumwidth < &textlen($pin)) {
-
 
106
                $pinnumwidth = &textlen($pin);
-
 
107
        }
-
 
108
97
        if ($side =~ /left|right/) {
109
        if ($side =~ /left|right/) {
98
            $y = $piny{$pin} = $y{$side};
110
            $y = $piny{$pin} = $y{$side};
99
            $y{$side} += ($busmode ? 200 : 300);
111
            $y{$side} += ($busmode ? 200 : 300);
100
        }
112
        }
101
        if ($side =~ /top|bottom/) {
113
        if ($side =~ /top|bottom/) {
Line 106... Line 118...
106
118
107
    }
119
    }
108
120
109
}
121
}
110
122
-
 
123
$pinnumwidth += 100 - ($pinnumwidth % 100);
-
 
124
111
$minpin = $labelpin;
125
$minpin = $labelpin;
112
$boxwidth = 0;
126
$boxwidth = 0;
113
%bw = ();
127
%bw = ();
114
128
115
# for each horizontal slice of the symbol, keep track of how much
129
# for each horizontal slice of the symbol, keep track of how much
Line 187... Line 201...
187
201
188
# Adjust the position of the top/bottom pins so that, as a group,
202
# Adjust the position of the top/bottom pins so that, as a group,
189
# they're centered.
203
# they're centered.
190
for $p (keys %pinside) {
204
for $p (keys %pinside) {
191
    next unless $pinside{$p} =~ /top|bottom/;
205
    next unless $pinside{$p} =~ /top|bottom/;
192
    $pinx{$p} += &alignpin(($boxwidth - $w{$pinside{$p}})/2) + 300;
206
    $pinx{$p} += &alignpin(($boxwidth - $w{$pinside{$p}})/2) + $pinnumwidth;
193
}
207
}
194
208
195
# Labels are centered in the box.
209
# Labels are centered in the box.
196
# labels have to be top, lef
210
# labels have to be top, lef
197
for $lp ($minpin..-1) {
211
for $lp ($minpin..-1) {
198
    #$pinx{$lp} = &alignpin($boxwidth/2) + 300;
212
    #$pinx{$lp} = &alignpin($boxwidth/2) + 300;
199
    $pinx{$lp} = 300; # + &textlen($pinlabel{$lp})/2;
213
    $pinx{$lp} = $pinnumwidth;
200
}
214
}
201
215
202
# Version.
216
# Version.
203
print "v 20060123 1\n";
217
print "v 20060123 1\n";
204
218
205
# Symbol box.
219
# Symbol box.
206
printf("B %d %d %d %d 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1\n",
220
printf("B %d %d %d %d 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1\n",
207
       300, 300, $boxwidth, $maxy);
221
       $pinnumwidth, 300, $boxwidth, $maxy);
208
222
209
# These are the hidden labels.
223
# These are the hidden labels.
210
$ax = 300 + $boxwidth;
224
$ax = 300 + $boxwidth;
211
$ay = 400 + $maxy;
225
$ay = 400 + $maxy;
212
for $a (reverse @attrs) {
226
for $a (reverse @attrs) {
213
    printf("T %d %d 9 10 0 0 0 0 1\n%s\n",
227
    printf("T %d %d 9 10 0 0 0 0 1\n%s\n",
214
           $ax, $ay, $a);
228
           $ax, $ay, $a);
215
    $ay += 200;
229
    $ay += 200;
216
}
230
}
217
231
-
 
232
# blockname if present
-
 
233
if(defined $blockname) {
-
 
234
    printf("T %d %d 5 10 1 1 0 6 1\n%s\n", $boxwidth + $pinnumwidth, $maxy + 400, $blockname);
-
 
235
    printf STDERR "BLOCKNAME %s\n", $blockname;
-
 
236
}
-
 
237
218
# Now print all the pins.
238
# Now print all the pins.
219
for $p (sort {$a<=>$b} keys %pinside) {
239
for $p (sort {$a<=>$b} keys %pinside) {
220
    next unless $pinside{$p};
240
    next unless $pinside{$p};
221
    if ($pinside{$p} eq "left") {
241
    if ($pinside{$p} eq "left") {
222
        $pinx{$p} = 300;
242
        $pinx{$p} = $pinnumwidth;
223
    }
243
    }
224
    if ($pinside{$p} eq "right") {
244
    if ($pinside{$p} eq "right") {
225
        $pinx{$p} = 300 + $boxwidth;
245
        $pinx{$p} = $pinnumwidth + $boxwidth;
226
    }
246
    }
227
    if ($p > 0 && !$saw_pin{$p}) {
247
    if ($p > 0 && !$saw_pin{$p}) {
228
        print STDERR "MISSING PIN $p\n";
248
        print STDERR "MISSING PIN $p\n";
229
        $errors++;
249
        $errors++;
230
    } else {
250
    } else {
Line 289... Line 309...
289
               $pinx{$pin}+100, $piny{$pin},
309
               $pinx{$pin}+100, $piny{$pin},
290
               $pinx{$pin}, $piny{$pin}+50);
310
               $pinx{$pin}, $piny{$pin}+50);
291
311
292
    }
312
    }
293
    printf("P %d %d %d %d 1 0 0\n",
313
    printf("P %d %d %d %d 1 0 0\n",
294
           $pinx{$pin} - 300, $piny{$pin}, $x, $piny{$pin});
314
           $pinx{$pin} - $pinnumwidth, $piny{$pin}, $x, $piny{$pin});
295
    print "{\n";
315
    print "{\n";
296
    &pltext($pinx{$pin} + $px, $piny{$pin}, 1, $pinlabel{$pin});
316
    &pltext($pinx{$pin} + $px, $piny{$pin}, 1, $pinlabel{$pin});
297
    &ntext($pinx{$pin} -100, $piny{$pin} + 50, 6, $pin);
317
    &ntext($pinx{$pin} -100, $piny{$pin} + 50, 6, $pin);
298
    print "}\n";
318
    print "}\n";
299
}
319
}
Line 315... Line 335...
315
               $pinx{$pin}-100, $piny{$pin},
335
               $pinx{$pin}-100, $piny{$pin},
316
               $pinx{$pin}, $piny{$pin}+50);
336
               $pinx{$pin}, $piny{$pin}+50);
317
337
318
    }
338
    }
319
    printf("P %d %d %d %d 1 0 0\n",
339
    printf("P %d %d %d %d 1 0 0\n",
320
           $pinx{$pin} + 300, $piny{$pin}, $x, $piny{$pin});
340
           $pinx{$pin} + $pinnumwidth, $piny{$pin}, $x, $piny{$pin});
321
    print "{\n";
341
    print "{\n";
322
    &pltext($pinx{$pin} - $px, $piny{$pin}, 7, $pinlabel{$pin});
342
    &pltext($pinx{$pin} - $px, $piny{$pin}, 7, $pinlabel{$pin});
323
    &ntext($pinx{$pin} +100, $piny{$pin} + 50, 0, $pin);
343
    &ntext($pinx{$pin} +100, $piny{$pin} + 50, 0, $pin);
324
    print "}\n";
344
    print "}\n";
325
}
345
}