-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtestbench_utils.py
More file actions
35 lines (25 loc) · 1.26 KB
/
testbench_utils.py
File metadata and controls
35 lines (25 loc) · 1.26 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
import os
def os_cmd(command_string):
res = os.system(command_string)
if (res != 0):
print('FAILED COMMAND: ', command_string)
assert(False)
# Module by module tests
def build_module_with_main(mod_name, main_name, flags):
#v_command = "verilator -Ifirst_cpu -Icommon -Ipipelined_basic -Wall -Wno-DECLFILENAME --cc " + mod_name + ".v --exe " + main_name + " --top-module " + mod_name + " -CFLAGS -O3 -CFLAGS -march=native -DDEBUG_ON"
v_command = "verilator " + flags + " -Wall -Wno-DECLFILENAME --cc " + mod_name + ".v --exe " + main_name + " --top-module " + mod_name + " -CFLAGS -O3 -CFLAGS -march=native -DDEBUG_ON"
verilate = os.system(v_command);
if (verilate != 0):
print('ERROR: ' + mod_name + ' verilation failure')
assert(False)
m_command = "make -C obj_dir -j -f V" + mod_name + ".mk V" + mod_name
make_cmd = os.system(m_command)
if (make_cmd != 0):
print('ERROR: ' + mod_name + ' could not make verilated code')
assert(False)
run_cmd = os.system('./obj_dir/V' + mod_name)
if (run_cmd != 0):
print('ERROR: ' + mod_name + ' tests failed')
assert(False)
def build_module(mod_name, flags=''):
build_module_with_main(mod_name, mod_name + '_main.cpp', flags)