Skip to content

Commit b5867ae

Browse files
committed
vtr_flow: added tiles step to upgrade arch
Signed-off-by: Alessandro Comodi <[email protected]>
1 parent dc1cd4a commit b5867ae

File tree

2 files changed

+102
-56
lines changed

2 files changed

+102
-56
lines changed

vtr_flow/scripts/add_tiles.py

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -43,49 +43,6 @@
4343
</complexblocklist>
4444
"""
4545

46-
"""
47-
This script is intended to modify the architecture description file to be compliant with
48-
the new format.
49-
50-
It moves the top level pb_types attributes and tags to the tiles high-level tag.
51-
52-
BEFORE:
53-
<complexblocklist>
54-
<pb_type name="BRAM" area="2" height="4" width="1" capacity="1">
55-
<input ... />
56-
<input ... />
57-
<input ... />
58-
<output ... />
59-
<output ... />
60-
<output ... />
61-
<interconnect ... />
62-
<fc ... />
63-
<pinlocations ... />
64-
<switchblock_locations ... />
65-
</pb_type>
66-
</complexblocklist>
67-
68-
AFTER:
69-
<tiles>
70-
<tile name="BRAM" area="2" height="4" width="1" capacity="1">
71-
<interconnect ... />
72-
<fc ... />
73-
<pinlocations ... />
74-
<switchblock_locations ... />
75-
</tile>
76-
</tiles>
77-
<complexblocklist
78-
<pb_type name="BRAM">
79-
<input ... />
80-
<input ... />
81-
<input ... />
82-
<output ... />
83-
<output ... />
84-
<output ... />
85-
</pb_type>
86-
</complexblocklist>
87-
"""
88-
8946
from lxml import etree as ET
9047
import argparse
9148

vtr_flow/scripts/upgrade_arch.py

Lines changed: 102 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def __init__(self):
3939
"upgrade_port_equivalence",
4040
"upgrade_complex_sb_num_conns",
4141
"add_missing_comb_model_internal_timing_edges",
42+
"move_top_level_pb_type_to_tiles",
4243
]
4344

4445
def parse_args():
@@ -137,6 +138,11 @@ def main():
137138
if result:
138139
modified = True
139140

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+
140146
if modified:
141147
if args.debug:
142148
root.write(sys.stdout, pretty_print=args.pretty)
@@ -155,7 +161,7 @@ def add_model_timing(arch):
155161
#Find all primitive pb types
156162
prim_pbs = arch.findall(".//pb_type[@blif_model]")
157163

158-
#Build up the timing specifications from
164+
#Build up the timing specifications from
159165
default_models = frozenset([".input", ".output", ".latch", ".names"])
160166
primitive_timing_specs = {}
161167
for prim_pb in prim_pbs:
@@ -237,7 +243,7 @@ def upgrade_fc_overrides(arch):
237243
port = old_pin_override.attrib['name']
238244
fc_type = old_pin_override.attrib['fc_type']
239245
fc_val = old_pin_override.attrib['fc_val']
240-
246+
241247
fc_tag.remove(old_pin_override)
242248

243249
new_attrib = OrderedDict()
@@ -285,7 +291,7 @@ def upgrade_fc_overrides(arch):
285291
new_attrib["fc_val"] = out_val
286292

287293
fc_override = ET.SubElement(fc_tag, "fc_override", attrib=new_attrib)
288-
294+
289295
changed = True
290296
return changed
291297

@@ -350,7 +356,7 @@ def upgrade_device_layout(arch):
350356
device_auto.attrib['height'] = height
351357
else:
352358
assert False, "Unrecognized <layout> specification"
353-
359+
354360
if 0:
355361
for type, locs in type_to_grid_specs.iteritems():
356362
print "Type:", type
@@ -370,7 +376,7 @@ def upgrade_device_layout(arch):
370376
device_auto.text = "\n" + 2*INDENT
371377
device_auto.tail = "\n"
372378

373-
379+
374380
for type_name, locs in type_to_grid_specs.iteritems():
375381
for loc in locs:
376382
assert loc.tag == "loc"
@@ -408,8 +414,8 @@ def upgrade_device_layout(arch):
408414
col_spec.attrib['priority'] = str(priority)
409415
col_spec.tail = "\n" + 2*INDENT
410416

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
413419
#location information, but of type 'EMPTY' and with slightly lower priority than the real type.
414420

415421
col_empty_spec = ET.SubElement(device_auto, 'col')
@@ -451,8 +457,8 @@ def upgrade_device_layout(arch):
451457
col_spec.attrib['priority'] = str(priority)
452458
col_spec.tail = "\n" + 2*INDENT
453459

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
456462
#location information, but of type 'EMPTY' and with slightly lower priority than the real type.
457463
col_empty_spec = ET.SubElement(device_auto, 'col')
458464
col_empty_spec.attrib['type'] = "EMPTY"
@@ -496,7 +502,7 @@ def upgrade_device_layout(arch):
496502
assert False, "Unrecognzied <loc> type tag {}".format(loc_type)
497503

498504
return changed
499-
505+
500506
def remove_io_chan_distr(arch):
501507
"""
502508
Removes the legacy '<io>' channel width distribution tags
@@ -631,7 +637,7 @@ def upgrade_connection_block_input_switch(arch):
631637
#
632638
#Create the switch
633639
#
634-
640+
635641
switch_name = "ipin_cblock"
636642

637643
#Make sure the switch name doesn't already exist
@@ -673,7 +679,7 @@ def upgrade_switch_types(arch):
673679
assert switchlist_tag is not None
674680

675681
for switch_tag in switchlist_tag.findall("./switch"):
676-
682+
677683
switch_type = switch_tag.attrib['type']
678684

679685
if switch_type in ['buffered', 'pass_trans']:
@@ -710,7 +716,7 @@ def rename_fc_attributes(arch):
710716
def remove_longline_sb_cb(arch):
711717
"""
712718
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
714720
populations
715721
"""
716722

@@ -867,5 +873,88 @@ def add_missing_comb_model_internal_timing_edges(arch):
867873

868874
return changed
869875

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+
870959
if __name__ == "__main__":
871960
main()

0 commit comments

Comments
 (0)