wujian100_open:基于iverilog的仿真过程记录

简介: 本文介绍 Ubuntu1804环境下,基于iverilog仿真过程记录。

本次仿真在Ubuntu1804环境下进行,仿真工具使用iverilog。仿真过程用到tcsh,该shell需要手动安装。

准备阶段

安装iverilog、tcsh
sudo apt-get install tcsh iverilog verilator gtkwave

相关下载

开始仿真前,需要将仓库clone到本地,并下载官方提供的RISCV交叉编译工具

wujian100仓库clone git clone https://github.com/T-head-Semi/wujian100_open.git 交叉编译工具下载

环境配置

创建工程目录

ws@laptop:~$ mkdir ~/wujian_sim
ws@laptop:~$ cd ~/wujian_sim/
ws@laptop:~/wujian_sim$ 

添加wujian100仓库到该目录下

ws@laptop:~/wujian_sim$ cp -r ../wujian/wujian100_open/ ./

配置交叉编译工具 目前环境下用到的工具为工具包中的riscv64-elf-x86_64-20190731.tar.gz,需要在工程目录下新建名为riscv_toolchain的目录,并将该文件解压缩至该目录。

ws@laptop:~/wujian_sim$ mkdir riscv_toolchain
ws@laptop:~/wujian_sim$ cd riscv_toolchain/
ws@laptop:~/wujian_sim/riscv_toolchain$ tar xf ../../wujian/RISC-V\ Toolchain-V1.2.2/riscv64-elf-x86_64-20190731.tar.gz

ok,完成上述操作之后,就可以开始仿真了

仿真Hello Friend

根据仓库readme描述,进入tools目录

ws@laptop:~/wujian_sim/riscv_toolchain$ cd ../wujian100_open/tools/
ws@laptop:~/wujian_sim/wujian100_open/tools$

切换tcsh

ws@laptop:~/wujian_sim/wujian100_open/tools$ tcsh 
laptop:~/wujian_sim/wujian100_open/tools>

source环境变量

laptop:~/wujian_sim/wujian100_open/tools> source setup.csh

进入work目录,仿真走起

laptop:~/wujian_sim/wujian100_open/tools> cd ../workdir/
laptop:~/wujian_sim/wujian100_open/workdir> ../tools/run_case -sim_tool iverilog ../case/timer/timer_test.c

仿真输出

laptop:~/wujian_sim/wujian100_open/workdir> ../tools/run_case -sim_tool iverilog ../case/timer/timer_test.c
Useless use of not in void context at ../tools/run_case line 204.

Step1 (Remove all things in current 'workdir') is finished!
../case/timer//timer_test.c

Step2 (Process the command line arguments) is finished!
mkdir: cannot create directory ‘../regress/regress_result’: File exists
rm -rf *.o *.pat *.elf *.obj *.hex
../../riscv_toolchain/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o crt0.o crt0.s
../../riscv_toolchain/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o __dtostr.o __dtostr.c
../../riscv_toolchain/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o __isnan.o __isnan.c
../../riscv_toolchain/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o printf.o printf.c
../../riscv_toolchain/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o vprintf.o vprintf.c
../../riscv_toolchain/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o sprintf.o sprintf.c
../../riscv_toolchain/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o snprintf.o snprintf.c
../../riscv_toolchain/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o fprintf.o fprintf.c
../../riscv_toolchain/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o vfprintf.o vfprintf.c
../../riscv_toolchain/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o getchar.o getchar.c
../../riscv_toolchain/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o timer_test.o timer_test.c
In file included from timer_test.c:12:
vtimer.h: In function 'get_vtimer':
vtimer.h:14:14: warning: assignment to 'int *' from 'unsigned int' makes pointer from integer without a cast [-Wint-conversion]
   TIMER_ADDR = 0xE0013000;
              ^
../../riscv_toolchain/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o putc.o putc.c
../../riscv_toolchain/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o puts.o puts.c
../../riscv_toolchain/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o fputc.o fputc.c
../../riscv_toolchain/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o getc.o getc.c
../../riscv_toolchain/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o __isinf.o __isinf.c
../../riscv_toolchain/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o putchar.o putchar.c
../../riscv_toolchain/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o vsprintf.o vsprintf.c
../../riscv_toolchain/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o __v_printf.o __v_printf.c
../../riscv_toolchain/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o vsnprintf.o vsnprintf.c
../../riscv_toolchain/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o __lltostr.o __lltostr.c
../../riscv_toolchain/bin/riscv64-unknown-elf-gcc -c -march=rv32emcxcki -mabi=ilp32e -De902 -Wa,--defsym=e902=1 -O3 -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns -ffunction-sections -fdata-sections -o __ltostr.o __ltostr.c
../../riscv_toolchain/bin/riscv64-unknown-elf-gcc -Tlinker.lcf -nostartfiles -march=rv32emc -mabi=ilp32e -lc -lgcc  crt0.o getchar.o vprintf.o sprintf.o snprintf.o fprintf.o __lltostr.o puts.o __isnan.o timer_test.o getc.o printf.o vsprintf.o __v_printf.o vsnprintf.o __dtostr.o vfprintf.o putc.o fputc.o __isinf.o putchar.o __ltostr.o -o timer_test.elf -lm 
../../riscv_toolchain/bin/riscv64-unknown-elf-objcopy -O srec timer_test.elf timer_test.hex 
rm -f *.pat
#../tools/Srec2vmem.py timer_test.hex test.pat
../tools/Srec2vmem.py -i timer_test.hex -o test.pat
../../riscv_toolchain/bin/riscv64-unknown-elf-objdump -S -Mnumeric timer_test.elf > timer_test.obj
make clean; make all CPU=e902m ENDIAN_MODE=little-endian FILE=timer_test HGPR=

Step3 (Make) is finished!
Use of uninitialized value $had_v in concatenation (.) or string at ../tools/run_case line 241.
warning: Found both default and `timescale based delays. Use
         -Wtimescale to find the module(s) with no `timescale.
######time:                   0, Dump start######
VCD info: dumpfile test.vcd opened for output.
    ******START TO LOAD PROGRAM******


Hello Friend!

timer test successfully
***************************************

*              Test Pass              *

***************************************


Step4 (Run simulation) is finished

总结

  1. Ubuntu默认使用bash shell,仿真环境配置文件setup.csh需要用tcsh,so 切换的tcsh至关重要;
  2. 仿真过程需要使用交叉编译工具,且目录必须与仓库所在目录一致,注意交叉编译工具文件夹的命名。

文章来源:芯片开放社区
文章链接:https://occ.t-head.cn/community/post/detail?spm=a2cl5.14300636.0.0.1b87180flWxVN5&id=650362409306816512

相关文章
|
自然语言处理 安全 C++
【C++ 格式化输出 】C++20 现代C++格式化:拥抱std--format简化你的代码
【C++ 格式化输出 】C++20 现代C++格式化:拥抱std--format简化你的代码
9578 4
|
Ubuntu Linux Shell
Windows-下学习阿里平头哥-RISC-V-芯片开发平台-wujian100
上个月,在第六届互联网大会上,阿里的平头哥,对,就是那个人狠话不多的公司!他们宣布开源了 wujian100 这个芯片设计平台。搭载基于 RISC-V 架构的玄铁 902 处理器。
Windows-下学习阿里平头哥-RISC-V-芯片开发平台-wujian100
|
7月前
|
存储 弹性计算 安全
阿里云服务器38元、99元、199元配置、适用场景区别及选择参考
目前,阿里云有多款特价云服务器产品,轻量云服务器2核2G200M峰值带宽38元一年,经济型e实例云服务器2核2G3M带宽99元1年、4核16G10M云服务器70元1个月、210元3个月,8核32G10M带宽160元1个月、480元3个月,通用算力型u1实例2核4G5M带宽199元一年、4核8G云服务器955元一年。本文将详细介绍阿里云的三款特价云服务器产品:38元的轻量应用服务器、99元的云服务器ECS经济型e实例,以及199元的云服务器ECS u1实例,帮助用户更好地了解这些产品的规格、配置、适用场景及购买资格和注意事项。
|
编解码 人工智能 自然语言处理
Stable Diffusion文生图-图生图-ControINet插件-线稿上色-生产全套表情包-3D Openpose-局部重绘-换衣服,换姿势人设三视图一键生成教程大全(一)
Stable Diffusion文生图-图生图-ControINet插件-线稿上色-生产全套表情包-3D Openpose-局部重绘-换衣服,换姿势人设三视图一键生成教程大全(一)
1668 2
|
自然语言处理 测试技术 计算机视觉
ICLR 2024:Time-LLM:基于大语言模型的时间序列预测
【2月更文挑战第28天】ICLR 2024:Time-LLM:基于大语言模型的时间序列预测
2340 1
ICLR 2024:Time-LLM:基于大语言模型的时间序列预测
|
存储 算法 搜索推荐
深度优先遍历与广度优先遍历:理解它们的原理与差异
深度优先遍历与广度优先遍历:理解它们的原理与差异
|
存储 异构计算
FPGA入门(4):时序逻辑(一)
FPGA入门(4):时序逻辑
337 0
|
机器学习/深度学习 算法 关系型数据库
【PyTorch深度强化学习】DDPG算法的讲解及实战(超详细 附源码)
【PyTorch深度强化学习】DDPG算法的讲解及实战(超详细 附源码)
5417 1
|
机器学习/深度学习 存储 人工智能
极智AI | 一文看懂Google TPU脉动阵列加速卷积计算原理
本教程详细解释了 Google TPU 脉动阵列加速卷积计算原理。
2490 0
|
机器学习/深度学习 计算机视觉 网络架构
【即插即用】Triplet Attention机制让Channel和Spatial交互更加丰富(附开源代码)
【即插即用】Triplet Attention机制让Channel和Spatial交互更加丰富(附开源代码)
743 0