-
Notifications
You must be signed in to change notification settings - Fork 1
/
DataPathAnalysis.py
44 lines (35 loc) · 1.4 KB
/
DataPathAnalysis.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# This file is part of GenMap and released under the MIT License, see LICENSE.
# Author: Takuya Kojima
from PEArrayModel import PEArrayModel
from Individual import Individual
import networkx as nx
class DataPathAnalysis():
@staticmethod
def get_data_path(CGRA, individual):
"""Analyzes data path on the PE array.
Args:
CGRA (PEArrayModel): A model of the CGRA
individual (Individual): An individual to be evaluated
Returns:
list: list of path(networkx)
"""
# data path analysis
graph = individual.routed_graph
used_inports = set(graph.nodes()) & set(CGRA.getInputPorts())
used_outports = set(graph.nodes()) & set(CGRA.getOutputPorts())
paths = []
for i_port in used_inports:
for o_port in used_outports:
paths.extend([p[1:-1] for p in nx.all_simple_paths(graph, i_port, o_port)])
# path separation by activate pipeline register
if CGRA.getPregNumber() != 0:
data_path = []
st_domain = CGRA.getStageDomains(individual.preg)
for p in paths:
for stage in st_domain:
dp = sorted(set(p) & set(stage), key=p.index)
if not dp in data_path:
data_path.append(dp)
else:
data_path = paths
return data_path