Werner's Miscellanea
Sign in or create your account | Project List | Help
Werner's Miscellanea Git Source Tree
Root/
Source at commit d3a27c7b9ba1179cd263208c3ee1275f547d43ff created 12 years 22 days ago. By Werner Almesberger, m1r1/dsv/SUPPLEMENT: delete mechanical components; fixed last non-Yageo bad link | |
---|---|
1 | #!/usr/bin/perl |
2 | # |
3 | # xdltap - Route nets from inside the FPGA to I/O pads |
4 | # |
5 | # Written 2011 by Werner Almesberger |
6 | # Copyright 2011 by Werner Almesberger |
7 | # |
8 | # This program is free software; you can redistribute it and/or modify |
9 | # it under the terms of the GNU General Public License as published by |
10 | # the Free Software Foundation; either version 2 of the License, or |
11 | # (at your option) any later version. |
12 | # |
13 | |
14 | |
15 | sub change |
16 | { |
17 | local ($s, $v, $from, $to) = @_; |
18 | |
19 | if (defined $from) { |
20 | die "${v}::$from not found in\n$s" |
21 | unless $s =~ /\b${v}::$from/; |
22 | return "$`${v}::$to$'"; |
23 | } else { |
24 | die "${v}::... not found in\n$s" |
25 | unless $s =~ /\b${v}::\S+/; |
26 | return "$`${v}::$to$'"; |
27 | } |
28 | } |
29 | |
30 | |
31 | sub change_var |
32 | { |
33 | local ($s, $from, $to) = @_; |
34 | |
35 | die "${from}::... not found in\n$s" |
36 | unless $s =~ /\b${from}::/; |
37 | return "$`${to}::$'"; |
38 | } |
39 | |
40 | |
41 | sub reassign |
42 | { |
43 | local ($s, $from, $to) = @_; |
44 | |
45 | $s =~ s/\bINBUF:${to}_IBUF:/OUTBUF:${to}_OBUF:/ || |
46 | die "INBUF:${to}_IBUF: not found in\n$s"; |
47 | $s =~ s/\bPULL:${to}_PULLDOWN:// || |
48 | die "PULL:${to}_PULLDOWN: not found in\n$s"; |
49 | $s =~ s/\bIMUX:[^:]+:I/IMUX::#OFF/ || |
50 | die "IMUX:...:I not found in\n$s"; |
51 | $s = &change($s, "BYPASS_MUX", "I", "#OFF"); |
52 | $s = &change($s, "DRIVEATTRBOX", "#OFF", "12"); |
53 | $s = &change($s, "OUSED", "#OFF", "0"); |
54 | $s = &change($s, "PULLTYPE", "PULLDOWN", "#OFF"); |
55 | $s = &change($s, "SLEW", "#OFF", "SLOW"); |
56 | $s = &change($s, "SUSPEND", "#OFF", "3STATE"); |
57 | $s = &change_var($s, "ISTANDARD", "OSTANDARD"); |
58 | return $s; |
59 | } |
60 | |
61 | |
62 | sub usage |
63 | { |
64 | print STDERR <<"END" |
65 | usage: $0 [net=output ...] [file] |
66 | |
67 | net fully qualified path to the signal in question, e.g., |
68 | usb/sie/rx_pending |
69 | output name of the (input) connected to the output pin, e.g., exp<8> |
70 | |
71 | For better shell compatibility, { and } can be used instead of < and > |
72 | END |
73 | ; |
74 | exit(1); |
75 | } |
76 | |
77 | |
78 | &usage if $ARGV[0] =~ /^-/; |
79 | |
80 | while ($ARGV[0] =~ /=/) { |
81 | ($from, $to) = ($`, $'); |
82 | $to =~ tr/{}/<>/; |
83 | $from{$from} = $to; |
84 | $to{$to} = $from; |
85 | $need{$from} = $need{$to} = 1; |
86 | shift @ARGV; |
87 | } |
88 | |
89 | while (<>) { |
90 | if ($_ =~ /^inst "([^"]*)"/ && defined $to{$1}) { |
91 | die "" unless $need{$1}; |
92 | delete $need{$1}; |
93 | $s = $_; |
94 | while (!/;\s*$/) { |
95 | $_ = <>; |
96 | $s .= $_; |
97 | } |
98 | print &reassign($s, $to{$1}, $1) || die "write: $!"; |
99 | next; |
100 | } |
101 | if (/^net "([^"]*)_IBUF"/ && defined $to{$1}) { |
102 | next if /;\s*$/; |
103 | while (<>) { |
104 | last if /;\s*$/; |
105 | } |
106 | next; |
107 | } |
108 | print || die "write: $!"; |
109 | if (/^net "([^"]*)"/) { |
110 | next unless defined $from{$1}; |
111 | die unless $need{$1}; |
112 | delete $need{$1}; |
113 | print " inpin \"$from{$1}\" O,\n" || die "write: $!"; |
114 | } |
115 | } |
116 | |
117 | die "not found: ".join(", ", sort keys %need) if %need; |
118 |
Branches:
master