Makefile 1.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

18 19
# Directories
ROOTDIR = $(CURDIR)
20 21 22 23
VTA_DIR = $(CURDIR)/../..
BUILD_DIR = $(VTA_DIR)/build/hardware/xilinx
SCRIPT_DIR = $(CURDIR)/scripts
SRC_DIR = $(CURDIR)/src
24 25 26 27

# Executables
VIVADO_HLS = vivado_hls
VIVADO = vivado
28

29
# Process VTA JSON config
30
VTA_CONFIG := $(CURDIR)/../../config/vta_config.py
31

32
# Derive config name
33 34 35
CONF := $(shell python ${VTA_CONFIG} --cfg-str)
IP_BUILD_PATH := $(BUILD_DIR)/hls/$(CONF)
HW_BUILD_PATH := $(BUILD_DIR)/vivado/$(CONF)
36

37
# IP file path
38
IP_PATH := $(BUILD_DIR)/hls/$(CONF)/vta_compute/soln/impl/ip/xilinx_com_hls_compute_1_0.zip
39 40

# Bitstream file path
41
BIT_PATH := $(BUILD_DIR)/vivado/$(CONF)/export/$(CONF).bit
42

43
.PHONY: all ip bit clean clean_all
44

45
all: bit
46 47 48 49
ip: $(IP_PATH)
bit: $(BIT_PATH)

$(IP_PATH): $(SRC_DIR)/*
50 51
	mkdir -p $(IP_BUILD_PATH)
	cd $(IP_BUILD_PATH) && \
52 53 54 55 56
		$(VIVADO_HLS) \
		-f $(SCRIPT_DIR)/hls.tcl \
		-tclargs \
			$(VTA_DIR) \
			${VTA_CONFIG}
57

58
$(BIT_PATH): $(IP_PATH)
59 60
	mkdir -p $(HW_BUILD_PATH)
	cd $(HW_BUILD_PATH) && \
61 62 63 64 65 66
		$(VIVADO) \
		-mode tcl \
		-source $(SCRIPT_DIR)/vivado.tcl \
		-tclargs \
			$(BUILD_DIR)/hls/$(CONF) \
			${VTA_CONFIG}
67 68

clean:
69
	rm -rf *.out *.log
70

71
cleanall: clean
72
	rm -rf $(BUILD_DIR)