安装
1. 安装Python
Ubuntu 17.10 and 18.04 默认带有 python-3.6.9,足以使用 riscv-ctg。
如果您使用的是 Ubuntu 16.10 和 17.04,您可以直接使用 Universe 仓库安装 python3.6。
$ sudo apt-get install python3.6
$ pip3 install --upgrade pip
如果您使用的是 Ubuntu 14.04 或 16.04,您需要从个人包档案 (PPA) 获取 python3.6。
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
$ sudo apt-get install python3.6 -y
$ pip3 install --upgrade pip
您现在应该在您的 $PATH 中有两个二进制文件:python3 和 pip3。您可以如下检查版本。
$ python3 --version
Python 3.6.9
$ pip3 --version
pip 20.1 from <user-path>.local/lib/python3.6/site-packages/pip (python 3.6)
通过git安装
要安装 RISC-V 兼容性测试生成器,请在终端中运行以下命令:
$ python3 -m pip3 install git+https://github.com/riscv/riscv-ctg.git
这是安装 RISC-V 兼容性测试生成器的首选方法,因为它总是会安装最新的稳定版本。
如果你没有安装 pip,可以参考这个 Python 安装指南来完成安装过程。
通过pip安装
注意
如果你使用的是上述提到的 pyenv,请确保在执行以下步骤之前启用该环境。
$ pip3 install riscv_ctg
要将已安装的 RISCV-CTG 更新到最新版本:
$ pip3 install -U riscv_ctg
要检出特定版本的 riscv_ctg:
$ pip3 install riscv_ctg==1.x.x
安装CTG开发版本
RISC-V 兼容性测试生成器的源代码可以从 GitHub 仓库下载。
你可以克隆该仓库:
$ git clone https://github.com/riscv/riscv-ctg
一旦你有了源代码的副本,你可以使用以下命令进行安装:
$ cd riscv_ctg
$ pip3 install --editable .
详细安装方式参考资料:安装文档
使用
一旦安装了RISCV-CTG,执行 riscv_ctg --help
应该会在终端打印以下内容。
Usage: riscv_ctg [OPTIONS]
Options:
--version Show the version and exit.
-v, --verbose [info|error|debug]
Set verbose level
-d, --out-dir PATH Output directory path
-r, --randomize Randomize Outputs.
-cf, --cgf PATH Path to the cgf file(s). Multiple allowed.
-p, --procs INTEGER Max number of processes to spawn
-bi, --base-isa [rv32e|rv32i|rv64i]
Base ISA string for the tests.
--help Show this message and exit.
要在项目中使用RISC-V Compatibility Test Generator:
import riscv_ctg
运行测试生成器
为了生成 RV32I 的测试,使用以下命令:
$ mkdir tests/
$ riscv_ctg -v debug -d ./tests/ -r -cf ./sample_cgfs/dataset.cgf -cf ./sample_cgfs/rv32i.cgf -bi rv32i -p2
套件特征
目录结构
各种 .S
文件是测试本身。
.
├── Addi.S
├── Add.S
├── Andi.S
├── And.S
├── Auipc.S
├── Beq.S
├── Bge.S
├── Bgeu.S
├── Blt.S
├── Bltu.S
├── Bne.S
├── env # Contains the necessary environment files
│ ├── arch_test.h # Header file containing the macros used in tests
│ └── encoding.h # Header file containing varios encodings required
├── Jalr.S
├── Jal.S
├── Lb-align.S
├── Lbu-align.S
├── Lh-align.S
├── Lhu-align.S
├── Lui.S
├── Lw-align.S
├── Ori.S
├── Or.S
├── Sb-align.S
├── Sh-align.S
├── Slli.S
├── Sll.S
├── Slti.S
├── Sltiu.S
├── Slt.S
├── Sltu.S
├── Srai.S
├── Sra.S
├── Srli.S
├── Srl.S
├── Sub.S
├── Sw-align.S
├── Xori.S
└── Xor.S
测试结构
所有测试都遵循测试规范格式,详细信息请参见:测试规范格式