Reading enum from a file

Hi,

I am trying to read a enum from a file, but i dont see that is being driven from Sequence to driver and in the print statements. The example has read.txt which has 2 enum’s and reading it from seq_a. Appreciate the help.

Enum_from_file

In reply to rag123:

You cannot convert a string to an enum label directly. Fortunately the UVM has a utility helper class uvm_enum_wrapper that you can use.

string instc_str;
...
count_items = $fscanf(file_handle,"%s",instc_str);
if (count_items && !uvm_enum_wrapper#(inst_e)::from_name(instc_str,instc) )
      `uvm_error("bad_enum",instc_str)

A couple of other notes about your example:

  • You should
    `include “uvm_macros.svh”
    , not
    `uvm_pkg.sv
    . Most tools already compile the UVM package for you (and EDAPlayground takes advantage of that)—you are compiling it as an extra step.

`uvm_sequence_utils is deprecated. Use
`uvm_object_utils
instead

In reply to dave_59:

Thanks Dave :)