-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
107 lines (92 loc) · 5.58 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# build software version of testbench (to check the "desired behaviour")
AHIR_RELEASE=/home/ahir/ahir-latest/release/
SOCKETLIB_INCLUDE=$(AHIR_RELEASE)/CtestBench/include
SOCKETLIB_LIB=$(AHIR_RELEASE)/CtestBench/lib
PIPEHANDLER_INCLUDE=$(AHIR_RELEASE)/pipeHandler/include
PIPEHANDLER_LIB=$(AHIR_RELEASE)/pipeHandler/lib
PTHREADUTILS_INCLUDE=$(AHIR_RELEASE)/pthreadUtils/include
VHDL_LIB=$(AHIR_RELEASE)/vhdl
VHDL_VHPI_LIB=$(AHIR_RELEASE)/CtestBench/vhdl
FUNCTIONLIB=$(AHIR_RELEASE)/functionLibrary/
SRC=./src
all: SW HW
TOAA:c2llvmbc llvmbc2aa aalink
TOVC:c2llvmbc llvmbc2aa aalink aa2vc
VC2VHDL: vc2vhdl vhdlsim
AA2VHDLSIM: aa2vc vc2vhdl vhdlsim
TOVHDL:TOVC vc2vhdl
# llvm2aa opts: pipelined case, extract-do-while.
#LLVM2AAOPTS=--storageinit=true
LLVM2AAOPTS=-extract_do_while=true --storageinit=true -pipedepths=pipedepths.txt
#program defs: no unrolling
#PROGDEFS=-DPIPELINE
#PROGDEFS=-DPIPELINE -DALT (what does this do, used in c2llvmbc)
#PROGDEFS=-DUNROLL
PROGDEFS=
TOPMODULES=-T qrsDet -T bestFit
# compile with SW defined.
# note the use of IOLIB in building the testbench.
SW: $(SRC)/divide.c $(SRC)/filter.c $(SRC)/ptrFunc.c $(SRC)/qrsDet.c $(SRC)/hermite.c $(SRC)/bestFit.c $(SRC)/testBestFit.c $(SRC)/divide.h $(SRC)/filter.h $(SRC)/ptrFunc.h $(SRC)/qrsDet.h $(SRC)/hermite.h $(SRC)/bestFit.h $(FUNCTIONLIB)/src/timer.c
gcc -g -c -DSW $(PROGDEFS) -I$(PIPEHANDLER_INCLUDE) -I$(FUNCTIONLIB)/include -I$(SRC) $(SRC)/divide.c
gcc -g -c -DSW $(PROGDEFS) -I$(PIPEHANDLER_INCLUDE) -I$(FUNCTIONLIB)/include -I$(SRC) $(SRC)/filter.c
gcc -g -c -DSW $(PROGDEFS) -I$(PIPEHANDLER_INCLUDE) -I$(FUNCTIONLIB)/include -I$(SRC) $(SRC)/ptrFunc.c
gcc -g -c -DSW $(PROGDEFS) -I$(PIPEHANDLER_INCLUDE) -I$(FUNCTIONLIB)/include -I$(SRC) $(SRC)/qrsDet.c
gcc -g -c -DSW $(PROGDEFS) -I$(PIPEHANDLER_INCLUDE) -I$(FUNCTIONLIB)/include -I$(SRC) $(SRC)/hermite.c
gcc -g -c -DSW $(PROGDEFS) -I$(PIPEHANDLER_INCLUDE) -I$(FUNCTIONLIB)/include -I$(SRC) $(SRC)/bestFit.c
gcc -g -c -DSW $(PROGDEFS) -I$(FUNCTIONLIB)/include -I$(SRC) $(FUNCTIONLIB)/src/timer.c
gcc -g -c -DSW $(PROGDEFS) -I$(PIPEHANDLER_INCLUDE) -I$(PTHREADUTILS_INCLUDE) -I$(SRC) $(SRC)/testBestFit.c
gcc -o testbench_sw divide.o filter.o ptrFunc.o qrsDet.o hermite.o bestFit.o timer.o testBestFit.o -L$(PIPEHANDLER_LIB) -lPipeHandler -lpthread -lm -lrt
# five steps from C to vhdl simulator.
HW: c2llvmbc llvmbc2aa aalink aa2vc vc2vhdl vhdlsim
AA2VHDL: aa2vc vc2vhdl vhdlsim
# C to llvm byte-code.. use clang.
CLANGOPTS=-O3
c2llvmbc: $(SRC)/divide.c $(SRC)/divide.h $(SRC)/filter.c $(SRC)/filter.h $(SRC)/ptrFunc.c $(SRC)/ptrFunc.h $(SRC)/qrsDet.c $(SRC)/qrsDet.h
clang $(CLANGOPTS) -I/usr/include/i386-linux-gnu -std=gnu89 $(PROGDEFS) -I$(SRC) -I$(SOCKETLIB_INCLUDE) -I$(FUNCTIONLIB)/include -emit-llvm -c $(SRC)/qrsDet.c
opt --indvars --loopsimplify qrsDet.o -o qrsDet.opt.o
llvm-dis qrsDet.opt.o
clang $(CLANGOPTS) -I/usr/include/i386-linux-gnu -std=gnu89 $(PROGDEFS) -I$(SRC) -I$(SOCKETLIB_INCLUDE) -I$(FUNCTIONLIB)/include -emit-llvm -c $(SRC)/filter.c
opt --indvars --loopsimplify filter.o -o filter.opt.o
llvm-dis filter.opt.o
clang $(CLANGOPTS) -I/usr/include/i386-linux-gnu -std=gnu89 $(PROGDEFS) -I$(SRC) -I$(SOCKETLIB_INCLUDE) -I$(FUNCTIONLIB)/include -emit-llvm -c $(SRC)/divide.c
opt --indvars --loopsimplify divide.o -o divide.opt.o
llvm-dis divide.opt.o
clang $(CLANGOPTS) -I/usr/include/i386-linux-gnu -std=gnu89 $(PROGDEFS) -I$(SRC) -I$(SOCKETLIB_INCLUDE) -I$(FUNCTIONLIB)/include -emit-llvm -c $(SRC)/ptrFunc.c
opt --indvars --loopsimplify ptrFunc.o -o ptrFunc.opt.o
llvm-dis ptrFunc.opt.o
# llvm byte-code to Aa..
llvmbc2aa: divide.opt.o filter.opt.o ptrFunc.opt.o qrsDet.opt.o
llvm2aa $(LLVM2AAOPTS) divide.opt.o | vcFormat > divide.aa
llvm2aa $(LLVM2AAOPTS) filter.opt.o | vcFormat > filter.aa
llvm2aa $(LLVM2AAOPTS) ptrFunc.opt.o | vcFormat > ptrFunc.aa
llvm2aa $(LLVM2AAOPTS) qrsDet.opt.o | vcFormat > qrsDet.aa
# Aa to vC
aalink: qrsDet.aa filter.aa divide.aa ptrFunc.aa
AaLinkExtMem -I 1 -E mempool divide.aa filter.aa ptrFunc.aa qrsDet.aa | vcFormat > prog.linked.aa
AaOpt -B prog.linked.aa | vcFormat > prog.linked.opt.aa
aa2vc: prog.linked.opt.aa
Aa2VC -I mempool -O -C prog.linked.opt.aa | vcFormat > prog.vc
# vC to VHDL
vc2vhdl: prog.vc
vc2vhdl -O -S 4 -I 2 -v -a -C -e ahir_system -w -s ghdl $(TOPMODULES) -f prog.vc -L $(FUNCTIONLIB)/timer.list
vhdlFormat < ahir_system_global_package.unformatted_vhdl > ahir_system_global_package.vhdl
vhdlFormat < ahir_system.unformatted_vhdl > ahir_system.vhdl
vhdlFormat < ahir_system_test_bench.unformatted_vhdl > ahir_system_test_bench.vhdl
# build testbench and ghdl executable
# note the use of SOCKETLIB in building the testbench.
vhdlsim: ahir_system.vhdl ahir_system_test_bench.vhdl $(SRC)/testBestFit.c vhdlCStubs.h vhdlCStubs.c
gcc -c vhdlCStubs.c -I$(SRC) -I./ -I$(SOCKETLIB_INCLUDE)
gcc -c $(SRC)/testDetect.c -I$(PTHREADUTILS_INCLUDE) -I$(SRC) -I./ -I$(SOCKETLIB_INCLUDE)
gcc -o testbench_hw testDetect.o vhdlCStubs.o -L$(SOCKETLIB_LIB) -lSocketLib -lpthread -lm
ghdl --clean
ghdl --remove
ghdl -i --work=GhdlLink $(VHDL_LIB)/GhdlLink.vhdl
ghdl -i --work=ahir $(VHDL_LIB)/ahir.vhdl
ghdl -i --work=aHiR_ieee_proposed $(VHDL_LIB)/aHiR_ieee_proposed.vhdl
ghdl -i --work=work ahir_system_global_package.vhdl
ghdl -i --work=work ahir_system.vhdl
ghdl -i --work=work ahir_system_test_bench.vhdl
ghdl -m -g --work=work -Wl,-L$(SOCKETLIB_LIB) -Wl,-lVhpi ahir_system_test_bench
clean:
rm -rf *.o* *.cf *.*vhdl vhdlCStubs.* *.vcd in_data* out_data* testbench_sw testbench_hw ahir_system_test_bench vhpi.log *.aa *.vc *.lso xst *.ngc *_xmsgs *.xrpt pipeHandler.log *.srp *.ghw *.dot
PHONY: all clean