Skip to content

Commit 43e39f7

Browse files
authored
Allow to build Synlig as Python module (#2591)
Now Synlig can be build as Python module. It can be installed by running: ``` make install@pysynlig -j $(nproc) ``` after installation it can be used in Python: ``` from PySynlig import libsynlig as synlig synlig.run_pass("read_systemverilog counter.sv") ```
2 parents 704669c + cb88b28 commit 43e39f7

File tree

18 files changed

+428
-185
lines changed

18 files changed

+428
-185
lines changed

.ci.yml

Lines changed: 98 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
include:
2+
- project: repositories/synlig-ci
3+
ref: master
4+
file: .ci.yml
5+
16
stages:
27
- "Check code format"
38
- "Build binaries"
@@ -38,9 +43,6 @@ variables:
3843
3944
.job_template: &build_binary
4045
stage: "Build binaries"
41-
variables:
42-
SCALENODE_RAM: 8000
43-
SCALENODE_CPU: 8
4446
only:
4547
- main
4648
- merge_requests
@@ -49,44 +51,50 @@ variables:
4951
paths:
5052
- out/
5153

54+
.common_build_prefix: &common_build_prefix |-
55+
echo "##/ Install dependencies and build \##"
56+
apt update && apt install -y $BUILD_DEPENDENCIES
57+
echo "##/ Load submodules \##"
58+
git submodule sync && git submodule update --init --recursive third_party/{surelog,yosys}
59+
echo "##/ Build binaries \##"
60+
5261
build_plugin:
5362
<<: *build_binary
5463
script:
55-
- echo "##/ Install dependencies and build \##"
56-
- apt update && apt install -y $BUILD_DEPENDENCIES
57-
- echo "##/ Build yosys, surelog and plugin binaries \##"
58-
- git submodule sync && git submodule update --init --recursive third_party/{surelog,yosys}
64+
- *common_build_prefix
5965
- make install-plugin install@surelog -j $(nproc) PREFIX=out
6066

6167
build_asan:
6268
<<: *build_binary
6369
script:
64-
- echo "##/ Install dependencies and build \##"
65-
- apt update && apt install -y $BUILD_DEPENDENCIES
66-
- echo "##/ Build yosys, surelog and synlig binaries \##"
67-
- git submodule sync && git submodule update --init --recursive third_party/{surelog,yosys}
68-
- make install install@surelog -j $(nproc) ENABLE_ASAN=1 CC=clang CXX=clang++ CFG_BUILD_TYPE=asan PREFIX=out
70+
- *common_build_prefix
71+
- make install@surelog install@asan -j $(nproc) CC=clang CXX=clang++ PREFIX=out
6972

7073
build_release:
7174
<<: *build_binary
7275
script:
73-
- echo "##/ Install dependencies and build \##"
74-
- apt update && apt install -y $BUILD_DEPENDENCIES
75-
- echo "##/ Build synlig binary \##"
76-
- git submodule sync && git submodule update --init --recursive --checkout third_party/{surelog,yosys,sv2v}
76+
- *common_build_prefix
7777
- make install install@surelog -j $(nproc) PREFIX=out
7878
- echo "##/ Build tools \##"
79+
- git submodule update --init --recursive --checkout third_party/sv2v
7980
- wget -qO- https://get.haskellstack.org/ | sh -s - -f -d /usr/local/bin
8081
- make install@sv2v install@yosys-tools -j$(nproc) PREFIX=out
8182

82-
build_package:
83+
build_pysynlig:
8384
<<: *build_binary
8485
script:
8586
- echo "##/ Install dependencies and build \##"
8687
- apt update && apt install -y $BUILD_DEPENDENCIES
8788
- echo "##/ Build yosys, surelog and synlig binaries \##"
88-
- git submodule sync && git submodule update --init --recursive third_party/{surelog,yosys}
89+
- git submodule sync && git submodule update --init --recursive third_party/{surelog,yosys,pybind11}
90+
- make install@surelog install@pysynlig -j $(nproc) PREFIX=out
91+
92+
build_package:
93+
<<: *build_binary
94+
script:
95+
- *common_build_prefix
8996
- make install -j $(nproc) PREFIX=out
97+
- echo "##/ Prepare release \##"
9098
- mkdir synlig
9199
- cp out/bin/synlig synlig/
92100
- cp -r out/share/synlig synlig/share
@@ -104,52 +112,62 @@ build_package:
104112
when: always
105113
paths:
106114
- build/
107-
script:
108-
- ./tests/scripts/run_parsing.sh install_dependencies load_submodules --type $BUILD_TYPE read_uhdm
109-
- ./tests/scripts/run_parsing.sh --type $BUILD_TYPE gather_results
115+
116+
.parsing_tests_script: &parsing_tests_script |-
117+
./tests/scripts/run_parsing.sh install_dependencies load_submodules --type $BUILD_TYPE $COMMAND
118+
./tests/scripts/run_parsing.sh --type $BUILD_TYPE gather_results
110119

111120
plugin_read_uhdm:
112121
<<: *parsing_test
113122
dependencies: [build_plugin]
114-
variables:
115-
BUILD_TYPE: plugin
123+
script:
124+
- BUILD_TYPE=plugin
125+
- COMMAND=read_uhdm
126+
- *parsing_tests_script
116127

117128
plugin_read_systemverilog:
118129
<<: *parsing_test
119130
dependencies: [build_plugin]
120-
variables:
121-
BUILD_TYPE: plugin
131+
script:
132+
- BUILD_TYPE=plugin
133+
- COMMAND=read_systemverilog
134+
- *parsing_tests_script
122135

123136
asan_read_uhdm:
124137
<<: *parsing_test
125138
dependencies: [build_asan]
126-
variables:
127-
BUILD_TYPE: asan
139+
script:
140+
- BUILD_TYPE=asan
141+
- COMMAND=read_uhdm
142+
- *parsing_tests_script
128143

129144
asan_read_systemverilog:
130145
<<: *parsing_test
131146
dependencies: [build_asan]
132-
variables:
133-
BUILD_TYPE: asan
147+
script:
148+
- BUILD_TYPE=asan
149+
- COMMAND=read_systemverilog
150+
- *parsing_tests_script
134151

135152
release_read_uhdm:
136153
<<: *parsing_test
137154
dependencies: [build_release]
138-
variables:
139-
BUILD_TYPE: release
155+
script:
156+
- BUILD_TYPE=release
157+
- COMMAND=read_uhdm
158+
- *parsing_tests_script
140159

141160
release_read_systemverilog:
142161
<<: *parsing_test
143162
dependencies: [build_release]
144-
variables:
145-
BUILD_TYPE: release
163+
script:
164+
- BUILD_TYPE=release
165+
- COMMAND=read_systemverilog
166+
- *parsing_tests_script
146167

147168
.job_template: &formal_test
148169
stage: "Run parsing and formal verification tests"
149170
dependencies: [build_release]
150-
variables:
151-
SCALENODE_RAM: 8000
152-
SCALENODE_CPU: 6
153171
only:
154172
- main
155173
- merge_requests
@@ -158,20 +176,26 @@ release_read_systemverilog:
158176
paths:
159177
- ./*_formal_verification_logs.tar.gz
160178

179+
.formal_tests_script: &formal_tests_script |-
180+
./tests/scripts/run_formal.sh --name $TESTS_SUITE_NAME install_dependencies load_submodules build_dependencies run pack_logs gather_results
181+
161182
simple_formal_verification_tests:
162183
<<: *formal_test
163184
script:
164-
- ./tests/scripts/run_formal.sh --name simple install_dependencies load_submodules build_dependencies run pack_logs gather_results
185+
- TESTS_SUITE_NAME=simple
186+
- *formal_tests_script
165187

166188
yosys_formal_verification_tests:
167189
<<: *formal_test
168190
script:
169-
- ./tests/scripts/run_formal.sh --name yosys install_dependencies load_submodules build_dependencies run pack_logs gather_results
191+
- TESTS_SUITE_NAME=yosys
192+
- *formal_tests_script
170193

171194
sv2v_formal_verification_tests:
172195
<<: *formal_test
173196
script:
174-
- ./tests/scripts/run_formal.sh --name sv2v install_dependencies load_submodules build_dependencies run pack_logs gather_results
197+
- TESTS_SUITE_NAME=sv2v
198+
- *formal_tests_script
175199

176200
.job_template: &large_design_test
177201
stage: "Run large designs tests"
@@ -184,69 +208,57 @@ sv2v_formal_verification_tests:
184208
paths:
185209
- tests/build/
186210

211+
.large_design_script: &large_design_script |-
212+
./tests/scripts/run_large_designs.sh --name $TEST_NAME install_dependencies load_submodules run
213+
187214
veer_synth_large_design:
188215
<<: *large_design_test
189-
variables:
190-
SCALENODE_RAM: 12000
191-
SCALENODE_CPU: 4
192216
script:
193-
- ./tests/scripts/run_large_designs.sh --name veer install_dependencies load_submodules run
217+
- TEST_NAME=veer
218+
- *large_design_script
194219

195220
blackparrot_synth_AMD_xilinx_large_design:
196221
<<: *large_design_test
197-
variables:
198-
SCALENODE_RAM: 20000
199-
SCALENODE_CPU: 6
200222
script:
201-
- ./tests/scripts/run_large_designs.sh --name blackparrot_AMD install_dependencies load_submodules run
223+
- TEST_NAME=blackparrot_AMD
224+
- *large_design_script
202225

203226
blackparrot_synth_ASIC_xilinx_large_design:
204227
<<: *large_design_test
205-
variables:
206-
SCALENODE_RAM: 20000
207-
SCALENODE_CPU: 6
208228
script:
209-
- ./tests/scripts/run_large_designs.sh --name blackparrot_ASIC install_dependencies load_submodules run
229+
- TEST_NAME=blackparrot_ASIC
230+
- *large_design_script
210231
artifacts:
211232
paths:
233+
- tests/build/
212234
- third_party/OpenROAD-flow-scripts/logs
213235
- third_party/OpenROAD-flow-scripts/reports
214236
- third_party/OpenROAD-flow-scripts/results
215237

238+
.large_design_script_with_tools: &large_design_script_with_tools |-
239+
./tests/scripts/run_large_designs.sh --name $TEST_NAME install_dependencies
240+
echo "##/ Setup tools \##"
241+
eval $SETUP_TOOLS && export PATH="$PATH:$TOOLS_HOME/bin"
242+
./tests/scripts/run_large_designs.sh --name $TEST_NAME load_submodules run
243+
216244
ibex_synth_large_design:
217245
<<: *large_design_test
218-
variables:
219-
SCALENODE_RAM: 16000
220-
SCALENODE_CPU: 6
221246
script:
222-
- ./tests/scripts/run_large_designs.sh --name ibex install_dependencies
223-
- echo "##/ Setup tools \##"
224-
- eval $SETUP_TOOLS && export PATH="$PATH:$TOOLS_HOME/bin"
225-
- ./tests/scripts/run_large_designs.sh --name ibex load_submodules run
247+
- TEST_NAME=ibex
248+
- *large_design_script_with_tools
226249

227250
opentitan_9d82960888_synth_large_design:
228251
<<: *large_design_test
229-
variables:
230-
SCALENODE_RAM: 50000
231-
SCALENODE_CPU: 6
232252
script:
233-
- ./tests/scripts/run_large_designs.sh --name opentitan_9d82960888 install_dependencies
234-
- echo "##/ Setup tools \##"
235-
- eval $SETUP_TOOLS && export PATH="$PATH:$TOOLS_HOME/bin"
236-
- ./tests/scripts/run_large_designs.sh --name opentitan_9d82960888 load_submodules run
253+
- TEST_NAME=opentitan_9d82960888
254+
- *large_design_script_with_tools
237255

238256
opentitan_synth_large_design:
239257
<<: *large_design_test
240-
tags: ['ace-x86_64-high-mem']
241258
when: manual
242-
variables:
243-
SCALENODE_RAM: 160000
244-
SCALENODE_CPU: 6
245259
script:
246-
- ./tests/scripts/run_large_designs.sh --name opentitan install_dependencies
247-
- echo "##/ Setup tools \##"
248-
- eval $SETUP_TOOLS && export PATH="$PATH:$TOOLS_HOME/bin"
249-
- ./tests/scripts/run_large_designs.sh --name opentitan load_submodules run
260+
- TEST_NAME=opentitan
261+
- *large_design_script_with_tools
250262

251263
.job_template: &opentitan_parsing_test
252264
stage: "Run large designs tests"
@@ -261,27 +273,16 @@ opentitan_synth_large_design:
261273

262274
opentitan_parse_report_quick_large_design:
263275
<<: *opentitan_parsing_test
264-
variables:
265-
SCALENODE_RAM: 36000
266-
SCALENODE_CPU: 6
267276
script:
268-
- ./tests/scripts/run_large_designs.sh --name opentitan_parse_quick install_dependencies
269-
- echo "##/ Setup tools \##"
270-
- eval $SETUP_TOOLS && export PATH="$PATH:$TOOLS_HOME/bin"
271-
- ./tests/scripts/run_large_designs.sh --name opentitan_parse_quick load_submodules run
277+
- TEST_NAME=opentitan_parse_quick
278+
- *large_design_script_with_tools
272279

273280
opentitan_parse_report_full_large_design:
274281
<<: *opentitan_parsing_test
275-
tags: ['ace-x86_64-high-mem']
276282
when: manual
277-
variables:
278-
SCALENODE_RAM: 120000
279-
SCALENODE_CPU: 6
280283
script:
281-
- ./tests/scripts/run_large_designs.sh --name opentitan_parse_full install_dependencies
282-
- echo "##/ Setup tools \##"
283-
- eval $SETUP_TOOLS && export PATH="$PATH:$TOOLS_HOME/bin"
284-
- ./tests/scripts/run_large_designs.sh --name opentitan_parse_full load_submodules run
284+
- TEST_NAME=opentitan_parse_full
285+
- *large_design_script_with_tools
285286

286287
ibex_synth_f4pga_large_design:
287288
stage: "Run large designs tests"
@@ -293,23 +294,15 @@ ibex_synth_f4pga_large_design:
293294
when: always
294295
paths:
295296
- tests/build/
296-
variables:
297-
SCALENODE_RAM: 20000
298-
SCALENODE_CPU: 6
299297
script:
300-
- ./tests/scripts/run_large_designs.sh --name ibex_f4pga install_dependencies
301-
- echo "##/ Setup tools \##"
302-
- eval $SETUP_TOOLS && export PATH="$PATH:$TOOLS_HOME/bin"
303-
- ./tests/scripts/run_large_designs.sh --name ibex_f4pga load_submodules run
298+
- TEST_NAME=ibex_f4pga
299+
- *large_design_script_with_tools
304300

305301
check_README:
306-
stage: "Optional tests"
302+
stage: "Build binaries"
307303
only:
308304
- main
309305
- merge_requests
310-
variables:
311-
SCALENODE_RAM: 8000
312-
SCALENODE_CPU: 6
313306
script:
314307
- echo "##/ Install Prerequisites \##"
315308
- apt update && apt install -y pipx git wget
@@ -334,6 +327,12 @@ check_README:
334327
- tuttest README.md large-designs-help | bash -eo pipefail -
335328
- tuttest README.md parsing-tests-help | bash -eo pipefail -
336329

330+
blackparrot_synth_AMD_xilinx_large_design_python:
331+
<<: *large_design_test
332+
dependencies: [build_pysynlig]
333+
script:
334+
- ./tests/scripts/run_large_designs.sh --name blackparrot_AMD_python install_dependencies load_submodules run
335+
337336
bsg_test_diff:
338337
stage: "Optional tests"
339338
dependencies: [build_plugin]

0 commit comments

Comments
 (0)