title: In SystemVerilog, is it allowed to read a parameter from an interface
body: <p>I am a bit confused as to if it is legal, from a standards stand point, to read a parameter from an interface.</p>
  
  <p>Like so</p>
  
  <pre><code>interface foo_if #(parameter BAR=5)();
  ...
  logic [BAR-1:0] data;
  modport slave(input data, ...);
  endinterface
  
  module foobar(foo_if.slave s);
  ...
  logic [s.BAR-1:0] bar;
  logic [$bits(s.data)-1:0] m_data;
  ...
  endmodule
  </code></pre>
  
  <p>I have a problem where a major synthesis tool vendor can not even handle this. And they explicitly tell you in the help message that it is not allowed to use $bits() with a interface member.</p>
  
  <p>However a simulation tool from another vendor handles this perfectly as does another synthesis tool I have.</p>
  
  <p>However in <em>SystemVerilog for Design</em> by S. Sutherland et al. it is stated:</p>
  
  <blockquote>
    <p>Because the design hierarchy may not be yet fully resolved during
    elaboration, it is illegal to assign a parameter, specparam, or
    localparam constants a value that is derived from elsewhere in the
    design hierarchy</p>
  </blockquote>
  
  <p>However if I am not allowed to use parameters from interfaces, it really cripples the usefulness of interfaces.</p>
  
  <p>The <em>SystemVerilog 1800-2012 Standard</em> on the other hand states:</p>
  
  <blockquote>
    <p>25.10 Access to interface objects</p>
    
    <p>Access to objects declared in an interface shall be available by
    hierarchical name reference, regardless of whether the interface is
    also accessed through a port connection or through a virtual
    interface, and regardless of the existence of any declared modports in
    that interface. A modport may be used to restrict access to objects
    declared in an interface that are referenced through a port connection
    or virtual interface by explicitly listing the accessible objects in
    the modport. However, objects that are not permissible to be listed in
    a modport shall remain accessible.</p>
  </blockquote>