Created
November 7, 2018 15:32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef enum {VAL0, VAL1, VAL2, VAL3, VAL4} val_e; | |
typedef uvm_enum_wrapper#(val_e) uvm_vt; | |
module top(); | |
val_e vt; | |
string str; | |
initial begin | |
#5; | |
if ($value$plusargs("VAL_E=%0s", str)) begin | |
//`uvm_info("top", $sformatf("str get from command line:%s", str), UVM_LOW) | |
if(!(uvm_vt::from_name(str, vt) )) begin | |
`uvm_error("top", $sformatf("Wrong enum value passed from command line")) | |
end | |
else begin | |
`uvm_info("top", $sformatf("enum name:%s", vt.name()), UVM_LOW) | |
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_uvm_1p2.sv(17) @ 5: reporter [top] Wrong enum value passed from command line | |
//Simulation command: | |
// ./simv +VAL_E=VAL2 | |
//Output: | |
// UVM_INFO pass_enum_value_from_cmd_uvm_1p2.sv(14) @ 5: reporter [top] enum name:VAL2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment