-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun
executable file
·39 lines (33 loc) · 823 Bytes
/
run
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
#!/usr/bin/env bash
# No point in using Makefile, since we don't have
# one generated output per input without GCC.
set -e
cc='ghdl'
cflags='--std=08'
in_ext='.vhdl'
in_suffix='_tb'
get_prefix() {
prefix="$1"
prefix="${prefix%$in_ext}"
prefix="${prefix%$in_suffix}"
echo "$prefix"
}
analyze_or_run() {
prefix="$(get_prefix "$1")"
if [ -r "${prefix}${in_ext}" ]; then
$cc -a $cflags "${prefix}${in_ext}"
fi
if [ -r "${prefix}${in_suffix}${in_ext}" ]; then
$cc -a $cflags "${prefix}${in_suffix}${in_ext}"
$cc -e $cflags "${prefix}${in_suffix}"
$cc -r $cflags "${prefix}${in_suffix}" --assert-level=error --vcd="${prefix}.vcd"
fi
}
$cc -a $cflags "common${in_ext}"
if [ $# -gt 0 ]; then
analyze_or_run "$1"
else
for f in *${in_suffix}${in_ext}; do
analyze_or_run "$f"
done
fi