Skip to content
Snippets Groups Projects
Commit a2c75e7e authored by Yaman Umuroglu's avatar Yaman Umuroglu
Browse files

Merge branch 'dev' of https://github.com/Xilinx/finn into...

Merge branch 'dev' of https://github.com/Xilinx/finn into quetric-feature/GiveUniqueParameterTensors
parents 9139e407 4bcd0bc3
No related branches found
No related tags found
No related merge requests found
name: QuicktestPRAgainstDev
on:
pull_request:
branches: [ dev ]
push:
branches: [ dev ]
jobs:
test:
name: Run quicktest on PR branch
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: DockerRunQuicktest
run: sh run-docker.sh quicktest
...@@ -96,6 +96,8 @@ gecho "Port-forwarding for Netron $NETRON_PORT:$NETRON_PORT" ...@@ -96,6 +96,8 @@ gecho "Port-forwarding for Netron $NETRON_PORT:$NETRON_PORT"
gecho "Vivado IP cache dir is at $VIVADO_IP_CACHE" gecho "Vivado IP cache dir is at $VIVADO_IP_CACHE"
gecho "Using default PYNQ board $PYNQ_BOARD" gecho "Using default PYNQ board $PYNQ_BOARD"
DOCKER_INTERACTIVE = ""
if [ "$1" = "test" ]; then if [ "$1" = "test" ]; then
gecho "Running test suite (all tests)" gecho "Running test suite (all tests)"
DOCKER_CMD="python setup.py test" DOCKER_CMD="python setup.py test"
...@@ -108,6 +110,7 @@ elif [ "$1" = "notebook" ]; then ...@@ -108,6 +110,7 @@ elif [ "$1" = "notebook" ]; then
else else
gecho "Running container only" gecho "Running container only"
DOCKER_CMD="bash" DOCKER_CMD="bash"
DOCKER_INTERACTIVE="-it"
fi fi
# Build the FINN Docker image # Build the FINN Docker image
...@@ -123,7 +126,7 @@ docker build -f docker/Dockerfile.finn_dev --tag=$DOCKER_TAG \ ...@@ -123,7 +126,7 @@ docker build -f docker/Dockerfile.finn_dev --tag=$DOCKER_TAG \
# Launch container with current directory mounted # Launch container with current directory mounted
# important to pass the --init flag here for correct Vivado operation, see: # important to pass the --init flag here for correct Vivado operation, see:
# https://stackoverflow.com/questions/55733058/vivado-synthesis-hangs-in-docker-container-spawned-by-jenkins # https://stackoverflow.com/questions/55733058/vivado-synthesis-hangs-in-docker-container-spawned-by-jenkins
docker run -t --rm --name $DOCKER_INST_NAME -it --init \ docker run -t --rm --name $DOCKER_INST_NAME $DOCKER_INTERACTIVE --init \
--hostname $DOCKER_INST_NAME \ --hostname $DOCKER_INST_NAME \
-e "XILINX_VIVADO=$VIVADO_PATH" \ -e "XILINX_VIVADO=$VIVADO_PATH" \
-e "SHELL=/bin/bash" \ -e "SHELL=/bin/bash" \
......
...@@ -109,6 +109,31 @@ class HLSCustomOp(CustomOp): ...@@ -109,6 +109,31 @@ class HLSCustomOp(CustomOp):
) )
return verilog_file return verilog_file
def get_all_verilog_paths(self):
"Return list of all folders containing Verilog code for this node."
code_gen_dir = self.get_nodeattr("code_gen_dir_ipgen")
assert (
code_gen_dir != ""
), """Node attribute "code_gen_dir_ipgen" is
not set. Please run HLSSynthIP first."""
verilog_path = "{}/project_{}/sol1/impl/verilog/".format(
code_gen_dir, self.onnx_node.name
)
# default impl only returns the HLS verilog codegen dir
return [verilog_path]
def get_all_verilog_filenames(self):
"Return list of all Verilog files used for this node."
verilog_files = []
verilog_paths = self.get_all_verilog_paths()
for verilog_path in verilog_paths:
for f in os.listdir(verilog_path):
if f.endswith(".v"):
verilog_files += [f]
return verilog_files
def prepare_rtlsim(self): def prepare_rtlsim(self):
"""Creates a Verilator emulation library for the RTL code generated """Creates a Verilator emulation library for the RTL code generated
for this node, sets the rtlsim_so attribute to its path and returns for this node, sets the rtlsim_so attribute to its path and returns
...@@ -116,24 +141,15 @@ class HLSCustomOp(CustomOp): ...@@ -116,24 +141,15 @@ class HLSCustomOp(CustomOp):
if PyVerilator is None: if PyVerilator is None:
raise ImportError("Installation of PyVerilator is required.") raise ImportError("Installation of PyVerilator is required.")
# ensure that code is generated verilog_paths = self.get_all_verilog_paths()
code_gen_dir = self.get_nodeattr("code_gen_dir_ipgen") verilog_files = self.get_all_verilog_filenames()
assert (
code_gen_dir != ""
), """Node attribute "code_gen_dir_ipgen" is
not set. Please run HLSSynthIP first."""
verilog_file = self.get_verilog_top_filename()
assert os.path.isfile(verilog_file), "Cannot find top-level Verilog file."
# build the Verilator emu library # build the Verilator emu library
sim = PyVerilator.build( sim = PyVerilator.build(
verilog_file, verilog_files,
build_dir=make_build_dir("pyverilator_" + self.onnx_node.name + "_"), build_dir=make_build_dir("pyverilator_" + self.onnx_node.name + "_"),
verilog_path=[ verilog_path=verilog_paths,
"{}/project_{}/sol1/impl/verilog/".format(
code_gen_dir, self.onnx_node.name
)
],
trace_depth=get_rtlsim_trace_depth(), trace_depth=get_rtlsim_trace_depth(),
top_module_name=self.get_verilog_top_module_name(),
) )
# save generated lib filename in attribute # save generated lib filename in attribute
self.set_nodeattr("rtlsim_so", sim.lib._name) self.set_nodeattr("rtlsim_so", sim.lib._name)
......
...@@ -83,14 +83,27 @@ def pyverilate_stitched_ip(model): ...@@ -83,14 +83,27 @@ def pyverilate_stitched_ip(model):
def file_to_dir(x): def file_to_dir(x):
return os.path.dirname(os.path.realpath(x)) return os.path.dirname(os.path.realpath(x))
def file_to_basename(x):
return os.path.basename(os.path.realpath(x))
all_verilog_dirs = list(map(file_to_dir, all_verilog_srcs)) all_verilog_dirs = list(map(file_to_dir, all_verilog_srcs))
top_verilog = model.get_metadata_prop("wrapper_filename") all_verilog_files = list(
set(
filter(
lambda x: x.endswith(".v"),
list(map(file_to_basename, all_verilog_srcs)),
)
)
)
top_module_name = model.get_metadata_prop("wrapper_filename")
top_module_name = file_to_basename(top_module_name).strip(".v")
build_dir = make_build_dir("pyverilator_ipstitched_") build_dir = make_build_dir("pyverilator_ipstitched_")
sim = PyVerilator.build( sim = PyVerilator.build(
top_verilog, all_verilog_files,
verilog_path=all_verilog_dirs, verilog_path=all_verilog_dirs,
build_dir=build_dir, build_dir=build_dir,
trace_depth=get_rtlsim_trace_depth(), trace_depth=get_rtlsim_trace_depth(),
top_module_name=top_module_name,
) )
return sim return sim
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment