@@ -39,6 +39,7 @@ def __init__(self):
39
39
"upgrade_port_equivalence" ,
40
40
"upgrade_complex_sb_num_conns" ,
41
41
"add_missing_comb_model_internal_timing_edges" ,
42
+ "move_top_level_pb_type_to_tiles" ,
42
43
]
43
44
44
45
def parse_args ():
@@ -137,6 +138,11 @@ def main():
137
138
if result :
138
139
modified = True
139
140
141
+ if "move_top_level_pb_type_to_tiles" in args .features :
142
+ result = move_top_level_pb_type_to_tiles (arch )
143
+ if result :
144
+ modified = True
145
+
140
146
if modified :
141
147
if args .debug :
142
148
root .write (sys .stdout , pretty_print = args .pretty )
@@ -155,7 +161,7 @@ def add_model_timing(arch):
155
161
#Find all primitive pb types
156
162
prim_pbs = arch .findall (".//pb_type[@blif_model]" )
157
163
158
- #Build up the timing specifications from
164
+ #Build up the timing specifications from
159
165
default_models = frozenset ([".input" , ".output" , ".latch" , ".names" ])
160
166
primitive_timing_specs = {}
161
167
for prim_pb in prim_pbs :
@@ -237,7 +243,7 @@ def upgrade_fc_overrides(arch):
237
243
port = old_pin_override .attrib ['name' ]
238
244
fc_type = old_pin_override .attrib ['fc_type' ]
239
245
fc_val = old_pin_override .attrib ['fc_val' ]
240
-
246
+
241
247
fc_tag .remove (old_pin_override )
242
248
243
249
new_attrib = OrderedDict ()
@@ -285,7 +291,7 @@ def upgrade_fc_overrides(arch):
285
291
new_attrib ["fc_val" ] = out_val
286
292
287
293
fc_override = ET .SubElement (fc_tag , "fc_override" , attrib = new_attrib )
288
-
294
+
289
295
changed = True
290
296
return changed
291
297
@@ -350,7 +356,7 @@ def upgrade_device_layout(arch):
350
356
device_auto .attrib ['height' ] = height
351
357
else :
352
358
assert False , "Unrecognized <layout> specification"
353
-
359
+
354
360
if 0 :
355
361
for type , locs in type_to_grid_specs .iteritems ():
356
362
print "Type:" , type
@@ -370,7 +376,7 @@ def upgrade_device_layout(arch):
370
376
device_auto .text = "\n " + 2 * INDENT
371
377
device_auto .tail = "\n "
372
378
373
-
379
+
374
380
for type_name , locs in type_to_grid_specs .iteritems ():
375
381
for loc in locs :
376
382
assert loc .tag == "loc"
@@ -408,8 +414,8 @@ def upgrade_device_layout(arch):
408
414
col_spec .attrib ['priority' ] = str (priority )
409
415
col_spec .tail = "\n " + 2 * INDENT
410
416
411
- #Classic VPR fills blank spaces (e.g. where a height > 1 block won't fit) with "EMPTY"
412
- #instead of with the underlying type. To replicate that we create a col spec with the same
417
+ #Classic VPR fills blank spaces (e.g. where a height > 1 block won't fit) with "EMPTY"
418
+ #instead of with the underlying type. To replicate that we create a col spec with the same
413
419
#location information, but of type 'EMPTY' and with slightly lower priority than the real type.
414
420
415
421
col_empty_spec = ET .SubElement (device_auto , 'col' )
@@ -451,8 +457,8 @@ def upgrade_device_layout(arch):
451
457
col_spec .attrib ['priority' ] = str (priority )
452
458
col_spec .tail = "\n " + 2 * INDENT
453
459
454
- #Classic VPR fills blank spaces (e.g. where a height > 1 block won't fit) with "EMPTY"
455
- #instead of with the underlying type. To replicate that we create a col spec with the same
460
+ #Classic VPR fills blank spaces (e.g. where a height > 1 block won't fit) with "EMPTY"
461
+ #instead of with the underlying type. To replicate that we create a col spec with the same
456
462
#location information, but of type 'EMPTY' and with slightly lower priority than the real type.
457
463
col_empty_spec = ET .SubElement (device_auto , 'col' )
458
464
col_empty_spec .attrib ['type' ] = "EMPTY"
@@ -496,7 +502,7 @@ def upgrade_device_layout(arch):
496
502
assert False , "Unrecognzied <loc> type tag {}" .format (loc_type )
497
503
498
504
return changed
499
-
505
+
500
506
def remove_io_chan_distr (arch ):
501
507
"""
502
508
Removes the legacy '<io>' channel width distribution tags
@@ -631,7 +637,7 @@ def upgrade_connection_block_input_switch(arch):
631
637
#
632
638
#Create the switch
633
639
#
634
-
640
+
635
641
switch_name = "ipin_cblock"
636
642
637
643
#Make sure the switch name doesn't already exist
@@ -673,7 +679,7 @@ def upgrade_switch_types(arch):
673
679
assert switchlist_tag is not None
674
680
675
681
for switch_tag in switchlist_tag .findall ("./switch" ):
676
-
682
+
677
683
switch_type = switch_tag .attrib ['type' ]
678
684
679
685
if switch_type in ['buffered' , 'pass_trans' ]:
@@ -710,7 +716,7 @@ def rename_fc_attributes(arch):
710
716
def remove_longline_sb_cb (arch ):
711
717
"""
712
718
Drops <sb> and <cb> of any <segment> types with length="longline",
713
- since we now assume longlines have full switch block/connection block
719
+ since we now assume longlines have full switch block/connection block
714
720
populations
715
721
"""
716
722
@@ -867,5 +873,88 @@ def add_missing_comb_model_internal_timing_edges(arch):
867
873
868
874
return changed
869
875
876
+ def move_top_level_pb_type_to_tiles (arch ):
877
+ """
878
+ This script is intended to modify the architecture description file to be compliant with
879
+ the new format.
880
+
881
+ It moves the top level pb_types attributes and tags to the tiles high-level tag.
882
+
883
+ BEFORE:
884
+ <complexblocklist>
885
+ <pb_type name="BRAM" area="2" height="4" width="1" capacity="1">
886
+ <input ... />
887
+ <input ... />
888
+ <input ... />
889
+ <output ... />
890
+ <output ... />
891
+ <output ... />
892
+ <interconnect ... />
893
+ <fc ... />
894
+ <pinlocations ... />
895
+ <switchblock_locations ... />
896
+ </pb_type>
897
+ </complexblocklist>
898
+
899
+ AFTER:
900
+ <tiles>
901
+ <tile name="BRAM" area="2" height="4" width="1" capacity="1">
902
+ <interconnect ... />
903
+ <fc ... />
904
+ <pinlocations ... />
905
+ <switchblock_locations ... />
906
+ </tile>
907
+ </tiles>
908
+ <complexblocklist
909
+ <pb_type name="BRAM">
910
+ <input ... />
911
+ <input ... />
912
+ <input ... />
913
+ <output ... />
914
+ <output ... />
915
+ <output ... />
916
+ </pb_type>
917
+ </complexblocklist>
918
+ """
919
+
920
+ changed = False
921
+
922
+ TAGS_TO_SWAP = ['fc' , 'pinlocations' , 'switchblock_locations' ]
923
+ ATTR_TO_REMOVE = ['area' , 'height' , 'width' , 'capacity' ]
924
+
925
+ def swap_tags (tile , pb_type ):
926
+ # Moving tags from top level pb_type to tile
927
+ for child in pb_type :
928
+ if child .tag in TAGS_TO_SWAP :
929
+ pb_type .remove (child )
930
+ tile .append (child )
931
+
932
+ tiles = arch .find ('tiles' )
933
+
934
+ if tiles is None :
935
+ tiles = ET .SubElement (arch , 'tiles' )
936
+
937
+ top_pb_types = []
938
+ for pb_type in arch .iter ('pb_type' ):
939
+ if pb_type .getparent ().tag == 'complexblocklist' :
940
+ top_pb_types .append (pb_type )
941
+
942
+ for pb_type in top_pb_types :
943
+ tile = ET .SubElement (tiles , 'tile' )
944
+ attrs = pb_type .attrib
945
+
946
+ for attr in attrs :
947
+ tile .set (attr , pb_type .get (attr ))
948
+
949
+ # Remove attributes of top level pb_types only
950
+ for attr in ATTR_TO_REMOVE :
951
+ pb_type .attrib .pop (attr , None )
952
+
953
+ swap_tags (tile , pb_type )
954
+
955
+ changed = True
956
+
957
+ return changed
958
+
870
959
if __name__ == "__main__" :
871
960
main ()
0 commit comments