3 from argparse
import ArgumentParser
4 from io
import StringIO
5 from enum
import Enum
, auto
11 def __init__(self
, name
, keep
=False, port_attrs
={}):
14 self
.port_attrs
= port_attrs
18 # Design elements types listed in Xilinx UG615.
24 # Arithmetic functions.
25 Cell('DSP48A1', port_attrs
={'CLK': ['clkbuf_sink']}),
28 # Cell('BUFG', port_attrs={'O': ['clkbuf_driver']}),
29 Cell('BUFGCE', port_attrs
={'O': ['clkbuf_driver']}),
30 Cell('BUFGCE_1', port_attrs
={'O': ['clkbuf_driver']}),
31 Cell('BUFGMUX', port_attrs
={'O': ['clkbuf_driver']}),
32 Cell('BUFGMUX_1', port_attrs
={'O': ['clkbuf_driver']}),
33 Cell('BUFH', port_attrs
={'O': ['clkbuf_driver']}),
34 Cell('BUFIO2', port_attrs
={'IOCLK': ['clkbuf_driver'], 'DIVCLK': ['clkbuf_driver']}),
35 Cell('BUFIO2_2CLK', port_attrs
={'IOCLK': ['clkbuf_driver'], 'DIVCLK': ['clkbuf_driver']}),
36 Cell('BUFIO2FB', port_attrs
={'O': ['clkbuf_driver']}),
37 Cell('BUFPLL_MCB', port_attrs
={'IOCLK0': ['clkbuf_driver'], 'IOCLK1': ['clkbuf_driver']}),
42 # Config/BSCAN components.
43 Cell('BSCAN_SPARTAN6', keep
=True),
45 Cell('ICAP_SPARTAN6', keep
=True),
46 Cell('POST_CRC_INTERNAL'),
47 Cell('STARTUP_SPARTAN6', keep
=True),
48 Cell('SUSPEND_SYNC', keep
=True),
52 # Cell('IBUF', port_attrs={'I': ['iopad_external_pin']}),
53 Cell('IBUFDS', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
54 Cell('IBUFDS_DIFF_OUT', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
55 Cell('IBUFG', port_attrs
={'I': ['iopad_external_pin']}),
56 Cell('IBUFGDS', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
57 Cell('IBUFGDS_DIFF_OUT', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
58 Cell('IOBUF', port_attrs
={'IO': ['iopad_external_pin']}),
59 Cell('IOBUFDS', port_attrs
={'IO': ['iopad_external_pin']}),
60 Cell('IODELAY2', port_attrs
={'IOCLK0': ['clkbuf_sink'], 'IOCLK1': ['clkbuf_sink'], 'CLK': ['clkbuf_sink']}),
61 Cell('IODRP2', port_attrs
={'IOCLK0': ['clkbuf_sink'], 'IOCLK1': ['clkbuf_sink'], 'CLK': ['clkbuf_sink']}),
62 Cell('IODRP2_MCB', port_attrs
={'IOCLK0': ['clkbuf_sink'], 'IOCLK1': ['clkbuf_sink'], 'CLK': ['clkbuf_sink']}),
63 Cell('ISERDES2', port_attrs
={
64 'CLK0': ['clkbuf_sink'],
65 'CLK1': ['clkbuf_sink'],
66 'CLKDIV': ['clkbuf_sink'],
69 # Cell('OBUF', port_attrs={'O': ['iopad_external_pin']}),
70 Cell('OBUFDS', port_attrs
={'O': ['iopad_external_pin'], 'OB': ['iopad_external_pin']}),
71 Cell('OBUFT', port_attrs
={'O': ['iopad_external_pin']}),
72 Cell('OBUFTDS', port_attrs
={'O': ['iopad_external_pin'], 'OB': ['iopad_external_pin']}),
73 Cell('OSERDES2', port_attrs
={
74 'CLK0': ['clkbuf_sink'],
75 'CLK1': ['clkbuf_sink'],
76 'CLKDIV': ['clkbuf_sink'],
82 #Cell('RAM128X1D', port_attrs={'WCLK': ['clkbuf_sink']}),
83 # NOTE: not in the official library guide!
84 Cell('RAM128X1S', port_attrs
={'WCLK': ['clkbuf_sink']}),
85 Cell('RAM256X1S', port_attrs
={'WCLK': ['clkbuf_sink']}),
86 Cell('RAM32M', port_attrs
={'WCLK': ['clkbuf_sink']}),
87 #Cell('RAM32X1D', port_attrs={'WCLK': ['clkbuf_sink']}),
88 Cell('RAM32X1S', port_attrs
={'WCLK': ['clkbuf_sink']}),
89 Cell('RAM32X1S_1', port_attrs
={'WCLK': ['clkbuf_sink']}),
90 Cell('RAM32X2S', port_attrs
={'WCLK': ['clkbuf_sink']}),
91 Cell('RAM64M', port_attrs
={'WCLK': ['clkbuf_sink']}),
92 #Cell('RAM64X1D', port_attrs={'WCLK': ['clkbuf_sink']}),
93 Cell('RAM64X1S', port_attrs
={'WCLK': ['clkbuf_sink']}),
94 Cell('RAM64X1S_1', port_attrs
={'WCLK': ['clkbuf_sink']}),
95 # NOTE: not in the official library guide!
96 Cell('RAM64X2S', port_attrs
={'WCLK': ['clkbuf_sink']}),
97 # Cell('RAMB8BWER', port_attrs={'CLKAWRCLK': ['clkbuf_sink'], 'CLKBRDCLK': ['clkbuf_sink']}),
98 # Cell('RAMB16BWER', port_attrs={'CLKA': ['clkbuf_sink'], 'CLKB': ['clkbuf_sink']}),
109 Cell('IDDR2', port_attrs
={'C0': ['clkbuf_sink'], 'C1': ['clkbuf_sink']}),
112 Cell('ODDR2', port_attrs
={'C0': ['clkbuf_sink'], 'C1': ['clkbuf_sink']}),
114 # Slice/CLB primitives.
116 Cell('CFGLUT5', port_attrs
={'CLK': ['clkbuf_sink']}),
126 # Cell('SRL16E', port_attrs={'CLK': ['clkbuf_sink']}),
127 # Cell('SRLC32E', port_attrs={'CLK': ['clkbuf_sink']}),
132 # Design elements types listed in Xilinx UG623.
138 # Arithmetic functions.
139 Cell('DSP48E1', port_attrs
={'CLK': ['clkbuf_sink']}),
142 # Cell('BUFG', port_attrs={'O': ['clkbuf_driver']}),
143 Cell('BUFGCE', port_attrs
={'O': ['clkbuf_driver']}),
144 Cell('BUFGCE_1', port_attrs
={'O': ['clkbuf_driver']}),
145 #Cell('BUFGCTRL', port_attrs={'O': ['clkbuf_driver']}),
146 Cell('BUFGMUX', port_attrs
={'O': ['clkbuf_driver']}),
147 Cell('BUFGMUX_1', port_attrs
={'O': ['clkbuf_driver']}),
148 Cell('BUFGMUX_CTRL', port_attrs
={'O': ['clkbuf_driver']}),
149 Cell('BUFH', port_attrs
={'O': ['clkbuf_driver']}),
150 #Cell('BUFHCE', port_attrs={'O': ['clkbuf_driver']}),
151 Cell('BUFIO', port_attrs
={'O': ['clkbuf_driver']}),
152 Cell('BUFIODQS', port_attrs
={'O': ['clkbuf_driver']}),
153 Cell('BUFR', port_attrs
={'O': ['clkbuf_driver']}),
154 Cell('IBUFDS_GTXE1', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
158 # Config/BSCAN components.
159 Cell('BSCAN_VIRTEX6', keep
=True),
160 Cell('CAPTURE_VIRTEX6', keep
=True),
163 Cell('FRAME_ECC_VIRTEX6'),
164 Cell('ICAP_VIRTEX6', keep
=True),
165 Cell('STARTUP_VIRTEX6', keep
=True),
166 Cell('USR_ACCESS_VIRTEX6'),
169 Cell('DCIRESET', keep
=True),
172 # Cell('IBUF', port_attrs={'I': ['iopad_external_pin']}),
173 Cell('IBUFDS', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
174 Cell('IBUFDS_DIFF_OUT', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
175 Cell('IBUFDS_GTHE1', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
176 Cell('IBUFG', port_attrs
={'I': ['iopad_external_pin']}),
177 Cell('IBUFGDS', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
178 Cell('IBUFGDS_DIFF_OUT', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
179 Cell('IDELAYCTRL', keep
=True, port_attrs
={'REFCLK': ['clkbuf_sink']}),
180 Cell('IOBUF', port_attrs
={'IO': ['iopad_external_pin']}),
181 Cell('IOBUFDS', port_attrs
={'IO': ['iopad_external_pin']}),
182 Cell('IODELAYE1', port_attrs
={'C': ['clkbuf_sink']}),
183 Cell('ISERDESE1', port_attrs
={
184 'CLK': ['clkbuf_sink'],
185 'CLKB': ['clkbuf_sink'],
186 'OCLK': ['clkbuf_sink'],
187 'CLKDIV': ['clkbuf_sink'],
190 # Cell('OBUF', port_attrs={'O': ['iopad_external_pin']}),
191 Cell('OBUFDS', port_attrs
={'O': ['iopad_external_pin'], 'OB': ['iopad_external_pin']}),
192 Cell('OBUFT', port_attrs
={'O': ['iopad_external_pin']}),
193 Cell('OBUFTDS', port_attrs
={'O': ['iopad_external_pin'], 'OB': ['iopad_external_pin']}),
194 Cell('OSERDESE1', port_attrs
={'CLK': ['clkbuf_sink'], 'CLKDIV': ['clkbuf_sink']}),
197 Cell('TEMAC_SINGLE'),
200 Cell('FIFO18E1', port_attrs
={'RDCLK': ['clkbuf_sink'], 'WRCLK': ['clkbuf_sink']}),
201 Cell('FIFO36E1', port_attrs
={'RDCLK': ['clkbuf_sink'], 'WRCLK': ['clkbuf_sink']}),
202 #Cell('RAM128X1D', port_attrs={'WCLK': ['clkbuf_sink']}),
203 Cell('RAM128X1S', port_attrs
={'WCLK': ['clkbuf_sink']}),
204 Cell('RAM256X1S', port_attrs
={'WCLK': ['clkbuf_sink']}),
205 Cell('RAM32M', port_attrs
={'WCLK': ['clkbuf_sink']}),
206 #Cell('RAM32X1D', port_attrs={'WCLK': ['clkbuf_sink']}),
207 Cell('RAM32X1S', port_attrs
={'WCLK': ['clkbuf_sink']}),
208 Cell('RAM32X1S_1', port_attrs
={'WCLK': ['clkbuf_sink']}),
209 Cell('RAM32X2S', port_attrs
={'WCLK': ['clkbuf_sink']}),
210 Cell('RAM64M', port_attrs
={'WCLK': ['clkbuf_sink']}),
211 #Cell('RAM64X1D', port_attrs={'WCLK': ['clkbuf_sink']}),
212 Cell('RAM64X1S', port_attrs
={'WCLK': ['clkbuf_sink']}),
213 Cell('RAM64X1S_1', port_attrs
={'WCLK': ['clkbuf_sink']}),
214 # NOTE: not in the official library guide!
215 Cell('RAM64X2S', port_attrs
={'WCLK': ['clkbuf_sink']}),
216 # Cell('RAMB18E1', port_attrs={'CLKARDCLK': ['clkbuf_sink'], 'CLKBWRCLK': ['clkbuf_sink']}),
217 # Cell('RAMB36E1', port_attrs={'CLKARDCLK': ['clkbuf_sink'], 'CLKBWRCLK': ['clkbuf_sink']}),
228 Cell('IDDR', port_attrs
={'C': ['clkbuf_sink']}),
229 Cell('IDDR_2CLK', port_attrs
={'C': ['clkbuf_sink'], 'CB': ['clkbuf_sink']}),
232 Cell('ODDR', port_attrs
={'C': ['clkbuf_sink']}),
234 # Slice/CLB primitives.
236 Cell('CFGLUT5', port_attrs
={'CLK': ['clkbuf_sink']}),
246 # Cell('SRL16E', port_attrs={'CLK': ['clkbuf_sink']}),
247 # Cell('SRLC32E', port_attrs={'CLK': ['clkbuf_sink']}),
252 # Design elements types listed in Xilinx UG953.
255 Cell('GTHE2_CHANNEL'),
256 Cell('GTHE2_COMMON'),
257 Cell('GTPE2_CHANNEL'),
258 Cell('GTPE2_COMMON'),
259 Cell('GTXE2_CHANNEL'),
260 Cell('GTXE2_COMMON'),
265 # Arithmetic functions.
266 Cell('DSP48E1', port_attrs
={'CLK': ['clkbuf_sink']}),
269 # Cell('BUFG', port_attrs={'O': ['clkbuf_driver']}),
270 Cell('BUFGCE', port_attrs
={'O': ['clkbuf_driver']}),
271 Cell('BUFGCE_1', port_attrs
={'O': ['clkbuf_driver']}),
272 #Cell('BUFGCTRL', port_attrs={'O': ['clkbuf_driver']}),
273 Cell('BUFGMUX', port_attrs
={'O': ['clkbuf_driver']}),
274 Cell('BUFGMUX_1', port_attrs
={'O': ['clkbuf_driver']}),
275 Cell('BUFGMUX_CTRL', port_attrs
={'O': ['clkbuf_driver']}),
276 Cell('BUFH', port_attrs
={'O': ['clkbuf_driver']}),
277 #Cell('BUFHCE', port_attrs={'O': ['clkbuf_driver']}),
278 Cell('BUFIO', port_attrs
={'O': ['clkbuf_driver']}),
279 Cell('BUFMR', port_attrs
={'O': ['clkbuf_driver']}),
280 Cell('BUFMRCE', port_attrs
={'O': ['clkbuf_driver']}),
281 Cell('BUFR', port_attrs
={'O': ['clkbuf_driver']}),
287 # Config/BSCAN components.
288 Cell('BSCANE2', keep
=True),
289 Cell('CAPTUREE2', keep
=True),
293 Cell('ICAPE2', keep
=True),
294 Cell('STARTUPE2', keep
=True),
295 Cell('USR_ACCESSE2'),
298 Cell('DCIRESET', keep
=True),
299 # Cell('IBUF', port_attrs={'I': ['iopad_external_pin']}),
300 Cell('IBUF_IBUFDISABLE', port_attrs
={'I': ['iopad_external_pin']}),
301 Cell('IBUF_INTERMDISABLE', port_attrs
={'I': ['iopad_external_pin']}),
302 Cell('IBUFDS', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
303 Cell('IBUFDS_DIFF_OUT', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
304 Cell('IBUFDS_DIFF_OUT_IBUFDISABLE', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
305 Cell('IBUFDS_DIFF_OUT_INTERMDISABLE', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
306 Cell('IBUFDS_GTE2', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
307 Cell('IBUFDS_IBUFDISABLE', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
308 Cell('IBUFDS_INTERMDISABLE', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
309 Cell('IBUFG', port_attrs
={'I': ['iopad_external_pin']}),
310 Cell('IBUFGDS', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
311 Cell('IBUFGDS_DIFF_OUT', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
312 Cell('IDELAYCTRL', keep
=True, port_attrs
={'REFCLK': ['clkbuf_sink']}),
313 Cell('IDELAYE2', port_attrs
={'C': ['clkbuf_sink']}),
314 Cell('IN_FIFO', port_attrs
={'RDCLK': ['clkbuf_sink'], 'WRCLK': ['clkbuf_sink']}),
315 Cell('IOBUF', port_attrs
={'IO': ['iopad_external_pin']}),
316 Cell('IOBUF_DCIEN', port_attrs
={'IO': ['iopad_external_pin']}),
317 Cell('IOBUF_INTERMDISABLE', port_attrs
={'IO': ['iopad_external_pin']}),
318 Cell('IOBUFDS', port_attrs
={'IO': ['iopad_external_pin']}),
319 Cell('IOBUFDS_DCIEN', port_attrs
={'IO': ['iopad_external_pin'], 'IOB': ['iopad_external_pin']}),
320 Cell('IOBUFDS_DIFF_OUT', port_attrs
={'IO': ['iopad_external_pin'], 'IOB': ['iopad_external_pin']}),
321 Cell('IOBUFDS_DIFF_OUT_DCIEN', port_attrs
={'IO': ['iopad_external_pin'], 'IOB': ['iopad_external_pin']}),
322 Cell('IOBUFDS_DIFF_OUT_INTERMDISABLE', port_attrs
={'IO': ['iopad_external_pin'], 'IOB': ['iopad_external_pin']}),
323 Cell('IOBUFDS_INTERMDISABLE', port_attrs
={'IO': ['iopad_external_pin'], 'IOB': ['iopad_external_pin']}),
324 Cell('ISERDESE2', port_attrs
={
325 'CLK': ['clkbuf_sink'],
326 'CLKB': ['clkbuf_sink'],
327 'OCLK': ['clkbuf_sink'],
328 'OCLKB': ['clkbuf_sink'],
329 'CLKDIV': ['clkbuf_sink'],
330 'CLKDIVP': ['clkbuf_sink'],
333 # Cell('OBUF', port_attrs={'O': ['iopad_external_pin']}),
334 Cell('OBUFDS', port_attrs
={'O': ['iopad_external_pin'], 'OB': ['iopad_external_pin']}),
335 Cell('OBUFT', port_attrs
={'O': ['iopad_external_pin']}),
336 Cell('OBUFTDS', port_attrs
={'O': ['iopad_external_pin'], 'OB': ['iopad_external_pin']}),
337 Cell('ODELAYE2', port_attrs
={'C': ['clkbuf_sink']}),
338 Cell('OSERDESE2', port_attrs
={'CLK': ['clkbuf_sink'], 'CLKDIV': ['clkbuf_sink']}),
339 Cell('OUT_FIFO', port_attrs
={'RDCLK': ['clkbuf_sink'], 'WRCLK': ['clkbuf_sink']}),
341 Cell('PHASER_IN_PHY'),
343 Cell('PHASER_OUT_PHY'),
350 Cell('FIFO18E1', port_attrs
={'RDCLK': ['clkbuf_sink'], 'WRCLK': ['clkbuf_sink']}),
351 Cell('FIFO36E1', port_attrs
={'RDCLK': ['clkbuf_sink'], 'WRCLK': ['clkbuf_sink']}),
352 #Cell('RAM128X1D', port_attrs={'WCLK': ['clkbuf_sink']}),
353 Cell('RAM128X1S', port_attrs
={'WCLK': ['clkbuf_sink']}),
354 Cell('RAM256X1S', port_attrs
={'WCLK': ['clkbuf_sink']}),
355 Cell('RAM32M', port_attrs
={'WCLK': ['clkbuf_sink']}),
356 #Cell('RAM32X1D', port_attrs={'WCLK': ['clkbuf_sink']}),
357 Cell('RAM32X1S', port_attrs
={'WCLK': ['clkbuf_sink']}),
358 Cell('RAM32X1S_1', port_attrs
={'WCLK': ['clkbuf_sink']}),
359 Cell('RAM32X2S', port_attrs
={'WCLK': ['clkbuf_sink']}),
360 Cell('RAM64M', port_attrs
={'WCLK': ['clkbuf_sink']}),
361 #Cell('RAM64X1D', port_attrs={'WCLK': ['clkbuf_sink']}),
362 Cell('RAM64X1S', port_attrs
={'WCLK': ['clkbuf_sink']}),
363 Cell('RAM64X1S_1', port_attrs
={'WCLK': ['clkbuf_sink']}),
364 # NOTE: not in the official library guide!
365 Cell('RAM64X2S', port_attrs
={'WCLK': ['clkbuf_sink']}),
366 # Cell('RAMB18E1', port_attrs={'CLKARDCLK': ['clkbuf_sink'], 'CLKBWRCLK': ['clkbuf_sink']}),
367 # Cell('RAMB36E1', port_attrs={'CLKARDCLK': ['clkbuf_sink'], 'CLKBWRCLK': ['clkbuf_sink']}),
378 Cell('IDDR', port_attrs
={'C': ['clkbuf_sink']}),
379 Cell('IDDR_2CLK', port_attrs
={'C': ['clkbuf_sink'], 'CB': ['clkbuf_sink']}),
382 Cell('ODDR', port_attrs
={'C': ['clkbuf_sink']}),
384 # Slice/CLB primitives.
386 Cell('CFGLUT5', port_attrs
={'CLK': ['clkbuf_sink']}),
396 # Cell('SRL16E', port_attrs={'CLK': ['clkbuf_sink']}),
397 # Cell('SRLC32E', port_attrs={'CLK': ['clkbuf_sink']}),
399 # NOTE: not in the official library guide!
400 Cell('PS7', keep
=True),
405 # Design elements types listed in Xilinx UG974.
410 Cell('GTHE3_CHANNEL'),
411 Cell('GTHE3_COMMON'),
412 Cell('GTHE4_CHANNEL'),
413 Cell('GTHE4_COMMON'),
414 Cell('GTYE3_CHANNEL'),
415 Cell('GTYE3_COMMON'),
416 Cell('GTYE4_CHANNEL'),
417 Cell('GTYE4_COMMON'),
418 Cell('IBUFDS_GTE3', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
419 Cell('IBUFDS_GTE4', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
422 Cell('OBUFDS_GTE3', port_attrs
={'O': ['iopad_external_pin'], 'OB': ['iopad_external_pin']}),
423 Cell('OBUFDS_GTE3_ADV', port_attrs
={'O': ['iopad_external_pin'], 'OB': ['iopad_external_pin']}),
424 Cell('OBUFDS_GTE4', port_attrs
={'O': ['iopad_external_pin'], 'OB': ['iopad_external_pin']}),
425 Cell('OBUFDS_GTE4_ADV', port_attrs
={'O': ['iopad_external_pin'], 'OB': ['iopad_external_pin']}),
431 # Arithmetic functions.
432 Cell('DSP48E2', port_attrs
={'CLK': ['clkbuf_sink']}),
435 Cell('FIFO18E2', port_attrs
={'RDCLK': ['clkbuf_sink'], 'WRCLK': ['clkbuf_sink']}),
436 Cell('FIFO36E2', port_attrs
={'RDCLK': ['clkbuf_sink'], 'WRCLK': ['clkbuf_sink']}),
437 Cell('RAMB18E2', port_attrs
={'CLKARDCLK': ['clkbuf_sink'], 'CLKBWRCLK': ['clkbuf_sink']}),
438 Cell('RAMB36E2', port_attrs
={'CLKARDCLK': ['clkbuf_sink'], 'CLKBWRCLK': ['clkbuf_sink']}),
439 Cell('URAM288', port_attrs
={'CLK': ['clkbuf_sink']}),
440 Cell('URAM288_BASE', port_attrs
={'CLK': ['clkbuf_sink']}),
444 #Cell('RAM128X1D', port_attrs={'WCLK': ['clkbuf_sink']}),
445 Cell('RAM128X1S', port_attrs
={'WCLK': ['clkbuf_sink']}),
446 Cell('RAM256X1D', port_attrs
={'WCLK': ['clkbuf_sink']}),
447 Cell('RAM256X1S', port_attrs
={'WCLK': ['clkbuf_sink']}),
448 Cell('RAM32M', port_attrs
={'WCLK': ['clkbuf_sink']}),
449 Cell('RAM32M16', port_attrs
={'WCLK': ['clkbuf_sink']}),
450 #Cell('RAM32X1D', port_attrs={'WCLK': ['clkbuf_sink']}),
451 Cell('RAM32X1S', port_attrs
={'WCLK': ['clkbuf_sink']}),
452 Cell('RAM512X1S', port_attrs
={'WCLK': ['clkbuf_sink']}),
453 Cell('RAM64M', port_attrs
={'WCLK': ['clkbuf_sink']}),
454 Cell('RAM64M8', port_attrs
={'WCLK': ['clkbuf_sink']}),
455 #Cell('RAM64X1D', port_attrs={'WCLK': ['clkbuf_sink']}),
456 Cell('RAM64X1S', port_attrs
={'WCLK': ['clkbuf_sink']}),
459 Cell('CFGLUT5', port_attrs
={'CLK': ['clkbuf_sink']}),
470 # Cell('SRL16E', port_attrs={'CLK': ['clkbuf_sink']}),
471 # Cell('SRLC32E', port_attrs={'CLK': ['clkbuf_sink']}),
474 # Cell('BUFG', port_attrs={'O': ['clkbuf_driver']}),
475 Cell('BUFG_GT', port_attrs
={'O': ['clkbuf_driver']}),
476 Cell('BUFG_GT_SYNC'),
477 Cell('BUFG_PS', port_attrs
={'O': ['clkbuf_driver']}),
478 Cell('BUFGCE', port_attrs
={'O': ['clkbuf_driver']}),
479 Cell('BUFGCE_1', port_attrs
={'O': ['clkbuf_driver']}),
480 Cell('BUFGCE_DIV', port_attrs
={'O': ['clkbuf_driver']}),
481 #Cell('BUFGCTRL', port_attrs={'O': ['clkbuf_driver']}),
482 Cell('BUFGMUX', port_attrs
={'O': ['clkbuf_driver']}),
483 Cell('BUFGMUX_1', port_attrs
={'O': ['clkbuf_driver']}),
484 Cell('BUFGMUX_CTRL', port_attrs
={'O': ['clkbuf_driver']}),
495 Cell('BSCANE2', keep
=True),
499 Cell('ICAPE3', keep
=True),
500 Cell('MASTER_JTAG', keep
=True),
501 Cell('STARTUPE3', keep
=True),
502 Cell('USR_ACCESSE2'),
505 Cell('BITSLICE_CONTROL', keep
=True),
506 Cell('DCIRESET', keep
=True),
509 # Cell('IBUF', port_attrs={'I': ['iopad_external_pin']}),
510 Cell('IBUF_ANALOG', port_attrs
={'I': ['iopad_external_pin']}),
511 Cell('IBUF_IBUFDISABLE', port_attrs
={'I': ['iopad_external_pin']}),
512 Cell('IBUF_INTERMDISABLE', port_attrs
={'I': ['iopad_external_pin']}),
513 Cell('IBUFDS', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
514 Cell('IBUFDS_DIFF_OUT', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
515 Cell('IBUFDS_DIFF_OUT_IBUFDISABLE', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
516 Cell('IBUFDS_DIFF_OUT_INTERMDISABLE', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
517 Cell('IBUFDS_DPHY', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
518 Cell('IBUFDS_IBUFDISABLE', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
519 Cell('IBUFDS_INTERMDISABLE', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
520 Cell('IBUFDSE3', port_attrs
={'I': ['iopad_external_pin'], 'IB': ['iopad_external_pin']}),
521 Cell('IBUFE3', port_attrs
={'I': ['iopad_external_pin']}),
522 Cell('IDELAYCTRL', keep
=True, port_attrs
={'REFCLK': ['clkbuf_sink']}),
523 Cell('IDELAYE3', port_attrs
={'CLK': ['clkbuf_sink']}),
524 Cell('IOBUF', port_attrs
={'IO': ['iopad_external_pin']}),
525 Cell('IOBUF_DCIEN', port_attrs
={'IO': ['iopad_external_pin']}),
526 Cell('IOBUF_INTERMDISABLE', port_attrs
={'IO': ['iopad_external_pin']}),
527 Cell('IOBUFDS', port_attrs
={'IO': ['iopad_external_pin']}),
528 Cell('IOBUFDS_DCIEN', port_attrs
={'IO': ['iopad_external_pin'], 'IOB': ['iopad_external_pin']}),
529 Cell('IOBUFDS_DIFF_OUT', port_attrs
={'IO': ['iopad_external_pin'], 'IOB': ['iopad_external_pin']}),
530 Cell('IOBUFDS_DIFF_OUT_DCIEN', port_attrs
={'IO': ['iopad_external_pin'], 'IOB': ['iopad_external_pin']}),
531 Cell('IOBUFDS_DIFF_OUT_INTERMDISABLE', port_attrs
={'IO': ['iopad_external_pin'], 'IOB': ['iopad_external_pin']}),
532 Cell('IOBUFDS_INTERMDISABLE', port_attrs
={'IO': ['iopad_external_pin'], 'IOB': ['iopad_external_pin']}),
533 Cell('IOBUFDSE3', port_attrs
={'IO': ['iopad_external_pin']}),
534 Cell('IOBUFE3', port_attrs
={'IO': ['iopad_external_pin']}),
535 Cell('ISERDESE3', port_attrs
={
536 'CLK': ['clkbuf_sink'],
537 'CLK_B': ['clkbuf_sink'],
538 'FIFO_RD_CLK': ['clkbuf_sink'],
539 'CLKDIV': ['clkbuf_sink'],
542 # Cell('OBUF', port_attrs={'O': ['iopad_external_pin']}),
543 Cell('OBUFDS', port_attrs
={'O': ['iopad_external_pin'], 'OB': ['iopad_external_pin']}),
544 Cell('OBUFDS_DPHY', port_attrs
={'O': ['iopad_external_pin'], 'OB': ['iopad_external_pin']}),
545 Cell('OBUFT', port_attrs
={'O': ['iopad_external_pin']}),
546 Cell('OBUFTDS', port_attrs
={'O': ['iopad_external_pin'], 'OB': ['iopad_external_pin']}),
547 Cell('ODELAYE3', port_attrs
={'CLK': ['clkbuf_sink']}),
548 Cell('OSERDESE3', port_attrs
={'CLK': ['clkbuf_sink'], 'CLKDIV': ['clkbuf_sink']}),
553 Cell('RXTX_BITSLICE'),
555 Cell('TX_BITSLICE_TRI'),
562 Cell('HARD_SYNC', port_attrs
={'CLK': ['clkbuf_sink']}),
563 Cell('IDDRE1', port_attrs
={'C': ['clkbuf_sink'], 'CB': ['clkbuf_sink']}),
566 Cell('ODDRE1', port_attrs
={'C': ['clkbuf_sink']}),
568 # NOTE: not in the official library guide!
569 Cell('PS8', keep
=True),
576 IN_OTHER_MODULE
= auto()
580 def xtract_cell_decl(cell
, dirs
, outf
):
582 fname
= os
.path
.join(dir, cell
.name
+ '.v')
584 with
open(fname
) as f
:
585 state
= State
.OUTSIDE
587 # Probably the most horrible Verilog "parser" ever written.
589 l
= l
.partition('//')[0]
591 if l
== 'module {}'.format(cell
.name
) or l
.startswith('module {} '.format(cell
.name
)):
593 print('Multiple modules in {}.'.format(fname
))
595 elif state
!= State
.OUTSIDE
:
596 print('Nested modules in {}.'.format(fname
))
599 state
= State
.IN_MODULE
601 outf
.write('(* keep *)\n')
602 outf
.write('module {} (...);\n'.format(cell
.name
))
603 elif l
.startswith('module '):
604 if state
!= State
.OUTSIDE
:
605 print('Nested modules in {}.'.format(fname
))
607 state
= State
.IN_OTHER_MODULE
608 elif l
.startswith('task '):
609 if state
== State
.IN_MODULE
:
610 state
= State
.IN_TASK
611 elif l
.startswith('function '):
612 if state
== State
.IN_MODULE
:
613 state
= State
.IN_FUNCTION
615 if state
== State
.IN_TASK
:
616 state
= State
.IN_MODULE
617 elif l
== 'endfunction':
618 if state
== State
.IN_FUNCTION
:
619 state
= State
.IN_MODULE
620 elif l
== 'endmodule':
621 if state
== State
.IN_MODULE
:
624 elif state
!= State
.IN_OTHER_MODULE
:
625 print('endmodule in weird place in {}.'.format(cell
.name
, fname
))
627 state
= State
.OUTSIDE
628 elif l
.startswith(('input ', 'output ', 'inout ')) and state
== State
.IN_MODULE
:
629 if l
.endswith((';', ',')):
632 print('Weird port line in {} [{}].'.format(fname
, l
))
634 kind
, _
, ports
= l
.partition(' ')
635 for port
in ports
.split(','):
637 for attr
in cell
.port_attrs
.get(port
, []):
638 outf
.write(' (* {} *)\n'.format(attr
))
639 outf
.write(' {} {};\n'.format(kind
, port
))
640 elif l
.startswith('parameter ') and state
== State
.IN_MODULE
:
643 if l
.endswith((';', ',')):
646 l
= l
.replace(' ', ' ')
648 print('Weird parameter line in {} [{}].'.format(fname
, l
))
650 outf
.write(' {};\n'.format(l
))
651 if state
!= State
.OUTSIDE
:
652 print('endmodule not found in {}.'.format(fname
))
655 print('Cannot find module {} in {}.'.format(cell
.name
, fname
))
658 except FileNotFoundError
:
660 print('Cannot find {}.'.format(cell
.name
))
663 if __name__
== '__main__':
664 parser
= ArgumentParser(description
='Extract Xilinx blackbox cell definitions from ISE and Vivado.')
665 parser
.add_argument('vivado_dir', nargs
='?', default
='/opt/Xilinx/Vivado/2018.1')
666 parser
.add_argument('ise_dir', nargs
='?', default
='/opt/Xilinx/ISE/14.7')
667 args
= parser
.parse_args()
670 os
.path
.join(args
.vivado_dir
, 'data/verilog/src/xeclib'),
671 os
.path
.join(args
.vivado_dir
, 'data/verilog/src/retarget'),
672 os
.path
.join(args
.ise_dir
, 'ISE_DS/ISE/verilog/xeclib/unisims'),
675 if not os
.path
.isdir(dir):
676 print('{} is not a directory'.format(dir))
678 for ofile
, cells
in [
679 ('xc6s_cells_xtra.v', XC6S_CELLS
),
680 ('xc6v_cells_xtra.v', XC6V_CELLS
),
681 ('xc7_cells_xtra.v', XC7_CELLS
),
682 ('xcu_cells_xtra.v', XCU_CELLS
),
686 xtract_cell_decl(cell
, dirs
, out
)
688 with
open(ofile
, 'w') as f
:
689 f
.write('// Created by cells_xtra.py from Xilinx models\n')
691 f
.write(out
.getvalue())