From 17cfc969ddfe800525dbeab272b53949846e28b8 Mon Sep 17 00:00:00 2001 From: Muthu Annamalai Date: Sun, 7 May 2023 06:19:02 +0000 Subject: [PATCH 1/2] [YOSYS] Issue #3498 - Fix Synopsys style unquoted Liberty style function body parsing with unittest --- passes/techmap/libparse.cc | 11 +++++++---- tests/liberty/issue3498_bad.lib | 8 ++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100755 tests/liberty/issue3498_bad.lib diff --git a/passes/techmap/libparse.cc b/passes/techmap/libparse.cc index 3d0ebaea3..1a1726f94 100644 --- a/passes/techmap/libparse.cc +++ b/passes/techmap/libparse.cc @@ -236,10 +236,13 @@ LibertyAst *LibertyParser::parse() if (tok == ':' && ast->value.empty()) { tok = lexer(ast->value); - if (tok != 'v') - error(); - tok = lexer(str); - while (tok == '+' || tok == '-' || tok == '*' || tok == '/') { + if (tok != 'v') { + //Synopsys-style unquoted identifiers issue#3498 + } else { + //Liberty canonical identifier including double quotes + tok = lexer(str); + } + while (tok == '+' || tok == '-' || tok == '*' || tok == '/' || tok == '!') { ast->value += tok; tok = lexer(str); if (tok != 'v') diff --git a/tests/liberty/issue3498_bad.lib b/tests/liberty/issue3498_bad.lib new file mode 100755 index 000000000..f85c4e19b --- /dev/null +++ b/tests/liberty/issue3498_bad.lib @@ -0,0 +1,8 @@ +library(fake) { + cell(bugbad) { + bundle(X) { + members(x1, x2); + power_down_function : !a+b ; + } + } +} From c855502bd5bf7d006f2758679a0f2491f90b6f90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Muthiah=20Annamalai=20=28=E0=AE=AE=E0=AF=81=E0=AE=A4?= =?UTF-8?q?=E0=AF=8D=E0=AE=A4=E0=AF=81=20=E0=AE=85=E0=AE=A3=E0=AF=8D?= =?UTF-8?q?=E0=AE=A3=E0=AE=BE=E0=AE=AE=E0=AE=B2=E0=AF=88=29?= Date: Tue, 9 May 2023 06:40:21 -0700 Subject: [PATCH 2/2] Update passes/techmap/libparse.cc Allow Liberty canonical identifier including double quotes in if-body and pass-through for Synopsys-style unquoted identifiers issue#3498 Co-authored-by: Aki <201479+lethalbit@users.noreply.github.com> --- passes/techmap/libparse.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/passes/techmap/libparse.cc b/passes/techmap/libparse.cc index 1a1726f94..664e99e24 100644 --- a/passes/techmap/libparse.cc +++ b/passes/techmap/libparse.cc @@ -236,12 +236,9 @@ LibertyAst *LibertyParser::parse() if (tok == ':' && ast->value.empty()) { tok = lexer(ast->value); - if (tok != 'v') { - //Synopsys-style unquoted identifiers issue#3498 - } else { - //Liberty canonical identifier including double quotes - tok = lexer(str); - } + if (tok == 'v') { + tok = lexer(str); + } while (tok == '+' || tok == '-' || tok == '*' || tok == '/' || tok == '!') { ast->value += tok; tok = lexer(str);