-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
55 lines (47 loc) · 2.05 KB
/
Makefile
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
.ONESHELL:
.PHONY: clean run tests debugtests
TEST_SRC = src/aig-sim.cpp src/aig-rtlil.cpp src/test.cpp src/genome.cpp src/aig-genome.cpp src/generation.cpp src/config-parse.cpp
cgploss.so: yosys/yosys
yosys/yosys-config --exec --cxx --cxxflags --ldflags -o cgploss.so -shared src/* -I yosys/ -I include/ --ldlibs
multicore: yosys/yosys
yosys/yosys-config --exec --cxx --cxxflags --ldflags -fopenmp -o cgploss.so -shared src/* -I yosys/ -I include/ --ldlibs
yosys/yosys:
cd yosys && make
run: cgploss.so
yosys/yosys -m cgploss.so
test: cgploss.so
@echo "[info] starting implementation test $(dir)"
@EXIT_CODE=0
for f in ./tests/$(dir); do \
if [ -d "$$f" -a $$(echo -n "$$f" | tail -c 1) != "-" -a $$(echo -n "$$f" | tail -c 4) != "unit" ]; then \
#echo "$$f STARTED" && \
yosys/yosys -m cgploss.so < "$$f/run" > test_run.txt || { echo -e "$$f \e[31mFAILED\e[0m" ; EXIT_CODE=1; continue; } && \
iverilog -o test_design test_out.v "$$f/tb.v" || { echo -e "$$f \e[31mFAILED\e[0m" ; EXIT_CODE=1; continue; } && \
vvp test_design || { echo -e "$$f \e[31mFAILED\e[0m" ; EXIT_CODE=1; continue; } && \
echo -e "$$f \e[32mPASS\e[0m"; \
elif [ -d "$$f" -a $$(echo -n "$$f" | tail -c 1) != "-" -a $$(echo -n "$$f" | tail -c 4) == "unit" ]; then \
#echo "$$f STARTED UNIT TEST" && \
cp $$f/test.cpp src/test.cpp && \
yosys/yosys-config --exec --cxx --cxxflags --ldflags -o cgplossUnit.so -shared $(TEST_SRC) -I yosys/ -I include/ --ldlibs > test_run.txt 2>&1 || { echo -e "$$f \e[31mFAILED\e[0m" ; EXIT_CODE=1; continue; } && \
rm -f src/test.cpp && \
yosys/yosys -m cgplossUnit.so < "$$f/run" >> test_run.txt || { echo -e "$$f \e[31mFAILED\e[0m" ; EXIT_CODE=1; continue; } && \
echo -e "$$f \e[32mPASS\e[0m"; \
fi \
done
# remove tests outputs
@echo "[info] implementation test $(dir) done"
@exit $$EXIT_CODE
tests:
make test dir=*
rm -f test_design
rm -f test_run.txt
rm -f test_out.v
clean:
rm -f cgploss.so
rm -f cgploss.d
rm -f test_design
rm -f test_run.txt
rm -f test_out.v
rm -f cgplossUnit.d
rm -f cgplossUnit.so
rm -f src/test.cpp