Subversion Repositories OpenARM Single-board Computer

Rev

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

Rev 222 Rev 231
Line 15... Line 15...
15
15
16
my $pinnumwidth = 0;
16
my $pinnumwidth = 0;
17
my $blockname;
17
my $blockname;
18
18
19
# vars used later too
19
# vars used later too
20
my (%x, %y);
20
#my (%x, %y);
21
21
22
# vars used during parsing
22
# vars used during parsing
23
my ($side, $busmode, $errors) = ('',0, 0);
23
my ($side, $busmode, $errors) = ('',0, 0);
24
# main loop which parses file
24
# main loop which parses file
25
while (<>) {
25
while (<>) {
Line 35... Line 35...
35
35
36
        # remove all CR/LF newlines
36
        # remove all CR/LF newlines
37
        s/[\r\n]+$//;
37
        s/[\r\n]+$//;
38
38
39
        # Note change of section.
39
        # Note change of section.
40
        if (/^\[(.*)\]/) {
40
        if (/^\[(.*)\]/) {
41
                $side = $1;
41
                $side = $1;
42
                $space = 0;
42
                $space = 0;
43
                next;
43
                next;
44
        }
44
        }
45
45
46
        # Start a bus 
46
        # Start a bus
47
        if (/^\.bus/) {
47
        if (/^\.bus/) {
48
                $busmode = 1;
48
                $busmode = 1;
49
                next;
49
                next;
50
        }
50
        }
51
51
52
        # blank lines - cancel bus, add gap.
52
        # blank lines - cancel bus, add gap.
53
        if (! /\S/) {
53
        if (! /\S/) {
54
                if ($busmode) {
54
                if ($busmode == 1) {
55
                        $y{$side} += 200;
55
                        $y{$side} += 200;
56
                        $busmode = 0;
56
                        $busmode = 0;
57
                }
57
                }
58
                if ($space) {
58
                if ($space) {
59
                        if ($side =~ /left|right/) {
59
                        if ($side =~ /left|right/) {
60
                                $y{$side} += 300;
60
                                $y{$side} += 300;
-
 
61
                        }
61
                        } elsif ($side =~ /top|bottom/) {
62
                        if ($side =~ /top|bottom/) {
62
                                $x{$side} += 400;
63
                                $x{$side} += 400;
63
                        }
64
                        }
64
                        $space = 0;
65
                        $space = 0;
65
                }
66
                }
66
                next;
67
                next;
67
        }
68
        }
68
69
69
70
70
        # Hidden labels are stored separately, because we don't care how 
71
        # Hidden labels are stored separately, because we don't care how
71
        # big they are. 
72
        # big they are.
72
        if (/! (\S.*)/ && $side eq "labels") {
73
        if (/! (\S.*)/ && $side eq "labels") {
73
                # code probably could be more smart and store labels ex in certain order
74
                # code probably could be more smart and store labels ex in certain order
74
                push(@attrs, $1);
75
                push(@attrs, $1);
75
                next;
76
                next;
76
        }
77
        }
77
78
78
        # Visible labels are stored as pins because their size affects the
79
        # Visible labels are stored as pins because their size affects the
79
        # size of the symbols' box.
80
        # size of the symbols' box.
80
        if (/\S/ && $side eq "labels") {
81
        if (/\S/ && $side eq "labels") {
81
                # an blockswith
82
                # an blockswith
82
                if ($_ =~ /^block=/) {
83
                if ($_ =~ /^block=/) {
83
                        $blockname = $_;
84
                        $blockname = $_;
84
                        # printf STDERR "Blocname %s\n", $blockname;
85
                        # printf STDERR "Blocname %s\n", $blockname;
85
                        next;
86
                        next;
86
                }
87
                }
87
88
88
                $labelpin --;
89
                $labelpin --;
Line 97... Line 98...
97
        # Regular pins are handled here.
98
        # Regular pins are handled here.
98
        if (/^([0-9A-Za-z]+)\s*(.*)/) {
99
        if (/^([0-9A-Za-z]+)\s*(.*)/) {
99
                $space = 1;
100
                $space = 1;
100
                ($pin, $rest) = ($1,$2);
101
                ($pin, $rest) = ($1,$2);
101
102
102
                if ($saw_pin{$pin}) {
103
                if ($saw_pin{$pin}) {
103
                        print STDERR "DUPLICATE PIN $pin (was $pinlabel{$pin}, now $rest)\n";
104
                        print STDERR "DUPLICATE PIN $pin (was $pinlabel{$pin}, now $rest)\n";
104
                        $errors ++;
105
                        $errors ++;
105
                }
106
                }
106
107
107
                $saw_pin{$pin} = 1;
108
                $saw_pin{$pin} = 1;
108
                # our symbols use letters in names so next line wents wrong imo
109
                # our symbols use letters in names so next line wents wrong imo
109
                # we have two solutions, use numbers only (hard for BGA or sth like that)
110
                # we have two solutions, use numbers only (hard for BGA or sth like that)
Line 113... Line 114...
113
114
114
                $pinside{$pin} = $side;
115
                $pinside{$pin} = $side;
115
116
116
                next if $side eq "nc";
117
                next if $side eq "nc";
117
118
118
                if ($rest =~ /^([!>]+) (.*)/) {
119
                if ($rest =~ /^([!>]+) (.*)/) {
119
                        $flags = $1;
120
                        $flags = $1;
120
                        $pinlabel{$pin} = $2;
121
                        $pinlabel{$pin} = $2;
121
                        $bubble{$pin} = 1 if $flags =~ /!/;
122
                        $bubble{$pin} = 1 if $flags =~ /!/;
122
                        $edge{$pin} = 1 if $flags =~ />/;
123
                        $edge{$pin} = 1 if $flags =~ />/;
123
                } else {
124
                } else {
124
                        $pinlabel{$pin} = $rest;
125
                        $pinlabel{$pin} = $rest;
125
                }
126
                }
126
               
127
               
127
                $rlen{$pin} = &textlen($pinlabel{$pin});
128
                $rlen{$pin} = &textlen($pinlabel{$pin});
Line 129... Line 130...
129
                if ($pinnumwidth < &textlen($pin)) {
130
                if ($pinnumwidth < &textlen($pin)) {
130
                        $pinnumwidth = &textlen($pin);
131
                        $pinnumwidth = &textlen($pin);
131
                }
132
                }
132
133
133
                if ($side =~ /left|right/) {
134
                if ($side =~ /left|right/) {
134
                        $y = $piny{$pin} = $y{$side};
135
                        $y = $piny{$pin} = $y{$side};
135
                        $y{$side} += ($busmode ? 200 : 300);
136
                        $y{$side} += ($busmode ? 200 : 300);
136
                }
137
                }
137
               
138
               
138
                if ($side =~ /top|bottom/) {
139
                if ($side =~ /top|bottom/) {
139
                        $tw = &alignpin((200 + $rlen{$pin}) / 2);
140
                        $tw = &alignpin((200 + $rlen{$pin}) / 2);
140
                        $pinx{$pin} = $w{$side} + $tw;
141
                        $pinx{$pin} = $w{$side} + $tw;
141
                        $w{$side} += $tw + $tw;
142
                        $w{$side} += $tw + $tw;
142
                }
143
                }
143
144
144
        }
145
        }
145
146
Line 155... Line 156...
155
%bw = ();
156
%bw = ();
156
157
157
# for each horizontal slice of the symbol, keep track of how much
158
# for each horizontal slice of the symbol, keep track of how much
158
# width is used up by the left, middle, and right labels.
159
# width is used up by the left, middle, and right labels.
159
for $lp (keys %pinside) {
160
for $lp (keys %pinside) {
160
    next unless $pinside{$lp} =~ /left|right|label/;
161
        next unless $pinside{$lp} =~ /left|right|label/;
161
    $yb = &alignpin($piny{$lp});
162
        $yb = &alignpin($piny{$lp});
162
    for ($y=$yb-100; $y<=$yb+100; $y+=100) {
163
        for ($y=$yb-100; $y<=$yb+100; $y+=100) {
163
            # again we got not numbers inside, so lt/gt operator dont work well.. need to track why and how fix
164
                # again we got not numbers inside, so lt/gt operator dont work well.. need to track why and how fix
164
        if ($bw{$y}{$pinside{$lp}} < $rlen{$lp}) {
165
                if ($bw{$y}{$pinside{$lp}} < $rlen{$lp}) {
165
            $bw{$y}{$pinside{$lp}} = $rlen{$lp};
166
                        $bw{$y}{$pinside{$lp}} = $rlen{$lp};
-
 
167
                }
166
        }
168
        }
167
    }
-
 
168
}
169
}
169
170
170
# Compute the height of the box. 
171
# Compute the height of the box.
171
for $p (keys %pinside) {
172
for $p (keys %pinside) {
172
        next unless $pinside{$p} =~ /left|right/;
173
        next unless $pinside{$p} =~ /left|right/;
173
        if ($maxy < $piny{$p}) {
174
        if ($maxy < $piny{$p}) {
174
                $maxy = $piny{$p};
175
                $maxy = $piny{$p};
175
        }
176
        }
176
}
177
}
177
$maxy += 300;
178
$maxy += 300;
178
179
Line 188... Line 189...
188
        $wl = ($bw{$i}{left} + $bw{$i}{labels}/2) * 2;
189
        $wl = ($bw{$i}{left} + $bw{$i}{labels}/2) * 2;
189
        $w = $wl if $w < $wl;
190
        $w = $wl if $w < $wl;
190
        $wl = ($bw{$i}{right} + $bw{$i}{labels}/2) * 2;
191
        $wl = ($bw{$i}{right} + $bw{$i}{labels}/2) * 2;
191
        $w = $wl if $w < $wl;
192
        $w = $wl if $w < $wl;
192
    }
193
    }
193
    # need to review that if()'s 
194
    # need to review that if()'s
194
    if ($bw{$i}{left} && $bw{$i}{labels}) {
195
    if ($bw{$i}{left} && $bw{$i}{labels}) {
195
        $w += 100;
196
        $w += 100;
196
    } elsif ($bw{$i}{left} && $bw{$i}{right}) {
197
    } elsif ($bw{$i}{left} && $bw{$i}{right}) {
197
        $w += 200;
198
        $w += 200;
198
    }
199
    }
Line 251... Line 252...
251
252
252
# Labels are centered in the box.
253
# Labels are centered in the box.
253
# labels have to be top, lef
254
# labels have to be top, lef
254
for $lp ($minpin..-1) {
255
for $lp ($minpin..-1) {
255
    #$pinx{$lp} = &alignpin($boxwidth/2) + 300;
256
    #$pinx{$lp} = &alignpin($boxwidth/2) + 300;
256
    $pinx{$lp} = $pinnumwidth;
257
    $pinx{$lp} = $pinnumwidth;
257
}
258
}
258
259
259
# Version.
260
# Version.
260
print "v 20060123 1\n";
261
print "v 20060123 1\n";
261
262
Line 285... Line 286...
285
        $pinx{$p} = $pinnumwidth;
286
        $pinx{$p} = $pinnumwidth;
286
    }
287
    }
287
    if ($pinside{$p} eq "right") {
288
    if ($pinside{$p} eq "right") {
288
        $pinx{$p} = $pinnumwidth + $boxwidth;
289
        $pinx{$p} = $pinnumwidth + $boxwidth;
289
    }
290
    }
290
        # here we get warning about undefined value in addition, probably one of things isnt defined.. 
291
        # here we get warning about undefined value in addition, probably one of things isnt defined..
291
    if ($p > 0 && !$saw_pin{$p}) {
292
    if ($p > 0 && !$saw_pin{$p}) {
292
        print STDERR "MISSING PIN $p\n";
293
        print STDERR "MISSING PIN $p\n";
293
        $errors++;
294
        $errors++;
294
    } else {
295
    } else {
295
        printf STDERR ("%3d  %-6s  %4d %4d  %s\n",
296
        printf STDERR ("%3d  %-6s  %4d %4d  %s\n",