Skip to content

Commit c482bce

Browse files
authored
Merge branch 'YosysHQ:main' into master
2 parents 8ffca44 + 58c7dc7 commit c482bce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+3627
-842
lines changed

.github/workflows/test-verific.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,42 @@ jobs:
8383
shell: bash
8484
run: |
8585
make -j$procs unit-test ENABLE_LTO=1 ENABLE_LIBYOSYS=1
86+
87+
test-pyosys:
88+
needs: pre-job
89+
if: ${{ needs.pre-job.outputs.should_skip != 'true' && github.repository == 'YosysHQ/Yosys' }}
90+
runs-on: [self-hosted, linux, x64, fast]
91+
steps:
92+
- name: Checkout Yosys
93+
uses: actions/checkout@v4
94+
with:
95+
persist-credentials: false
96+
submodules: true
97+
- name: Install UV
98+
run: |
99+
curl -LsSf https://astral.sh/uv/install.sh | sh
100+
- name: Runtime environment
101+
run: |
102+
echo "procs=$(nproc)" >> $GITHUB_ENV
103+
echo "${{ github.workspace }}/.local/bin" >> $GITHUB_PATH
104+
105+
- name: Build pyosys
106+
run: |
107+
make config-clang
108+
echo "ENABLE_VERIFIC := 1" >> Makefile.conf
109+
echo "ENABLE_VERIFIC_EDIF := 1" >> Makefile.conf
110+
echo "ENABLE_VERIFIC_LIBERTY := 1" >> Makefile.conf
111+
echo "ENABLE_VERIFIC_YOSYSHQ_EXTENSIONS := 1" >> Makefile.conf
112+
echo "ENABLE_CCACHE := 1" >> Makefile.conf
113+
echo "ENABLE_PYOSYS := 1" >> Makefile.conf
114+
echo "PYTHON_DESTDIR := /usr/lib/python3/site-packages" >> Makefile.conf
115+
make -j$procs
116+
117+
- name: Install pyosys
118+
run: |
119+
make install DESTDIR=${GITHUB_WORKSPACE}/.local PREFIX=
120+
121+
- name: Run pyosys tests
122+
run: |
123+
export PYTHONPATH=${GITHUB_WORKSPACE}/.local/usr/lib/python3/site-packages:$PYTHONPATH
124+
python3 tests/pyosys/run_tests.py

CHANGELOG

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,20 @@
22
List of major changes and improvements between releases
33
=======================================================
44

5-
Yosys 0.59 .. Yosys 0.60-dev
5+
Yosys 0.60 .. Yosys 0.61-dev
66
--------------------------
77

8+
Yosys 0.59 .. Yosys 0.60
9+
--------------------------
10+
* Various
11+
- read_verilog: suport unsized parameters.
12+
- Added static library compile option.
13+
14+
* New commands and options
15+
- Added "sdc" pass for reading SDC files.
16+
- Added experimental "sdc_expand" and "opensta" for OpenSTA integration.
17+
- Added "icell_liberty" pass for used internal cells.
18+
819
Yosys 0.58 .. Yosys 0.59
920
--------------------------
1021
* Various

Makefile

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ ENABLE_VERIFIC_EDIF := 0
2323
ENABLE_VERIFIC_LIBERTY := 0
2424
ENABLE_COVER := 1
2525
ENABLE_LIBYOSYS := 0
26+
ENABLE_LIBYOSYS_STATIC := 0
2627
ENABLE_ZLIB := 1
2728
ENABLE_HELP_SOURCE := 0
2829

@@ -161,7 +162,7 @@ ifeq ($(OS), Haiku)
161162
CXXFLAGS += -D_DEFAULT_SOURCE
162163
endif
163164

164-
YOSYS_VER := 0.59+0
165+
YOSYS_VER := 0.60+0
165166
YOSYS_MAJOR := $(shell echo $(YOSYS_VER) | cut -d'.' -f1)
166167
YOSYS_MINOR := $(shell echo $(YOSYS_VER) | cut -d'.' -f2 | cut -d'+' -f1)
167168
YOSYS_COMMIT := $(shell echo $(YOSYS_VER) | cut -d'+' -f2)
@@ -184,7 +185,7 @@ endif
184185
OBJS = kernel/version_$(GIT_REV).o
185186

186187
bumpversion:
187-
sed -i "/^YOSYS_VER := / s/+[0-9][0-9]*$$/+`git log --oneline 03eb220.. | wc -l`/;" Makefile
188+
sed -i "/^YOSYS_VER := / s/+[0-9][0-9]*$$/+`git log --oneline 5bafeb7.. | wc -l`/;" Makefile
188189

189190
ABCMKARGS = CC="$(CXX)" CXX="$(CXX)" ABC_USE_LIBSTDCXX=1 ABC_USE_NAMESPACE=abc VERBOSE=$(Q)
190191

@@ -342,6 +343,9 @@ endif
342343

343344
ifeq ($(ENABLE_LIBYOSYS),1)
344345
TARGETS += libyosys.so
346+
ifeq ($(ENABLE_LIBYOSYS_STATIC),1)
347+
TARGETS += libyosys.a
348+
endif
345349
endif
346350

347351
PY_WRAPPER_FILE = pyosys/wrappers
@@ -474,6 +478,9 @@ else
474478
ifeq ($(ABCEXTERNAL),)
475479
TARGETS := $(PROGRAM_PREFIX)yosys-abc$(EXE) $(TARGETS)
476480
endif
481+
ifeq ($(DISABLE_SPAWN),1)
482+
$(error ENABLE_ABC=1 requires either LINK_ABC=1 or DISABLE_SPAWN=0)
483+
endif
477484
endif
478485
endif
479486

@@ -772,6 +779,9 @@ else
772779
$(P) $(CXX) -o libyosys.so -shared -Wl,-soname,libyosys.so $(LINKFLAGS) $^ $(LIBS) $(LIBS_VERIFIC)
773780
endif
774781

782+
libyosys.a: $(filter-out kernel/driver.o,$(OBJS))
783+
$(P) $(AR) rcs $@ $^
784+
775785
%.o: %.cc
776786
$(Q) mkdir -p $(dir $@)
777787
$(P) $(CXX) -o $@ -c $(CPPFLAGS) $(CXXFLAGS) $<
@@ -902,6 +912,7 @@ MK_TEST_DIRS += tests/arch/xilinx
902912
MK_TEST_DIRS += tests/bugpoint
903913
MK_TEST_DIRS += tests/opt
904914
MK_TEST_DIRS += tests/sat
915+
MK_TEST_DIRS += tests/sdc
905916
MK_TEST_DIRS += tests/sim
906917
MK_TEST_DIRS += tests/svtypes
907918
MK_TEST_DIRS += tests/techmap
@@ -1022,7 +1033,7 @@ install-dev: $(PROGRAM_PREFIX)yosys-config share
10221033

10231034
install: $(TARGETS) $(EXTRA_TARGETS)
10241035
$(INSTALL_SUDO) mkdir -p $(DESTDIR)$(BINDIR)
1025-
$(INSTALL_SUDO) cp $(filter-out libyosys.so,$(TARGETS)) $(DESTDIR)$(BINDIR)
1036+
$(INSTALL_SUDO) cp $(filter-out libyosys.so libyosys.a,$(TARGETS)) $(DESTDIR)$(BINDIR)
10261037
ifneq ($(filter $(PROGRAM_PREFIX)yosys,$(TARGETS)),)
10271038
if [ -n "$(STRIP)" ]; then $(INSTALL_SUDO) $(STRIP) -S $(DESTDIR)$(BINDIR)/$(PROGRAM_PREFIX)yosys; fi
10281039
endif
@@ -1038,9 +1049,12 @@ ifeq ($(ENABLE_LIBYOSYS),1)
10381049
$(INSTALL_SUDO) mkdir -p $(DESTDIR)$(LIBDIR)
10391050
$(INSTALL_SUDO) cp libyosys.so $(DESTDIR)$(LIBDIR)/
10401051
if [ -n "$(STRIP)" ]; then $(INSTALL_SUDO) $(STRIP) -S $(DESTDIR)$(LIBDIR)/libyosys.so; fi
1052+
ifeq ($(ENABLE_LIBYOSYS_STATIC),1)
1053+
$(INSTALL_SUDO) cp libyosys.a $(DESTDIR)$(LIBDIR)/
1054+
endif
10411055
ifeq ($(ENABLE_PYOSYS),1)
10421056
$(INSTALL_SUDO) mkdir -p $(DESTDIR)$(PYTHON_DESTDIR)/$(subst -,_,$(PROGRAM_PREFIX))pyosys
1043-
$(INSTALL_SUDO) cp pyosys/__init__.py $(DESTDIR)$(PYTHON_DESTDIR)/$(subst -,_,$(PROGRAM_PREFIX))pyosys/__init__.py
1057+
$(INSTALL_SUDO) cp $(YOSYS_SRC)/pyosys/__init__.py $(DESTDIR)$(PYTHON_DESTDIR)/$(subst -,_,$(PROGRAM_PREFIX))pyosys/__init__.py
10441058
$(INSTALL_SUDO) cp libyosys.so $(DESTDIR)$(PYTHON_DESTDIR)/$(subst -,_,$(PROGRAM_PREFIX))pyosys/libyosys.so
10451059
$(INSTALL_SUDO) cp -r share $(DESTDIR)$(PYTHON_DESTDIR)/$(subst -,_,$(PROGRAM_PREFIX))pyosys
10461060
ifeq ($(ENABLE_ABC),1)
@@ -1060,6 +1074,9 @@ uninstall:
10601074
$(INSTALL_SUDO) rm -rvf $(DESTDIR)$(DATDIR)
10611075
ifeq ($(ENABLE_LIBYOSYS),1)
10621076
$(INSTALL_SUDO) rm -vf $(DESTDIR)$(LIBDIR)/libyosys.so
1077+
ifeq ($(ENABLE_LIBYOSYS_STATIC),1)
1078+
$(INSTALL_SUDO) rm -vf $(DESTDIR)$(LIBDIR)/libyosys.a
1079+
endif
10631080
ifeq ($(ENABLE_PYOSYS),1)
10641081
$(INSTALL_SUDO) rm -vf $(DESTDIR)$(PYTHON_DESTDIR)/$(subst -,_,$(PROGRAM_PREFIX))pyosys/libyosys.so
10651082
$(INSTALL_SUDO) rm -vf $(DESTDIR)$(PYTHON_DESTDIR)/$(subst -,_,$(PROGRAM_PREFIX))pyosys/__init__.py
@@ -1158,7 +1175,7 @@ clean-py:
11581175
rm -f $(PY_WRAPPER_FILE).inc.cc $(PY_WRAPPER_FILE).cc
11591176
rm -f $(PYTHON_OBJECTS)
11601177
rm -f *.whl
1161-
rm -f libyosys.so
1178+
rm -f libyosys.so libyosys.a
11621179
rm -rf kernel/*.pyh
11631180

11641181
clean-abc:

abc

backends/functional/smtlib_rosette.cc

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,20 +188,27 @@ struct SmtrModule {
188188
Functional::IR ir;
189189
SmtrScope scope;
190190
std::string name;
191-
191+
bool use_assoc_list_helpers;
192+
std::optional<std::string> input_helper_name;
193+
std::optional<std::string> output_helper_name;
194+
192195
SmtrStruct input_struct;
193196
SmtrStruct output_struct;
194197
SmtrStruct state_struct;
195198

196-
SmtrModule(Module *module)
197-
: ir(Functional::IR::from_module(module))
198-
, scope()
199-
, name(scope.unique_name(module->name))
200-
, input_struct(scope.unique_name(module->name.str() + "_Inputs"), scope)
201-
, output_struct(scope.unique_name(module->name.str() + "_Outputs"), scope)
202-
, state_struct(scope.unique_name(module->name.str() + "_State"), scope)
199+
SmtrModule(Module *module, bool assoc_list_helpers)
200+
: ir(Functional::IR::from_module(module)), scope(), name(scope.unique_name(module->name)), use_assoc_list_helpers(assoc_list_helpers),
201+
input_struct(scope.unique_name(module->name.str() + "_Inputs"), scope),
202+
output_struct(scope.unique_name(module->name.str() + "_Outputs"), scope),
203+
state_struct(scope.unique_name(module->name.str() + "_State"), scope)
203204
{
204205
scope.reserve(name + "_initial");
206+
if (assoc_list_helpers) {
207+
input_helper_name = scope.unique_name(module->name.str() + "_inputs_helper");
208+
scope.reserve(*input_helper_name);
209+
output_helper_name = scope.unique_name(module->name.str() + "_outputs_helper");
210+
scope.reserve(*output_helper_name);
211+
}
205212
for (auto input : ir.inputs())
206213
input_struct.insert(input->name, input->sort);
207214
for (auto output : ir.outputs())
@@ -257,6 +264,45 @@ struct SmtrModule {
257264
w.pop();
258265
}
259266

267+
void write_assoc_list_helpers(SExprWriter &w)
268+
{
269+
log_assert(output_helper_name && input_helper_name);
270+
271+
// Input struct keyword-based constructor.
272+
w.push();
273+
w.open(list("define"));
274+
const auto inputs_name = "inputs";
275+
w.open(list(*input_helper_name, inputs_name));
276+
w.close();
277+
w.open(list(input_struct.name));
278+
for (auto input : ir.inputs()) {
279+
w.push();
280+
w.open(list("let"));
281+
w.push();
282+
w.open(list());
283+
w.open(list("assoc-result"));
284+
w << list("assoc", "\"" + RTLIL::unescape_id(input->name) + "\"", inputs_name);
285+
w.pop();
286+
w.open(list("if", "assoc-result"));
287+
w << list("cdr", "assoc-result");
288+
w.open(list("begin"));
289+
w << list("fprintf", list("current-error-port"), "\"%s not found in inputs\"");
290+
w << "'not-found";
291+
w.pop();
292+
}
293+
w.pop();
294+
// Output struct keyword-based destructuring
295+
w.push();
296+
w.open(list("define"));
297+
const auto outputs_name = "outputs";
298+
w << list(*output_helper_name, outputs_name);
299+
w.open(list("list"));
300+
for (auto output : ir.outputs()) {
301+
w << list("cons", "\"" + RTLIL::unescape_id(output->name) + "\"", output_struct.access("outputs", output->name));
302+
}
303+
w.pop();
304+
}
305+
260306
void write(std::ostream &out)
261307
{
262308
SExprWriter w(out);
@@ -265,6 +311,10 @@ struct SmtrModule {
265311
output_struct.write_definition(w);
266312
state_struct.write_definition(w);
267313

314+
if (use_assoc_list_helpers) {
315+
write_assoc_list_helpers(w);
316+
}
317+
268318
write_eval(w);
269319
write_initial(w);
270320
}
@@ -282,12 +332,16 @@ struct FunctionalSmtrBackend : public Backend {
282332
log("\n");
283333
log(" -provides\n");
284334
log(" include 'provide' statement(s) for loading output as a module\n");
335+
log(" -assoc-list-helpers\n");
336+
log(" provide helper functions which convert inputs/outputs from/to association lists\n");
337+
log(" \n");
285338
log("\n");
286339
}
287340

288341
void execute(std::ostream *&f, std::string filename, std::vector<std::string> args, RTLIL::Design *design) override
289342
{
290343
auto provides = false;
344+
auto assoc_list_helpers = false;
291345

292346
log_header(design, "Executing Functional Rosette Backend.\n");
293347

@@ -296,6 +350,8 @@ struct FunctionalSmtrBackend : public Backend {
296350
{
297351
if (args[argidx] == "-provides")
298352
provides = true;
353+
else if (args[argidx] == "-assoc-list-helpers")
354+
assoc_list_helpers = true;
299355
else
300356
break;
301357
}
@@ -307,8 +363,8 @@ struct FunctionalSmtrBackend : public Backend {
307363
}
308364

309365
for (auto module : design->selected_modules()) {
310-
log("Processing module `%s`.\n", module->name);
311-
SmtrModule smtr(module);
366+
log("Processing module `%s`.\n", module->name.c_str());
367+
SmtrModule smtr(module, assoc_list_helpers);
312368
smtr.write(*f);
313369
}
314370
}

backends/rtlil/rtlil_backend.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ void RTLIL_BACKEND::dump_const(std::ostream &f, const RTLIL::Const &data, int wi
6161
return;
6262
}
6363
}
64-
f << stringf("%d'", width);
64+
if ((data.flags & RTLIL::CONST_FLAG_UNSIZED) == 0) {
65+
f << stringf("%d'", width);
66+
}
6567
if (data.flags & RTLIL::CONST_FLAG_SIGNED) {
6668
f << stringf("s");
6769
}
@@ -173,9 +175,10 @@ void RTLIL_BACKEND::dump_cell(std::ostream &f, std::string indent, const RTLIL::
173175
dump_attributes(f, indent, cell);
174176
f << stringf("%s" "cell %s %s\n", indent, cell->type, cell->name);
175177
for (const auto& [name, param] : reversed(cell->parameters)) {
176-
f << stringf("%s parameter%s%s %s ", indent,
178+
f << stringf("%s parameter%s%s%s %s ", indent,
177179
(param.flags & RTLIL::CONST_FLAG_SIGNED) != 0 ? " signed" : "",
178180
(param.flags & RTLIL::CONST_FLAG_REAL) != 0 ? " real" : "",
181+
(param.flags & RTLIL::CONST_FLAG_UNSIZED) != 0 ? " unsized" : "",
179182
name);
180183
dump_const(f, param);
181184
f << stringf("\n");

backends/verilog/verilog_backend.cc

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,22 +108,30 @@ IdString initial_id;
108108

109109
void reset_auto_counter_id(RTLIL::IdString id, bool may_rename)
110110
{
111-
const char *str = id.c_str();
111+
auto it = id.begin();
112+
auto it_end = id.end();
113+
if (it == it_end)
114+
return;
112115

113-
if (*str == '$' && may_rename && !norename)
116+
if (*it == '$' && may_rename && !norename)
114117
auto_name_map[id] = auto_name_counter++;
115118

116-
if (str[0] != '\\' || str[1] != '_' || str[2] == 0)
119+
if (*it != '\\' || (it + 1) == it_end || *(it + 1) != '_' || (it + 2) == it_end)
117120
return;
118121

119-
for (int i = 2; str[i] != 0; i++) {
120-
if (str[i] == '_' && str[i+1] == 0)
121-
continue;
122-
if (str[i] < '0' || str[i] > '9')
122+
std::string s;
123+
it += 2;
124+
while (it != it_end) {
125+
char ch = *it;
126+
if (ch == '_' && (it + 1) == it_end)
127+
break;
128+
if (ch < '0' || ch > '9')
123129
return;
130+
s.push_back(ch);
131+
++it;
124132
}
125133

126-
int num = atoi(str+2);
134+
int num = atoi(s.c_str());
127135
if (num >= auto_name_offset)
128136
auto_name_offset = num + 1;
129137
}

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
project = 'YosysHQ Yosys'
77
author = 'YosysHQ GmbH'
88
copyright ='2025 YosysHQ GmbH'
9-
yosys_ver = "0.59"
9+
yosys_ver = "0.60"
1010

1111
# select HTML theme
1212
html_theme = 'furo-ys'

frontends/aiger2/xaiger.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ struct Xaiger2Frontend : public Frontend {
110110
for (int i = 0; i < (int) O; i++) {
111111
int po;
112112
*f >> po;
113-
log_assert(f->get() == '\n');
113+
int c = f->get();
114+
log_assert(c == '\n');
114115
outputs.push_back(po);
115116
}
116117

0 commit comments

Comments
 (0)