Commit 937762d7f07da10ff33c742f216b6ef0e5a01adc

Authored by Brice Colombier
1 parent c179eab2f9
Exists in master

Added an option to modify the graph or return the list of nodes to mask

Showing 2 changed files with 13 additions and 21 deletions

1 1 *.pyc
  2 +parsers/
  3 +test.py
  4 +benchmarks/
... ... @@ -14,19 +14,6 @@
14 14 Last update: 2015-03-17
15 15 """
16 16  
17   -import sys
18   -sys.path.append("../Designs/Demonstrator/Parsers/")
19   -
20   -import build_bench
21   -import build_blif
22   -import build_edif
23   -import build_slif
24   -import build_verilog_rtl
25   -import build_verilog_struct
26   -import build_vhd_rtl
27   -import build_vhd_struct
28   -import build_xilinx
29   -
30 17 import random
31 18 import networkx as nx
32 19 import igraph
... ... @@ -40,7 +27,7 @@
40 27  
41 28 import numpy as np
42 29  
43   -def masking(g, name, prim_in, prim_out, nodes, overhead, heuristic):
  30 +def masking(g, name, prim_in, prim_out, nodes, overhead, heuristic, mod=True):
44 31  
45 32 h = g.copy() #Perform deep copy
46 33 key_size = int(len(nodes)*overhead)
47 34  
... ... @@ -62,13 +49,15 @@
62 49 list_nodes_to_mask = heuristic_current_flow_betweenness.heuristic_current_flow_betweenness(g_nx, key_size)
63 50 else:
64 51 raise ValueError("Unknown heuristic")
65   -
66   - masking_key = []
67   - for i in list_nodes_to_mask:
68   - masking_key.append(random.randint(0, 1))
69   - h = modify_nodes_mask.modify_nodes_mask(h, list_nodes_to_mask, masking_key)
70 52  
71   - return h, masking_key
  53 + if mod:
  54 + masking_key = []
  55 + for i in list_nodes_to_mask:
  56 + masking_key.append(random.randint(0, 1))
  57 + h = modify_nodes_mask.modify_nodes_mask(h, list_nodes_to_mask, masking_key)
  58 + return h, masking_key
  59 + else:
  60 + return list_nodes_to_mask
72 61  
73 62 if __name__ == "__main__":
74 63 for name in ["c3540"]: