]> git.zerfleddert.de Git - proxmark3-svn/blob - fpga/tests/Makefile
Merge pull request #362 from merlokk/master
[proxmark3-svn] / fpga / tests / Makefile
1 #-----------------------------------------------------------------------------
2 # Copyright (C) 2014 iZsh <izsh at fail0verflow.com>
3 #
4 # This code is licensed to you under the terms of the GNU GPL, version 2 or,
5 # at your option, any later version. See the LICENSE.txt file for the text of
6 # the license.
7 #-----------------------------------------------------------------------------
8
9 TEST_OUTDIR = tb_tmp
10
11 TB_SOURCES = \
12 tb_lp20khz_1MSa_iir_filter.v \
13 tb_min_max_tracker.v \
14 tb_lf_edge_detect.v
15
16 TBS = $(TB_SOURCES:.v=.vvp)
17
18 TB_DATA = \
19 pcf7931_write1byte_1MSA_data \
20 pcf7931_read_1MSA_data
21
22 all: $(TBS) tests
23
24 %.vvp: %.v
25 iverilog -I .. -o $@ $<
26
27 clean:
28 rm -rf *.vvp $(TEST_OUTDIR)
29
30 tests: tb_lp20khz_1MSa_iir_filter tb_min_max_tracker tb_lf_edge_detect
31
32 tb_lp20khz_1MSa_iir_filter: tb_lp20khz_1MSa_iir_filter.vvp | test_dir
33 @printf "Testing $@\n"
34 @for d in $(TB_DATA); do \
35 $(call run_test,$@.vvp,$$d,in); \
36 $(call check_golden,$$d,filtered); \
37 done; \
38 rm -f $(TEST_OUTDIR)/data.*
39
40 tb_min_max_tracker: tb_min_max_tracker.vvp | test_dir
41 @printf "Testing $@\n"
42 @for d in $(TB_DATA); do \
43 $(call run_test,$@.vvp,$$d,in filtered.gold); \
44 $(call check_golden,$$d,min); \
45 $(call check_golden,$$d,max); \
46 done; \
47 rm -f $(TEST_OUTDIR)/data.*
48
49 tb_lf_edge_detect: tb_lf_edge_detect.vvp | test_dir
50 @printf "Testing $@\n"
51 @for d in $(TB_DATA); do \
52 $(call run_test,$@.vvp,$$d,in filtered.gold); \
53 $(call check_golden,$$d,min); \
54 $(call check_golden,$$d,max); \
55 $(call check_golden,$$d,state); \
56 $(call check_golden,$$d,toggle); \
57 $(call check_golden,$$d,high); \
58 $(call check_golden,$$d,highz); \
59 $(call check_golden,$$d,lowz); \
60 $(call check_golden,$$d,low); \
61 done; \
62 rm -f $(TEST_OUTDIR)/data.*
63
64 test_dir:
65 @if [ ! -d $(TEST_OUTDIR) ] ; then mkdir $(TEST_OUTDIR) ; fi
66
67 .PHONY: all clean
68
69 # $(1) = basename
70 # $(2) = extension to check
71 check_golden = \
72 printf " Checking $(1).$(2)... "; \
73 mv $(TEST_OUTDIR)/data.$(2) $(TEST_OUTDIR)/$(1).$(2); \
74 if cmp -s tb_data/$(1).$(2).gold $(TEST_OUTDIR)/$(1).$(2); then \
75 printf "OK\n"; \
76 else \
77 printf "ERROR\n"; \
78 fi
79
80 # $(1) = vvp file
81 # $(2) = data basename
82 # $(3) = data extensions to copy
83 run_test = \
84 env echo " With $(2)... "; \
85 cp tb_data/$(2).time $(TEST_OUTDIR); \
86 for e in $(3); do cp tb_data/$(2).$$e $(TEST_OUTDIR)/data.$$e; done; \
87 ./$(1)
Impressum, Datenschutz