Skip to content

Instantly share code, notes, and snippets.

@sagar5258
Last active November 7, 2018 13:58
Show Gist options
  • Save sagar5258/013b3d1416e50bba01d5453d5a53fe24 to your computer and use it in GitHub Desktop.
Save sagar5258/013b3d1416e50bba01d5453d5a53fe24 to your computer and use it in GitHub Desktop.
typedef enum {VAL0, VAL1, VAL2, VAL3, VAL4} val_e;
module top();
val_e vt;
string str;
bit match;
initial begin
#5;
if ($value$plusargs("VAL_E=%0s", str)) begin
vt = vt.first();
do begin
if (vt.name() == str) begin
`uvm_info("top", $sformatf("matching Value:%s", vt.name()), UVM_LOW)
match = 1;
break;
end
else begin
vt = vt.next();
end
end while (vt.first() != vt);
if (match == 0) begin
`uvm_error("top", $sformatf("Wrong enum value passed from command line"))
end
else begin
match = 0;
end
end
else begin
`uvm_info("top", $sformatf("enum value not passed from command line"), UVM_LOW)
end
end
endmodule : top
//Simulation command:
// ./simv +VAL_E=VAL_2
//Output:
// UVM_ERROR pass_enum_value_from_cmd_uvm1p1d.sv(24) @ 5: reporter [top] Wrong enum value passed from command line
//Simulation command:
// ./simv +VAL_E=VAL2
//Output:
// UVM_INFO pass_enum_value_from_cmd_uvm1p1d.sv(14) @ 5: reporter [top] matching Value:VAL2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment