summaryrefslogtreecommitdiff
path: root/tests/vloghtb/common.sh
blob: 3f7fc258dcd5fc1828c8ad8ccebb86af384c93ff (plain)
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
log_pass()
{
	printf "%-15s %s %s %s\n" "$1" "$2" "`printf "%20s" "$2" | tr -d a-zA-Z0-9_ | tr ' ' .`" "pass."
}

log_fail()
{
	printf "%-15s %s %s %s\n" "$1" "$2" "`printf "%20s" "$2" | tr -d a-zA-Z0-9_ | tr ' ' .`" "FAIL."
}

test_autotest()
{
	# Usage:
	# test_autotest <test_name> <mod_name> <vlog_file> <autotest_cmd_line_options>

	test_name="$1"
	mod_name="$2"
	vlog_file="$3"
	shift 3

	mkdir -p log_test_$test_name
	rm -rf log_test_$test_name/$mod_name.*

	cp $vlog_file log_test_$test_name/$mod_name.v

	cd log_test_$test_name
	if bash ../../tools/autotest.sh "$@" $mod_name.v > /dev/null 2>&1; then
		mv $mod_name.out $mod_name.txt
		log_pass test_$test_name $mod_name
	else
		log_fail test_$test_name $mod_name
	fi

	cd ..
}

test_equiv()
{
	# Usage:
	# test_equiv <test_name> <synth_script> <sat_options> <mod_name> <vlog_file>

	mkdir -p log_test_$1
	rm -f log_test_$1/$4.txt
	rm -f log_test_$1/$4.err

	if ! ../../yosys -q -l log_test_$1/$4.out - 2> /dev/null <<- EOT
		read_verilog $5
		proc;;

		copy $4 gold
		rename $4 work

		cd work
		$2
		cd ..

		miter -equiv -ignore_gold_x -make_outputs -make_outcmp gold work miter
		flatten miter
		sat $3 -verify -prove trigger 0 -show-inputs -show-outputs miter
	EOT
	then
		log_fail test_$1 $4
		mv log_test_$1/$4.out log_test_$1/$4.err
		exit 1
	fi

	log_pass test_$1 $4
	mv log_test_$1/$4.out log_test_$1/$4.txt
}