How to find port dimensions
From Verific Design Automation FAQ
Revision as of 13:42, 6 April 2017 by Hoa (Talk | contribs) (Created page with "'''Q: How do I get port dimensions?''' A port can have multiple (packed/unpacked) dimensions like "module test (input [1:0][2:3] in1 [4:5][6:7]);". Below is a code excerpt in...")
Q: How do I get port dimensions?
A port can have multiple (packed/unpacked) dimensions like "module test (input [1:0][2:3] in1 [4:5][6:7]);". Below is a code excerpt in C++:
Array *port_arr = vgModule->GetPorts(); VeriIdDef *port_id ; unsigned i; FOREACH_ARRAY_ITEM(port_arr, i, port_id) { if (!port_id) continue ; char* name = port_id->GetName(); unsigned j=0 ; VeriRange *dim ; while (dim = port_id->GetDimensionAt(j++)) { VeriExpression *left = dim->GetLeft() ; // Left range bound VeriExpression *right = dim->GetRight() ; // right range bound } }
For array (e.g. "module test (input [15:0] in1);"), it's sufficient to call GetDimensionAt(0) instead of the FOREACH loop as above.