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

[VTA] add doc to tsim-example driver and update verilator env variable #3302

Merged
merged 8 commits into from
Jun 7, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
21 changes: 17 additions & 4 deletions vta/apps/tsim_example/python/tsim/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,27 @@
import os.path as osp
from sys import platform

def driver(hw, sw):
def driver(hw_lib, sw_lib):
"""Init hardware and software shared library for add-by-one accelerator

Parameters
------------
hw_lib : str
Name of hardware shared library

sw_lib : str
Name of software shared library
"""
_cur_path = osp.dirname(osp.abspath(osp.expanduser(__file__)))
_root_path = osp.join(_cur_path, "..", "..")
_cfg_file = osp.join(_root_path, "config", "config.json")
_cfg = json.load(open(_cfg_file))
_ext = ".dylib" if platform == "darwin" else ".so"
_hw_lib = osp.join(_root_path, _cfg['BUILD_NAME'], hw + _ext)
_sw_lib = osp.join(_root_path, _cfg['BUILD_NAME'], sw + _ext)
if not hw_lib.endswith(("dylib", "so")):
hw_lib += ".dylib" if platform == "darwin" else ".so"
if not sw_lib.endswith(("dylib", "so")):
sw_lib += ".dylib" if platform == "darwin" else ".so"
_hw_lib = osp.join(_root_path, _cfg['BUILD_NAME'], hw_lib)
_sw_lib = osp.join(_root_path, _cfg['BUILD_NAME'], sw_lib)

def load_dll(dll):
try:
Expand Down
13 changes: 7 additions & 6 deletions vta/hardware/chisel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# specific language governing permissions and limitations
# under the License.

export VERILATOR_INC_DIR = /usr/local/share/verilator/include
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be external to the Makefile IMO; and set by the user. See: https://docs.tvm.ai/install/from_source.html#tvm-package

I think we should make it clear in the instructions that this variable needs to be set by the user, when they install verilator.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe just wrap the export in an ifndef

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I guess we could try to check if the path exists in the makefile then?.

I think having to setup more environment variables is a pain for the user.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that hard coded paths will fail at some point depending on os, or package manager. Given that the user will need to install verilator themselves, this is part of the installation process. We just need to add a line saying to export blah.

Copy link
Member Author

@vegaluisjose vegaluisjose Jun 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just added something that test if path exist otherwise it won't build. We will add this to the documentation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should have a cascade of checks: check that the variable exists, if not, set to default path; check that the binary exists, else error out

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I just added the cascade of checks for binary first then for the path.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, it looks good except that we shouldn't use export in a Makefile. Instead can we use a ?= to set if not set?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


CONFIG = DefaultF1Config
TOP = VTA
TOP_TEST = Test
Expand All @@ -25,7 +27,6 @@ VTA_LIBNAME = libvta_hw
config_test = $(TOP_TEST)$(CONFIG)
vta_dir = $(abspath ../../)
tvm_dir = $(abspath ../../../)
verilator_inc_dir = /usr/local/share/verilator/include
verilator_build_dir = $(vta_dir)/$(BUILD_NAME)/verilator
chisel_build_dir = $(vta_dir)/$(BUILD_NAME)/chisel

Expand All @@ -50,22 +51,22 @@ cxx_flags += -DVM_SC=0
cxx_flags += -Wno-sign-compare
cxx_flags += -include V$(TOP_TEST).h
cxx_flags += -I$(verilator_build_dir)
cxx_flags += -I$(verilator_inc_dir)
cxx_flags += -I$(verilator_inc_dir)/vltstd
cxx_flags += -I$(VERILATOR_INC_DIR)
cxx_flags += -I$(VERILATOR_INC_DIR)/vltstd
cxx_flags += -I$(vta_dir)/include
cxx_flags += -I$(tvm_dir)/include
cxx_flags += -I$(tvm_dir)/3rdparty/dlpack/include

cxx_files = $(verilator_inc_dir)/verilated.cpp
cxx_files += $(verilator_inc_dir)/verilated_dpi.cpp
cxx_files = $(VERILATOR_INC_DIR)/verilated.cpp
cxx_files += $(VERILATOR_INC_DIR)/verilated_dpi.cpp
cxx_files += $(wildcard $(verilator_build_dir)/*.cpp)
cxx_files += $(vta_dir)/hardware/dpi/tsim_device.cc

ifneq ($(USE_TRACE), 0)
verilator_opt += --trace
cxx_flags += -DVM_TRACE=1
cxx_flags += -DTSIM_TRACE_FILE=$(verilator_build_dir)/$(TOP_TEST).vcd
cxx_files += $(verilator_inc_dir)/verilated_vcd_c.cpp
cxx_files += $(VERILATOR_INC_DIR)/verilated_vcd_c.cpp
else
cxx_flags += -DVM_TRACE=0
endif
Expand Down