Download the Virtual Simulator
$ git clone https://github.com/nvdla/vp.git
$ cd vp
$ git submodule update --init --recursive
Install Dependencies
1. Install required tools and libraries
$ sudo apt-get install g++ cmake libboost-dev python-dev libglib2.0-dev libpixman-1-dev liblua5.2-dev swig libcap-dev libattr1-dev
2. Download and install SystemC 2.3.0
$ wget -O systemc-2.3.0a.tar.gz http://www.accellera.org/images/downloads/standards/systemc/systemc-2.3.0a.tar.gz
$ tar -xzvf systemc-2.3.0a.tar.gz
$ cd systemc-2.3.0a
$ sudo mkdir -p /usr/local/systemc-2.3.0/
$ mkdir objdir
$ cd objdir
$ ../configure --prefix=/usr/local/systemc-2.3.0
$ make
$ sudo make install
如果遇到make install没有安装到制定目录的问题,查看Makefile中prefix变量赋值
prefix = /usr/local/systemc-2.3.0
3. Download and build NVDLA CMOD
$ git clone https://github.com/nvdla/hw.git
$ cd hw
$ make
如果遇到make install没有安装到制定目录的问题,查看Makefile中prefix变量赋值
prefix = /usr/local/systemc-2.3.0
3. Download and build NVDLA CMOD
$ git clone https://github.com/nvdla/hw.git
$ cd hw
$ make
这步按照提示输入对应工具路径,以下为参考:
DEFAULT_CPP := /usr/bin/cpp
DEFAULT_GCC := /usr/bin/g++
DEFAULT_PERL := /usr/bin/perl
DEFAULT_JAVA := /usr/bin/java
DEFAULT_SYSTEMC := /usr/local/systemc-2.3.0
DEFAULT_VERILATOR := verilator
DEFAULT_CLANG := clang
DEFAULT_PROJ := nv_full
$ tools/bin/tmake -build cmod_top
4. Cmake build
$ cd vp
$ cmake -DCMAKE_INSTALL_PREFIX=build -DSYSTEMC_PREFIX=/usr/local/systemc-2.3.0/ -DNVDLA_HW_PREFIX=/path/to/nvdla/hw -DNVDLA_HW_PROJECT=nv_full
$ make
编译vp中会遇到一些问题,参考以下解决方法
Can't locate YAML.pm/Tee.pm error
安装YAML.pm
downloading from url: http://search.cpan.org/CPAN/authors/id/T/TI/TINITA/YAML-1.24.tar.gz
perl Makefile.PL
make;
sudo make install
安装IO/Tee.pm
downloading from url: http://search.cpan.org/CPAN/authors/id/N/NE/NEILB/IO-Tee-0.65.tar.gz
perl Makefile.PL
make;
sudo make install
Deprecated Error
/usr/local/systemc-2.3.0/include/sysc/packages/boost/get_pointer.hpp:21:40: error: ‘template<class> class std::auto_ptr’ is deprecated [-Werror=deprecated-declarations]
template<class T> T * get_pointer(std::auto_ptr<T> const& p)
修改vp/CMakeLists.txt
注释下面三行:
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSC_INCLUDE_DYNAMIC_PROCESSES -Wall -Werror ${AWS_FPGA_CFLAGS} ${TRACE_CFLAGS}")
# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSC_INCLUDE_DYNAMIC_PROCESSES -Wall -Werror -DDEBUG_LOG=1 ${AWS_FPGA_CFLAGS} ${TRACE_CFLAGS}")
# set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DSC_INCLUDE_DYNAMIC_PROCESSES -Wall -Werror ${AWS_FPGA_CFLAGS} ${TRACE_CFLAGS}")
添加如下:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSC_INCLUDE_DYNAMIC_PROCESSES -Wall ${AWS_FPGA_CFLAGS} ${TRACE_CFLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSC_INCLUDE_DYNAMIC_PROCESSES -Wall -DDEBUG_LOG=1 ${AWS_FPGA_CFLAGS} ${TRACE_CFLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DSC_INCLUDE_DYNAMIC_PROCESSES -Wall ${AWS_FPGA_CFLAGS} ${TRACE_CFLAGS}")
将子目录下CMakeList.txt中的 CMAKE_CXX_FLAGS语句中的-Werror删除
./models/nvdla/CMakeLists.txt +87
./models/nvdla/CMakeLists.txt +88
./models/nvdla/CMakeLists.txt +89
./fpga/aws-fpga/fpga_sc_wrapper/CMakeLists.txt +91
./fpga/aws-fpga/fpga_sc_wrapper/CMakeLists.txt +92
./fpga/aws-fpga/fpga_sc_wrapper/CMakeLists.txt +93
./fpga/aws-fpga/cosim_sc_wrapper/CMakeLists.txt +82
./fpga/aws-fpga/cosim_sc_wrapper/CMakeLists.txt +83
./fpga/aws-fpga/cosim_sc_wrapper/CMakeLists.txt +84
安装YAML.pm
downloading from url: http://search.cpan.org/CPAN/authors/id/T/TI/TINITA/YAML-1.24.tar.gz
perl Makefile.PL
make;
sudo make install
安装IO/Tee.pm
downloading from url: http://search.cpan.org/CPAN/authors/id/N/NE/NEILB/IO-Tee-0.65.tar.gz
perl Makefile.PL
make;
sudo make install
Deprecated Error
/usr/local/systemc-2.3.0/include/sysc/packages/boost/get_pointer.hpp:21:40: error: ‘template<class> class std::auto_ptr’ is deprecated [-Werror=deprecated-declarations]
template<class T> T * get_pointer(std::auto_ptr<T> const& p)
修改vp/CMakeLists.txt
注释下面三行:
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSC_INCLUDE_DYNAMIC_PROCESSES -Wall -Werror ${AWS_FPGA_CFLAGS} ${TRACE_CFLAGS}")
# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSC_INCLUDE_DYNAMIC_PROCESSES -Wall -Werror -DDEBUG_LOG=1 ${AWS_FPGA_CFLAGS} ${TRACE_CFLAGS}")
# set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DSC_INCLUDE_DYNAMIC_PROCESSES -Wall -Werror ${AWS_FPGA_CFLAGS} ${TRACE_CFLAGS}")
添加如下:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSC_INCLUDE_DYNAMIC_PROCESSES -Wall ${AWS_FPGA_CFLAGS} ${TRACE_CFLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSC_INCLUDE_DYNAMIC_PROCESSES -Wall -DDEBUG_LOG=1 ${AWS_FPGA_CFLAGS} ${TRACE_CFLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DSC_INCLUDE_DYNAMIC_PROCESSES -Wall ${AWS_FPGA_CFLAGS} ${TRACE_CFLAGS}")
将子目录下CMakeList.txt中的 CMAKE_CXX_FLAGS语句中的-Werror删除
./models/nvdla/CMakeLists.txt +87
./models/nvdla/CMakeLists.txt +88
./models/nvdla/CMakeLists.txt +89
./fpga/aws-fpga/fpga_sc_wrapper/CMakeLists.txt +91
./fpga/aws-fpga/fpga_sc_wrapper/CMakeLists.txt +92
./fpga/aws-fpga/fpga_sc_wrapper/CMakeLists.txt +93
./fpga/aws-fpga/cosim_sc_wrapper/CMakeLists.txt +82
./fpga/aws-fpga/cosim_sc_wrapper/CMakeLists.txt +83
./fpga/aws-fpga/cosim_sc_wrapper/CMakeLists.txt +84
Python库不是2.x,导致PyString_* 找不到
/home/bg193/works/nvdla/vp/libs/greenlib/greenscript/src/greenscript.cpp: In member function ‘void gs::script::GreenScriptModule::load(const char*)’:
/home/bg193/works/nvdla/vp/libs/greenlib/greenscript/src/greenscript.cpp:221:46: error: ‘PyString_AsString’ was not declared in this scope
std::string s(PyString_AsString(path_py));
修改vp/libs/greenlib/CMakeLists.txt
# set(EXTERNAL_INCLUDE_DIRS ${EXTERNAL_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS})
set(EXTERNAL_INCLUDE_DIRS ${EXTERNAL_INCLUDE_DIRS} "/usr/include/python2.7")
5.运行模拟器
VP编译完毕后,复制aarch64_toplevel到sw/prebuild/linux
修改aarch64_nvdla.lua
-kernel /home/bg193/works/nvdla/sw/prebuilt/linux/Image
-drive file=/home/bg193/works/nvdla/sw/prebuilt/linux/rootfs.ext4
在sw/prebuild/linux下执行:
$ export SC_SIGNAL_WRITE_CHECK=DISABLE
$ ./build/bin/aarch64_toplevel -c conf/aarch64_nvdla.lua
执行test测试
将vp/test目录下文件复制到sw/prebuild/linux,命令中r代表模拟器执行目录
# mount -t 9p -o trans=virtio r /mnt
# cd /mnt/tests/hello
# ./aarch64_hello
修改vp/libs/greenlib/CMakeLists.txt
# set(EXTERNAL_INCLUDE_DIRS ${EXTERNAL_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS})
set(EXTERNAL_INCLUDE_DIRS ${EXTERNAL_INCLUDE_DIRS} "/usr/include/python2.7")
5.运行模拟器
VP编译完毕后,复制aarch64_toplevel到sw/prebuild/linux
修改aarch64_nvdla.lua
-kernel /home/bg193/works/nvdla/sw/prebuilt/linux/Image
-drive file=/home/bg193/works/nvdla/sw/prebuilt/linux/rootfs.ext4
在sw/prebuild/linux下执行:
$ export SC_SIGNAL_WRITE_CHECK=DISABLE
$ ./build/bin/aarch64_toplevel -c conf/aarch64_nvdla.lua
执行test测试
将vp/test目录下文件复制到sw/prebuild/linux,命令中r代表模拟器执行目录
# mount -t 9p -o trans=virtio r /mnt
# cd /mnt/tests/hello
# ./aarch64_hello
---------------------
作者:hywcogost
来源:CSDN
原文:https://blog.csdn.net/hywCogost/article/details/82114529
版权声明:本文为博主原创文章,转载请附上博文链接!