-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path00_stat_aig.py
More file actions
45 lines (38 loc) · 1.52 KB
/
00_stat_aig.py
File metadata and controls
45 lines (38 loc) · 1.52 KB
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
44
45
import os
import numpy as np
import random
import glob
import re
import time
import utils.aiger_utils as aiger_utils
import utils.circuit_utils as circuit_utils
from utils.utils import hash_arr, run_command
aig_dir = './data/raw_aig'
if __name__ == '__main__':
f = open('stat_aig.csv', 'w')
f.write('Design,Module,Succ,Input,Output,Lat,And,Lev\n')
no_circuits = 0
for aig_path in glob.glob(os.path.join(aig_dir, '*/*.aig')):
arr = aig_path.replace('.aig', '').split('/')
design_name = arr[-2]
module_name = arr[-1]
aig_name = '{}/{}'.format(design_name, module_name)
abc_cmd = 'abc -c \"read {}; print_stats;\"'.format(aig_path)
stdout, runtime = run_command(abc_cmd)
no_circuits += 1
print('Circuit: {}, No. Circuits: {}'.format(aig_name, no_circuits))
# Parse
pattern = r"i/o\s*=\s*(\d+)/\s*(\d+)\s*lat\s*=\s*(\d+)\s*and\s*=\s*(\d+)\s*lev\s*=\s*(\d+)"
matches = re.search(pattern, stdout[-2])
if matches:
input_var = int(matches.group(1))
output_var = int(matches.group(2))
lat_var = int(matches.group(3))
and_var = int(matches.group(4))
lev_var = int(matches.group(5))
f.write('{},{},1,{},{},{},{},{}\n'.format(
design_name, module_name, input_var, output_var, lat_var, and_var, lev_var
))
else:
f.write('{},{},0,0,0,0,0,0\n'.format(design_name, module_name))
f.close()