-
Notifications
You must be signed in to change notification settings - Fork 113
/
run.py
executable file
·220 lines (160 loc) · 7.01 KB
/
run.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
import sys
import time
import unittest
import os
import re
import subprocess
DEBUG = True
re_UVM_ERROR = re.compile("^UVM_ERROR\s+:\s+(\d+)$" ,re.M)
re_UVM_WARNING = re.compile("^UVM_WARNING\s+:\s+(\d+)$" ,re.M)
re_UVM_INFO = re.compile("^UVM_INFO\s+:\s+(\d+)$" ,re.M)
re_IUS_ERROR = re.compile("^irun:\s+\*E\," ,re.M)
re_IUS_WARNING = re.compile("^irun:\s+\*W\," ,re.M)
class IUSAXIBase(unittest.TestCase):
def setUp(self):
os.chdir('/user/seanchen/project/uvm_axi')
self.m_demo_home = os.getcwd()
self.m_tb_home = None
self.m_tb_name = None
def tearDown(self):
global DEBUG
if not DEBUG:
self.clearIUS();
def runIUS(self):
""" run IUS ps: it need subprocess to parallel run """
m_str = "irun -uvm \
-incdir %(DEMO_HOME)s/sv \
-incdir %(DEMO_HOME)s/sv/sequence_libs \
-incdir %(DEMO_HOME)s/v \
-incdir %(DEMO_HOME)s/pli \
-incdir %(DEMO_HOME)s/dpi \
-incdir %(TB_HOME)s \
+notimingchecks \
+notchkmsg \
+no_notifier \
+define+AXI_BUSY \
+libext+.v \
%(DEMO_HOME)s/pli/dram.c \
%(DEMO_HOME)s/pli/vpi_user.c \
-loadvpi mem_alloc,mem_free,mem_read,mem_write,mem_init,mem_dump.register_user_tasks \
-coverage b:u \
-covoverwrite \
+UVM_TESTNAME=%(TEST_NAME)s \
+UVM_VERBOSITY=UVM_FULL \
%(TB_HOME)s/demo_top.sv \
+access+rwc" % { 'DEMO_HOME' : self.m_demo_home, \
'TEST_NAME' : self.m_tb_name, \
'TB_HOME' : self.m_tb_home}
subprocess.call(m_str, shell=True)
def reportIUS(self):
""" report IUS """
# it need subprocess to return the sysout result
# >>> grep "*E" irun.log
# >>> grep "UVM_ERROR" irun.log ...
f = open('./log/%(TEST_NAME)s.log' % { 'TEST_NAME' : self.m_tb_name})
uvm_errs = re_UVM_ERROR.findall(f.read())
ius_errs = re_IUS_ERROR.findall(f.read())
uvm_warns = re_UVM_WARNING.findall(f.read())
ius_warns = re_IUS_WARNING.findall(f.read())
if len(ius_errs) == 0:
if uvm_errs[0] == '0':
return True
return False
def clearIUS(self):
""" clear """
os.system("rm -rf cov_work")
os.system("rm -rf INCA_libs")
os.system("rm -rf *.vcd*")
def logIUS(self):
""" move to log """
m_str = 'mv irun.log ./log/%(TEST_NAME)s.log' % { 'TEST_NAME' : self.m_tb_name}
m_vcd = 'mv demo_tb.vcd ./log/%(TEST_NAME)s.vcd' % { 'TEST_NAME' : self.m_tb_name}
os.system(m_str)
os.system(m_vcd)
class TestAXIBFMVirtual(IUSAXIBase):
""" test virtual AXI bus functional model """
def test_phase_write_data_after_write_addr(self):
""" test AXI write data phase is after write addr phase """
self.m_tb_home = self.m_demo_home + '/examples/virtual_master_to_virtual_slave'
self.m_tb_name = 'Test_write_data_after_write_addr'
self.runIUS()
self.logIUS()
self.assertEqual(self.reportIUS(), True)
def test_phase_write_addr_after_write_data(self):
""" test AXI write addr phase is after write data phase """
self.m_tb_home = self.m_demo_home + '/examples/virtual_master_to_virtual_slave'
self.m_tb_name = 'Test_write_addr_after_write_data'
self.runIUS()
self.logIUS()
self.assertEqual(self.reportIUS(), True)
def test_phase_wite_addr_write_data_at_same_time(self):
""" test AXI write addr and write data at the same time """
self.m_tb_home = self.m_demo_home + '/examples/virtual_master_to_virtual_slave'
self.m_tb_name = 'Test_write_addr_write_data_at_same_time'
self.runIUS()
self.logIUS()
self.assertEqual(self.reportIUS(), True)
def test_phase_write_interleave_data(self):
""" test AXI write interleave data """
self.m_tb_home = self.m_demo_home + '/examples/virtual_master_to_virtual_slave'
self.m_tb_name = 'Test_write_interleave_data'
self.runIUS()
self.logIUS()
self.assertEqual(self.reportIUS(), True)
def test_phase_write_out_of_performance(self):
""" test AXI write out of performance """
self.m_tb_home = self.m_demo_home + '/examples/virtual_master_to_virtual_slave'
self.m_tb_name = 'Test_write_out_of_performance'
self.runIUS()
self.logIUS()
self.assertEqual(self.reportIUS(), False)
def test_phase_read_out_of_performance(self):
""" test AXI read out of performance """
self.m_tb_home = self.m_demo_home + '/examples/virtual_master_to_virtual_slave'
self.m_tb_name = 'Test_read_out_of_performance'
self.runIUS()
self.logIUS()
self.assertEqual(self.reportIUS(), False)
class TestAXIBFMDUT(IUSAXIBase):
""" test AXI bus functional model """
def test_phase_write_data_after_write_addr(self):
""" test AXI write data phase is after write addr phase """
self.m_tb_home = self.m_demo_home + '/examples/virtual_master_to_dut_slave'
self.m_tb_name = 'Test_write_data_after_write_addr'
self.runIUS()
self.logIUS()
self.assertEqual(self.reportIUS(), True)
def test_phase_write_addr_after_write_data(self):
""" test AXI write addr phase is after write data phase """
self.m_tb_home = self.m_demo_home + '/examples/virtual_master_to_dut_slave'
self.m_tb_name = 'Test_write_addr_after_write_data'
self.runIUS()
self.logIUS()
self.assertEqual(self.reportIUS(), True)
def test_phase_wite_addr_write_data_at_same_time(self):
""" test AXI write addr and write data at the same time """
self.m_tb_home = self.m_demo_home + '/examples/virtual_master_to_dut_slave'
self.m_tb_name = 'Test_write_addr_write_data_at_same_time'
self.runIUS()
self.logIUS()
self.assertEqual(self.reportIUS(), True)
def test_phase_write_interleave_data(self):
""" test AXI write interleave data """
self.m_tb_home = self.m_demo_home + '/examples/virtual_master_to_dut_slave'
self.m_tb_name = 'Test_write_interleave_data'
self.runIUS()
self.logIUS()
self.assertEqual(self.reportIUS(), True)
def suite():
suite = unittest.TestSuite()
suite.addTest(TestAXIBFMVirtual('test_phase_write_data_after_write_addr'))
suite.addTest(TestAXIBFMVirtual('test_phase_write_addr_after_write_data'))
suite.addTest(TestAXIBFMVirtual('test_phase_write_out_of_performance'))
suite.addTest(TestAXIBFMVirtual('test_phase_read_out_of_performance'))
suite.addTest(TestAXIBFMDUT('test_phase_write_data_after_write_addr'))
suite.addTest(TestAXIBFMDUT('test_phase_write_addr_after_write_data'))
return suite
if __name__ == '__main__':
runner = unittest.TextTestRunner()
test_suite = suite()
runner.run(test_suite)