Skip to content

Commit 2aebf53

Browse files
committed
temp(graph): fix the pblock-related methods
1 parent 5633cb6 commit 2aebf53

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

src/autobridge/Opt/DataflowGraph.py

+20-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
22
import math
3+
import re
34
from typing import Dict
45

56
from autobridge.HLSParser.vivado_hls.TopRTLParser import TopRTLParser
@@ -52,7 +53,7 @@ def getSRLFIFOArea(self, skip_balance_part: bool) -> Dict[str, int]:
5253
'URAM': 0,
5354
'FF': 0,
5455
'LUT': 0
55-
}
56+
}
5657

5758
if not skip_balance_part:
5859
fifo_depth += self.added_depth_for_rebalance
@@ -102,6 +103,7 @@ def __init__(self, type:str, name : str):
102103
self.name = name
103104
self.id = self.type + self.name
104105
self.area = {} # str_name -> count
106+
self.pblock = ''
105107

106108
def __hash__(self):
107109
return hash(self.id)
@@ -114,10 +116,10 @@ def getEdgeNames(self):
114116

115117
def getEdges(self):
116118
return self.in_edges + self.out_edges
117-
119+
118120
def getInEdges(self):
119121
return self.in_edges
120-
122+
121123
def getOutEdges(self):
122124
return self.out_edges
123125

@@ -136,13 +138,24 @@ def getVertexAndInboundFIFOArea(self) -> Dict[str, int]:
136138
return {
137139
item: sum(e.getArea()[item] for e in self.in_edges) + val for item, val in self.area.items()
138140
}
139-
141+
140142
def assign_pblock(self, pblock: str) -> None:
143+
# FIXME: temp fix for tapa
144+
if pblock == 'COARSE_X1Y0':
145+
pblock = 'CLOCKREGION_X4Y0:CLOCKREGION_X7Y3'
146+
elif pblock == 'COARSE_X0Y0':
147+
pblock = 'CLOCKREGION_X0Y0:CLOCKREGION_X3Y3'
148+
149+
match = re.search(r'^CLOCKREGION_X(\d+)Y(\d+)[ ]*:[ ]*CLOCKREGION_X(\d+)Y(\d+)$', pblock)
150+
assert match, f'incorrect pblock {pblock}'
141151
self.pblock = pblock
142152

143153
def get_pblock(self) -> str:
144154
return self.pblock
145155

156+
def is_assigned_to_pblock(self) -> bool:
157+
return self.pblock != ''
158+
146159

147160
class DataflowGraph:
148161
def __init__(self, hls_prj_manager : HLSProjectManager, top_rtl_parser : TopRTLParser):
@@ -159,7 +172,7 @@ def __init__(self, hls_prj_manager : HLSProjectManager, top_rtl_parser : TopRTLP
159172
self.__initEdges(e_node)
160173

161174
self.__linkEdgeAndVertex()
162-
175+
163176
self.__checker()
164177

165178
self.v_type_2_int = {} # map each vertex type to an integer
@@ -168,7 +181,7 @@ def __init__(self, hls_prj_manager : HLSProjectManager, top_rtl_parser : TopRTLP
168181
self.int_2_v_name = {}
169182
self.__initVTypeToInt()
170183
self.__initVInstToInt()
171-
184+
172185
# assign an integer to v type
173186
def __initVTypeToInt(self):
174187
id = 1
@@ -224,7 +237,7 @@ def __initVertices(self, v_node):
224237

225238
# get area
226239
v.area = self.hls_prj_manager.getAreaFromModuleType(v.type)
227-
240+
228241
v.in_edge_names = self.top_rtl_parser.getInFIFOsOfModuleInst(v.name)
229242
v.out_edge_names = self.top_rtl_parser.getOutFIFOsOfModuleInst(v.name)
230243

0 commit comments

Comments
 (0)