2021年9月27日星期一

用verilator搭的测试框架大概流程

verilator testbench 和 run_func之间的关系

 

chiplab/sims/verilator/run_func下有Makefile_run

还有configure.sh,makefile,生成的文件有output等。

 

chiplab/software/下是测试代码,还有testbench代码

u@unamed:~/prjs/chiplab/software$ ls
coremark  dhrystone  func  generic  linux  my_program  random_boot

 

func下就是func_lab3这样的测试例子。

 

verilator模拟的时候是需要先编译verilog项目,再编译testbench cpp代码,然后运行编译好的二进制代码模拟。

testbench在sims/verilator目录下,include目录里是测试框架的实现部分。

u@unamed:~/prjs/chiplab/sims/verilator/testbench$ ls
include  sim_main.cpp  simu_top.v

比如include/testbench.h里是CpuTestbench的实现。run_func/Makefile_run里的参数例如DUMP_DELAY也都是传递给testbench cpp代码的。

        ../output ${RUN_FLAG} --dump-delay $(DUMP_DELAY) --dump-trace $(DUMP_TRACE) --time-limit $(TIME_LIMIT) --save-bp-time $(SAVE_BP_TIME) --ram-save-bp-file $(RAM_SAVE_BP_FILE) --top-save-bp-file $(TOP_SAVE_BP_FILE) --restore-bp-time $(RESTORE_BP_TIME) --ram-restore-bp-file $(RAM_RESTORE_BP_FILE) --top-restore-bp-file $(TOP_RESTORE_BP_FILE)


testbench编译出来就是这个output。

u@unamed:~/prjs/chiplab/sims/verilator/run_func$ ls
config-generator.mak  config-software.mak  log   log_script  Makefile_run  obj_dir  qemu_system_run.sh
config.log            configure.sh         logs  Makefile    obj           output   tmp

比如,software/func/func_lab3下面并没有编译生成的文件,而是在下面这个目录

u@unamed:~/prjs/chiplab/sims/verilator/run_func/obj/func/func_lab3_obj/obj$ ls
data_ram.coe  data_ram.mif  inst_ram.coe  inst_ram.mif  main.bin  main.data  main.elf  rom.vlog  test.s


main.elf就是func_lab3编译生成的longarch目标代码,通过func_lab3下的convert.c转换成main.bin, main.data,最终以指令内存和数据内存的形式(data_ram.coe data_ram.mif inst_ram.coe inst_ram.mif)由testbench的ouput程序加载。


测试程序运行的流程大概是这样:

chiplab/sims/verilator/run_func下运行make

在Makefile中分别编译testbench,run_func,生成文件复制到run_func下相应的目录

(可能还有golden trace)

然后Makefile里调用Makefile_run

Makefile_run里最终调用output(也就是testbench编译生成的),把编译好的目标代码以指令内存和数据内存文件的方式送给output。

 

 

要测某一条指令,可以在run_func下写个一句汇编(比如addi.w)的程序,编译以后生成inst_ram,运行testbench后检查寄存器。

2021年8月8日星期日

can't find libnettle.so.6, ubuntu 20.04 has libnettle.so.7

 u@unamed:~/prjs$ wget  http://archive.ubuntu.com/ubuntu/pool/main/n/nettle/libnettle6_3.4-1_amd64.deb

 

u@unamed:~/prjs$ sudo dpkg -i libnettle6_3.4-1_amd64.deb

 

 libisl.so.15

http://archive.ubuntu.com/ubuntu/pool/universe/i/isl-0.18/libisl15_0.18-4_amd64.deb

 

libmpfr.so.4

http://ftp.br.debian.org/debian/pool/main/m/mpfr4/libmpfr4_3.1.5-1_amd64.deb

 

 

 

  1. To install a .deb file, simply Right click on the .deb file, and choose Kubuntu Package Menu->Install Package.

  2. Alternatively, you can also install a .deb file by opening a terminal and typing:

    sudo dpkg -i package_file.deb
  3. To uninstall a .deb file, remove it using Adept, or type:

    sudo apt-get remove package_name

 

2021年3月6日星期六

compile risc-v toolchain

git clone https://github.com/riscv/riscv-gnu-toolchain

create folder /home/uty/riscv32i

 [uty@u riscv-gnu-toolchain]$ ./configure --prefix=/home/uty/riscv32i --with-arch=rv32ia --with-abi=ilp32

[uty@u riscv-gnu-toolchain]$ make linux


I only need riscv32i, but, to successfully compile the toolchain, the minimal instruction set must be rv32ia

2021年2月16日星期二

Sipeed M1n RISC-V AI K210

 https://www.youtube.com/watch?v=GX6euKNH2iE

this video is a good start.


Here are the firmwares.

https://dl.sipeed.com/shareURL/MAIX/MaixPy/release/master/maixpy_v0.6.2_27_g4d8d4fbf0

I tried this one, maixpy_v0.6.2_27_g4d8d4fbf0_openmv_kmodel_v4_with_ide_support

To work with the MaixPy IDE, the firmware needs to have "with_ide" in it.

This one also has kmodel, so it is convenient to run face find script with this firmware.


In MAxiPy IDE, for M1n board, choose Tools->Select Board ->Sipeed Maixduino


MaixPy IDE download

https://dl.sipeed.com/MAIX/MaixPy/ide/v0.2.4


kflash_gui download

https://github.com/sipeed/kflash_gui/releases


find face script and other scripts in this github repository

https://github.com/sipeed/MaixPy_scripts/blob/master/machine_vision/face_find/demo_find_face.py



On my laptop, the board creates com4 and com5. Use com4 for IDE and kflash




K210 SoC datasheet

https://github.com/kendryte/kendryte-doc-datasheet/

pdf version

https://cdn.hackaday.io/files/1654127076987008/kendryte_datasheet_20181011163248_en.pdf


SiPeed document

https://maixpy.sipeed.com/en/




Longan Nano 是基于兆易创新(GigaDevice)最新基于 RISC-V 32 位内核的GD32VF103CBT6 单片机的极简开发板。方便广大学生、工程师、极客爱好者们接触最新一代的RISC-V处理器。了解其特性。

主芯片为 GD32VF103CBT6 ,基于芯来科技.的Bumblebee内核(指令集文档在此下载:http://dl.sipeed.com/LONGAN/Nano/DOC/.。

http://longan.sipeed.com/zh/

2021年1月24日星期日

arch linux update signature error

 try by updating the keyring first:

pacman -Sy archlinux-keyring

then try again

pacman -Syu

2020年12月5日星期六

compile QUME

$ apt-get install build-essential zlib1g-dev pkg-config libglib2.0-dev binutils-dev libboost-all-dev autoconf libtool libssl-dev libpixman-1-dev libpython-dev python-pip python-capstone virtualenv


qemu$ mkdir build

qemu$ cd build

out-of-tree build


u@kde:~/prjs/qemu/build$ ../configure --target-list=i386-softmmu --enable-tcg-interpreter --enable-debug-tcg --enable-debug-info

u@kde:~/prjs/qemu/build$ make

test run bios

u@kde:~/prjs/qemu/build$ ./qemu-system-i386



use vnc to see the screen

 u@kde:~/prjs/qemu/build$ sudo apt-get install xtightvncviewer



Always crash when install win7 x64 sp1, with 0xc000001e

I tried branch stable-5.0, and it seems to have a bug.

Also tried branch stable-4.2, cannot make it install win7


Currently I use the master branch, at

commit d73c46e4a84e47ffc61b8bf7c378b1383e7316b5 (HEAD -> master, tag: v5.2.0-rc4, origin/master, origin/HEAD, list)

Author: Peter Maydell <peter.maydell@linaro.org>

Date:   Tue Dec 1 16:21:01 2020 +0000


tried 

[uty@u build]$ ../configure --target-list=x86_64-softmmu --enable-system

This works, it can install win7 x64.


Don't use --enable-sdl, it make the GUI worse.


Later I will try 

[uty@u build]$ ../configure --target-list=x86_64-softmmu --enable-system --enable-tcg-interpreter --enable-debug-tcg --enable-debug-info


Two sprits that I use to install vm and start vm.

[uty@u win7_testqemu]$ cat installwin7.sh 

#!/bin/bash

~/prjs/qemu/build/qemu-img create -f qcow2 win7.hd 60G

#qemu-system-x86_64 -m 2048 -enable-kvm -cdrom ~/iso/rutgers_windows7_sp1_x64.iso -boot d  win7.hd


~/prjs/qemu/build/qemu-system-x86_64 -m 2048 \

-monitor stdio \

-vga cirrus \

-cdrom ~/iso/en_windows_7_ultimate_with_sp1_x64_dvd_618240.iso \

-boot d \

win7.hd

~/prjs/qemu/build/qemu-img create -f qcow2 -b win7.hd snapshot.hd


[uty@u win7_testqemu]$ cat installwin7.sh 

#!/bin/bash

~/prjs/qemu/build/qemu-img create -f qcow2 win7.hd 60G

#qemu-system-x86_64 -m 2048 -enable-kvm -cdrom ~/iso/rutgers_windows7_sp1_x64.iso -boot d  win7.hd


~/prjs/qemu/build/qemu-system-x86_64 -m 2048 \

-monitor stdio \

-vga cirrus \

-cdrom ~/iso/en_windows_7_ultimate_with_sp1_x64_dvd_618240.iso \

-boot d \

win7.hd

~/prjs/qemu/build/qemu-img create -f qcow2 -b win7.hd snapshot.hd



Notice, qemu-img and qemu-system-x86_64 should use the ones with the same version


2020年7月20日星期一

Nios II minimum system

AN 717: Nios II Gen2 Hardware Development Tutorial

The latest is from 2014.09.22. Things change.

The minimum system only needs clk, nios process, on chip memory, and jtag art.

I use Quartus 19.1.

The difference is that the new Nios II processor module has two more ports, debug_reset_request and debug_mem_slave.


The debug_reset_request should connect to all other modules except clk_0.
This reset output signal appears when the JTAG Debug module is enabled. This signal is triggered by the JTAG debugger or nios2-download -r command. This signal must be connected to the reset input signal of the Nios II processor which allows the JTAG debugger to reset the processor. This signal can be connected to the reset input signal of other components when needed.

debug_mem_slave connects both data_master and instruction master.