title: Randomizing structure with typedefs
body: <p>I am trying to randomize a structure which has typedefs, but it is not getting randomized. How can I achieve that?</p>
  <pre><code>typedef enum bit[1:0]{A=0, B=1,E=2,F=3}dl_pkt_type;
  typedef enum bit[2:0]{G=4,H=5,C=6, D=7}tl_pkt_type;
    
    typedef struct {
      dl_pkt_type dl_pkt;
      tl_pkt_type tl_pkt;
    } pkt_struct;
      
  class packet;
  
   rand pkt_struct p;
   rand dl_pkt_type dl;
   rand tl_pkt_type tl;
    //pre randomization function
    function void pre_randomize();
      $display(&quot;Inside pre_randomize&quot;);
    endfunction
    
    //post randomization function
    function void post_randomize();
      $display(&quot;Inside post_randomize&quot;);
      $display(&quot;dl: %0s   tl: %0s&quot;,p.dl_pkt,p.tl_pkt);
      $display(&quot;dl: %0s   tl: %0s&quot;,dl,tl);
    endfunction
  endclass
  
  module rand_methods;
    initial begin
      packet pkt;
      pkt = new();
      pkt.randomize;
    end
  endmodule
  </code></pre>
  <p>This is the output that I am getting:</p>
  <pre><code>Inside pre_randomize
  Inside post_randomize
  p.dl_pkt: A   p.tl_pkt: 
  dl: B   tl: G
  </code></pre>
  <p>I am expecting <code>p.dl_pkt</code> and <code>p.tl_pkt</code> to be randomized.</p>