Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose ExprEval::size to Python #1006

Merged
merged 3 commits into from
Aug 31, 2023

Conversation

Thomasb81
Copy link
Contributor

Following PR is a tentative to answer to #998.

Method ExprEval::size has been added. But no test demonstrating it works :

The method has several argument with usage not obvious to guess

  uint64_t size(
      const any* object, bool& invalidValue, const any* inst, const any* pexpr,
      bool full /* false: use only last range size, true: use all ranges */,
      bool muteError = false);

@Thomasb81
Copy link
Contributor Author

test script used at my end on

typedef struct { bit [7:0] opcode; bit [23:0] addr; } IR;

module test();

  IR a_var;

endmodule
import uhdm

vpiObj_typedef_list = []


s = uhdm.Serializer()
data = s.Restore('slpp_all/surelog.uhdm')

typedef_iterator = uhdm.vpi_iterate(uhdm.vpiTypedef,data[0])
while(True):
    vpiObj_typedef = uhdm.vpi_scan(typedef_iterator)
    if vpiObj_typedef is None:
        break
    vpiObj_typedef_list.append(vpiObj_typedef)
    print(uhdm.vpi_get_str(uhdm.vpiName,vpiObj_typedef))

exprEval = uhdm.ExprEval()
data,invalidValue = exprEval.size(
        vpiObj_typedef_list[-1],
        invalidValue=invalidValue,
        inst=None,
        pexpr=None,
        full=False,
        muteError=False
)
print(data,invalidValue)

It print
32 True

@alaindargelas
Copy link
Collaborator

@Thomasb81, Awesome!
LGTM, please convert to full PR.

@alaindargelas alaindargelas marked this pull request as ready for review August 31, 2023 04:54
@alaindargelas alaindargelas merged commit 5be4444 into chipsalliance:master Aug 31, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants