Skip to content

Commit 0701c6a

Browse files
committed
feat(ci): add workflow dispatch for STA timing analysis CI
1 parent 1ca1c3c commit 0701c6a

File tree

5 files changed

+1320
-0
lines changed

5 files changed

+1320
-0
lines changed

.github/workflows/sta.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: STA Nightly Regression
2+
3+
on:
4+
schedule:
5+
# 12:00 UTC == 20:00 UTC+8
6+
- cron: '00 12 * * *'
7+
workflow_dispatch:
8+
pull_request:
9+
10+
jobs:
11+
run-sta-xiangshan:
12+
timeout-minutes: 1440
13+
runs-on: self-hosted
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Prepare XiangShan
19+
run: |
20+
cd $GITHUB_WORKSPACE/..
21+
rm -rf XiangShan
22+
proxychains git clone --single-branch --branch master --depth 1 https://github.com/OpenXiangShan/XiangShan.git
23+
cd XiangShan && make init && rm -rf difftest && cp -r $GITHUB_WORKSPACE .
24+
echo "NOOP_HOME=$(pwd)" >> $GITHUB_ENV
25+
echo "DIFF_RTL_HOME=$(pwd)/difftest/build" >> $GITHUB_ENV
26+
27+
- name: Build XiangShan
28+
run: |
29+
cd $NOOP_HOME
30+
make verilog DEBUG_ARGS="--difftest-config ESBIFDU --difftest-exclude Vec" FPGA=1 WITH_CHISELDB=0 WITH_CONSTANTIN=0 CONFIG=XSNoCDiffTopConfig -j10
31+
32+
- name: Build DiffTest
33+
run: |
34+
cd $NOOP_HOME/difftest
35+
export NOOP_HOME=$(pwd)
36+
make difftest_verilog PROFILE=../build/generated-src/difftest_profile.json NUMCORES=1 CONFIG=ESBIFDU
37+
38+
- name: Run STA
39+
run: |
40+
export PATH=/nfs/home/share/tools/yosys:$PATH
41+
export YOSYS_STA_DIR=/nfs/home/share/tools/yosys-sta
42+
cd $NOOP_HOME/difftest
43+
# Redirect all output to log file to avoid GitHub log size limit
44+
bash ./scripts/ieda/run_sta.sh $DIFF_RTL_HOME GatewayEndpoint > sta_run.log 2>&1; EXIT_CODE=$?
45+
# Print summary (only key steps and errors)
46+
echo "===== STA Run Summary ====="
47+
grep -E '(^Step|Error|completed|saved|Results|====)' sta_run.log || true
48+
# Check if critical_paths.txt was generated
49+
if [ ! -f "./scripts/ieda/sta_results/critical_paths.txt" ]; then
50+
echo "ERROR: STA did not complete successfully - critical_paths.txt not found"
51+
echo "Full log:"
52+
cat sta_run.log
53+
exit 1
54+
fi
55+
# Exit with original exit code
56+
exit $EXIT_CODE
57+
58+
- name: Print critical results
59+
run: |
60+
cd $NOOP_HOME/difftest
61+
if [ -f "./scripts/ieda/sta_results/critical_paths.txt" ]; then
62+
cat ./scripts/ieda/sta_results/critical_paths.txt
63+
else
64+
echo "ERROR: critical_paths.txt not found!"
65+
exit 1
66+
fi

scripts/ieda/README.md

Lines changed: 298 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,298 @@
1+
# Yosys Synthesis and Static Timing Analysis Tool
2+
3+
A comprehensive toolchain for RTL synthesis and static timing analysis using Yosys and iEDA/iSTA.
4+
5+
## Overview
6+
7+
This tool provides an automated workflow for:
8+
- RTL synthesis using Yosys
9+
- Static timing analysis using iEDA/iSTA
10+
- SystemVerilog preprocessing for Yosys compatibility
11+
- Timing report extraction and analysis
12+
13+
## Directory Structure
14+
15+
```
16+
yosys_synth_tool/
17+
├── run_sta.sh # Main script for synthesis and timing analysis
18+
├── sv_preprocessor.py # SystemVerilog preprocessor
19+
├── extract_timing_report.sh # Timing report extraction script
20+
├── README.md # This file
21+
└── sta_results/ # Generated results directory
22+
23+
yosys-sta/ (installed separately, location specified via YOSYS_STA_DIR)
24+
├── scripts/
25+
│ ├── yosys.tcl # Yosys synthesis script
26+
│ ├── sta.tcl # iSTA timing analysis script
27+
│ └── default.sdc # Default SDC constraints
28+
├── pdk/
29+
│ ├── nangate45/ # Nangate 45nm PDK
30+
│ └── icsprout55/ # ICSPROUT 55nm PDK
31+
└── bin/
32+
└── iEDA # iEDA binary
33+
```
34+
35+
## Prerequisites
36+
37+
- Yosys (installed locally and available in PATH)
38+
- Python 3.x
39+
- Bash shell
40+
- iEDA/iSTA (yosys-sta installation)
41+
- Yosys-sta directory set via `YOSYS_STA_DIR` environment variable
42+
43+
## Quick Start
44+
45+
### 1. Set up yosys-sta Location
46+
47+
Set the `YOSYS_STA_DIR` environment variable to point to your yosys-sta installation:
48+
49+
```bash
50+
# Add to your ~/.bashrc or ~/.zshrc for persistent configuration
51+
export YOSYS_STA_DIR=/path/to/yosys-sta
52+
```
53+
54+
Or specify it inline when running the script.
55+
56+
### 2. Basic Usage
57+
58+
```bash
59+
./run_sta.sh <rtl_directory> [top_module_name]
60+
```
61+
62+
**Example:**
63+
```bash
64+
./run_sta.sh /path/to/rtl/files MyTopModule
65+
```
66+
67+
### 3. With Environment Variables
68+
69+
```bash
70+
YOSYS_STA_DIR=/path/to/yosys-sta CLK_PORT_NAME=clock CLK_FREQ_MHZ=1000 ./run_sta.sh /path/to/rtl/files MyTopModule
71+
```
72+
73+
## Environment Variables
74+
75+
| Variable | Description | Default |
76+
|----------|-------------|---------|
77+
| `YOSYS_STA_DIR` | Path to yosys-sta installation directory | `./yosys-sta` |
78+
| `CLK_FREQ_MHZ` | Clock frequency in MHz | `500` |
79+
| `CLK_PORT_NAME` | Clock port name | `clock` |
80+
| `SDC_FILE` | Custom SDC constraints file | `$YOSYS_STA_DIR/scripts/default.sdc` |
81+
| `PDK` | Process design kit | `nangate45` |
82+
83+
## Supported File Types
84+
85+
- **`.v`** - Verilog design files
86+
- **`.vh`** - Verilog header files
87+
- **`.sv`** - SystemVerilog design files
88+
- **`.svh`** - SystemVerilog header files (automatically handled)
89+
90+
## Features
91+
92+
### 1. Automatic RTL File Collection
93+
94+
The script automatically discovers RTL files in the input directory and all subdirectories, excluding test directories:
95+
- `test/`
96+
- `sim/`
97+
- `tb/`
98+
- `verification/`
99+
- `bench/`
100+
101+
### 2. SystemVerilog Preprocessing
102+
103+
The tool includes a preprocessor that converts Yosys-incompatible SystemVerilog syntax:
104+
105+
#### Supported Conversions
106+
107+
| Original Syntax | Converted Syntax |
108+
|----------------|------------------|
109+
| `string var_name;` | `// string var_name;` (commented out) |
110+
| `automatic logic func();` | `logic func();` (keyword removed) |
111+
| `wire [15:0][3:0] var = '{val1, val2, ...};` | `wire [15:0][3:0] var; assign var[0] = val1; ...` |
112+
113+
### 3. Header File Handling
114+
115+
`.svh` header files are automatically:
116+
- Discovered in the RTL directory
117+
- Copied to the preprocessing directory
118+
- Added to Yosys include path
119+
120+
### 4. Duplicate File Detection
121+
122+
Files with identical names are automatically deduplicated (first occurrence is kept).
123+
124+
### 5. Comprehensive Timing Reports
125+
126+
The tool generates multiple output files:
127+
128+
#### Synthesis Outputs
129+
- `*.netlist.v` - Synthesized netlist
130+
- `yosys.log` - Yosys synthesis log
131+
- `synth_stat.txt` - Synthesis statistics
132+
- `synth_check.txt` - Design check results
133+
134+
#### Timing Analysis Outputs
135+
- `*.rpt` - Main timing report
136+
- `sta.log` - iSTA analysis log
137+
- `*_setup.skew` - Setup skew report
138+
- `*_hold.skew` - Hold skew report
139+
- `*.cap` - Capacitance report
140+
- `*.fanout` - Fanout report
141+
- `*.trans` - Transition report
142+
143+
## Output Directory
144+
145+
Results are stored in a fixed directory:
146+
```
147+
sta_results/
148+
├── GatewayEndpoint.netlist.v
149+
├── GatewayEndpoint.rpt
150+
├── yosys.log
151+
├── sta.log
152+
└── ...
153+
```
154+
155+
## Timing Report Extraction
156+
157+
Extract key timing information from the generated report:
158+
159+
```bash
160+
./extract_timing_report.sh sta_results/GatewayEndpoint.rpt
161+
```
162+
163+
### Report Sections
164+
165+
1. **TNS Summary** - Total Negative Slack by clock
166+
2. **Setup Critical Paths** - Top 10 worst setup paths
167+
3. **Hold Critical Paths** - Top 10 worst hold paths
168+
4. **Path Details** - Detailed timing breakdown
169+
5. **Statistics** - Path counts and violation detection
170+
171+
## Examples
172+
173+
### Example 1: Basic Synthesis
174+
175+
```bash
176+
./run_sta.sh /home/user/project/rtl TopModule
177+
```
178+
179+
### Example 1: Basic Synthesis
180+
181+
```bash
182+
# Set yosys-sta location
183+
export YOSYS_STA_DIR=/opt/yosys-sta
184+
185+
# Run synthesis and timing analysis
186+
./run_sta.sh /home/user/project/rtl TopModule
187+
```
188+
189+
### Example 2: Custom Clock Frequency
190+
191+
```bash
192+
YOSYS_STA_DIR=/opt/yosys-sta CLK_FREQ_MHZ=1000 ./run_sta.sh /home/user/project/rtl TopModule
193+
```
194+
195+
### Example 3: Custom Clock Port
196+
197+
```bash
198+
YOSYS_STA_DIR=/opt/yosys-sta CLK_PORT_NAME=clk ./run_sta.sh /home/user/project/rtl TopModule
199+
```
200+
201+
### Example 4: Custom SDC File
202+
203+
```bash
204+
YOSYS_STA_DIR=/opt/yosys-sta SDC_FILE=/path/to/custom.sdc ./run_sta.sh /home/user/project/rtl TopModule
205+
```
206+
207+
### Example 5: Different PDK
208+
209+
```bash
210+
YOSYS_STA_DIR=/opt/yosys-sta PDK=icsprout55 ./run_sta.sh /home/user/project/rtl TopModule
211+
```
212+
213+
## Troubleshooting
214+
215+
### Common Issues
216+
217+
#### 1. "yosys-sta directory not found"
218+
219+
**Cause:** `YOSYS_STA_DIR` environment variable not set or incorrect
220+
221+
**Solution:** Set the `YOSYS_STA_DIR` environment variable:
222+
```bash
223+
export YOSYS_STA_DIR=/path/to/yosys-sta
224+
```
225+
226+
#### 2. "Can't open include file"
227+
228+
**Cause:** `.svh` header files not found
229+
230+
**Solution:** Ensure header files are in the RTL directory or its subdirectories
231+
232+
#### 3. "syntax error, unexpected TOK_AUTOMATIC"
233+
234+
**Cause:** SystemVerilog `automatic` keyword not supported
235+
236+
**Solution:** The preprocessor automatically removes this keyword
237+
238+
#### 4. "get_ports clk was not found"
239+
240+
**Cause:** Clock port name mismatch
241+
242+
**Solution:** Set the correct clock port name:
243+
```bash
244+
CLK_PORT_NAME=your_clock_name ./run_sta.sh ...
245+
```
246+
247+
#### 5. "Re-definition of module"
248+
249+
**Cause:** Multiple files with the same module definition
250+
251+
**Solution:** The script automatically deduplicates files by name
252+
253+
## Workflow
254+
255+
```
256+
┌─────────────────────┐
257+
│ Input RTL Files │
258+
└──────────┬──────────┘
259+
260+
261+
┌─────────────────────┐
262+
│ SV Preprocessing │ ← Convert incompatible syntax
263+
└──────────┬──────────┘
264+
265+
266+
┌─────────────────────┐
267+
│ Yosys Synthesis │ ← Generate netlist
268+
└──────────┬──────────┘
269+
270+
271+
┌─────────────────────┐
272+
│ iSTA Timing Analysis│ ← Static timing analysis
273+
└──────────┬──────────┘
274+
275+
276+
┌─────────────────────┐
277+
│ Timing Reports │ ← Extract critical paths
278+
└─────────────────────┘
279+
```
280+
281+
## License
282+
283+
This tool uses:
284+
- Yosys (https://github.com/YosysHQ/yosys)
285+
- iEDA/iSTA (https://github.com/OSCC-Project/iEDA)
286+
287+
Please refer to their respective licenses.
288+
289+
## Contributing
290+
291+
Contributions are welcome! Please ensure:
292+
- All scripts use POSIX-compatible bash
293+
- Python scripts follow PEP 8 style guidelines
294+
- Comments and documentation are in English
295+
296+
## Contact
297+
298+
For issues or questions, please refer to the project documentation or create an issue in the project repository.

0 commit comments

Comments
 (0)