Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade from Vivado HLS to Vitis HLS v2024.2 #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,31 @@
*.upa
*.upb
main.pdf
*.bin
*.bin
*.o

# hls projects
**/*.proj/
**/*.comp/

# ignore any python virtual environments
**/.venv/

# ignore examples/tcl files since they are auto-generated
examples/*.tcl

*.pyc

.vscode/

examples/hls/

.gradle/

examples/*.out.dat
examples/out.*.dat
examples/out.dat
examples/video*.bmp

scripts/tests/___summary_all_header.adoc

19 changes: 15 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
base=main
all: main.pdf

# pdflatex is part of the Texlive distribution.
#
# See https://tug.org/texlive/ for TexLive installation instructions.
# Docker image available at https://hub.docker.com/r/texlive/texlive/

# NOTE: You *must* put the path to your texlive installation here.
TEXLIVE_BINDIR=/wrk/xsjhdnobkup2/mpettigr/projects_nobkup/texlive/texlive/install-tl-20240625/./texlive/2024/bin/x86_64-linux
PDFLATEX=PATH=$(TEXLIVE_BINDIR):$$PATH $(TEXLIVE_BINDIR)/pdflatex
BIBTEX=PATH=$(TEXLIVE_BINDIR):$$PATH $(TEXLIVE_BINDIR)/bibtex

main.aux: all.bib
pdflatex \\nonstopmode\\input main.tex
bibtex main
$(PDFLATEX) \\nonstopmode\\input main.tex
$(BIBTEX) main

main.pdf: main.aux *.tex
pdflatex \\nonstopmode\\input main.tex
pdflatex \\nonstopmode\\input main.tex
$(PDFLATEX) \\nonstopmode\\input main.tex
$(PDFLATEX) \\nonstopmode\\input main.tex

clean:
rm -rf main.pdf *.log *~ *.aux *.bbl *.blg *.out

4 changes: 4 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
ignores: [(commit) => commit.includes('chore(release)')],
};
160 changes: 134 additions & 26 deletions examples/Makefile
Original file line number Diff line number Diff line change
@@ -1,59 +1,167 @@
VHLS = $(shell vivado_hls -r)
# This makefile was tested with Vivado HLS 2019.2
# and Vitis v2024.1
#
#

# select the HLS compiler to use (vivado_hls or vitis)
USE_VITIS=1

ifeq ($(USE_VITIS),1)
VITIS_COMPILER := $(shell dirname $(shell which vitis_hls))

VHLS = $(VITIS_COMPILER)/../../../Vitis/2024.2
HLS_COMPILER=vitis-run --mode hls --tcl
else
VHLS := $(shell vivado_hls -r)
HLS_COMPILER=vivado_hls -f
endif

EXAMPLES = $(shell ls *-top.c)
EXAMPLES_CPP = $(shell ls *-top.cpp)
EXAMPLES_BIN = $(patsubst %.c,%,$(EXAMPLES))
EXAMPLES_BIN += $(patsubst %.cpp,%,$(EXAMPLES_CPP))
EXAMPLES_LOG = $(patsubst %.c,%.log,$(EXAMPLES))
EXAMPLES_LOG += $(patsubst %.cpp,%.log,$(EXAMPLES_CPP))

#CC = $(VHLS)/lnx64/tools/gcc/bin/gcc
#CXX = $(VHLS)/lnx64/tools/gcc/bin/g++
#CC = $(VHLS)/lnx64/tools/clang/bin/clang
#CXX = $(VHLS)/lnx64/tools/clang/bin/clang++
CC = gcc
CXX = g++

# insert new LD path to the LD_LIBRARY_PATH if it is not already there
#
LD_PATH_NEW = /usr/lib/x86_64-linux-gnu
LD_LIBRARY_PATH := $(shell echo $(value LD_LIBRARY_PATH) | grep -q $(LD_PATH_NEW) || echo $(LD_PATH_NEW):)$(value LD_LIBRARY_PATH)

#GEN_TCL = $(CURDIR)/../scripts/gen_hls_csynth_script.py
GEN_TCL = $(CURDIR)/../scripts/gen_hls_runner_script.py

#HLS_CONFIG_FILE = $(CURDIR)/__hls_config__.ini
HLS_CONFIG_FILE = $(CURDIR)/__hls_config__versal500__.ini

$(warning $(EXAMPLES_LOG))

INPUTFILE=BBC_HD_test_1920x1080.bmp
INPUTFILE=test_20x20.bmp
INPUTFILE_GOLDEN_REF=test_20x20_filtered_opencv.bmp
video_simple-top.log: video_simple-top.bin
./$< $(INPUTFILE) video_simple.bmp > $@

video_2dfilter-top.log: video_2dfilter-top.bin
./$< $(INPUTFILE) video_2dfilter.bmp > $@
./$< $(INPUTFILE) $(INPUTFILE_GOLDEN_REF) video_2dfilter.bmp > $@

video_2dfilter_boundary_condition-top.log: video_2dfilter_boundary_condition-top.bin
./$< $(INPUTFILE) video_2dfilter_boundary_condition.bmp > $@
./$< $(INPUTFILE) $(INPUTFILE_GOLDEN_REF) video_2dfilter_boundary_condition.bmp > $@

video_2dfilter_linebuffer-top.log: video_2dfilter_linebuffer-top.bin
./$< $(INPUTFILE) video_2dfilter_linebuffer.bmp > $@
./$< $(INPUTFILE) $(INPUTFILE_GOLDEN_REF) video_2dfilter_linebuffer.bmp > $@

video_2dfilter_linebuffer_extended-top.log: video_2dfilter_linebuffer_extended-top.bin
./$< $(INPUTFILE) video_2dfilter_linebuffer_extended.bmp > $@
./$< $(INPUTFILE) $(INPUTFILE_GOLDEN_REF) video_2dfilter_linebuffer_extended.bmp > $@

video_2dfilter_linebuffer_extended_constant-top.log: video_2dfilter_linebuffer_extended_constant-top.bin
./$< $(INPUTFILE) video_2dfilter_linebuffer_extended_constant.bmp > $@
./$< $(INPUTFILE) $(INPUTFILE_GOLDEN_REF) video_2dfilter_linebuffer_extended_constant.bmp > $@

%.o: %.c
$(CC) -I$(VHLS)/include -c $< -o $@
%.o: %.cpp
$(CXX) -I$(VHLS)/include -c $< -o $@

complex_fir-top.bin: complex_fir-top.o complex_fir.o fir.o
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) $(CXX) -I$(VHLS)/include -g -o $@ $^

%-top.bin: %-top.c %.c bitmap.c
gcc -I$(VHLS)/include -std=c99 $? -g -o $@
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) $(CC) -I$(VHLS)/include -std=c99 $^ -g -o $@

%-top.bin: %-top.cpp %.cpp
g++ -I$(VHLS)/include $? -g -o $@
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) $(CXX) -I$(VHLS)/include $? -g -o $@

insertion_cell_sort-top.bin: insertion_cell_sort-top.cpp insertion_cell_sort.cpp insertion_sort.cpp
g++ -I$(VHLS)/include $? -g -o $@

#: %-top.bin
%.tcl:
rm -f $@
echo "open_project $*.proj -reset" > $@
echo "add_file $*.c" >> $@
echo "add_file -tb $*-top.c" >> $@
echo "set_top $*" >> $@
echo "open_solution solution -reset" >> $@
echo "set_part virtex7" >> $@
echo "create_clock -period 5" >> $@
echo "csynth_design" >> $@

%.proj: %.tcl
vivado_hls $?
echo $(LD_LIBRARY_PATH)
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) $(CXX) -I$(VHLS)/include $? -g -o $@

# missing cos_table and sin_table definition. No testbench files available
# dft.c \
# dft_precompute.c \

CC_HLS_TARGET_FILES = \
block_fir.c \
fir.c \
fir11_initial.c \
fir_cslowed.c \
firrolled.c \
matrix_vector_base.c \
matrix_vector_base_unroll_inner.c \
matrix_vector_optimized.c \
matrix_vector_unroll_inner2.c \
video_2dfilter.c \
video_2dfilter_boundary_condition.c \
video_2dfilter_linebuffer.c \
video_2dfilter_linebuffer_extended.c \
video_2dfilter_linebuffer_extended_constant.c \
video_simple.c

CXX_HLS_TARGET_FILES = \
block_mm.cpp \
complex_fir.cpp \
cordic.cpp \
cordic_fixed.cpp \
fft_stages.cpp \
fft_stages_loop.cpp \
fft_sw.cpp \
histogramSW.cpp \
histogram_dependence.cpp \
histogram_opt1.cpp \
huffman_encoding.cpp \
insertion_cell_sort.cpp \
insertion_sort.cpp \
insertion_sort_parallel.cpp \
insertion_sort_relaxed.cpp \
matrixmultiplication.cpp \
merge_sort.cpp \
merge_sort_loop_merged.cpp \
merge_sort_parallel.cpp \
merge_sort_restructured.cpp \
prefixsumBO.cpp \
prefixsumHW.cpp \
prefixsumSW.cpp \
prefixsum_optimized.cpp \
prefixsum_unrolled.cpp \
restructured_merge_sort.cpp \
spmv.cpp \
spmv_restructured.cpp \
spmv2.cpp \
spmv2_interleaved.cpp \
spmv2_restructured.cpp \
spmv_unrolled.cpp

HLS_TARGETS = $(patsubst %.c,%.comp,$(CC_HLS_TARGET_FILES))
HLS_TARGETS += $(patsubst %.cpp,%.comp,$(CXX_HLS_TARGET_FILES))

%.comp: %.tcl
# vivado_hls -f $?
$(HLS_COMPILER) $? || (echo "$(HLS_COMPILER) $? failed $$?"; exit 0)

%.tcl: %.c
$(GEN_TCL) -c $(HLS_CONFIG_FILE) -i $< -o $@

%.tcl: %.cpp
$(GEN_TCL) -c $(HLS_CONFIG_FILE) -i $< -o $@

%.log: %.bin
./$< > $@
-./$< > $@ || (echo "./$< > $@ failed $$?"; exit 1)


hls: $(HLS_TARGETS)

test: $(EXAMPLES_LOG)


clean:
rm -rf *.o *.log *.bin *.tcl *.comp logs/* hls/*

.PHONY: clean hls test

# Prevent make from deleting the .bin intermediate files
.PRECIOUS: %.bin %.tcl block_fir-top.bin fir-top.bin
Loading