-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
1020 lines (866 loc) · 43.7 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -----------------------------------------------------------------------------
SYFALA_VERSION_MAJOR := 0
SYFALA_VERSION_MINOR := 10
SYFALA_VERSION_PATCH := 0
SYFALA_VERSION := $(SYFALA_VERSION_MAJOR).$(SYFALA_VERSION_MINOR)
SYFALA_VERSION_FULL := $(SYFALA_VERSION).$(SYFALA_VERSION_PATCH)
SYFALA_COMMIT_HASH := $(shell git rev-parse HEAD)
# -----------------------------------------------------------------------------
# Includes
# -----------------------------------------------------------------------------
# Makefile absolute path, if make gets called from another directory
MK_ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
MK_CONFIG_DIR := $(MK_ROOT_DIR)/config
MK_ENV := $(MK_ROOT_DIR)/makefile.env
# -----------------------------------------------------------------------------
# Include Makefile submodules
# -----------------------------------------------------------------------------
# Utilities:
include $(MK_CONFIG_DIR)/utilities.mk
ifeq ($(call file_exists, $(MK_ENV)), 1)
include $(MK_ENV)
$(call static_info, Found '$(B)makefile.env$(N)' - including definitions)
endif
$(call static_info, Running $(B)syfala$(N) toolchain \
($(B)v$(SYFALA_VERSION_FULL)$(N)) on $(B)$(OS_PRETTY_NAME)$(N))
$(call static_info, Commit #$(SYFALA_COMMIT_HASH))
$(call static_info, Running $(B)from$(N): $(PWD))
$(call static_info, $(B)Make targets$(N): $(MAKECMDGOALS))
# Sources:
include $(MK_CONFIG_DIR)/sources.mk
# Xilinx-related
include $(MK_CONFIG_DIR)/xilinx.mk
include $(MK_CONFIG_DIR)/boards.mk
include $(MK_CONFIG_DIR)/runtime-parameters.mk
# -----------------------------------------------------------------------------
SD_DEVICE ?= null
# -----------------------------------------------------------------------------
$(call static_info, - $(B)SD_DEVICE$(N) = $(SD_DEVICE))
# TODO:check partition formats
ifeq ($(call dev_exists,$(SD_DEVICE)),1)
ifeq ($(SD_DEVICE), /dev/mmcblk0)
$(call static_info, Found device: $(SD_DEVICE))
SD_DEVICE_BOOT_PARTITION := /dev/mmcblk0p1
SD_DEVICE_ROOT_PARTITION := /dev/mmcblk0p2
else ifeq ($(SD_DEVICE), /dev/sda)
$(call static_info, Found device: $(SD_DEVICE))
SD_DEVICE_BOOT_PARTITION := /dev/sda1
SD_DEVICE_ROOT_PARTITION := /dev/sda2
else
$(call static_info, Unsupported device: $(SD_DEVICE) (blame developer))
SD_DEVICE_BOOT_PARTITION := null
SD_DEVICE_ROOT_PARTITION := null
endif
endif
# -----------------------------------------------------------------------------
.PHONY: all
# -----------------------------------------------------------------------------
all: hw sw
# -----------------------------------------------------------------------------
# Linux
# -----------------------------------------------------------------------------
ifeq (linux, $(filter linux, $(MAKECMDGOALS)))
LINUX := TRUE
else
LINUX := FALSE
endif
# -----------------------------------------------------------------------------
HLS_FLAGS_INCLUDE = -I$(BUILD_INCLUDE_DIR)
# -----------------------------------------------------------------------------
# Including designs
# -----------------------------------------------------------------------------
ifeq ($(shell expr $(MULTISAMPLE) \> 0), 1) #--------------
include $(MK_CONFIG_DIR)/designs/multisample.mk
else # ----------------------------------------------------
$(call static_ok, - $(B)ONE_SAMPLE$(N) configuration)
endif # ---------------------------------------------------
ifeq ($(CONFIG_EXPERIMENTAL_TDM), TRUE) # -----------------
include $(MK_CONFIG_DIR)/designs/tdm.mk
endif # ---------------------------------------------------
ifeq ($(CONFIG_EXPERIMENTAL_ETHERNET), TRUE) # ------------
include $(MK_CONFIG_DIR)/designs/ethernet-audio.mk
else # ----------------------------------------------------
ETHERNET := 0
endif # ---------------------------------------------------
ifeq ($(CONFIG_EXPERIMENTAL_SIGMA_DELTA), TRUE) # ---------
include $(MK_CONFIG_DIR)/designs/sigma-delta.mk
else # ----------------------------------------------------
SIGMA_DELTA := 0
SIGMA_DELTA_ORDER := 0
endif # ---------------------------------------------------
ifeq (ETHERNET, $(filter ETHERNET, $(CONFIG)))
ifeq (MULTISAMPLE, $(filter MULTISAMPLE, $(CONFIG)))
ifeq (TDM, $(filter TDM, $(CONFIG)))
# -------------------------------------------------------------------
# ETHERNET + TDM + MULTISAMPLE
# -------------------------------------------------------------------
BD_TARGET ?= $(SOURCE_BD_DIR)/ethernet_tdm_multisample.tcl
I2S_SOURCE ?= $(SOURCE_I2S_DIR)/i2s_ethernet_tdm_multisample.vhd
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/base_design.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/syfala_ip.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/transceiver_tdm.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/multisample_bd.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/ethernet_base.tcl
else
# -------------------------------------------------------------------
# ETHERNET + MULTISAMPLE
# -------------------------------------------------------------------
BD_TARGET ?= $(SOURCE_BD_DIR)/ethernet_multisample.tcl
I2S_SOURCE ?= $(SOURCE_I2S_DIR)/i2s_ethernet_multisample.vhd
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/base_design.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/syfala_ip.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/transceiver_i2s.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/multisample_bd.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/ethernet_base.tcl
endif # -----------------------------------------------------------------
else ifeq (TDM, $(filter TDM, $(CONFIG)))
# -------------------------------------------------------------------
# ETHERNET + TDM
# -------------------------------------------------------------------
BD_TARGET ?= $(SOURCE_BD_DIR)/ethernet_tdm.tcl
I2S_SOURCE ?= $(SOURCE_I2S_DIR)/i2s_ethernet_tdm.vhd
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/base_design.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/syfala_ip.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/transceiver_tdm.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/onesample.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/ethernet_base.tcl
else
# -------------------------------------------------------------------
# ETHERNET
# -------------------------------------------------------------------
BD_TARGET ?= $(SOURCE_BD_DIR)/ethernet.tcl
I2S_SOURCE ?= $(SOURCE_I2S_DIR)/i2s_ethernet.vhd
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/base_design.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/syfala_ip.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/transceiver_i2s.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/onesample.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/ethernet_base.tcl
endif
else ifeq (TDM, $(filter TDM, $(CONFIG)))
ifeq (MULTISAMPLE, $(filter MULTISAMPLE, $(CONFIG)))
# -------------------------------------------------------------------
# TDM + MULTISAMPLE
# -------------------------------------------------------------------
BD_TARGET ?= $(SOURCE_BD_DIR)/tdm_multisample.tcl
I2S_SOURCE ?= $(SOURCE_I2S_DIR)/i2s_tdm_multisample.vhd
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/base_design.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/syfala_ip.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/transceiver_tdm.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/multisample_bd.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/spi.tcl
else
# -------------------------------------------------------------------
# TDM
# -------------------------------------------------------------------
BD_TARGET ?= $(SOURCE_BD_DIR)/tdm.tcl
I2S_SOURCE ?= $(SOURCE_I2S_DIR)/i2s_tdm.vhd
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/base_design.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/syfala_ip.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/transceiver_tdm.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/onesample.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/spi.tcl
endif
else ifeq (MULTISAMPLE, $(filter MULTISAMPLE, $(CONFIG)))
# -------------------------------------------------------------------
# MULTISAMPLE
# -------------------------------------------------------------------
BD_TARGET ?= $(SOURCE_BD_DIR)/multisample.tcl
I2S_SOURCE ?= $(SOURCE_I2S_DIR)/i2s_multisample.vhd
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/base_design.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/syfala_ip.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/transceiver_i2s.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/multisample_bd.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/spi.tcl
else ifeq (SIGMA_DELTA, $(filter SIGMA_DELTA, $(CONFIG)))
I2S_SOURCE ?= $(SOURCE_I2S_DIR)/i2s_standard.vhd
else
# -------------------------------------------------------------------
# ONE-SAMPLE
# -------------------------------------------------------------------
BD_TARGET ?= $(SOURCE_BD_DIR)/standard.tcl
I2S_SOURCE ?= $(SOURCE_I2S_DIR)/i2s_standard.vhd
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/base_design.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/syfala_ip.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/transceiver_i2s.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/onesample.tcl
PROJECT_DEPENDENCIES += $(SOURCE_BD_DIR)/modules/spi.tcl
endif # -------------------------------------------------------------------------
MULTISAMPLE ?= 0
ARM_BENCHMARK ?= 0
CTRL_MIDI ?= 0
CTRL_OSC ?= 0
CTRL_HTTP ?= 0
$(call static_info, - $(B)CONTROL_MIDI$(N): $(CTRL_MIDI))
$(call static_info, - $(B)CONTROL_OSC$(N) : $(CTRL_OSC))
$(call static_info, - $(B)CONTROL_HTTP$(N): $(CTRL_HTTP))
# -----------------------------------------------------------------------------
# Targets
# -----------------------------------------------------------------------------
TARGET_TYPE ?= faust
$(call static_info, - $(B)TARGET_TYPE$(N): $(TARGET_TYPE))
PREPROCESSOR_HLS ?= TRUE
PREPROCESSOR_I2S ?= TRUE
$(call static_info, - $(B)PREPROCESSOR_HLS$(N): $(PREPROCESSOR_HLS))
$(call static_info, - $(B)PREPROCESSOR_I2S$(N): $(PREPROCESSOR_I2S))
$(call static_info, - $(B)LINUX$(N): $(LINUX))
DEBUG ?= FALSE
VERBOSE ?= 0
DEBUG_AUDIO ?= 0
ADAU_EXTERN ?= 0
ADAU_MOTHERBOARD ?= 0
HLS_CSIM_NUM_ITER ?= 1
CONFIG_EXPERIMENTAL_ETHERNET_NO_OUTPUT ?= 0
# Note: the following rule has to be shared with the different target submodules
# (faust, cpp, etc.)
define set_arm_config_definition # ----------------------------------------------------
$(call shell_info, Setting #define $(B)$(1)$(N) $(2))
@sed -i 's/^#define\s$(1)\s[^ ]\+/#define $(1) $(2)/g' $(BUILD_SYFALA_ARM_CONFIG_H)
endef # -------------------------------------------------------------------------------
$(BUILD_SYFALA_ARM_CONFIG_H): $(SYFALA_ARM_CONFIG_H)
@mkdir -p $(BUILD_INCLUDE_DIR)/syfala
@cp -r $(SYFALA_ARM_CONFIG_H) $(BUILD_SYFALA_ARM_CONFIG_H)
$(call shell_info, Setting $(B)compile-time definitions$(N) in $(BUILD_SYFALA_ARM_CONFIG_H))
$(call set_arm_config_definition,SYFALA_SSM_VOLUME,$(SSM_VOLUME))
$(call set_arm_config_definition,SYFALA_SSM_SPEED,$(SSM_SPEED))
$(call set_arm_config_definition,SYFALA_ADAU_EXTERN,$(ADAU_EXTERN))
$(call set_arm_config_definition,SYFALA_ADAU_MOTHERBOARD,$(ADAU_MOTHERBOARD))
$(call set_arm_config_definition,SYFALA_ARM_BENCHMARK,$(ARM_BENCHMARK))
$(call set_arm_config_definition,SYFALA_CONTROLLER_TYPE,$(CONTROLLER_TYPE))
$(call set_arm_config_definition,SYFALA_CONTROL_MIDI,$(CTRL_MIDI))
$(call set_arm_config_definition,SYFALA_CONTROL_OSC,$(CTRL_OSC))
$(call set_arm_config_definition,SYFALA_CONTROL_HTTP,$(CTRL_HTTP))
$(call set_arm_config_definition,SYFALA_VERBOSE,$(VERBOSE))
$(call set_arm_config_definition,FAUST_INTERFACE_NEW,$(FAUST_INTERFACE_NEW))
ifneq ($(TARGET_TYPE), faust)
$(call set_arm_config_definition,SYFALA_FAUST_TARGET,0)
endif
ifeq ($(TARGET_TYPE), faust) # ----------------------------
include $(MK_CONFIG_DIR)/targets/faust.mk
endif # ---------------------------------------------------
ifeq ($(TARGET_TYPE), cpp) # ------------------------------
include $(MK_CONFIG_DIR)/targets/cpp.mk
endif # ---------------------------------------------------
ifeq ($(TARGET_TYPE), faust2vhdl) # -----------------------
include $(MK_CONFIG_DIR)/targets/faust2vhdl.mk
endif # ---------------------------------------------------
ifeq ($(CONFIG_EXPERIMENTAL_PD), TRUE) # ------------------
include $(MK_CONFIG_DIR)/targets/pd.mk
endif # ---------------------------------------------------
# -----------------------------------------------------------------------------
# Parameters
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
BD_TARGET ?= $(BD_STD)
# Block design target file, used to generate the full Vivado project
# -----------------------------------------------------------------------------
ifeq ($(call file_exists, $(BD_TARGET)), 0)
$(call static_error, $(BD_TARGET) does not exist, aborting...)
else
$(call static_ok, - $(B)BD_TARGET$(N): $(notdir $(BD_TARGET)))
endif
# -----------------------------------------------------------------------------
.PHONY: install
# Installs syfala.tcl in /usr/bin/syfala
# After that, users can simply call 'syfala <command>' instead
# of './syfala.tcl'
# -----------------------------------------------------------------------------
PREFIX ?= /usr
install:
$(call shell_info, Installing symlink in $(PREFIX)/bin/syfala)
@$(sudo) ln -fs $(PWD)/syfala.tcl $(PREFIX)/bin/syfala
$(call shell_info, You can now use the command 'syfala --help' to \
check if\n \t script has been properly installed)
# -----------------------------------------------------------------------------
.PHONY: status
# -----------------------------------------------------------------------------
status:
@exit
# -----------------------------------------------------------------------------
.PHONY: tidy
# Cleans up Xilinx temporary files & logs in repository's root
# -----------------------------------------------------------------------------
tidy:
@rm -rf vivado_*
@rm -rf vivado.*
@rm -rf Vitis_HLS
@rm -rf *.Xil
# -----------------------------------------------------------------------------
.PHONY: clean
# -----------------------------------------------------------------------------
clean: tidy
$(call remove_dir_confirm, $(BUILD_DIR))
$(call shell_info, Cleaning up $(B)build/$(N) directory)
@rm -rf *.log
# -----------------------------------------------------------------------------
.PHONY: reset
# Removes syfala 'build' directory and all of its contents
# -----------------------------------------------------------------------------
reset: clean
$(call shell_info, Resetting $(B)makefile.env$(N) & $(B)syfala_log.txt$(N))
@rm -rf makefile.env
@rm -rf syfala_log.txt
# -----------------------------------------------------------------------------
.PHONY: reset-linux
# Removes syfala 'build' AND 'build-linux' directories
# -----------------------------------------------------------------------------
reset-linux:
$(call shell_info, Removing $(B)build-linux$(N) directory)
$(call remove_dir_confirm, $(BUILD_LINUX_DIR), $(sudo))
# -----------------------------------------------------------------------------
.PHONY: reset-linux-root
# TODO: this should be in the linux submodule
# Removes build-linux/build/root & build-linux/output/root directories
# -----------------------------------------------------------------------------
reset-linux-root:
$(call shell_info, Removing $(B)build-linux root$(N) directories)
$(call remove_dir_confirm, $(BUILD_LINUX_ROOT_DIR) \
$(BUILD_LINUX_OUTPUT_ROOT_DIR), \
$(sudo) \
)
# -----------------------------------------------------------------------------
.PHONY: reset-linux-boot
# TODO: this should be in the linux submodule
# Removes build-linux/build/boot & build-linux/output/boot directories
# -----------------------------------------------------------------------------
reset-linux-boot:
$(call shell_info, Removing $(B)build-linux boot$(N) directories)
$(call remove_dir_confirm, $(BUILD_LINUX_BOOT_DIR) \
$(BUILD_LINUX_OUTPUT_BOOT_DIR))
# -----------------------------------------------------------------------------
.PHONY: help
# -----------------------------------------------------------------------------
help:
@cat doc/help.txt
# -----------------------------------------------------------------------------
.PHONY: version
# -----------------------------------------------------------------------------
version:
$(call shell_info, Running syfala toolchain script \
(v$(SYFALA_VERSION_FULL)) on $(OS_PRETTY_NAME))
# -----------------------------------------------------------------------------
.PHONY: log
# -----------------------------------------------------------------------------
log:
@cat syfala_log.txt
# -----------------------------------------------------------------------------
.PHONY: import
# Imports .zip file containing a previously saved syfala build
# ideally, in the future, we should have a more normalized way to do this
# and check for incorrect builds, or version compatibility issues...
# -----------------------------------------------------------------------------
import:
ifeq ($(call file_exists, $(IMPORT_TARGET)), 1)
$(call remove_dir_confirm, $(BUILD_DIR))
$(call shell_info, Importing build: $(B)$(IMPORT_TARGET)$(N))
@unzip -q $(IMPORT_TARGET) -d $(MK_ROOT_DIR)
$(call shell_info, Overwriting 'makefile.env')
@cp -r $(BUILD_DIR)/makefile.env $(MK_ROOT_DIR)
$(call shell_ok, Target successfully imported!)
else
$(call shell_error, $(B)IMPORT_TARGET$(N) does not exist, aborting)
$(error abort)
endif
# -----------------------------------------------------------------------------
.PHONY: export
# Exports the contents of $(BUILD_DIR) to a .zip file in the export/ directory
# parameters: $(EXPORT_TARGET): has to be set by the user
# -----------------------------------------------------------------------------
export:
$(call shell_info, Exporting build to $(B)export/$(EXPORT_TARGET).zip$(N))
@mkdir -p export/
ifeq ($(call file_exists, makefile.env), 1) # --------
@cp -r makefile.env $(BUILD_DIR)
endif # ----------------------------------------------
@zip -q -r export/$(EXPORT_TARGET).zip build/
$(call shell_ok, Build successfully exported!)
# -----------------------------------------------------------------------------
.PHONY: hls-target-file
# Rules to generate the HLS target files
# (build/syfala_ip/syfala_ip.cpp & build/syfala_ip/syfala_ip_preprocessed.cpp)
# -----------------------------------------------------------------------------
hls-target-file: $(HLS_TARGET_FILE)
HLS_DEPENDENCIES += $(HLS_TARGET_FILE)
ADD_FILES_CMD += add_files $(HLS_TARGET_FILE)
# -----------------------------------------------------------------------------
.PHONY: hls-includes
# Prepare cpp include files for the main HLS source:
# - config_common.hpp, containing all runtime parameters defined as macros,
# which will be overwritten using 'sed'.
# - utilities.hpp, an additional set of runtime definitions and compile-time
# expressions.
# -----------------------------------------------------------------------------
HLS_INCLUDES += $(BUILD_SYFALA_CONFIG_H)
HLS_INCLUDES += $(BUILD_SYFALA_UTILITIES_H)
HLS_DEPENDENCIES += $(HLS_INCLUDES)
define set_config_definition # ------------------------------------------------
$(call shell_info, Setting #define $(B)$(1)$(N) $(2))
@sed -i 's/^#define\s$(1)\s[^ ]\+/#define $(1) $(2)/g' $(BUILD_SYFALA_CONFIG_H)
endef # -----------------------------------------------------------------------
hls-includes: $(HLS_INCLUDES)
$(HLS_INCLUDES): $(SYFALA_CONFIG_H) $(SYFALA_UTILITIES_H) $(HLS_TARGET_FILE)
$(call shell_info, Preparing $(B)HLS$(N) sources...)
@mkdir -p $(BUILD_INCLUDE_DIR)/syfala
@cp -r $(SYFALA_CONFIG_H) $(BUILD_SYFALA_CONFIG_H)
@cp -r $(SYFALA_UTILITIES_H) $(BUILD_SYFALA_UTILITIES_H)
$(call shell_info, Setting $(B)compile-time definitions$(N) in $(BUILD_SYFALA_CONFIG_H))
$(call set_config_definition,SYFALA_BOARD,$(BOARD_CPP_ID))
$(call set_config_definition,SYFALA_SAMPLE_RATE,$(SAMPLE_RATE))
$(call set_config_definition,SYFALA_SAMPLE_WIDTH,$(SAMPLE_WIDTH))
$(call set_config_definition,SYFALA_MEMORY_USE_DDR,$(DDR))
$(call set_config_definition,SYFALA_BLOCK_NSAMPLES,$(MULTISAMPLE))
$(call set_config_definition,SYFALA_CSIM_NUM_ITER,$(HLS_CSIM_NUM_ITER))
$(call set_config_definition,SYFALA_DEBUG_AUDIO,$(DEBUG_AUDIO))
$(call set_config_definition,FAUST_VEC,$(FAUST_VEC))
$(call set_config_definition,SYFALA_ETHERNET_NO_OUTPUT,$(CONFIG_EXPERIMENTAL_ETHERNET_NO_OUTPUT))
$(call set_config_definition,SYFALA_ETHERNET_NCHANNELS_TO_I2S,$(shell $(get_nchannels_i)))
$(call set_config_definition,SYFALA_ETHERNET_NCHANNELS_FROM_I2S,$(shell $(get_nchannels_o)))
ifneq ($(TARGET_TYPE), faust)
$(call set_config_definition,SYFALA_CONTROL_BLOCK,0)
endif
# -----------------------------------------------------------------------------
.PHONY: hls
# Synthesizes the Syfala DSP IP using Vitis HLS
# -----------------------------------------------------------------------------
HLS_OUTPUT := $(BUILD_IP_DIR)/syfala/impl/vhdl/syfala.vhd
HLS_REPORT := $(BUILD_IP_DIR)/syfala/syn/report/syfala_csynth.rpt
HLS_TOP_LEVEL := syfala
ADD_FILES_CMD += -cflags "$(HLS_FLAGS_INCLUDE)";
HLS_DIRECTIVES += config_interface -m_axi_max_widen_bitwidth 512;
HLS_DIRECTIVES += config_interface -m_axi_alignment_byte_size 64;
ifeq ($(HLS_DIRECTIVES_UNSAFE_MATH_OPTIMIZATIONS), TRUE) # ---------
HLS_DIRECTIVES += config_compile -unsafe_math_optimizations=true
#; config_array_partition -complete_threshold=1
endif # ------------------------------------------------------------
ifeq ($(HLS_ROUTING_AND_PLACEMENT), TRUE)
HLS_FLOW += -flow impl
endif
ifdef HLS_SOURCE_FILES # -------------------------------------------
ADD_FILES_CMD += add_files "$(HLS_SOURCE_FILES)";
endif # ------------------------------------------------------------
# -------------------------------------------------------------------------------
HLS_COMMAND := cd $(BUILD_DIR); \
open_project -reset $(notdir $(BUILD_IP_DIR)); \
$(ADD_FILES_CMD) \
set_top $(HLS_TOP_LEVEL); \
open_solution -reset $(HLS_TOP_LEVEL) -flow_target vivado; \
set_part $(BOARD_PART); \
create_clock -period $(HLS_CLOCK_PERIOD); \
$(HLS_DIRECTIVES); \
config_export $(HLS_FLOW) -format ip_catalog -rtl vhdl; \
if [catch csynth_design] {exit 2}; \
export_design; \
exit;
# -------------------------------------------------------------------------------
hls: $(HLS_OUTPUT)
$(HLS_OUTPUT): $(HLS_DEPENDENCIES)
$(call shell_info, Running $(B)Vitis_HLS$(N) on file $(notdir $(HLS_TARGET_FILE)))
@echo '$(HLS_COMMAND)' | $(HLS_EXEC) -i
$(call shell_ok, High-level synthesis done)
# -----------------------------------------------------------------------------
.PHONY: hls-export
# -----------------------------------------------------------------------------
HLS_EXPORT_OUTPUT := $(DSP_TARGET_NAME)-hls-export.zip
hls-export: $(HLS_EXPORT_OUTPUT)
HLS_ADDITIONAL_INCLUDES += $(wildcard $(dir $(HLS_SOURCE_MAIN))*.h)
HLS_ADDITIONAL_INCLUDES += $(wildcard $(dir $(HLS_SOURCE_MAIN))*.hpp)
# -------------------------------------------------------------------------------
HLS_COMMAND_EXPORT := \
\n open_project -reset project; \
\n add_files syfala_ip_preprocessed.cpp -cflags "-Iinclude"; \
\n set_top $(HLS_TOP_LEVEL); \
\n open_solution -reset $(HLS_TOP_LEVEL) -flow_target vivado; \
\n set_part $(BOARD_PART); \
\n create_clock -period $(HLS_CLOCK_PERIOD); \
\n $(HLS_DIRECTIVES); \
\n config_export $(HLS_FLOW) -format ip_catalog -rtl vhdl; \
\n exit;
# -------------------------------------------------------------------------------
HLS_SCRIPT := $(BUILD_IP_DIR)/make_project.tcl
HLS_EXPORT_MAKEFILE := \
\nVITIS_HLS ?= vitis_hls \
\nall: \
\n\t$$(VITIS_HLS) make_project.tcl \
\n\t$$(VITIS_HLS) -p project
$(HLS_SCRIPT):
$(call shell_info, Generating HLS script)
echo '$(HLS_COMMAND_EXPORT)' > $(HLS_SCRIPT)
$(HLS_EXPORT_OUTPUT): $(HLS_DEPENDENCIES) $(HLS_SCRIPT)
$(call shell_info, Exporting HLS project to $(HLS_EXPORT_OUTPUT))
cp -r $(BUILD_INCLUDE_DIR) $(BUILD_IP_DIR)
cp -r $(HLS_ADDITIONAL_INCLUDES) $(BUILD_IP_DIR)/include
cp -r $(BUILD_IP_DIR) $(BUILD_DIR)/$(DSP_TARGET_NAME)
echo '$(HLS_EXPORT_MAKEFILE)' > $(BUILD_DIR)/$(DSP_TARGET_NAME)/Makefile
cd $(BUILD_DIR) && \
zip -q -r $(HLS_EXPORT_OUTPUT) $(DSP_TARGET_NAME)/ \
-x $(DSP_TARGET_NAME)/syfala/\* \
-x $(DSP_TARGET_NAME)/hls.app \
-x $(DSP_TARGET_NAME)/syfala_ip.cpp
mv $(BUILD_DIR)/$(HLS_EXPORT_OUTPUT) .
rm -rf $(BUILD_DIR)/$(DSP_TARGET_NAME)
# -----------------------------------------------------------------------------
.PHONY: hls-csim-target
# Generates the C-Simulation .cpp file (scripted by preprocessor if needed)
# Output in build/csim/csim_main.cpp
# -----------------------------------------------------------------------------
BUILD_CSIM_DIR := $(BUILD_DIR)/csim
HLS_CSIM_TARGET := $(BUILD_CSIM_DIR)/csim_main.cpp
HLS_CSIM_INCLUDE_SRC := $(TESTS_DIR)/csim/csim_template_utilities.hpp
HLS_CSIM_INCLUDE_DST := $(BUILD_CSIM_DIR)/csim_template_utilities.hpp
hls-csim-target: $(HLS_CSIM_TARGET)
define set_csim_definition # --------------------------------------------------
$(call shell_info, Setting #define $(B)$(1)$(N) $(2))
@sed -i 's/^#define\s$(1)\s[^ ]\+/#define $(1) $(2)/g' $(HLS_CSIM_INCLUDE_DST)
endef # -----------------------------------------------------------------------
# TODO: check HLS_CSIM_SOURCE
$(HLS_CSIM_INCLUDE_DST): $(HLS_CSIM_INCLUDE_SRC) $(HLS_TARGET_FILE)
$(call shell_info, Creating $(B)CSIM build includes$(N))
@mkdir -p $(BUILD_CSIM_DIR)
@cp -r $(HLS_CSIM_INCLUDE_SRC) $(HLS_CSIM_INCLUDE_DST)
$(call shell_info, Setting $(B)CSIM definitions$(N))
$(call set_csim_definition,SYFALA_NUM_INPUTS,$(shell $(get_nchannels_i)))
$(call set_csim_definition,SYFALA_NUM_OUTPUTS,$(shell $(get_nchannels_o)))
$(call set_csim_definition,SYFALA_NCONTROLS_F,$(shell $(get_ncontrols_f)))
$(call set_csim_definition,SYFALA_NCONTROLS_I,$(shell $(get_ncontrols_i)))
$(call set_csim_definition,SYFALA_NCONTROLS_P,$(shell $(get_ncontrols_p)))
$(HLS_CSIM_TARGET): $(HLS_CSIM_SOURCE) $(HLS_CSIM_INCLUDE_DST)
$(call shell_info, Creating $(B)CSIM build files$(N))
@cp -r $(HLS_CSIM_SOURCE) $(HLS_CSIM_TARGET)
# -----------------------------------------------------------------------------
.PHONY: hls-csim
# Rule to build and run the C-Simulation using Vitis HLS
# -----------------------------------------------------------------------------
HLS_CSIM_RUN := $(BUILD_CSIM_DIR)/syfala_csim/csim/build/run_sim.tcl
HLS_CSIM_REPORT := $(BUILD_CSIM_DIR)/syfala_csim/csim/report/syfala_csim.log
HLS_CSIM_OUTPUTS_DIR := $(MK_ROOT_DIR)/reports/$(DSP_TARGET_NAME)
hls-csim: $(HLS_CSIM_RUN)
# Add config_common.hpp & utilities.hpp header files
# Add the __CSIM__ def to utilities.hpp, which will allow <ap_int/ap_fixed> includes:
CSIM_FILES += add_files $(BUILD_SYFALA_CONFIG_H);
CSIM_FILES += add_files $(BUILD_INCLUDE_DIR)/syfala/utilities.hpp
CSIM_FILES += -cflags "-I$(BUILD_INCLUDE_DIR) -D__CSIM__";
# Add the preprocessed HLS file, include its source directory and add the __CSIM__ definition:
CSIM_FILES += add_files $(HLS_TARGET_FILE)
CSIM_FILES += -cflags "-I$(BUILD_INCLUDE_DIR) -I$(dir $(HLS_SOURCE_MAIN)) -D__CSIM__"
# Finally, include the testbench file, with all the required includes and definitions:
CSIM_TB += add_files -tb $(HLS_CSIM_TARGET)
CSIM_TB += -cflags "-I$(BUILD_INCLUDE_DIR) -I$(BUILD_IP_DIR) -I$(dir $(HLS_CSIM_SOURCE)) -D__CSIM__"
CSIM_ARGV += $(HLS_CSIM_OUTPUTS_DIR)
CSIM_ARGV += $(HLS_CSIM_INPUTS_DIR)
# -------------------------------------------------------------------------------
CSIM_COMMAND := cd $(BUILD_DIR); \
open_project -reset $(notdir $(BUILD_CSIM_DIR)); \
$(CSIM_FILES); \
set_top $(HLS_TOP_LEVEL); \
$(CSIM_TB); \
open_solution -reset syfala_csim -flow_target vivado; \
set_part $(BOARD_PART); \
create_clock -period $(HLS_CLOCK_PERIOD); \
csim_design -argv "$(CSIM_ARGV)"; \
exit;
# -------------------------------------------------------------------------------
$(HLS_CSIM_RUN): $(HLS_CSIM_TARGET) $(HLS_INCLUDES)
@mkdir -p $(HLS_CSIM_OUTPUTS_DIR)
$(call shell_info, Running $(B)Vitis_HLS$(N) on file $(notdir $(HLS_CSIM_TARGET)))
@echo '$(CSIM_COMMAND)' | $(HLS_EXEC) -i
# -----------------------------------------------------------------------------
.PHONY: open-project-hls
# -----------------------------------------------------------------------------
open-project-hls: $(HLS_OUTPUT)
$(call shell_info, Opening Vitis HLS project)
$(HLS_EXEC) -p $(BUILD_IP_DIR)
# -----------------------------------------------------------------------------
.PHONY: report-hls
# -----------------------------------------------------------------------------
report-hls: $(HLS_OUTPUT)
@less $(HLS_REPORT)
# -----------------------------------------------------------------------------
.PHONY: i2s
# -----------------------------------------------------------------------------
I2S_SOURCE ?= $(SOURCE_I2S_DIR)/i2s_template.vhd
I2S_TARGET := $(BUILD_RTL_DIR)/i2s_transceiver.vhd
ifeq ($(TARGET_TYPE), faust2vhdl) # -------------
I2S_DEPENDENCIES := $(FAUST_VHDL_OUTPUT)
else # -------------------------------------
I2S_DEPENDENCIES := $(HLS_OUTPUT)
endif #-------------------------------------
i2s: $(I2S_TARGET)
ifeq ($(call file_exists, $(I2S_SOURCE)), 1) # -----------------------
$(call static_ok, - $(B)I2S_SOURCE$(N): $(notdir $(I2S_SOURCE)))
else # ---------------------------------------------------------------
$(call static_error, - $(B)I2S_SOURCE$(N) file does not exist \
$(I2S_SOURCE))
$(error abort)
endif # --------------------------------------------------------------
ifeq ($(PREPROCESSOR_I2S), TRUE) # ----------------------------------
$(I2S_TARGET): $(I2S_SOURCE) $(I2S_DEPENDENCIES)
@mkdir -p $(BUILD_RTL_DIR)
$(call shell_info, Running $(B)preprocessor$(N) on \
$(B)I2S$(N) template ($(notdir $(I2S_TARGET))))
@tclsh $(SCRIPT_PREPROCESSOR) --i2s $(I2S_SOURCE) \
$(I2S_TARGET) \
$(shell $(get_nchannels_i)) \
$(shell $(get_nchannels_o)) \
$(SAMPLE_WIDTH) \
$(SAMPLE_RATE) \
$(MULTISAMPLE)
else # --------------------------------------------------------------
$(I2S_TARGET): $(I2S_SOURCE) $(I2S_DEPENDENCIES)
@mkdir -p $(BUILD_RTL_DIR)
@cp -r $(I2S_SOURCE) $(I2S_TARGET)
$(call shell_ok, Added $(notdir $(I2S_SOURCE)) to $(B)RTL targets$(N))
endif # -------------------------------------------------------------
# -----------------------------------------------------------------------------
.PHONY: rtl-targets
# -----------------------------------------------------------------------------
RTL_SOURCES += $(SOURCE_RTL_DIR)/mux_2to1.vhd
RTL_TARGETS += $(addprefix $(BUILD_RTL_DIR)/,$(notdir $(RTL_SOURCES)))
rtl-targets: $(RTL_TARGETS)
$(RTL_TARGETS): $(RTL_SOURCES)
$(call shell_info, Preparing $(B)RTL sources$(N))
@mkdir -p $(BUILD_RTL_DIR)
@cp -r $(RTL_SOURCES) $(BUILD_RTL_DIR)/
$(foreach rtl,$(RTL_SOURCES), \
$(call shell_ok, Added $(notdir $(rtl)) to $(B)RTL targets$(N)) \
)
# -----------------------------------------------------------------------------
.PHONY: project
# -----------------------------------------------------------------------------
BUILD_PROJECT_DIR := $(BUILD_DIR)/syfala_project
PROJECT_DEPENDENCIES += $(SCRIPT_PROJECT)
PROJECT_DEPENDENCIES += $(BD_TARGET)
PROJECT_DEPENDENCIES += $(RTL_TARGETS)
PROJECT_DEPENDENCIES += $(I2S_TARGET)
PROJECT_DEPENDENCIES += $(CONSTRAINT_FILE)
# ------------------------------------------------------------------------
VIVADO_CMD_ARGUMENTS += -mode batch -notrace -source $(SCRIPT_PROJECT)
VIVADO_CMD_ARGUMENTS += -tclargs
VIVADO_CMD_ARGUMENTS += $(BOARD)
VIVADO_CMD_ARGUMENTS += $(BOARD_PART)
VIVADO_CMD_ARGUMENTS += $(BOARD_PART_FULL)
VIVADO_CMD_ARGUMENTS += $(BOARD_ID)
VIVADO_CMD_ARGUMENTS += $(CONSTRAINT_FILE)
VIVADO_CMD_ARGUMENTS += $(MULTISAMPLE)
VIVADO_CMD_ARGUMENTS += $(SAMPLE_RATE)
VIVADO_CMD_ARGUMENTS += $(SAMPLE_WIDTH)
VIVADO_CMD_ARGUMENTS += $(BD_TARGET)
VIVADO_CMD_ARGUMENTS += $(ETHERNET)
VIVADO_CMD_ARGUMENTS += $(CONFIG_EXPERIMENTAL_ETHERNET_NO_OUTPUT)
VIVADO_CMD_ARGUMENTS += $(SIGMA_DELTA_ORDER)
# ------------------------------------------------------------------------
PROJECT_OUTPUT := $(BUILD_PROJECT_DIR)/syfala_project.gen/sources_1/bd/main/hdl/main_wrapper.vhd
PROJECT_OUTPUT += $(BUILD_PROJECT_DIR)/syfala_project.srcs/sources_1/bd/main/main.bd
PROJECT_FILE := $(BUILD_PROJECT_DIR)/syfala_project.xpr
project: $(PROJECT_OUTPUT)
$(PROJECT_OUTPUT): $(PROJECT_DEPENDENCIES)
$(call shell_info, Generating $(B)Vivado project$(N))
@mkdir -p $(BUILD_PROJECT_DIR)
$(VIVADO_EXEC) $(VIVADO_CMD_ARGUMENTS) \
$(shell $(get_nchannels_i)) \
$(shell $(get_nchannels_o))
$(call shell_ok, $(B)Vivado project$(N) succesfully generated)
# -----------------------------------------------------------------------------
.PHONY: open-project
# -----------------------------------------------------------------------------
open-project: $(PROJECT_OUTPUT)
$(call shell_info, Opening Vivado project)
$(VIVADO_EXEC) $(PROJECT_FILE)
# -----------------------------------------------------------------------------
.PHONY: synth
# -----------------------------------------------------------------------------
SYNTH_OUTPUT := $(BUILD_PROJECT_DIR)/syfala_project.runs/synth_1/__synthesis_is_complete__
SYNTH_COMMAND = open_project $(PROJECT_FILE); \
reset_run synth_1; \
launch_runs synth_1; \
wait_on_run synth_1;
synth: $(SYNTH_OUTPUT)
$(SYNTH_OUTPUT): $(PROJECT_OUTPUT)
$(call shell_info, Running $(B)project synthesis$(N) with Vivado)
echo "$(SYNTH_COMMAND)" | $(VIVADO_EXEC) -mode tcl
$(call shell_ok, Project synthesis succesfully completed)
# -----------------------------------------------------------------------------
.PHONY: impl
.PHONY: bitstream
# -----------------------------------------------------------------------------
IMPL_OUTPUT := $(BUILD_PROJECT_DIR)/syfala_project.runs/impl_1/main_wrapper.bit
BITSTREAM := $(IMPL_OUTPUT)
IMPL_COMMAND := open_project $(PROJECT_FILE); \
reset_run impl_1; \
launch_runs -to_step write_bitstream impl_1; \
wait_on_run impl_1;
impl: $(IMPL_OUTPUT)
bitstream: $(BITSTREAM)
$(IMPL_OUTPUT): $(SYNTH_OUTPUT)
$(call shell_info, Running $(B)project implementation$(N) with Vivado)
@echo "$(IMPL_COMMAND)" | $(VIVADO_EXEC) -mode tcl
@mkdir -p $(BUILD_DIR)/hw_export
@cp $(IMPL_OUTPUT) $(BUILD_DIR)/hw_export
$(call shell_ok, Project implementation succesfully completed)
# -----------------------------------------------------------------------------
.PHONY: hw
# -----------------------------------------------------------------------------
HW_PLATFORM := $(BUILD_DIR)/hw_export/main_wrapper.xsa
HW_COMMAND := open_project $(PROJECT_FILE); \
write_hw_platform \
-fixed \
-include_bit \
-force \
-file $(HW_PLATFORM)
hw: $(HW_PLATFORM)
$(HW_PLATFORM): $(IMPL_OUTPUT)
$(call shell_info, Exporting $(B)hardware platform$(N))
@mkdir -p $(BUILD_DIR)/hw_export
@echo "$(HW_COMMAND)" | $(VIVADO_EXEC) -mode tcl
$(call shell_ok, $(B)Hardware platform$(N) exported in build/hw_export)
# -----------------------------------------------------------------------------
# Host application
# -----------------------------------------------------------------------------
XSOURCES_DIR := $(BUILD_IP_DIR)/syfala/impl/ip/drivers/syfala_v1_0/src
XSOURCES += $(XSOURCES_DIR)/xsyfala.c
XSOURCES += $(XSOURCES_DIR)/xsyfala.h
XSOURCES += $(XSOURCES_DIR)/xsyfala_hw.h
XSOURCES += $(XSOURCES_DIR)/xsyfala_linux.c
XSOURCES += $(XSOURCES_DIR)/xsyfala_sinit.c
VITIS_CMD_ARGUMENTS := $(SCRIPT_HOST_CONFIG) \
$(BOARD) \
$(HOST_MAIN_SOURCE)
# -----------------------------------------------------------------------------
.PHONY: host-includes
# -----------------------------------------------------------------------------
HOST_INCLUDES += $(wildcard $(INCLUDE_DIR)/syfala/arm/*.hpp)
HOST_INCLUDES_CODECS += $(wildcard $(INCLUDE_DIR)/syfala/arm/codecs/*.hpp)
HOST_INCLUDES_CODECS += $(wildcard $(INCLUDE_DIR)/syfala/arm/codecs/*.h)
BUILD_HOST_INCLUDES += $(foreach hpp,$(HOST_INCLUDES), \
$(BUILD_INCLUDE_DIR)/syfala/arm/$(notdir $(hpp)))
BUILD_HOST_INCLUDES += $(foreach hpp,$(HOST_INCLUDES_CODECS), \
$(BUILD_INCLUDE_DIR)/syfala/arm/codecs/$(notdir $(hpp)))
host-includes: $(BUILD_HOST_INCLUDES)
$(BUILD_HOST_INCLUDES): $(HOST_INCLUDES) \
$(HOST_INCLUDES_CODECS) \
$(BUILD_SYFALA_ARM_CONFIG_H) \
$(BUILD_SYFALA_UTILITIES_H)
$(call shell_info, Copying host include directories)
@mkdir -p $(BUILD_INCLUDE_DIR)/syfala/arm
@cp -r $(HOST_INCLUDES) $(BUILD_INCLUDE_DIR)/syfala/arm/
@cp -r $(INCLUDE_DIR)/syfala/arm/codecs $(BUILD_INCLUDE_DIR)/syfala/arm/
# -----------------------------------------------------------------------------
.PHONY: host-application
# -----------------------------------------------------------------------------
HOST_APPLICATION := $(BUILD_SW_EXPORT_DIR)/application.elf
HOST_DEPENDENCIES += $(SCRIPT_HOST)
HOST_DEPENDENCIES += $(HW_PLATFORM)
HOST_DEPENDENCIES += $(BUILD_HOST_INCLUDES)
HOST_DEPENDENCIES += $(HOST_MAIN_SOURCE)
HOST_DEPENDENCIES += $(ARM_BAREMETAL_CPP_MODULES)
HOST_DEPENDENCIES += $(LINKER_FILE)
HOST_DEPENDENCIES += $(SOURCE_ARM_CODECS)
host-application: $(HOST_APPLICATION)
$(HOST_APPLICATION): $(HOST_DEPENDENCIES)
$(call shell_info, Building $(B)Host Control Application$(N))
@rm -rf $(BUILD_HOST_DIR)
@mkdir -p $(BUILD_HOST_DIR)
@mkdir -p $(BUILD_SW_EXPORT_DIR)
$(VITIS_EXEC) $(SCRIPT_HOST) $(VITIS_CMD_ARGUMENTS)
@cp -r $(BUILD_HOST_DIR)/application/Debug/application.elf $(HOST_APPLICATION)
$(call shell_ok, $(B)Host Control Application$(N) succesfully built)
# -----------------------------------------------------------------------------
ifeq ($(LINUX), FALSE)
# -----------------------------------------------------------------------------
BAREMETAL_BOOT_BIN := $(BUILD_DIR)/sw_export/boot.bin
# -----------------------------------------------------------------------------
.PHONY: boot
# -----------------------------------------------------------------------------
boot: $(BAREMETAL_BOOT_BIN)
$(BAREMETAL_BOOT_BIN): $(HOST_APPLICATION)
@mkdir -p $(BUILD_DIR)/sw_export
$(BOOTGEN_EXEC) -image $(SCRIPT_BIN_GENERATOR) \
-arch zynq \
-o $(BAREMETAL_BOOT_BIN) \
-w on
endif
# -----------------------------------------------------------------------------
.PHONY: flash-boot
# -----------------------------------------------------------------------------
ifeq ($(call dev_exists, $(SD_DEVICE_BOOT_PARTITION)), 1)
flash-boot: $(BAREMETAL_BOOT_BIN)
$(call shell_info, Mounting $(SD_DEVICE_BOOT_PARTITION))
@$(sudo) mount $(SD_DEVICE_BOOT_PARTITION) /mnt
$(call shell_info, Cleaning up $(SD_DEVICE_BOOT_PARTITION))
@rm -rf /mnt/*
$(call shell_info, Copying boot files)
@cp -r $(BAREMETAL_BOOT_BIN) /mnt
$(call shell_ok, Boot binary successfully copied)
$(call shell_info, Now syncing...)
@sync
$(call shell_info, Unmounting $(SD_DEVICE_BOOT_PARTITION))
@$(sudo) umount /mnt
else
$(call static_info, Could not find boot partition ($(SD_DEVICE_BOOT_PARTITION)))
SD_DEVICE_BOOT_PARTITION := null
endif
# -----------------------------------------------------------------------------
.PHONY: flash
# -----------------------------------------------------------------------------
FLASH_JTAG_TARGET ?= /dev/ttyUSB1
ifeq ($(call dev_exists, $(FLASH_JTAG_TARGET)),1)
flash: sw
$(call shell_info, Flashing build with JTAG)
$(VITIS_EXEC) $(SCRIPT_FLASH_JTAG) $(BOARD) $(VITIS_PATH)
else
flash: sw
$(call shell_error, Could not find device $(FLASH_JTAG_TARGET))
endif
# -----------------------------------------------------------------------------
ifeq ($(LINUX), TRUE)
# -----------------------------------------------------------------------------
include $(MK_CONFIG_DIR)/linux/linux.mk
# -----------------------------------------------------------------------------
.PHONY: sw
# -----------------------------------------------------------------------------
sw: linux
else
# -----------------------------------------------------------------------------
.PHONY: sw
# -----------------------------------------------------------------------------
sw: $(HOST_APPLICATION)
endif
# -----------------------------------------------------------------------------
.PHONY: sources
# -----------------------------------------------------------------------------
sources: $(BUILD_HOST_INCLUDES) \
$(FAUST_CONTROL_SOURCE) \
$(HLS_INCLUDES) \
$(HLS_TARGET_FILE)
# -----------------------------------------------------------------------------
.PHONY: reports
# -----------------------------------------------------------------------------
define faust_mem_count_cmd # ----------------------------------------
sed -n '/void\scomputemydsp/,/}/p' $(HLS_TARGET_FILE) \
| grep -o '$(1)' \
| wc -l
endef # -------------------------------------------------------------
faust_mem_count_cmd_r := $(call faust_mem_count_cmd,[if]Zone\[)
faust_mem_count_cmd_w := $(call faust_mem_count_cmd,[if]Zone\[.*\]\s=)
ifeq ($(MULTISAMPLE), 0)
REPORTS_NSAMPLES := 1
else
REPORTS_NSAMPLES := $(MULTISAMPLE)
endif