• Stars
    star
    163
  • Rank 231,141 (Top 5 %)
  • Language
    Scala
  • Created almost 13 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

RISC-V Torture Test
===========================================================================
RISC-V Torture Test Generator
===========================================================================
# Author: Yunsup Lee and Henry Cook
# Date: January 29th, 2012
# Version: (under version control)

This is the RISC-V torture test generator and framework. This repository
contains three sub-projects that build upon one another. The first, 
[generator], is used to create a single random torture test. The second,
[testrun], is used to run a particular test on particular simulators,
diffing the resulting signature with the ISA simulator and optionally
creating a derivative test subset that pinpoints the divergence. The third,
[overnight], wraps testrun, allowing tests to be run repeatedly for a given
duration or until a failure count.

 
---------------------------------------------------------------------------
Instructions
---------------------------------------------------------------------------

Modify "config/default.config" to set the parameters desired for building tests
(e.g., setting which instructions to use and in which ratio).

Modify "Makefile" as desired to execute the C simulator or RTL simulator of
your choice, and to set the other parameters as you require.

To build a single test and test it on Spike:

$ make igentest

To build single test and run it on the C simulator or RTL simulator, use 
"make cgentest" or "make rgentest".

To run overnight tests, you can use "make cnight" and "make rnight".
   
---------------------------------------------------------------------------
Signatures
---------------------------------------------------------------------------

Torture works by dumping the register state out to memory at the end of the
test program execution. This output is then compared against the output from
the Spike ISA simulator.

The torture program writes the register state to the memory address specified
by "xreg_output_data", which is located in the memory section 
".global begin_signature". The Spike ISA simulator will write out the data
found in the "begin_signature" section on exit if provided with the
"+signature=" argument:

$ spike +signature=my_spike_signature.txt test_binary

The Rocket-chip infrastructure uses the "riscv-fesvr" program to control the
execution of the C and RTL simulators. The "riscv-fesvr" also accepts the
+signature argument too.

$ ./csim-rocket-chip +signature=my_rocket_signature.txt test_binary

A simple diff between the Spike and chip simulator signatures will tell you if
any errors have occurred. 

$ diff my_spike_signature.txt my_rocket_signature.txt


**PORTING TORTURE TO YOUR OWN RISC-V PROCESSOR:**

If you would like to use riscv-torture with your own RISC-V processor, you will
need to provide a way to dump the "begin_signature" section to a file.

---------------------------------------------------------------------------
Low-level Usage
---------------------------------------------------------------------------
  
Some basic use cases are illustrated here (note the Makefile abstracts this for
you).

Make a single test:
% ./sbt generator/run
% cd output
% make
% spike +signature=test.sig test

Take an existing test and diff the signatures of ISA and C simulators:
% ./sbt 'testrun/run -a output/test.S -c /path/to/reference-chip/emulator/emulator'

*** Currently, due to the limiation of scala process library, you cannot
torture the RTL simulator ***
# Generate a random test and diff the signatures of ISA and RTL simulators:
# % ./sbt 'testrun/run -r /path/to/reference-chip/vlsi/build/vcs-sim-rtl/simv'

Run tests for 30 minutes, email hcook when done, and save failures to dir:
% ./sbt 'overnight/run -m 30 -e [email protected] -p dir'

---------------------------------------------------------------------------
Installing
---------------------------------------------------------------------------

% git submodule update --init


---------------------------------------------------------------------------
Overnight Overview
---------------------------------------------------------------------------

This framework utilizes both the test runner and test generator to perform
a long terms serach for failing test cases. It takes the following command
line arguments:

Usage: overnight/run [options] 
  -C <file> | --config <file>
        config file
  -p <dir> | --permdir <dir>
        dir to store failing tests
  -c <file> | --csim <file>
        C simulator
  -r <file> | --rtlsim <file>
        RTL simulator
  -e <address> | --email <address>
        email to report to
  -t <count> | --threshold <count>
        number of failures to trigger email
  -m <int> | --minutes <int>
        number of minutes to run tests

You can only generate tests with one instruction mix at a time (based on
the setting in the config file). It doesn't matter what simulator you use
with the -r and -c flags, they just determines the name used to describe
whose diff failed.

---------------------------------------------------------------------------
Testrun Overview
---------------------------------------------------------------------------

This utility compares the signatures generated by passing the -testsig flag
to the specified simulators. If it encounters a difference, it subdivides
the test into many subtests and searches for which exact program segment
reveals the failure. It takes the following command line arguments:

Usage: testrun/run [options] 
 -C <file> | --config <file>
        config file
  -a <file> | --asm <file>
        input ASM file
  -c <file> | --csim <file>
        C simulator
  -r <file> | --rtlsim <file>
        RTL simulator
  -s <boolean> | --seek <boolean>
        Seek for failing pseg
  -d <boolean> | --dump <boolean>
        Dump mismatched signatures

If you don't specify a asm file, a random one will be generated for you.
You can only generate tests with one instruction mix at a time (based on
the setting in the config file). It doesn't matter what simulator you use
with the -r and -c flags, they just determines the name used to describe
whose diff failed. By default, a failed diff will result in the subtest 
sweep occuring, but this search can be diasbled. Note that the pseg ID
reported is actually the pseg following the pseg containing the error.
You can optionally dump mistmatched signatures to the dir containing the 
asm file under test.

---------------------------------------------------------------------------
Generator Overview
---------------------------------------------------------------------------

To generate a random test, the torture test generator randomly generates
many test sequences from a set of test sequences that are written by hand,
performs a random register allocation for all test sequences, and finally
randomly interleaves instructions from these test sequences. To extend the
set of tests or coverage, the programmer needs to write new test sequences.
It takes the following command line arguments:

Usage: generator/run [options] 
  -o <filename> | --output <filename>
        output filename
  -C <file> | --config <file>
        config file

The following sections describe adding new functionality to the generator.

---------------------------------------------------------------------------
Test sequence example
---------------------------------------------------------------------------

Before we talk about how to write a test sequence, let's look at a very
simple example. The following example is a test sequence, which emits an
add instruction.

class SeqADD extends Seq
{
  val src1 = reg_read_any()
  val src2 = reg_read_any()
  val dest = reg_write(src1, src2)
  insts += ADD(dest, src1, src2)
}

As I hinted in the overview that the test generator will do register
allocation you don't write a string of instructions with architectural
registers. You request a virtual registers (i.e., registers that are yet
tied down to architectural registers) when you need them, save them in
scala values, and use them when you need to (e.g., in an instruction).

---------------------------------------------------------------------------
Types of virtual registers
---------------------------------------------------------------------------

 - Hidden (position dependent registers): Registers that will have
   different values when the code is positioned at a different address. An
   example is registers that hold addresses. Registers that are hidden should
   be excluded from the output signature.

 - Visible (position independent registers): Registers that are not hidden,
   therefore will have the same values when the code is positioned at
   a different address. These registers should be included as part of the
   output signature.

---------------------------------------------------------------------------
How to write a sequence
---------------------------------------------------------------------------

Use the following functions to request a register, and generate a string of
instructions (look at Inst.scala to see what instructions are available)
that uses these virtual registers, and add them to the insts array.

 - reg_read_zero(): returns register x0
 - reg_read_any(): returns any type of register (hidden or visible)
 - reg_read_visible(): returns a visible register
 - reg_write_ra(): returns register ra for write
 - reg_write_visible(): returns a visible register for write
 - reg_write_hidden(): returns a hidden register for write
 - reg_write(regs: Reg*): returns a register that matches the type of regs
   (if any reg in regs are hidden, the output type is hidden)

Note that the torture test framework is written in scala, you can use any
scala functionality to generate instructions. Look at SeqALU.scala,
SeqMem.scala, and SeqBranch.scala to get inspired.

---------------------------------------------------------------------------
Future TODO
---------------------------------------------------------------------------

 - provide support for loops

 - generate statistics of a test to get a sense of coverage
   + statistics should include instruction count of each type
   + statistics should include register usage

 - complete floating point tests
   + add floating point memory move tests
   + improve floating point init randomization
   + add rounding modes tests

 - complete vector tests
   + better randomization
   + add SeqVOnly: Tests special vf-only instructions

 - code refactoring
   + consolidate RegPool logic
   + detect and suppress unallocatable sequences

More Repositories

1

chipyard

An Agile RISC-V SoC Design Framework with in-order cores, out-of-order cores, accelerators, and more
Scala
1,601
star
2

gemmini

Berkeley's Spatial Array Generator
Scala
793
star
3

riscv-sodor

educational microarchitectures for risc-v isa
Scala
673
star
4

chisel-tutorial

chisel tutorial exercises and answers
Scala
643
star
5

riscv-mini

Simple RISC-V 3-stage Pipeline in Chisel
Scala
538
star
6

chisel2-deprecated

Scala
387
star
7

fpga-zynq

Support for Rocket Chip on Zynq FPGAs
Tcl
378
star
8

berkeley-hardfloat

Scala
264
star
9

hammer

Hammer: Highly Agile Masks Made Effortlessly from RTL
Python
253
star
10

chiseltest

The batteries-included testing and formal verification library for Chisel-based RTL designs.
Scala
220
star
11

dsptools

A Library of Chisel3 Tools for Digital Signal Processing
Scala
219
star
12

berkeley-softfloat-3

SoftFloat release 3
C
217
star
13

constellation

A Chisel RTL generator for network-on-chip interconnects
Scala
174
star
14

hwacha

Microarchitecture implementation of the decoupled vector-fetch accelerator
Scala
146
star
15

esp-llvm

UCB-BAR fork of LLVM! NOT UPSTREAM RISCV LLVM
C++
123
star
16

midas

FPGA-Accelerated Simulation Framework Automatically Transforming Arbitrary RTL
Scala
96
star
17

testchipip

Scala
80
star
18

onnxruntime-riscv

Fork of upstream onnxruntime focused on supporting risc-v accelerators
C++
79
star
19

sha3

Verilog
76
star
20

cosa

A scheduler for spatial DNN accelerators that generate high-performance schedules in one shot using mixed integer programming (MIP)
Python
72
star
21

ccbench

Memory System Microbenchmarks
C
57
star
22

gemmini-rocc-tests

Fork of seldridge/rocket-rocc-examples with tests for a systolic array based matmul accelerator
C
53
star
23

zscale

Z-scale Microarchitectural Implementation of RV32 ISA
C
53
star
24

chisel-gui

A prototype GUI for chisel-development
Scala
49
star
25

berkeley-testfloat-3

TestFloat release 3
C
46
star
26

hwacha-template

Template for projects using the Hwacha data-parallel accelerator
C
34
star
27

RoSE

A unified simulation platform that combines hardware and software, enabling pre-silicon, full-stack, closed-loop evaluation of your robotic system.
Python
33
star
28

barstools

Useful utilities for BAR projects
Scala
31
star
29

autophase

Python
28
star
30

shuttle

A Rocket-based RISC-V superscalar in-order core
Scala
26
star
31

riscv-benchmarks

C
22
star
32

MoCA

Scala
22
star
33

saturn-vectors

Chisel RISC-V Vector 1.0 Implementation
Assembly
22
star
34

libgloss-htif

A libgloss replacement for RISC-V that supports HTIF
C
21
star
35

nvdla-wrapper

Wraps the NVDLA project for Chipyard integration
Verilog
20
star
36

cva6-wrapper

Wrapper for ETH Ariane Core
Scala
20
star
37

esp-isa-sim

Custom extensions to the RISC-V isa simulator for the UCB-BAR ESP project
C
18
star
38

asyncqueue

Lightweight re-packaging of AsyncQueue library from rocket-chip
Scala
17
star
39

riscv-blas

Custom BLAS and LAPACK Cross-Compilation Framework for RISC-V
Fortran
17
star
40

fpga-spartan6

Support for zScale on Spartan6 FPGAs
Verilog
15
star
41

chisel-awl

Scala
13
star
42

dosa

DOSA: Differentiable Model-Based One-Loop Search for DNN Accelerators
Python
13
star
43

Baremetal-NN

A tool for converting PyTorch models into raw C codes that can be executed standalone in a baremetal runtime on RISC-V research chips.
C
12
star
44

rocket-dsp-utils

Tools for integrating DspTools components into a rocket-chip
Scala
11
star
45

protoacc

Scala
11
star
46

midas-examples

Simple MIDAS Examples
Scala
10
star
47

vaesa

Learning A Continuous and Reconstructible Latent Space for Hardware Accelerator Design
Python
10
star
48

firrtl-transform-tutorial

A template for developing custom FIRRTL transforms
Scala
10
star
49

hammer-cadence-plugins

Hammer plugins for Cadence tools
Python
10
star
50

FFTGenerator

Scala
9
star
51

esp-tools

Shell
9
star
52

fpga-images-zedboard

prebuilt images for zedboard zynq fpga
9
star
53

compress-acc

Scala
9
star
54

context-dependent-environments

A Scala library for Context-Dependent Evironments
Scala
9
star
55

firrtl-uclid

Scala
8
star
56

plsi-mdf

Macro description format
Scala
8
star
57

chisel-sift

Scala
8
star
58

hammer-synopsys-plugins

Hammer plugins for synopsys tools
Python
8
star
59

midas-release

MIDAS Public Release
Scala
8
star
60

fixedpoint

Chisel Fixed-Point Arithmetic Library
Scala
8
star
61

midas-top-release

MIDAS RocketChip Template
Scala
7
star
62

riscv-docker-images

Curated set of DockerFiles for RISC-V projects
Dockerfile
7
star
63

spec2017-workload

FireMarshal workload for SPEC2017
Python
7
star
64

midas-zynq

A zynq host-platform shell for midas generated simulators.
Tcl
7
star
65

spike-devices

Collection of device models for spike
C++
7
star
66

rerocc

Scala
7
star
67

Baremetal-IDE

A submodule of Chipyard https://github.com/ucb-bar/chipyard
HTML
7
star
68

maltese-smt

Archived! All relevant features are now part of the firrtl smt backend or the chiseltest library.
Scala
7
star
69

esp-tests

Custom extensions to the RISC-V tests for the UCB-BAR ESP project
C
6
star
70

nvdla-workload

Base NVDLA Workload for FireMarshal
Shell
5
star
71

hwacha-net

C
5
star
72

firrtl2

UC Berkeley Copy of the FIRRTL Compiler
Scala
5
star
73

AuRORA

Virtualized Accelerator Orchestration for Multi-Tenant Workloads
C
5
star
74

pyuartsi

A standalone implementation of the Tethered Serial Interface (TSI) in Python.
Python
5
star
75

chipyard-toolchain-prebuilt

Pre-built riscv-gnu-toolchain binaries. You should most likely only shallow clone this.
Makefile
4
star
76

pwm-chisel-example

pwm-chisel-example for risc-v summer 2016 workshop
Scala
4
star
77

cs152-lab4

CS152 Lab 4
C
4
star
78

ibex-wrapper

Wrapper for lowRISC Ibex
Scala
4
star
79

riscv-tools-feedstock

Shell
4
star
80

stac-top

The SRAM timing analysis chip for verifying SRAMs generated by SRAM22
Scala
3
star
81

opencl-kernels

OpenCL kernels for ucb-bar hardware
C
3
star
82

chipper-tutorial

tutorial for chipper
C++
3
star
83

coremark-workload

FireMarshal workload for CoreMark EEMBC
Shell
3
star
84

bits

Firebox Benchmarks
Python
3
star
85

2023-winter-demo-project-power-aka-bora

Python
3
star
86

Baremetal-llama

C
3
star
87

chipyard-cs152-sp24

C
3
star
88

riscv-coremark-pro

Compiles coremark-pro for riscv64 baremetal
Makefile
3
star
89

vcd2step

Converts a VCD file to a Chisel tester input file
C++
2
star
90

pocl

C
2
star
91

chisel-release

Chisel release tooling
2
star
92

chisel-torture

A tool that generates Chisel torture tests
C++
2
star
93

fpga-images-zybo

2
star
94

ara-wrapper

Scala
2
star
95

bar-fetchers

Berkeley Architecture Research pre-Fetchers
Scala
2
star
96

lbnl-torch

LBNL TORCH Reference Kernels
C
2
star
97

chisel-library-template

Use for developing Chisel+Firrtl libraries
2
star
98

fpga-images-zc706

2
star
99

baseband-modem

Digital baseband-modem processor for 2.4 GHz Bluetooth Low Energy and IEEE 802.15.4 standards
Jupyter Notebook
2
star
100

caliptra-aes-acc

SystemVerilog
2
star