This post is force-riscv which is framework to generate random sequences of riscv instructions. I still need to dig deeper into the docs/code to understand the full feature list, but it seems very powerful with option to constraint the generation.

Building Link to heading

Building force-riscv as simple as calling make

git clone https://github.com/openhwgroup/force-riscv
cd force-riscv
source setenv.bash
make

Smoke test Link to heading

In README.md, A smoke test is mentioned as first example to run

mkdir tmp && cd tmp
./../bin/friscv -t ../utils/smoke/test_force.py

In test_force.py, MainSequence is defined and set to MainSequenceClass which seems like hooks the framework provided to customize the randomization.

from riscv.EnvRISCV import EnvRISCV
from riscv.GenThreadRISCV import GenThreadRISCV
from base.Sequence import Sequence


class MainSequence(Sequence):
    def generate(self, **kargs):
        self.genInstruction("ADD##RISCV")
        self.genInstruction("SRA##RISCV")


#  Points to the MainSequence defined in this file
MainSequenceClass = MainSequence

#  Using GenThreadRISCV by default, can be overriden with extended classes
GenThreadClass = GenThreadRISCV

#  Using EnvRISCV by default, can be overriden with extended classes
EnvClass = EnvRISCV