Support `config` default liblist (#6714)

This commit is contained in:
Dan Ruelas-Petrisko 2025-11-20 03:38:46 -08:00 committed by GitHub
parent 7edf6d4749
commit a4e901135b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 98 additions and 49 deletions

View File

@ -95,6 +95,8 @@ void LinkCellsGraph::loopsMessageCb(V3GraphVertex* vertexp, V3EdgeFuncP edgeFunc
struct LinkCellsState final {
// Set of possible top module names from command line and configs
std::unordered_set<std::string> m_topModuleNames;
// Default library lists to search
std::vector<std::string> m_liblist;
};
class LinkConfigsVisitor final : public VNVisitor {
@ -114,6 +116,7 @@ class LinkConfigsVisitor final : public VNVisitor {
}
// We don't do iterateChildren here because we want to skip designp
iterateAndNextNull(nodep->itemsp());
VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep);
}
void visit(AstConfigCell* nodep) override {
@ -121,7 +124,14 @@ class LinkConfigsVisitor final : public VNVisitor {
iterateChildren(nodep);
}
void visit(AstConfigRule* nodep) override {
nodep->v3warn(E_UNSUPPORTED, "Unsupported: config rule");
if (!nodep->cellp()) {
for (AstNode* usep = nodep->usep(); usep;
usep = usep->nextp()) {
m_state.m_liblist.push_back(usep->name());
}
} else {
nodep->v3warn(E_UNSUPPORTED, "Unsupported: config cell rule");
}
iterateChildren(nodep);
}
void visit(AstConfigUse* nodep) override {
@ -197,11 +207,16 @@ class LinkCellsVisitor final : public VNVisitor {
}
AstNodeModule* findModuleSym(const string& modName, const string& libname) {
// Given module and library to start search in, resolve using config library choices
// TODO support IEEE config library search order
// First search local library
AstNodeModule* foundp = findModuleLibSym(modName, libname);
// First search IEEE config library list
AstNodeModule* foundp;
for (auto const& l : m_state.m_liblist) {
foundp = findModuleLibSym(modName, l);
if (foundp) return foundp;
}
// Then search local library
foundp = findModuleLibSym(modName, libname);
if (foundp) return foundp;
// THen search global
// Then search global
foundp = findModuleLibSym(modName, "__GLOBAL");
return foundp;
}

View File

@ -0,0 +1,5 @@
*-* All Finished *-*
liba:m1 %m=t.u_1 %l=liba.m1
liba:m3 %m=t.u_1.u_13 %l=liba.m3
liba:m3 %m=t.u_2.u_23 %l=liba.m3
libb:m2 %m=t.u_2 %l=libb.m2

View File

@ -0,0 +1,23 @@
#!/usr/bin/env python3
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2025 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
import vltest_bootstrap
test.scenarios('simulator')
test.compile(verilator_flags2=[
'--binary', '--top cfg1', '--work liba', 't/t_config_work__liba.v', '--work libb', 't/t_config_work__libb.v'
])
test.execute()
# Sort so that 'initial' scheduling order is not relevant
test.files_identical_sorted(test.run_log_filename, test.golden_filename, is_logfile=True)
test.passes()

View File

@ -0,0 +1,18 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2025 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
module t;
// Test config allows selecting two different libraries for these instances
m1 u_1();
m2 u_2();
final $write("*-* All Finished *-*\n");
endmodule
config cfg1;
design t;
// resolve liba, then libb
default liblist liba libb ;
endconfig

View File

@ -1,17 +1,17 @@
%Error-UNSUPPORTED: t/t_config_hier.v:36:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_hier.v:36:3: Unsupported: config cell rule
36 | instance t.u_1 use work.cfg2 :config;
| ^~~~~~~~
... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest
%Error-UNSUPPORTED: t/t_config_hier.v:36:18: Unsupported: config use
36 | instance t.u_1 use work.cfg2 :config;
| ^~~
%Error-UNSUPPORTED: t/t_config_hier.v:41:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_hier.v:41:3: Unsupported: config cell rule
41 | instance t.u_1 use cfg2 :config;
| ^~~~~~~~
%Error-UNSUPPORTED: t/t_config_hier.v:41:18: Unsupported: config use
41 | instance t.u_1 use cfg2 :config;
| ^~~
%Error-UNSUPPORTED: t/t_config_hier.v:46:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_hier.v:46:3: Unsupported: config cell rule
46 | cell work.m1 use work.cfg2 :config;
| ^~~~
%Error-UNSUPPORTED: t/t_config_hier.v:46:8: Unsupported: config cell
@ -20,7 +20,7 @@
%Error-UNSUPPORTED: t/t_config_hier.v:46:16: Unsupported: config use
46 | cell work.m1 use work.cfg2 :config;
| ^~~
%Error-UNSUPPORTED: t/t_config_hier.v:51:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_hier.v:51:3: Unsupported: config cell rule
51 | cell m1 use cfg2 :config;
| ^~~~
%Error-UNSUPPORTED: t/t_config_hier.v:51:8: Unsupported: config cell
@ -29,7 +29,7 @@
%Error-UNSUPPORTED: t/t_config_hier.v:51:11: Unsupported: config use
51 | cell m1 use cfg2 :config;
| ^~~
%Error-UNSUPPORTED: t/t_config_hier.v:56:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_hier.v:56:3: Unsupported: config cell rule
56 | cell work.m1 use work.cfg2;
| ^~~~
%Error-UNSUPPORTED: t/t_config_hier.v:56:8: Unsupported: config cell
@ -38,7 +38,7 @@
%Error-UNSUPPORTED: t/t_config_hier.v:56:16: Unsupported: config use
56 | cell work.m1 use work.cfg2;
| ^~~
%Error-UNSUPPORTED: t/t_config_hier.v:62:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_hier.v:62:3: Unsupported: config cell rule
62 | instance u_bb use work.c2_bb;
| ^~~~~~~~
%Error-UNSUPPORTED: t/t_config_hier.v:62:17: Unsupported: config use

View File

@ -1,56 +1,50 @@
%Error-UNSUPPORTED: t/t_config_rules.v:28:3: Unsupported: config rule
28 | default liblist;
| ^~~~~~~
... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest
%Error-UNSUPPORTED: t/t_config_rules.v:29:3: Unsupported: config rule
29 | default liblist liba libb;
| ^~~~~~~
%Error-UNSUPPORTED: t/t_config_rules.v:33:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_rules.v:33:3: Unsupported: config cell rule
33 | instance t.m20 liblist;
| ^~~~~~~~
%Error-UNSUPPORTED: t/t_config_rules.v:34:3: Unsupported: config rule
... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest
%Error-UNSUPPORTED: t/t_config_rules.v:34:3: Unsupported: config cell rule
34 | instance t.m21 liblist libc;
| ^~~~~~~~
%Error-UNSUPPORTED: t/t_config_rules.v:35:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_rules.v:35:3: Unsupported: config cell rule
35 | instance t.m22 liblist libc libd;
| ^~~~~~~~
%Error-UNSUPPORTED: t/t_config_rules.v:36:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_rules.v:36:3: Unsupported: config cell rule
36 | instance t.m23 liblist libc libd;
| ^~~~~~~~
%Error-UNSUPPORTED: t/t_config_rules.v:37:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_rules.v:37:3: Unsupported: config cell rule
37 | instance t.m24 liblist libc libd;
| ^~~~~~~~
%Error-UNSUPPORTED: t/t_config_rules.v:40:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_rules.v:40:3: Unsupported: config cell rule
40 | instance t.m30 use cell_identifier;
| ^~~~~~~~
%Error-UNSUPPORTED: t/t_config_rules.v:40:18: Unsupported: config use
40 | instance t.m30 use cell_identifier;
| ^~~
%Error-UNSUPPORTED: t/t_config_rules.v:41:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_rules.v:41:3: Unsupported: config cell rule
41 | instance t.m31 use lib_id.cell_id;
| ^~~~~~~~
%Error-UNSUPPORTED: t/t_config_rules.v:41:18: Unsupported: config use
41 | instance t.m31 use lib_id.cell_id;
| ^~~
%Error-UNSUPPORTED: t/t_config_rules.v:42:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_rules.v:42:3: Unsupported: config cell rule
42 | instance t.m32 use #();
| ^~~~~~~~
%Error-UNSUPPORTED: t/t_config_rules.v:42:18: Unsupported: config use
42 | instance t.m32 use #();
| ^~~
%Error-UNSUPPORTED: t/t_config_rules.v:45:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_rules.v:45:3: Unsupported: config cell rule
45 | cell m40 liblist libc libd;
| ^~~~
%Error-UNSUPPORTED: t/t_config_rules.v:45:8: Unsupported: config cell
45 | cell m40 liblist libc libd;
| ^~~
%Error-UNSUPPORTED: t/t_config_rules.v:46:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_rules.v:46:3: Unsupported: config cell rule
46 | cell work.m41 liblist libc libd;
| ^~~~
%Error-UNSUPPORTED: t/t_config_rules.v:46:8: Unsupported: config cell
46 | cell work.m41 liblist libc libd;
| ^~~~
%Error-UNSUPPORTED: t/t_config_rules.v:47:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_rules.v:47:3: Unsupported: config cell rule
47 | cell m42 use m42alt;
| ^~~~
%Error-UNSUPPORTED: t/t_config_rules.v:47:8: Unsupported: config cell
@ -59,7 +53,7 @@
%Error-UNSUPPORTED: t/t_config_rules.v:47:12: Unsupported: config use
47 | cell m42 use m42alt;
| ^~~
%Error-UNSUPPORTED: t/t_config_rules.v:48:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_rules.v:48:3: Unsupported: config cell rule
48 | cell work.m43 use work.m43alt;
| ^~~~
%Error-UNSUPPORTED: t/t_config_rules.v:48:8: Unsupported: config cell

View File

@ -1,56 +1,50 @@
%Error-UNSUPPORTED: t/t_config_unsup.v:28:3: Unsupported: config rule
28 | default liblist;
| ^~~~~~~
... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest
%Error-UNSUPPORTED: t/t_config_unsup.v:29:3: Unsupported: config rule
29 | default liblist liba libb;
| ^~~~~~~
%Error-UNSUPPORTED: t/t_config_unsup.v:32:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_unsup.v:32:3: Unsupported: config cell rule
32 | instance t.m20 liblist;
| ^~~~~~~~
%Error-UNSUPPORTED: t/t_config_unsup.v:33:3: Unsupported: config rule
... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest
%Error-UNSUPPORTED: t/t_config_unsup.v:33:3: Unsupported: config cell rule
33 | instance t.m21 liblist libc;
| ^~~~~~~~
%Error-UNSUPPORTED: t/t_config_unsup.v:34:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_unsup.v:34:3: Unsupported: config cell rule
34 | instance t.m22 liblist libc libd;
| ^~~~~~~~
%Error-UNSUPPORTED: t/t_config_unsup.v:35:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_unsup.v:35:3: Unsupported: config cell rule
35 | instance t.m23 liblist libc libd;
| ^~~~~~~~
%Error-UNSUPPORTED: t/t_config_unsup.v:36:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_unsup.v:36:3: Unsupported: config cell rule
36 | instance t.m24 liblist libc libd;
| ^~~~~~~~
%Error-UNSUPPORTED: t/t_config_unsup.v:39:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_unsup.v:39:3: Unsupported: config cell rule
39 | instance t.m30 use cell_identifier;
| ^~~~~~~~
%Error-UNSUPPORTED: t/t_config_unsup.v:39:18: Unsupported: config use
39 | instance t.m30 use cell_identifier;
| ^~~
%Error-UNSUPPORTED: t/t_config_unsup.v:40:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_unsup.v:40:3: Unsupported: config cell rule
40 | instance t.m31 use lib_id.cell_id;
| ^~~~~~~~
%Error-UNSUPPORTED: t/t_config_unsup.v:40:18: Unsupported: config use
40 | instance t.m31 use lib_id.cell_id;
| ^~~
%Error-UNSUPPORTED: t/t_config_unsup.v:41:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_unsup.v:41:3: Unsupported: config cell rule
41 | instance t.m32 use #();
| ^~~~~~~~
%Error-UNSUPPORTED: t/t_config_unsup.v:41:18: Unsupported: config use
41 | instance t.m32 use #();
| ^~~
%Error-UNSUPPORTED: t/t_config_unsup.v:44:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_unsup.v:44:3: Unsupported: config cell rule
44 | cell m40 liblist libc libd;
| ^~~~
%Error-UNSUPPORTED: t/t_config_unsup.v:44:8: Unsupported: config cell
44 | cell m40 liblist libc libd;
| ^~~
%Error-UNSUPPORTED: t/t_config_unsup.v:45:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_unsup.v:45:3: Unsupported: config cell rule
45 | cell work.m41 liblist libc libd;
| ^~~~
%Error-UNSUPPORTED: t/t_config_unsup.v:45:8: Unsupported: config cell
45 | cell work.m41 liblist libc libd;
| ^~~~
%Error-UNSUPPORTED: t/t_config_unsup.v:46:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_unsup.v:46:3: Unsupported: config cell rule
46 | cell m42 use m42alt;
| ^~~~
%Error-UNSUPPORTED: t/t_config_unsup.v:46:8: Unsupported: config cell
@ -59,7 +53,7 @@
%Error-UNSUPPORTED: t/t_config_unsup.v:46:12: Unsupported: config use
46 | cell m42 use m42alt;
| ^~~
%Error-UNSUPPORTED: t/t_config_unsup.v:47:3: Unsupported: config rule
%Error-UNSUPPORTED: t/t_config_unsup.v:47:3: Unsupported: config cell rule
47 | cell work.m43 use work.m43alt;
| ^~~~
%Error-UNSUPPORTED: t/t_config_unsup.v:47:8: Unsupported: config cell