title: SystemVerilog/Verilog: Is there a way to find the integer bit offset of a field of a packed struct?
body: <p>I was wondering if there is a standard function in verilog or systemverilog that will return the bit offset of a certain field within a packed struct. For instance, see use of hypothetical function $find_field_offset below:</p>
  
  <pre><code>typedef struct packed
  {
      logic [31:0] field_1,
      logic [15:0] field_2,
      logic [63:0] field_3
  } struct_type;
  
  struct_type the_struct;
  int field_1_offset;
  assign field_1_offset = $find_field_offset(the_struct.field_1);
  </code></pre>
  
  <p>Thanks!</p>