This repository was archived by the owner on May 19, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.optimized
More file actions
157 lines (134 loc) · 5.04 KB
/
Copy pathDockerfile.optimized
File metadata and controls
157 lines (134 loc) · 5.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# ==========================================
# Stage 1: Builder (编译 OpenSTA & CUDD)
# ==========================================
FROM ubuntu:22.04 AS builder
# 防止交互式提示中断构建
ENV DEBIAN_FRONTEND=noninteractive
# 1. 安装 OpenSTA 编译依赖
# 包括: cmake, swig (关键), eigen3 (关键), tcl, zlib 等
RUN apt-get update && apt-get install -y \
wget git build-essential cmake \
bison flex \
swig \
libtcl8.6 tcl-dev \
libz-dev libreadline-dev \
libeigen3-dev \
autoconf automake libtool \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /tmp/build
# 2. 编译 CUDD 3.0.0 (OpenSTA 强依赖)
RUN wget https://sourceforge.net/projects/cudd-mirror/files/cudd-3.0.0.tar.gz/download -O cudd-3.0.0.tar.gz \
&& tar -xzvf cudd-3.0.0.tar.gz \
&& cd cudd-3.0.0 \
&& ./configure --enable-shared --enable-obj \
&& make -j$(nproc) \
&& make install \
&& ldconfig
# 3. 编译 OpenSTA
# 使用 shallow clone 加快速度
RUN git clone --depth 1 --recursive https://github.com/The-OpenROAD-Project/OpenSTA.git \
&& cd OpenSTA \
&& mkdir build && cd build \
&& cmake .. \
-DCUDD_ROOT=/usr/local \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DCMAKE_BUILD_TYPE=Release \
&& make -j$(nproc) \
&& make install
# ==========================================
# Stage 2: Base System (系统基础环境)
# ==========================================
FROM ubuntu:22.04 AS base-system
ENV DEBIAN_FRONTEND=noninteractive
ENV SHELL=/bin/bash
# 1. 基础系统工具和 EDA 工具 (变更频率极低)
RUN apt-get update && apt-get install -y \
wget curl git make bzip2 \
g++ \
cmake ninja-build \
flex bison autoconf help2man \
libtcl8.6 libgomp1 graphviz \
libreadline8 locales \
yosys \
iverilog \
gtkwave \
python3 python3-pip python3-dev python3-venv \
&& rm -rf /var/lib/apt/lists/*
# 设置 UTF-8 语言环境 (Python 3 必须)
RUN locale-gen en_US.UTF-8
ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
# 2. 从 Builder 阶段复制编译好的 OpenSTA 及 CUDD 库 (几乎不变)
COPY --from=builder /usr/local/bin/sta /usr/local/bin/sta
COPY --from=builder /usr/local/lib/libcudd* /usr/local/lib/
RUN ldconfig
# 3. 环境变量与工作目录
ENV PDK_ROOT=/opt/pdk
RUN mkdir -p $PDK_ROOT
WORKDIR /workspace
# ==========================================
# Stage 3: Python Environment (Python环境配置)
# ==========================================
FROM base-system AS python-env
# 1. 配置 Python 虚拟环境 (Location: /opt/asic_env)
ENV PYTHON_ENV=/opt/asic_env
ENV PATH=$PYTHON_ENV/bin:$PATH
RUN mkdir -p $PYTHON_ENV \
&& python3 -m venv $PYTHON_ENV \
&& pip install --upgrade pip \
# 配置 pip 源 (可选,根据网络情况保留或删除)
&& pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ \
&& pip config set global.trusted-host mirrors.aliyun.com
# ==========================================
# Stage 4: Python EDA Libraries (Python EDA库)
# ==========================================
FROM python-env AS python-eda
# 安装 Python EDA 库 (中等变更频率)
# 锁定 Cocotb 2.0+ 以匹配 Verilator 5.036
RUN pip install --no-cache-dir \
cocotb>=2.0 \
cocotb-test \
cocotb-bus \
pytest \
numpy \
scipy \
matplotlib \
volare
# ==========================================
# Stage 5: Verilator (Verilator编译)
# ==========================================
FROM python-eda AS with-verilator
# 安装 Verilator 5.036 (源码编译) - 低变更频率
# 原因:apt 源的版本太旧,无法支持 Cocotb 2.0 的新调度器
RUN wget --tries=3 --timeout=30 -O verilator.tar.gz \
https://github.com/verilator/verilator/archive/refs/tags/v5.036.tar.gz \
&& ls -la verilator.tar.gz \
&& tar -xzf verilator.tar.gz \
&& cd verilator-5.036 \
&& autoconf \
&& ./configure --prefix=/usr/local \
&& make -j$(nproc) \
&& make install \
&& cd .. && rm -rf verilator-5.036 verilator.tar.gz
# ==========================================
# Stage 6: Verible (Verible工具)
# ==========================================
FROM with-verilator AS with-verible
# 安装 Verible (静态二进制包) - 中等变更频率
# 使用具体的 Commit hash 版本,保证下载链接有效
RUN wget -q https://github.com/chipsalliance/verible/releases/download/v0.0-4023-gc1271a00/verible-v0.0-4023-gc1271a00-linux-static-x86_64.tar.gz -O verible.tar.gz \
&& tar -xzf verible.tar.gz \
&& cp verible-*/bin/* /usr/local/bin/ \
&& rm -rf verible-* verible.tar.gz
# ==========================================
# Stage 7: Final (最终镜像)
# ==========================================
FROM with-verible
# 8. 最终构建自检 (验证所有工具是否就位)
RUN echo "=== Environment Check ===" \
&& echo "[Python] $(python --version)" \
&& echo "[Verilator] $(verilator --version)" \
&& echo "[CocoTB] $(pip show cocotb | grep Version)" \
&& echo "[Yosys] $(yosys -V)" \
&& echo "[OpenSTA] $(sta -version)" \
&& echo "Build Verified Successfully!"
CMD ["/bin/bash"]