chipsalliance / chipsalliance/Surelog

Duplicate variables in function

Open
#2,954 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
475
Forks
90
Avg merge
1h 39m
Merged PRs (30d)
37

Description

Input:
```
package riscv;
function string func();
automatic string str = "str";
return "";
endfunction
endpackage
```
Output:
```
\_package: riscv (riscv::), id:23 test.sv:1:1: , endln:6:11, parent:unnamed, parID:22
|vpiName:riscv
|vpiFullName:riscv::
|vpiDefName:riscv
|vpiTaskFunc:
\_function: (riscv::func), id:24, line:2:3, endln:5:14, parent:riscv::, parID:23
|vpiName:func
|vpiFullName:riscv::func
|vpiVariables:
\_string_var: (riscv::func::str), id:25, line:3:22, endln:3:25, parent:riscv::func, parID:24
|vpiName:str
|vpiFullName:riscv::func::str
|vpiAutomatic:1
|vpiVisibility:1
|vpiReturn:
\_string_var: , id:14, line:2:12, endln:2:18
|vpiStmt:
\_begin: (riscv::func), id:26, parent:riscv::func, parID:24
|vpiFullName:riscv::func
|vpiVariables:
\_string_var: (riscv::func::str), id:27, line:3:22, endln:3:25, parent:riscv::func, parID:26
|vpiName:str
|vpiFullName:riscv::func::str
|vpiAutomatic:1
|vpiStmt:
\_assign_stmt: , id:28, line:3:22, endln:3:33, parent:riscv::func, parID:26
|vpiRhs:
\_constant: , id:19, line:3:28, endln:3:33, parID:18
|vpiDecompile:str
|vpiSize:3
|STRING:str
|vpiConstType:6
|vpiLhs:
\_string_var: (riscv::func::str), id:29, line:3:22, endln:3:25, parID:28
|vpiName:str
|vpiFullName:riscv::func::str
|vpiAutomatic:1
|vpiStmt:
\_return_stmt: , id:30, line:4:5, endln:4:11, parent:riscv::func, parID:26
|vpiCondition:
\_constant: , id:21, line:4:12, endln:4:14, parID:20
|STRING:
|vpiConstType:6
|vpiInstance:
\_package: riscv (riscv::), id:23 test.sv:1:1: , endln:6:11, parent:unnamed, parID:22
```

Note the three instances of `string_var` variable `str` with ids 25, 27 and 29. Issue is not specific to `string` only.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the supplied SystemVerilog package and inspecting the generated VPI/UHDM output for the function variable. Trace why str appears as three string_var instances, then verify the output no longer duplicates the variable and that the same behavior is corrected for types beyond string.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.