Skip to content

Fix DSim support #2297

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

Merged
merged 6 commits into from
Jul 21, 2025
Merged

Fix DSim support #2297

merged 6 commits into from
Jul 21, 2025

Conversation

akashlevy
Copy link
Contributor

@akashlevy akashlevy commented Jul 16, 2025

Continued from #2286:

This PR fixes up Ibex UVM support for DSim simulator. Several things had to be fixed:

With these fixes, I was able to get most of the UVM tests running with SIMULATOR=dsim ITERATIONS=1:

82.14% PASS 46 PASSED, 10 FAILED

Future enhancements:

  • Fix remaining DSim failures
  • Coverage support for DSim
  • Fix METADATA-DIR make variable issue
  • Add support for Verific elaboration (needs a few more defines, etc.)

@akashlevy akashlevy mentioned this pull request Jul 16, 2025
@akashlevy
Copy link
Contributor Author

akashlevy commented Jul 16, 2025

Also, I'll share my DSim setup in case you want to try it out. I'm not using DSim Desktop, I'm using the CLI binaries. You need both AltairDSim2025.0.1_linux64.bin and dsim-license.json, which can be obtained via the Altair downloads page.

Here's my DSim base Dockerfile:

# Use Ubuntu as base image (needs --platform=linux/amd64)
FROM ubuntu:22.04

# Set environment variables to avoid interactive prompts during installation
ENV DEBIAN_FRONTEND=noninteractive

# Create a directory for dsim
WORKDIR /root

# Install required dependencies
RUN apt-get update -y
RUN apt-get install -y build-essential ca-certificates libsqlite3-dev

# Copy the dsim binary
COPY AltairDSim2025.0.1_linux64.bin /root/
COPY dsim-license.json /root/

# Make the binary executable
RUN chmod +x /root/AltairDSim2025.0.1_linux64.bin

# Install dsim
RUN /root/AltairDSim2025.0.1_linux64.bin -i silent -DACCEPT_EULA=YES

# Remove dsim installer
RUN rm /root/AltairDSim2025.0.1_linux64.bin

# Setup dsim environment
ENV DSIM=dsim
ENV DSIM_HOME=/root/AltairDSim/2025
ENV DSIM_LICENSE=/root/dsim-license.json
ENV DSIM_LIB_PATH=${DSIM_HOME}/lib
ENV UVM_HOME=${DSIM_HOME}/uvm/1.2/
ENV STD_LIBS=${DSIM_HOME}/std_pkgs/lib
ENV RADFLEX_PATH=${DSIM_HOME}/radflex
ENV LLVM_HOME=${DSIM_HOME}/llvm_small
ENV PATH=${LLVM_HOME}/bin:${DSIM_HOME}/bin:$PATH
ENV LD_LIBRARY_PATH=${DSIM_HOME}/lib:${LLVM_HOME}/lib

# Symlink libuvm_dpi.so to dsim lib path
RUN ln -s ${UVM_HOME}/src/dpi/libuvm_dpi.so ${DSIM_LIB_PATH}/libuvm_dpi.so

# Command to run when container starts
CMD ["dsim"]

And here's my ibex Dockerfile, which builds on this:

# Use dsim as base image (needs --platform=linux/amd64)
FROM dsim

# Install required dependencies
RUN apt-get update -y
RUN apt-get install -y device-tree-compiler git pkg-config python3-pip vim wget

# Install required python dependencies
RUN pip3 install --upgrade pip
RUN pip3 install bitstring junit_xml mako pathlib3x portalocker pydantic typeguard typing_utils pyyaml

# Install ibex spike
RUN git clone -b ibex_cosim https://github.com/lowRISC/riscv-isa-sim.git riscv-isa-sim-cosim && \
    cd riscv-isa-sim-cosim && \
    mkdir build && cd build && \
    ../configure --enable-commitlog --enable-misaligned --prefix=/opt/spike-cosim && \
    make -j`nproc` install && \
    cd ../.. && \
    rm -rf riscv-isa-sim-cosim

# Install riscv toolchain
RUN wget https://github.com/lowRISC/lowrisc-toolchains/releases/download/20250611-1/lowrisc-toolchain-gcc-rv32imcb-x86_64-20250611-1.tar.xz && \
    tar xvf lowrisc-toolchain-gcc-rv32imcb-x86_64-20250611-1.tar.xz && \
    mv lowrisc-toolchain-gcc-rv32imcb-x86_64-20250611-1 /opt/riscv && \
    rm lowrisc-toolchain-gcc-rv32imcb-x86_64-20250611-1.tar.xz

# Environment setup
ENV RISCV_TOOLCHAIN=/opt/riscv
ENV RISCV_GCC=$RISCV_TOOLCHAIN/bin/riscv32-unknown-elf-gcc
ENV RISCV_OBJCOPY=$RISCV_TOOLCHAIN/bin/riscv32-unknown-elf-objcopy
ENV SPIKE_PATH=/opt/spike-cosim
ENV PKG_CONFIG_PATH=/opt/spike-cosim/lib/pkgconfig
ENV IBEX_ROOT=/root/ibex
ENV PRJ_DIR=/root/ibex
ENV LOWRISC_IP_DIR=/root/ibex/vendor/lowrisc_ip

@akashlevy akashlevy changed the title Fix dsim support Fix DSim support Jul 16, 2025
@akashlevy
Copy link
Contributor Author

Tagging @hcallahan-lowrisc for review

@hcallahan-lowrisc hcallahan-lowrisc self-requested a review July 17, 2025 11:00
@hcallahan-lowrisc
Copy link
Contributor

This is great, thanks!
Just one minor tweak, and I think this is ready to be merged.
If you could split the changes to rtl/ibex_core.sv out into a seperate commit that should be it, we try to keep RTL changes standalone in the history.

ibex_mem_intf_agent_pkg -> ibex_mem_intf_pkg

Use ibex enum values instead of integers

Add #0 for dsim to start simulation
@akashlevy
Copy link
Contributor Author

Done! 0314b58 has rtl/ibex_core.sv changes separated out now.

Copy link
Contributor

@hcallahan-lowrisc hcallahan-lowrisc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution @akashlevy! It's great to see DSim functional again, and very much appreciated.

@hcallahan-lowrisc hcallahan-lowrisc added this pull request to the merge queue Jul 21, 2025
@akashlevy
Copy link
Contributor Author

Woo-hoo!

Merged via the queue into lowRISC:master with commit 11ce040 Jul 21, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants