[dv] Simplify instructions for how to use Spike with cosim

This depends on Spike version ibex-cosim-v0.2 (which exposes the
various library headers with pkg-config, making configuration much
easier).
This commit is contained in:
Rupert Swarbrick 2022-02-16 12:46:13 +00:00 committed by hcallahan-lowrisc
parent 394a0d2160
commit 42ce56b6b6
6 changed files with 9 additions and 34 deletions

View file

@ -67,10 +67,6 @@ steps:
displayName: Run RISC-V Compliance test for Ibex RV32IMC for ${{ config }}
- bash: |
# Setup environment to use cosim with Simple System
export IBEX_COSIM_ISS_ROOT=/opt/spike-cosim
export LD_LIBRARY_PATH=/opt/spike-cosim/lib:$LD_LIBRARY_PATH
# Build simple system with co-simulation
fusesoc --cores-root=. run --target=sim --setup --build lowrisc:ibex:ibex_simple_system_cosim $IBEX_CONFIG_OPTS

View file

@ -28,13 +28,12 @@ Setup and Usage
Clone the `lowRISC fork of Spike <https://github.com/lowRISC/riscv-isa-sim>`_ and check out the ``ibex-cosim-v0.2`` tag.
Other, later, versions called ``ibex-cosim-v*`` may also work but there's no guarantee of backwards compatibility.
Follow the Spike build instructions to build and install Spike.
The build will install multiple header files and libraries, it is recommended a custom install location (using ``--prefix=<path>`` with ``configure``) is used to avoid cluttering system directories.
The ``--enable-commitlog`` and ``--enable-misaligned`` options must be passed to ``configure``.
We recommend using a custom install location (using ``--prefix=<path>`` with ``configure``) to avoid cluttering system directories.
Note that, if you do this, you will also need to add an entry to ``PKG_CONFIG_PATH`` so that ``pkg-config`` can tell us how to build against the installed Spike libraries.
Once built, the ``IBEX_COSIM_ISS_ROOT`` environment variable must be set to the Spike root install directory (as given by ``--prefix=<path>`` to ``configure``) in order to build either the UVM DV environment or Simple System with co-simulation support.
To build/run the UVM DV environment with the co-simulator add the ``COSIM=1`` argument to the make command.
To build Simple System with the co-simulator build the ``lowrisc:ibex:ibex_simple_system_cosim`` core.
To build/run the UVM DV environment with the co-simulator, add the ``COSIM=1`` argument to the make command.
To build Simple System with the co-simulator, build the ``lowrisc:ibex:ibex_simple_system_cosim`` core.
Quick Build and Run Instructions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -55,9 +54,6 @@ Build and install the co-simulator
../configure --enable-commitlog --enable-misaligned --prefix=/opt/spike-cosim
sudo make -j8 install
# Setup IBEX_COSIM_ISS_ROOT so build flow can find the co-simulator
export IBEX_COSIM_ISS_ROOT=/opt/spike-cosim
Run the UVM DV regression with co-simulation enabled
.. code-block:: bash
@ -78,9 +74,6 @@ Build and run Simple System with the co-simulation enabled
# any read of those CSRs results in a mismatch and a failure.
make -C ./examples/sw/benchmarks/coremark SUPPRESS_PCOUNT_DUMP=1
# Spike's libsoftfloat.so needs to be accessible so add it to LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/opt/spike-cosim/lib:$LD_LIBRARY_PATH
# Run coremark binary with co-simulation checking
build/lowrisc_ibex_ibex_simple_system_cosim_0/sim-verilator/Vibex_simple_system --meminit=ram,examples/sw/benchmarks/coremark/coremark.elf

View file

@ -208,9 +208,6 @@ The entirety of this flow is controlled by the Makefile found at
# Compile and run RTL simulation
make TEST=xxx compile,rtl_sim
# Use a different ISS (default is spike)
make ... ISS=ovpsim
# Run a full regression with coverage
make COV=1

View file

@ -8,16 +8,6 @@ GEN_DIR := $(realpath ../../../vendor/google_riscv-dv)
TOOLCHAIN := ${RISCV_TOOLCHAIN}
export IBEX_ROOT := $(realpath ../../../)
ifeq ($(COSIM),1)
ifndef IBEX_COSIM_ISS_ROOT
$(error IBEX_COSIM_ISS_ROOT must be set to the root of a suitable spike build if COSIM=1)
else
# Spike builds a libsoftfloat.so shared library that the simulator binary needs.
# Set LD_LIBRARY_PATH so it can be found.
export LD_LIBRARY_PATH := $(IBEX_COSIM_ISS_ROOT)/lib/:${LD_LIBRARY_PATH}
endif
endif
# Explicitly ask for the bash shell
SHELL := bash

View file

@ -17,7 +17,7 @@
# As a result, passing -fno-extended-identifiers tells G++ to pretend that
# everything is ASCII, preventing strange compilation errors.
- tool: vcs
env_var: IBEX_COSIM_ISS_ROOT,IBEX_ROOT
env_var: SPIKE_CFLAGS,SPIKE_LDFLAGS,SPIKE_LIBS,IBEX_ROOT
compile:
cmd:
- "vcs -f <core_ibex>/ibex_dv.f -full64
@ -46,11 +46,10 @@
cosim_opts: >
-f <core_ibex>/ibex_dv_cosim_dpi.f
+define+INC_IBEX_COSIM
-LDFLAGS '-L<IBEX_COSIM_ISS_ROOT>/lib/'
-CFLAGS '-I<IBEX_COSIM_ISS_ROOT>/include'
-CFLAGS '-I<IBEX_COSIM_ISS_ROOT>/include/softfloat'
-LDFLAGS '<SPIKE_LDFLAGS>'
-CFLAGS '<SPIKE_CFLAGS>'
-CFLAGS '-I<IBEX_ROOT>/dv/cosim'
-lriscv -lsoftfloat -lfdt -ldl -ldisasm -lstdc++
<SPIKE_LIBS> -lstdc++
sim:
cmd: >
env SIM_DIR=<sim_dir>

View file

@ -3,7 +3,7 @@ CAPI=2:
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
name: "lowrisc:tool:ibex_cosim_setup_check:0.1"
description: "Check $IBEX_COSIM_ISS_ROOT is set"
description: "Check that Spike is installed properly for cosim"
filesets:
files_ibex_cosim_setup_check: