iT邦幫忙

2026 iThome 鐵人賽

DAY 2
0

剛開始的時候總是要來點環境設定
鑒於之前有人問XXX要怎麼設定,但是看到的時候早就有人幫忙回答了
這次採用在 Docker 開發的方式減少對系統環境的依賴

目前的環境是 WSL,使用 Ubuntu 提供的 ubuntu-24.04.3-wsl-amd64.wsl
在這個環境下,使用 Docker 作為 systemC & verilator 的開發環境
Docker version: Docker version 29.1.3, build 29.1.3-0ubuntu3~24.04.2
systemC version: 3.0.2
Verilator version: 5.046

Dockerfile:

# Adapted from ../nyan_ooo/Dockerfile, without the Java/Scala/Chisel stack.
FROM ubuntu:22.04

ARG SYSTEMC_VERSION=3.0.2
ARG VERILATOR_VERSION=5.046
ARG BUILD_JOBS=2

RUN apt-get update \
    && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
        autoconf \
        binutils-riscv64-unknown-elf \
        bison \
        build-essential \
        ca-certificates \
        ccache \
        cmake \
        curl \
        flex \
        gcc-riscv64-unknown-elf \
        gdb \
        git \
        help2man \
        less \
        libfl-dev \
        ninja-build \
        opensta \
        perl \
        pkg-config \
        python3 \
        vim \
        yosys \
        zlib1g-dev \
    && rm -rf /var/lib/apt/lists/*
    

# Match this project's C++17 ABI and use one predictable library directory.
RUN git clone --depth 1 --branch "${SYSTEMC_VERSION}" \
        https://github.com/accellera-official/systemc.git /tmp/systemc \
    && cmake -S /tmp/systemc -B /tmp/systemc/build \
        -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_CXX_STANDARD=17 \
        -DCMAKE_INSTALL_PREFIX=/usr/local \
        -DCMAKE_INSTALL_LIBDIR=lib \
        -DBUILD_SHARED_LIBS=ON \
    && cmake --build /tmp/systemc/build --parallel "${BUILD_JOBS}" \
    && cmake --install /tmp/systemc/build \
    && ldconfig \
    && rm -rf /tmp/systemc

ENV SYSTEMC_INCLUDE=/usr/local/include \
    SYSTEMC_LIBDIR=/usr/local/lib \
    PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig

# Configure Verilator after SystemC so --sc uses the same installation.
RUN git clone --depth 1 --branch "v${VERILATOR_VERSION}" \
        https://github.com/verilator/verilator.git /tmp/verilator \
    && cd /tmp/verilator \
    && autoconf \
    && ./configure --prefix=/usr/local \
    && make -j "${BUILD_JOBS}" \
    && make install \
    && rm -rf /tmp/verilator /root/.cache

RUN pkg-config --modversion systemc \
    && verilator --version \
    && riscv64-unknown-elf-gcc --version \
    && riscv64-unknown-elf-objcopy --version

WORKDIR /workspace
CMD ["/bin/bash"]

上一篇
天地初開
下一篇
SystemC Hello
系列文
猴子都寫得出來的 RISC-V OoO CPU5
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言