1 | # |
---|
2 | # $Id: Makefile.Synthesis 137 2010-02-16 12:35:48Z rosiere $ |
---|
3 | # |
---|
4 | # [ Description ] |
---|
5 | # |
---|
6 | # Makefile |
---|
7 | # |
---|
8 | |
---|
9 | #-----[ Variables ]---------------------------------------- |
---|
10 | |
---|
11 | DIR_VHDL = . |
---|
12 | WORK_NAME = work |
---|
13 | DIR_WORK = $(DIR_TMP)/$(WORK_NAME) |
---|
14 | |
---|
15 | FPGA_CFG_FILE_LOCAL = mkf.info |
---|
16 | FPGA_CFG_FILE_GLOBAL_DIR = $(DIR_MORPHEO)/Behavioural |
---|
17 | FPGA_CFG_FILE_GLOBAL = configure.mkf |
---|
18 | |
---|
19 | FPGA_FILES = $(patsubst $(DIR_CFG_GEN)/%.cfg,%,$(wildcard $(DIR_CFG_GEN)/*.cfg)) \ |
---|
20 | $(patsubst $(DIR_CFG_USER)/%.cfg,%,$(wildcard $(DIR_CFG_USER)/*.cfg)) |
---|
21 | |
---|
22 | FPGA_LOG_FILES = $(patsubst $(DIR_CFG_GEN)/%.cfg,$(DIR_LOG)/%.fpga.log,$(wildcard $(DIR_CFG_GEN)/*.cfg)) \ |
---|
23 | $(patsubst $(DIR_CFG_USER)/%.cfg,$(DIR_LOG)/%.fpga.log,$(wildcard $(DIR_CFG_USER)/*.cfg)) |
---|
24 | |
---|
25 | |
---|
26 | #-----[ Rules ]-------------------------------------------- |
---|
27 | .PRECIOUS : $(DIR_LOG)/%.vhdl.log $(DIR_LOG)/%.sim.log |
---|
28 | |
---|
29 | vhdl : $(EXEC_LOG) |
---|
30 | @\ |
---|
31 | $(MAKE) vhdl_package; \ |
---|
32 | $(MAKE) vhdl_entity; \ |
---|
33 | $(MAKE) vhdl_testbench |
---|
34 | |
---|
35 | vhdl_package : $(DIR_WORK) |
---|
36 | @\ |
---|
37 | declare -a vhdl_files=($$($(LS) $(DIR_VHDL)/*_Pack.vhdl)); \ |
---|
38 | declare -a log_files=($${vhdl_files[*]/%.vhdl/.vhdl.log}); \ |
---|
39 | if $(TEST) $${#log_files[*]} -ne 0; then $(MAKE) -k $${log_files[*]/#$(DIR_VHDL)/$(DIR_LOG)}; fi; |
---|
40 | |
---|
41 | vhdl_testbench : $(DIR_WORK) |
---|
42 | @\ |
---|
43 | $(LS) $(DIR_VHDL)/*_Testbench.vhdl &> /dev/null; \ |
---|
44 | if $(TEST) $$? -eq 0; then \ |
---|
45 | declare -a vhdl_files=($$($(LS) $(DIR_VHDL)/*_Testbench.vhdl)); \ |
---|
46 | declare -a log_files=($${vhdl_files[*]/%.vhdl/.vhdl.log}); \ |
---|
47 | if $(TEST) $${#log_files[*]} -ne 0; then \ |
---|
48 | $(MAKE) -k $${log_files[*]/#$(DIR_VHDL)/$(DIR_LOG)}; \ |
---|
49 | fi; \ |
---|
50 | fi; |
---|
51 | |
---|
52 | vhdl_entity : $(DIR_WORK) |
---|
53 | @\ |
---|
54 | declare -a vhdl_files=($$($(LS) $(DIR_VHDL)/*.vhdl|$(GREP_NOT) "(_Pack\.|_Testbench\.)")); \ |
---|
55 | declare -a log_files=($${vhdl_files[*]/%.vhdl/.vhdl.log}); \ |
---|
56 | if $(TEST) $${#log_files[*]} -ne 0; then $(MAKE) -k $${log_files[*]/#$(DIR_VHDL)/$(DIR_LOG)}; fi; \ |
---|
57 | |
---|
58 | #list : |
---|
59 | # @\ |
---|
60 | # declare -a vhdl_files=($$($(LS) $(DIR_VHDL)/*.vhdl|$(GREP_NOT) "(_Pack\.|_Testbench\.)")); \ |
---|
61 | # for file1 in $${vhdl_files[*]}; do \ |
---|
62 | # declare x=$$(basename $${file1} .vhdl); \ |
---|
63 | # declare -i count_x=$($(ECHO) $${x} | ${WC} -m); \ |
---|
64 | # for file2 in $${vhdl_files[*]}; do \ |
---|
65 | # if $(TEST) "$${file1}" != "$${file2}"; then\ |
---|
66 | # declare y=$$(basename $${file2} .vhdl); \ |
---|
67 | # declare -i count_y=$($(ECHO) $${y} | ${WC} -m); \ |
---|
68 | # if $(TEST) $${count_x} -gt $${count_y}; then \ |
---|
69 | # break; \ |
---|
70 | # fi; \ |
---|
71 | # $(ECHO) $${x}; \ |
---|
72 | # fi; \ |
---|
73 | # done; \ |
---|
74 | # done; |
---|
75 | |
---|
76 | sim : vhdl |
---|
77 | @\ |
---|
78 | $(LS) $(DIR_VHDL)/*_Testbench.vhdl &> /dev/null; \ |
---|
79 | if $(TEST) $$? -eq 0; then \ |
---|
80 | declare -a vhdl_files=($$($(LS) $(DIR_VHDL)/*_Testbench.vhdl)); \ |
---|
81 | declare -a log_files=($${vhdl_files[*]/%.vhdl/.sim.log}); \ |
---|
82 | if $(TEST) $${#log_files[*]} -ne 0; then \ |
---|
83 | $(MAKE) -k $${log_files[*]/#$(DIR_VHDL)/$(DIR_LOG)}; \ |
---|
84 | fi; \ |
---|
85 | fi; |
---|
86 | |
---|
87 | fpga : sim |
---|
88 | @\ |
---|
89 | $(ECHO) -e "" > $(FPGA_CFG_FILE_LOCAL); \ |
---|
90 | $(ECHO) "files :::::::: $(FPGA_FILES)"; \ |
---|
91 | for file in $(FPGA_FILES); do \ |
---|
92 | declare -a files=($$($(LS) $$file*.vhdl|$(GREP_NOT) "(_Testbench\.)")); \ |
---|
93 | $(ECHO) -e "# $$file" >> $(FPGA_CFG_FILE_LOCAL); \ |
---|
94 | $(ECHO) -e "target_dep\tall\t$$file.ngc" >> $(FPGA_CFG_FILE_LOCAL); \ |
---|
95 | $(ECHO) -e "target_dep\t$$file.ngc\t$$file.prj" >> $(FPGA_CFG_FILE_LOCAL); \ |
---|
96 | $(ECHO) -e "target_dep\t$$file.prj\t$${files[*]}" >> $(FPGA_CFG_FILE_LOCAL); \ |
---|
97 | $(ECHO) -e "" >> $(FPGA_CFG_FILE_LOCAL); \ |
---|
98 | done; \ |
---|
99 | ($(XILINX_ENV); cd $(FPGA_CFG_FILE_GLOBAL_DIR); ./$(FPGA_CFG_FILE_GLOBAL)); \ |
---|
100 | $(MAKE) -k $(FPGA_LOG_FILES); |
---|
101 | |
---|
102 | $(DIR_LOG)/%.fpga.log : |
---|
103 | @\ |
---|
104 | $(ECHO) "Synthetis on FPGA : $*"; \ |
---|
105 | $(XILINX_ENV); $(MAKE) -f Makefile.mkf $*.ngc &> $@; |
---|
106 | |
---|
107 | $(DIR_WORK) : |
---|
108 | @\ |
---|
109 | $(ECHO) "Create work-space : $@"; \ |
---|
110 | mkdir -p $@; \ |
---|
111 | $(MODELTECH_VLIB) $@; \ |
---|
112 | $(MODELTECH_VMAP) $(XILINX_LIBNAME) $(XILINX_LIBDIR); \ |
---|
113 | if $(TEST) $${?} -ne 0; then \ |
---|
114 | $(ECHO) "Xilinx corelib must be compiled to simulation tools"; \ |
---|
115 | $(ECHO) "Run manualy \"$(XILINX_COMPXLIB)\" with $(XILINX_CORELIB) directory"; \ |
---|
116 | fi; |
---|
117 | |
---|
118 | $(DIR_LOG)/%.sim.log : $(DIR_VHDL)/%.vhdl $(DIR_LOG)/%.vhdl.log |
---|
119 | @\ |
---|
120 | $(ECHO) "VHDL's Simulation : $*"; \ |
---|
121 | $(MODELTECH_VSIM) "$(DIR_WORK).`$(BASENAME) $* |$(UPPERtoLOWER)`" &> $@; \ |
---|
122 | declare -i count=`$(GREP) -ch "Test OK" $@`; \ |
---|
123 | if $(TEST) $$count -ne 0; \ |
---|
124 | then echo " $* ... OK"; \ |
---|
125 | else echo " $* ... KO"; exit 1; \ |
---|
126 | fi; |
---|
127 | |
---|
128 | $(DIR_LOG)/%.vhdl.log : $(DIR_VHDL)/%.vhdl |
---|
129 | @\ |
---|
130 | $(ECHO) "VHDL's Compilation : $*"; \ |
---|
131 | $(MODELTECH_VCOM) -work $(DIR_WORK) $< &> $@; |
---|
132 | |
---|
133 | synthesis_clean : |
---|
134 | @\ |
---|
135 | if $(TEST) -f Makefile.mkf; then $(MAKE) -f Makefile.mkf clean; fi; \ |
---|
136 | $(RM) $(DIR_WORK) transcript Makefile.mkf *wlf* modelsim.ini; |
---|
137 | |
---|
138 | synthesis_clean_all : synthesis_clean |
---|
139 | |
---|
140 | synthesis_help : |
---|
141 | @\ |
---|
142 | $(ECHO) " -----[ Synthesis ]----------------------------------";\ |
---|
143 | $(ECHO) "";\ |
---|
144 | $(ECHO) " * vhdl : compile all vhdl's file";\ |
---|
145 | $(ECHO) " * sim : simulate all testbench's file";\ |
---|
146 | $(ECHO) " * fpga : synthetis with fpga's tools";\ |
---|
147 | $(ECHO) ""; |
---|