Closed mingzheTerapines closed 2 weeks ago
This is a good example of the obstacle of supporting Struct type in circt-verilog
via slang frontend!
BTW, the book of SV, has extra definition of structure. It says packed structure consists of bit fields, which are packed together in memory without gaps. Reffering IEEE Standard for SystemVerilog—Unified Hardware Design,Specification, and VerificationLanguage7.2.1 Packed structures
A packed structure is a mechanism for subdividing a vector into subfields, which can be conveniently accessed as members. Consequently, a packed structure consists of bit fields, which are packed together in memory without gaps. An unpacked structure has an implementation-dependent packing, normally matching the C compiler. A packed structure differs from an unpacked structure in that, when a packed structure appears as a primary, it shall be treated as a single vector.
"type": "struct packed signed{int a;int b;}Foo.int64", may be not proper. Variables a and b need to be delcared here before using them.
I'm not sure what the problem here is. Both variables have the same type and access the same member so of course the symbol has the same address. It appears from your example that clang-18 also does the same thing.
I also don't understand your followup message. I'm aware of what the LRM says. Do you have a question related to how packed structs work?
"member": "2199025176592 b",
Thanks for your reply, what I mean is 2199025176592 in "member": "2199025176592 b", not the "b", which may means the addreess of member. In clang -MemberExpr 0x569514aa7e08 <col:9, col:12> 'int' lvalue .a 0x569514aa7a48 -MemberExpr 0x569514aa7f50 <col:9, col:12> 'int' lvalue .a 0x569514aa7a48 0x569514aa7e08 and 0x569514aa7f50 are different which can help me differ two different struct variable's same name member.
I believe you are highlighting the address of the expression itself. The address at the end of the line is the address of the member being accessed, which is the same in both cases just like it is in slang. The slang json doesn't print addresses for the expression objects because they aren't useful in cross referencing anything.
If you want to know which variable is being accessed you need to look deeper in the expression tree. In clang this is:
`-DeclRefExpr 0x569514aa7de8 <col:9> 'Int64' lvalue Var 0x569514aa7c40 'ii' 'Int64'
and in slang:
"value": {
"kind": "NamedValue",
"type": "struct packed signed{int a;int b;}Foo.int64",
"symbol": "2199025174064 ii"
}
Thanks a lot, I will look deeper to differ.
Dear developer, I have some trouble with mapping different Ops with different symbol in CIRCT Project because different variables have the same symbol. I'll appreciate it if you can solve this problem. -slang version 6.0.49+a3721010. test.v is like this
test.json will be like this
As you can see, the symbol of different struct value's symbol which should be different but found the same. Here is an example what clang-18 do. test.c
clang-18 -Xclang -ast-dump test.c