2020-09-24 22:18:27 +08:00
|
|
|
#!/usr/bin/env python3
|
2020-01-31 17:31:19 +08:00
|
|
|
from fusesoc.capi2.generator import Generator
|
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
|
|
|
class SwervConfigGenerator(Generator):
|
|
|
|
def run(self):
|
|
|
|
script_root = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '..'))
|
|
|
|
files = [
|
2021-01-15 22:13:01 +08:00
|
|
|
{"common_defines.vh" : {
|
2020-01-31 17:31:19 +08:00
|
|
|
"copyto" : "config/common_defines.vh",
|
|
|
|
"file_type" : "systemVerilogSource"}},
|
2021-01-15 22:13:01 +08:00
|
|
|
{"el2_pdef.vh" : {
|
2020-01-31 17:31:19 +08:00
|
|
|
"copyto" : "config/el2_pdef.vh",
|
|
|
|
"file_type" : "systemVerilogSource"}},
|
2021-01-15 22:13:01 +08:00
|
|
|
{"el2_param.vh" : {
|
2020-01-31 17:31:19 +08:00
|
|
|
"is_include_file" : True,
|
|
|
|
"file_type" : "systemVerilogSource"}},
|
2021-01-15 22:13:01 +08:00
|
|
|
{"pic_map_auto.h" : {
|
2020-01-31 17:31:19 +08:00
|
|
|
"is_include_file" : True,
|
|
|
|
"file_type" : "systemVerilogSource"}}]
|
|
|
|
|
|
|
|
env = os.environ.copy()
|
2021-01-15 22:13:01 +08:00
|
|
|
env['RV_ROOT'] = script_root
|
|
|
|
env['BUILD_PATH'] = os.getcwd()
|
2020-01-31 17:31:19 +08:00
|
|
|
args = ['configs/swerv.config'] + self.config.get('args', [])
|
2021-01-15 22:13:01 +08:00
|
|
|
|
|
|
|
rc = subprocess.call(args, cwd=script_root, env=env, stdout=subprocess.DEVNULL)
|
2020-01-31 17:31:19 +08:00
|
|
|
if rc:
|
|
|
|
exit(1)
|
|
|
|
filenames = []
|
|
|
|
for f in files:
|
|
|
|
for k in f:
|
|
|
|
filenames.append(k)
|
|
|
|
|
|
|
|
self.add_files(files)
|
|
|
|
|
|
|
|
g = SwervConfigGenerator()
|
|
|
|
g.run()
|
|
|
|
g.write()
|