-
Notifications
You must be signed in to change notification settings - Fork 0
/
bsg_fakeram_gen.py
46 lines (35 loc) · 1.3 KB
/
bsg_fakeram_gen.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
44
45
46
#!/usr/bin/env python
from fusesoc.capi2.generator import Generator
import subprocess
import json
class BSGFakeramGenerator(Generator):
def run(self):
path_to_cfg = self.config.get('path_to_cfg', 'example_cfgs/freepdk45.cfg')
rd = '../../bsg_fakeram_0-r1'
sd = subprocess.Popen( 'pwd', stdout=subprocess.PIPE).communicate()[0]
sd = str(sd).split("'")[1]
sd = sd.split("\\n")[0]
args = ['cp', '-rf','../bsg_fakeram_gen_0-r1/Makefile','Makefile']
rc = subprocess.call(args, cwd=rd)
args = ['make', 'tools']
rc = subprocess.call(args, cwd=rd)
args = ['cp', path_to_cfg,'./conf.cfg']
rc = subprocess.call(args, cwd=rd)
args = ['make', 'run']
rc = subprocess.call(args, cwd=rd)
if path_to_cfg[0]=='.':
f = open("../" + path_to_cfg)
else:
f = open(path_to_cfg)
data=json.load(f)
for i in data["srams"]:
a = i["name"]
to = sd+'/{}.v'.format(a)
args = ['cp', '-rf','results/{}/{}.v'.format(a,a),to]
rc = subprocess.call(args, cwd=rd)
self.add_files([{ '{}.v'.format(a) : {'file_type' : 'verilogSource'}}])
if rc:
exit(1)
g = BSGFakeramGenerator()
g.run()
g.write()