Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ci update, ISAC+CTG merged, added converpoints #495

Merged
merged 6 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Updated CI and added riscof-plugin directory
  • Loading branch information
UmerShahidengr committed Sep 23, 2024
commit b94d8e8b386a5071bfad8e67278c57334e7acdb3
74 changes: 64 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,81 @@ jobs:

ACT-sail-spike:
runs-on: ubuntu-latest
container: ghcr.io/riscv-software-src/riscof/act:latest
strategy:
fail-fast: false
matrix:
isa_group:
- RV32IMCZicsr_Zifencei
- RV64IMCZicsr_Zifencei

- RVIMAFDCZicsr_Zifencei

steps:

- name: Checkout source
uses: actions/checkout@v4

- name: Config riscof
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y python3 python3-pip python3-venv
sudo apt-get install -y gcc git autoconf automake libtool curl make unzip
sudo apt-get install autoconf automake autotools-dev curl python3 python3-pip libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev libslirp-dev
pip3 install git+https://github.com/riscv/riscof.git

- name: Build RISCV-GNU Toolchain (32 bit)
run: |
wget -c https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/2024.09.03/riscv32-elf-ubuntu-20.04-gcc-nightly-2024.09.03-nightly.tar.gz
tar -xzf riscv32-elf-ubuntu-20.04-gcc-nightly-2024.09.03-nightly.tar.gz
mv riscv riscv32
echo $GITHUB_WORKSPACE/riscv32/bin >> $GITHUB_PATH

- name: Build RISCV-GNU Toolchain (64 bit)
run: |
wget -c https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/2024.09.03/riscv64-elf-ubuntu-20.04-gcc-nightly-2024.09.03-nightly.tar.gz
tar -xzf riscv64-elf-ubuntu-20.04-gcc-nightly-2024.09.03-nightly.tar.gz
mv riscv riscv64
echo $GITHUB_WORKSPACE/riscv64/bin >> $GITHUB_PATH

- name: Install Spike
run: |
git config --global --add safe.directory '*'
riscof setup --dutname=spike
cp .github/isa_templates/${{ matrix.isa_group }}.yaml spike/spike_isa.yaml
git clone https://github.com/riscv/riscv-isa-sim.git
sudo apt-get install device-tree-compiler libboost-regex-dev libboost-system-dev
cd riscv-isa-sim
mkdir build
cd build
../configure --prefix=$GITHUB_WORKSPACE/riscv64
make -j$(nproc)
sudo make install
echo $GITHUB_WORKSPACE/riscv64/bin >> $GITHUB_PATH

- name: Install Sail
run: |
sudo apt-get install opam build-essential libgmp-dev z3 pkg-config zlib1g-dev
opam init -y --disable-sandboxing
opam switch create ocaml-base-compiler
opam install sail -y
eval $(opam config env)
git clone https://github.com/riscv/sail-riscv.git
cd sail-riscv
ARCH=RV32 make
ARCH=RV64 make
echo $PWD/c_emulator >> $GITHUB_PATH

- name: Install riscv-isac
run: |
cd riscv-isac
pip3 install --editable .

- name: Install riscv-ctg
run: |
cd riscv-ctg
pip3 install --editable .


- name: Config and run riscof for RV32
run: |
cd riscof-plugins/rv32
riscof run --config config.ini --suite ../../riscv-test-suite/rv32i_m/ --env ../../riscv-test-suite/env

- name: Run riscof
- name: Config and run riscof for RV64
run: |
riscof --verbose debug run --suite . --env ./riscv-test-suite/env
cd riscof-plugins/rv64
riscof run --config config.ini --suite ../../riscv-test-suite/rv64i_m/ --env ../../riscv-test-suite/env
14 changes: 14 additions & 0 deletions riscof-plugins/rv32/config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[RISCOF]
ReferencePlugin=sail_cSim
ReferencePluginPath=sail_cSim
DUTPlugin=spike_simple
DUTPluginPath=spike_simple

[spike_simple]
pluginpath=spike_simple
ispec=spike_simple/spike_simple_isa.yaml
pspec=spike_simple/spike_simple_platform.yaml
target_run=1

[sail_cSim]
pluginpath=sail_cSim
95 changes: 95 additions & 0 deletions riscof-plugins/rv32/makeplugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
### Plugin to use Makefile.include from old framework with riscof

- This plugin facilitates the use of Makefile.include from the targets of the old framework with
riscof and is intented to be used as a base for transition.
- The config node of the plugin can contain the following variables/
- **makefiles** (*required*)- Comma separated paths to the makefiles. If multiple are specified, all will be
merged in the final output makefile. Note that only the varaibles in the makefiles are written
out into the final makefiles. Any targets or includes will be left out. Such cases can be
handled by editing the plugin to output the relevant lines as a part of the `build` function.
- **jobs** - The number of threads to launch parallely. (Default is `1`)
- **ispec** (*required*)- The path to the input ISA yaml specification of the target.
- **pspec** (*required*)- The path to the input platform yaml specification of the target.
- **make** - The make utility to use like make,bmake,pmake etc. (Default is `make`)

- The commands in the makefiles need to be modified to make use of the following variables. The
values for these are resolved based on the inputs from riscof and are substituted before writing
out the final targets. An additional Makefile variable, `TARGET_DIR`, which contains the path
where the plugin resides is written out at the starting of the makefile and can be used as an anchor
point for resolving paths to other files.

| Variable | Description |
| ------------- | ----------- |
| `${target_dir}` | The directory where the plugin file resides. (riscof_makeplugin.py) |
| `${asm}` | Absolute path to the assemble test file i.e the .S file for the test. |
| `${work_dir}` | The absolute path to the work directory for the test. |
| `${test_name}` | The name of the test, for example add-01 etc. Can be used for naming any intermediate files generated. |
| `${include}` | The path to the directory which containts the test header files. This needs to be specified as an include path in the compile command. |
| `${march}` | The ISA to be used for compiling the test. This is in the format expected by march argument of gcc. |
| `${mabi}` | The abi to be used for compiling the test. This is in the format expected by mabi argument of gcc. |
| `${target_isa}` | This is the ISA specified in the input ISA yaml. The idea is that it can be used to configure the model at run time via cli arguments if necessary. |
| `${test_bin}` | The name of the binary file to be created after compilation. Can be ignored. Custom names can be used as long as the RUN_TARGET command picks up the correct binary to execute on the target. |
| `${signature_file}` | The absolute path to the signature file. This path cannot be changed and the signature file should be present at this path for riscof to verify at the end of testing. |
| `${macros}` | The macros to be defined while compilation. Currently they are in the format expected by gcc i.e. `-D <macro-name>=<macro-value>` |


The rewritten Makefile.include for the SAIL C Simulator from [here](https://github.com/riscv/riscv-arch-test/blob/2.4.4/riscv-target/sail-riscv-c/device/rv32i_m/I/Makefile.include) is included in the directory
for reference(`sail.include`).

**Note** - Value substitution for these variables happens only in the
`COMPILE_TARGET` and `RUN_TARGET` values in the makefile. There is no resolution of makefile
variables while substituting the values. The format of the output for each target is:
```
cd <work_directory>;<COMPILE_TARGET>;<RUN_TARGET>;
```

- Examples

**Correct** :

```
TARGET_SIM ?= riscv_sim_RV32 -V
TARGET_FLAGS =

RISCV_PREFIX ?= riscv32-unknown-elf-
RISCV_GCC ?= $(RISCV_PREFIX)gcc
RISCV_GCC_OPTS ?= -g -static -mcmodel=medany -fvisibility=hidden -nostdlib -nostartfiles \
-I$(TARGET_DIR)/env/

COMPILE_TARGET=\
$$(RISCV_GCC) -march=${march} -mabi=${mabi} $$(RISCV_GCC_OPTS) \
-I${include} \
-T${target_dir}/env/link.ld \
${asm} -o ${test_bin} ${macros};

RUN_TARGET=\
$(TARGET_SIM) $(TARGET_FLAGS)\
--test-signature=${signature_file} \
${test_bin}

```

**Wrong** :

```
TARGET_SIM ?= riscv_sim_RV32 -V
TARGET_FLAGS =

RISCV_PREFIX ?= riscv32-unknown-elf-
RISCV_GCC ?= $(RISCV_PREFIX)gcc
RISCV_GCC_OPTS ?= -g -static -mcmodel=medany -fvisibility=hidden -nostdlib -nostartfiles \
-I$(TARGET_DIR)/env/ -I${include} \

COMPILE_TARGET=\
$$(RISCV_GCC) -march=${march} -mabi=${mabi} $$(RISCV_GCC_OPTS) \
-T${target_dir}/env/link.ld \
${asm} -o ${test_bin} ${macros};

RUN_TARGET=\
$(TARGET_SIM) $(TARGET_FLAGS)\
--test-signature=${signature_file} \
${test_bin}
```
The commands produced using the above makefile will result in an error when executed because the
value of `${include}` will not be substituted in the `RISCV_GCC_OPTS` (Variable substitutions
are performed only for the `COMPILE_TARGET` and `RUN_TARGET` commands).
2 changes: 2 additions & 0 deletions riscof-plugins/rv32/makeplugin/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
18 changes: 18 additions & 0 deletions riscof-plugins/rv32/makeplugin/env/link.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
OUTPUT_ARCH( "riscv" )
ENTRY(rvtest_entry_point)

SECTIONS
{
. = 0x80000000;
.text.init : { *(.text.init) }
. = ALIGN(0x1000);
.tohost : { *(.tohost) }
. = ALIGN(0x1000);
.text : { *(.text) }
. = ALIGN(0x1000);
.data : { *(.data) }
.data.string : { *(.data.string)}
.bss : { *(.bss) }
_end = .;
}

60 changes: 60 additions & 0 deletions riscof-plugins/rv32/makeplugin/env/model_test.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#ifndef _COMPLIANCE_MODEL_H
#define _COMPLIANCE_MODEL_H
#if XLEN == 64
#define ALIGNMENT 3
#else
#define ALIGNMENT 2
#endif

#define RVMODEL_DATA_SECTION \
.pushsection .tohost,"aw",@progbits; \
.align 8; .global tohost; tohost: .dword 0; \
.align 8; .global fromhost; fromhost: .dword 0; \
.popsection; \
.align 8; .global begin_regstate; begin_regstate: \
.word 128; \
.align 8; .global end_regstate; end_regstate: \
.word 4;

//RV_COMPLIANCE_HALT
#define RVMODEL_HALT \
li x1, 1; \
write_tohost: \
sw x1, tohost, t5; \
j write_tohost;

#define RVMODEL_BOOT

//RV_COMPLIANCE_DATA_BEGIN
#define RVMODEL_DATA_BEGIN \
RVMODEL_DATA_SECTION \
.align ALIGNMENT;\
.global begin_signature; begin_signature:

//RV_COMPLIANCE_DATA_END
#define RVMODEL_DATA_END \
.global end_signature; end_signature:

//RVTEST_IO_INIT
#define RVMODEL_IO_INIT
//RVTEST_IO_WRITE_STR
#define RVMODEL_IO_WRITE_STR(_R, _STR)
//RVTEST_IO_CHECK
#define RVMODEL_IO_CHECK()
//RVTEST_IO_ASSERT_GPR_EQ
#define RVMODEL_IO_ASSERT_GPR_EQ(_S, _R, _I)
//RVTEST_IO_ASSERT_SFPR_EQ
#define RVMODEL_IO_ASSERT_SFPR_EQ(_F, _R, _I)
//RVTEST_IO_ASSERT_DFPR_EQ
#define RVMODEL_IO_ASSERT_DFPR_EQ(_D, _R, _I)

#define RVMODEL_SET_MSW_INT

#define RVMODEL_CLEAR_MSW_INT

#define RVMODEL_CLEAR_MTIMER_INT

#define RVMODEL_CLEAR_MEXT_INT


#endif // _COMPLIANCE_MODEL_H
Loading