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

相关文章
Cadence仿真出现Cannot Initialize Profile错误的解决方法和步骤
元器件和器件PSpice模型都准备好了,仿真原理图也画好了,但是在新建仿真配置文件的时候,提示Cannot Initialize Profile的错误。当时忘了截图了,问题解决了也没有出现这个错误。重启软件、重启电脑都没有再出现。
655 0
|
算法 异构计算
m基于FPGA的OFDM系统中降PAPR技术的实现,包含testbench测试文件和MATLAB辅助测试
m基于FPGA的OFDM系统中降PAPR技术的实现,包含testbench测试文件和MATLAB辅助测试
71 0
|
1月前
|
监控 算法 数据安全/隐私保护
基于三帧差算法的运动目标检测系统FPGA实现,包含testbench和MATLAB辅助验证程序
本项目展示了基于FPGA与MATLAB实现的三帧差算法运动目标检测。使用Vivado 2019.2和MATLAB 2022a开发环境,通过对比连续三帧图像的像素值变化,有效识别运动区域。项目包括完整无水印的运行效果预览、详细中文注释的代码及操作步骤视频,适合学习和研究。
|
6月前
|
编解码 算法 异构计算
基于FPGA的NC图像质量评估verilog实现,包含testbench和MATLAB辅助验证程序
在Vivado 2019.2和Matlab 2022a中测试的图像质量评估算法展示了效果。该算法基于NC指标,衡量图像与原始图像的相似度,关注分辨率、色彩深度和失真。提供的Verilog代码段用于读取并比较两个BMP文件,计算NC值。
|
5月前
|
算法 计算机视觉 异构计算
基于FPGA的图像直方图均衡化处理verilog实现,包含tb测试文件和MATLAB辅助验证
摘要: 在FPGA上实现了图像直方图均衡化算法,通过MATLAB2022a与Vivado2019.2进行仿真和验证。核心程序涉及灰度直方图计算、累积分布及映射变换。算法旨在提升图像全局对比度,尤其适合低对比度图像。FPGA利用可编程增益器和查表技术加速硬件处理,实现像素灰度的均匀重分布,提升视觉效果。![image preview](https://ucc.alicdn.com/pic/developer-ecology/3tnl7rfrqv6tw_a075525027db4afbb9c0529921fd0152.png)
|
6月前
|
算法 异构计算
基于FPGA的图像RGB转CIE-Lab实现,包含testbench和MATLAB辅助验证程序
基于FPGA的图像RGB转CIE-Lab实现,包含testbench和MATLAB辅助验证程序
|
6月前
|
算法 5G
基于RM编译码的协作MIMO系统误码率matlab仿真,对比不同RM编译码参数
基于RM编译码的协作MIMO系统误码率matlab仿真,对比不同RM编译码参数
|
数据可视化 Linux 异构计算
如何自动生成设计文件的状态机跳转图(仿真工具使用技巧)【Modesim/Questasim】
如何自动生成设计文件的状态机跳转图(仿真工具使用技巧)【Modesim/Questasim】
如何自动生成设计文件的状态机跳转图(仿真工具使用技巧)【Modesim/Questasim】
|
NoSQL 安全 开发工具
乐动ld06激光雷达sdk改bug记录分享
乐动ld06激光雷达sdk改bug记录分享
228 0
乐动ld06激光雷达sdk改bug记录分享
|
存储 NoSQL C#
基于C#的ArcEngine二次开发44: GDB矢量文件检查结果导出GDB/SHP的思路分析
基于C#的ArcEngine二次开发44: GDB矢量文件检查结果导出GDB/SHP的思路分析