Skip to content

Commit

Permalink
[VTA][TSIM] update app example (#3343)
Browse files Browse the repository at this point in the history
* add initial support to cycle counter to accelerator

* remove prints from c

* add event counter support to chisel tsim example

* make it more readable

* use a config class

* update driver

* add individual Makefile to chisel

* add rule for installing vta package

* add makefile for verilog backend

* update drivers

* update

* rename

* update README

* put default sim back

* set counter to zero
  • Loading branch information
vegaluisjose authored and tmoreau89 committed Jun 11, 2019
1 parent 2c41fd2 commit 124f9b7
Show file tree
Hide file tree
Showing 22 changed files with 511 additions and 406 deletions.
10 changes: 7 additions & 3 deletions vta/apps/tsim_example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND
set(CMAKE_CXX_FLAGS "-faligned-new ${CMAKE_CXX_FLAGS}")
endif()

# Module rules
include(cmake/modules/hw.cmake)
include(cmake/modules/sw.cmake)
file(GLOB TSIM_SW_SRC src/driver.cc)
add_library(sw SHARED ${TSIM_SW_SRC})
target_include_directories(sw PRIVATE ${VTA_DIR}/include)

if(APPLE)
set_target_properties(sw PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
endif(APPLE)
28 changes: 20 additions & 8 deletions vta/apps/tsim_example/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,32 @@

export PYTHONPATH:=$(PWD)/python:$(PYTHONPATH)

BUILD_DIR = $(shell python3 config/config.py --get-build-name)
BUILD_NAME = build
build_dir = $(abspath .)/$(BUILD_NAME)

default: cmake run
default: verilog driver run_verilog

run_chisel: chisel driver
python3 tests/python/chisel_accel.py

.PHONY: cmake

cmake: | $(BUILD_DIR)
cd $(BUILD_DIR) && cmake .. && make
driver: | $(build_dir)
cd $(build_dir) && cmake .. && make

$(BUILD_DIR):
$(build_dir):
mkdir -p $@

run:
python3 tests/python/add_by_one.py | grep PASS
verilog:
make -C hardware/verilog

chisel:
make -C hardware/chisel

run_verilog:
python3 tests/python/verilog_accel.py

clean:
-rm -rf $(BUILD_DIR)
-rm -rf $(build_dir)
make -C hardware/chisel clean
make -C hardware/verilog clean
28 changes: 12 additions & 16 deletions vta/apps/tsim_example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,25 @@ sudo apt install verilator sbt
## Setup in TVM

1. Install `verilator` and `sbt` as described above
2. Change `TARGET` to `tsim` in `<tvm-root>/tvm/vta/config/vta_config.json`
3. Build [tvm](https://docs.tvm.ai/install/from_source.html#build-the-shared-library)
2. Build [tvm](https://docs.tvm.ai/install/from_source.html#build-the-shared-library)

## How to run VTA TSIM examples

There are two sample VTA accelerators (add-by-one) designed in Chisel3 and Verilog to show how *TSIM* works.
There are two sample VTA accelerators, add-a-constant, designed in Chisel3 and Verilog to show how *TSIM* works.
The default `TARGET` language for these two implementations is Verilog. The following instructions show
how to run both of them:

* Verilog add-by-one
* Test Verilog backend
* Go to `<tvm-root>/vta/apps/tsim_example`
* Run `make` to build and run add-by-one test
* Run `make`

* Chisel3 add-by-one
* Open `<tvm-root>/vta/apps/tsim_example/python/tsim/config.json`
* Change `TARGET` from `verilog` to `chisel`
* Go to `tvm/vta/apps/tsim_example`
* Run `make` to build and run add-by-one test
* Test Chisel3 backend
* Open `<tvm-root>/vta/apps/tsim_example`
* Run `make run_chisel`

* Some pointers
* Add-by-one test `<tvm-root>/vta/apps/tsim_example/tests/python/add_by_one.py`
* Add-by-one accelerator in Verilog `<tvm-root>/vta/apps/tsim_example/hardware/verilog`
* Add-by-one accelerator in Chisel3 `<tvm-root>/vta/apps/tsim_example/hardware/chisel`
* Software driver that handles the accelerator `<tvm-root>/vta/apps/tsim_example/src/driver.cc`
* Build cmake script for software library`<tvm-root>/vta/apps/tsim_example/cmake/modules/sw.cmake`
* Build cmake script for hardware library`<tvm-root>/vta/apps/tsim_example/cmake/modules/hw.cmake`
* Verilog and Chisel3 tests in `<tvm-root>/vta/apps/tsim_example/tests/python`
* Verilog accelerator backend `<tvm-root>/vta/apps/tsim_example/hardware/verilog`
* Chisel3 accelerator backend `<tvm-root>/vta/apps/tsim_example/hardware/chisel`
* Software C++ driver (backend) that handles the accelerator `<tvm-root>/vta/apps/tsim_example/src/driver.cc`
* Software Python driver (frontend) that handles the accelerator `<tvm-root>/vta/apps/tsim_example/python/accel`
152 changes: 0 additions & 152 deletions vta/apps/tsim_example/cmake/modules/hw.cmake

This file was deleted.

7 changes: 0 additions & 7 deletions vta/apps/tsim_example/config/config.json

This file was deleted.

61 changes: 0 additions & 61 deletions vta/apps/tsim_example/config/config.py

This file was deleted.

Loading

0 comments on commit 124f9b7

Please sign in to comment.