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 | # xdlfixes - Pro-process a Xilinx .xdl file such that xdl -xdl2ncd accepts it |
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 usage |
16 | { |
17 | print STDERR "usage: $0 [infile]\n"; |
18 | exit(1); |
19 | } |
20 | |
21 | |
22 | &usage if $ARGV[0] =~ /^-/; |
23 | |
24 | while (<>) { |
25 | # |
26 | # BUG: identifiers containing commas are generated by xdl -ncd2xdl |
27 | # but cannot be parsed by xdl -xdl2ncd. We therefore replace all the |
28 | # commas in identifiers with underscores. |
29 | # |
30 | |
31 | $t = $_; |
32 | $s = ""; |
33 | while ($t =~ /[^\\]"\S+"/) { |
34 | $s .= $`; |
35 | ($q = $&) =~ y/,/_/; |
36 | $t = $'; |
37 | $s .= $q; |
38 | } |
39 | $s .= $t; |
40 | |
41 | # |
42 | # BUG: xdl -xdl2ncd does not seem to understand that inputs are not |
43 | # outputs. We have two choices here: define the output standard as |
44 | # "#OFF" or define it as "LVCMOS33". |
45 | # |
46 | # With "LVCMOS33", xdl will also insist on the slew rate and the drive |
47 | # strength. |
48 | # |
49 | # In any case, we end up with something the DRC of bitgen will reject. |
50 | # Luckily, bitgen has the option -d to turn off the DRC. It then |
51 | # cheerfully announces |
52 | # |
53 | # ERROR:Bitgen - Could not find programming information for I/O |
54 | # standard #OFF [...] |
55 | # The programming of the output buffers will not be correct. |
56 | # |
57 | # but the resulting mess appears to work regardless. |
58 | # |
59 | |
60 | if ($_ =~ /^inst /) { |
61 | $s = $_; |
62 | while (!/;\s*$/) { |
63 | $_ = <>; |
64 | $s .= $_; |
65 | } |
66 | # $s =~ s/\bISTANDARD::LVCMOS33\b/$& OSTANDARD::LVCMOS33/; |
67 | # $s =~ s/\bISTANDARD::LVCMOS33\b/$& OSTANDARD::#OFF/; |
68 | $s =~ s/\bISTANDARD::LVCMOS33\b/$& OSTANDARD::#OFF/ unless |
69 | $s =~ /\bOSTANDARD:/; |
70 | # $s =~ s/\bINBUF:/OUTBUF::#OFF $&/; |
71 | # if ($s =~ /\bISTANDARD::LVCMOS33\b/) { |
72 | # $s =~ s/\bSLEW::#OFF\b/SLEW::SLOW/g; |
73 | # $s =~ s/\bDRIVEATTRBOX::#OFF\b/DRIVEATTRBOX::12/g; |
74 | # } |
75 | } |
76 | |
77 | print $s || die "write: $!"; |
78 | } |
79 |
Branches:
master