简介
NVDLA虚拟平台提供了一个可精确注册的系统,可以在该系统上快速开发和调试软件。该虚拟平台基于GreenSocs QBOX,它是与QEMU和SystemC共同仿真的解决方案。下面的图89显示了NVDLA虚拟模拟器的顶层示意图。包含ARMv8“虚拟” SoC板的QEMU仿真器,以提供高性能CPU仿真和通用设备。该仿真器包装在带有一组TLM-2.0接口的标准SystemC模块内,可以与其他SystemC模块进行交互。
1、下载 Virtual Simulator
$ git clone https://github.com/nvdla/vp.git $ cd vp $ git submodule
update --init --recursive
2、安装依赖
2.1、安装包
$ 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.2. 下载安装 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、下载安装perl、YAML等包
$ wget -O YAML-1.24.tar.gz
http://search.cpan.org/CPAN/authors/id/T/TI/TINITA/YAML-1.24.tar.gz $
tar -xzvf YAML-1.24.tar.gz $ cd YAML-1.24
$ perl Makefile.PL
$ make $
sudo make install
$ wget -O IO-Tee-0.65.tar.gz
http://search.cpan.org/CPAN/authors/id/N/NE/NEILB/IO-Tee-0.65.tar.gz
$ tar -xzvf IO-Tee-0.65.tar.gz
$ cd IO-Tee-0.65
$ perl Makefile.PL
$ make
$ sudo make install
4. 下载编译NVDLA CMOD
ps:确定有相关环境:jdk1.8等
$ git clone https://github.com/nvdla/hw.git $ cd hw
$ make 如果遇到make install没有安装到制定目录的问题,查看Makefile中prefix变量赋值 prefix =
/usr/local/systemc-2.3.0
$ cd hw
$ make
这里提示确认工具链位置,按照实际填写或者修改makefile
$ tools/bin/tmake -build cmod_top
5、编译安装Virtual Simulator
5.1 cmake
$ cmake -DCMAKE_INSTALL_PREFIX=[install dir] -DSYSTEMC_PREFIX=[systemc
prefix] -DNVDLA_HW_PREFIX=[nvdla_hw prefix]
-DNVDLA_HW_PROJECT=[nvdla_hw project name]CMAKE_INSTALL_PREFIX是设置安装位置,SYSTEMC_PREFIX是systemC的安装位置,NVDLA_HW_PREFIX是hw的安装位置,NVDLA_HW_PROJECT是项目名称
例如: cmake -DCMAKE_INSTALL_PREFIX=build
-DSYSTEMC_PREFIX=/usr/local/systemc-2.3.0/ -DNVDLA_HW_PREFIX=/root/nvdla/vp/vp/hw -DNVDLA_HW_PROJECT=nv_full
5.2、编译安装
$ make
$ make install
如果是用的gcc python和文档中设定的版本不同make会报错
1
/usr/local/systemc-2.3.0/include/sysc/packages/boost/get_pointer.hpp:21:40: error: ‘template class std::auto_ptr’ is deprecated [-Werror=deprecated-declarations]
template T * get_pointer(std::auto_ptr const& p)
需要把CMakeList.txt中的-Werror去除去掉警告当错误,修改如下
修改vp/CMakeLists.txt
set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -DSC_INCLUDE_DYNAMIC_PROCESSES
-Wall ${AWS_FPGA_CFLAGS} T R A C E C F L A G S " ) s e t ( C M A K E C X X F L A G S D E B U G " {TRACE_CFLAGS}") set(CMAKE_CXX_FLAGS_DEBUG " TRACECFLAGS")set(CMAKECXXFLAGSDEBUG"{CMAKE_CXX_FLAGS_DEBUG} -DSC_INCLUDE_DYNAMIC_PROCESSES -Wall
-DDEBUG_LOG=1 ${AWS_FPGA_CFLAGS} T R A C E C F L A G S " ) s e t ( C M A K E C X X F L A G S R E L E A S E " {TRACE_CFLAGS}") set(CMAKE_CXX_FLAGS_RELEASE " TRACECFLAGS")set(CMAKECXXFLAGSRELEASE"{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
2
/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”)
原因为python不是2.x,需要手动指定
修改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”)
6、运行 Virtual Simulator
如果自己不编译linux kernel和rootfs,sw/prebuild中提供了已经编好的
如果需要自己编译,可以参考这里
6.1 拷贝prebuild中的Image和rootfs.ext4
修改conf/aarch64_nvdla.lua,手动指定image和rootfs到实际位置
-kernel /home/works/nvdla/sw/prebuilt/linux/Image
-drive file=/home/works/nvdla/sw/prebuilt/linux/rootfs.ext4$ export SC_SIGNAL_WRITE_CHECK=DISABLE $ ./build/bin/aarch64_toplevel
-c conf/aarch64_nvdla.lua Login the kernel. The demo image uses account ‘root’ and password ‘nvdla’.
vp/tests中已经提供了几个例子能跑
:# mount -t 9p -o trans=virtio r /mnt
:# cd /mnt/tests/hello :#
./aarch64_hello
如果看到打印hello world则成功
如果要跑runtime,那就把prebuilt\arm64-linux中drm.ko、opendla1.ko、opendla2.ko nvdla_runtime拷贝过来
$:insmod drm.ko $:insmod opendla1.ko #根据实际架构选择1还是2
说明:
opendla1.ko :nv_full
opendla2.ko :nv_small、nv_large
./nvdla_runtime --loadable fast-math.nvdla --image 0000.jpg