Enum value override from test

Hi all,
I want to modify the enum variable from test. pls help to resolve this issue.
I have a enum_pkg.sv file


typedef enum[3:0] { bike =4'h1, cycle =4'h2, car =4'h3,truck=4'h4}  vehicles;

class seq_item extends uvm_sequence_item;
  vehicles   vh;   // enum handle
endclass

class sequenc extends uvm_sequnence #(seq_item);
  
  task body();
    vehicles v ;  // enum handle
    v =cycle;    //assign enum variable
    seq_item  req  = seq_item::type_id::create("req");
    start_item(req);

    if(!(req.randomize() with  {  vh = =v ;}))
        `uvm_error("fail","cannot be randomize")
    finish_item(req);
  endtask
endclass

class test extends uvm_test;
  vehicles  vh;

  sequenc  s1 =sequenc::type_id::create("s1");
  task run_phase(uvm_phase phase);

     s1.v= bike;                    // throwing error : no filed named v
     s1.start(env.sequencer);
  endtask

In reply to komal_chatterjee:

It is unclear to me what do you mean with ‘overriding enum variable from test’?
It seems you want to randomize your seq_item to get a certain vehicle. Right?

I want to change the enum data type from test. How it will be done

In reply to komal_chatterjee:
Please use code tags making your code easier to read. I have added them for you. Also sequence is a reserved word, I changed it to sequenc.

There is no variable named seq—I think you meant req. And finally there is no need to redeclare req, it is already declared in uvm_sequence.

Thanks dave_59 for the correction.
Coming to the query how i will assign my enum datatype to a new variable from the test class.

Could you please correct me where i am going wrong in this question.

hi dave ,
the error is showing is like this :
ERROR: (vsim-3567)test.svh : NO field named ‘vh’ .

In reply to komal_chatterjee:
Please find a running example here:

You had 2 key problems:
(1) your typedef was incorrect;
(2) your data member in the seq_item was not intended for randomization. RThe rand key word was missing

Hi chr_sue,
Thanks for the solution