Skip to content

Commit 29c6295

Browse files
committed
feat: impl vcs comp method
1 parent ad5ad91 commit 29c6295

File tree

2 files changed

+55
-5
lines changed

2 files changed

+55
-5
lines changed

src/cicd_config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
SUB_DIR = SUBMIT_DIR + '/submit'
2424
RPT_DIR = SUBMIT_DIR + '/report'
2525

26+
VCS_DIR = HOME_DIR + '../vcs'
27+
VCS_RUN_DIR = VCS_DIR + '/run'
28+
VCS_CPU_DIR = VCS_DIR + '/cpu'
29+
2630

2731
def exec_cmd(cmd: str) -> str:
2832
try:

src/vcs_test.py

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,66 @@
11
#!/bin/python
2+
from enum import Enum
23
import os
4+
import cicd_config
5+
6+
7+
class LogState(Enum):
8+
start = 0
9+
end = 1
310

411

512
class VcsTest(object):
613
def __init__(self):
7-
pass
14+
self.dut = ''
15+
self.lint = []
16+
self.warn = []
17+
self.err = []
818

919
def clear(self):
10-
cmd = 'cd lib/vcs/run && make clean && '
11-
cmd += 'rm temp.fp getReg* novas* verdi* -rf'
20+
self.dut = ''
21+
self.lint = []
22+
self.warn = []
23+
self.err = []
24+
self.clear_dir()
25+
26+
def clear_dir(self):
27+
cmd = 'cd ' + cicd_config.VCS_RUN_DIR
28+
cmd += ' && make clean'
29+
cmd += ' && rm temp.fp getReg* novas* verdi* -rf'
1230
os.system(cmd)
13-
cmd = 'find lib/vcs/cpu/* | grep -v ysyx_210000.v | xargs rm -rf'
31+
cmd = 'find ' + cicd_config.VCS_CPU_DIR + '/*'
32+
cmd += ' grep -v ysyx_210000.v | xargs rm -rf'
1433
os.system(cmd)
1534

1635
def intg_soc(self):
1736
pass
1837

1938
def comp(self):
20-
pass
39+
cmd = 'cd ' + cicd_config.VCS_RUN_DIR
40+
cmd += ' && make comp'
41+
os.system(cmd)
42+
43+
log_state = [LogState.end, LogState.end, LogState.end]
44+
# NOTE: receive comp log
45+
with open(cicd_config.VCS_RUN_DIR + '/compile.log',
46+
'r',
47+
encoding='utf-8') as fp:
48+
for line in fp:
49+
if line[0:4] == 'Lint':
50+
log_state[0] = LogState.start
51+
elif line[0:7] == 'Warning':
52+
log_state[1] = LogState.start
53+
elif line[0:5] == 'Error':
54+
log_state[2] = LogState.start
55+
elif line == '\n':
56+
log_state = [LogState.end, LogState.end, LogState.end]
57+
58+
if log_state[0] == LogState.start:
59+
self.lint.append(line)
60+
elif log_state[1] == LogState.start:
61+
self.warn.append(line)
62+
elif log_state[2] == LogState.start:
63+
self.err.append(line)
2164

2265
def run(self):
2366
pass
@@ -29,6 +72,9 @@ def run(self):
2972
def main():
3073
print('[vcs test]')
3174
vcstest.clear()
75+
vcstest.intg_soc()
76+
vcstest.comp()
77+
vcstest.run()
3278

3379

3480
if __name__ == '__main__':

0 commit comments

Comments
 (0)