Last active
March 11, 2022 09:43
-
-
Save sagar5258/cd74fcaa3d9b0930cb7c03e5b53c4059 to your computer and use it in GitHub Desktop.
This file contains hidden or 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; | |
| val_e vt_q[$]; | |
| string str_q[$]; | |
| initial begin | |
| #5; | |
| if ($value$plusargs("VAL_E=%0s", str)) begin | |
| `uvm_info("top", $sformatf("str get from command line:%s", str), UVM_LOW) | |
| uvm_split_string(str, ",", str_q); | |
| foreach (str_q[i]) begin | |
| `uvm_info("top", $sformatf("str_q[%0d]:%s", i, str_q[i]), UVM_LOW) | |
| end | |
| foreach (str_q[i]) begin | |
| if(!(uvm_vt::from_name(str_q[i], 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) | |
| vt_q.push_back(vt); | |
| end | |
| end | |
| `uvm_info("top", $sformatf("Number of enum passed from command line:%0d", vt_q.size()), UVM_LOW) | |
| `uvm_info("top", $sformatf("enum queue:%p", vt_q), UVM_LOW) | |
| 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=VAL1,VAL4 | |
| //Output: | |
| // UVM_INFO pass_multi_enum_from_cmd_uvm1p2.sv(13) @ 5: reporter [top] str get from command line:VAL1,VAL4 | |
| // UVM_INFO pass_multi_enum_from_cmd_uvm1p2.sv(17) @ 5: reporter [top] str_q[0]:VAL1 | |
| // UVM_INFO pass_multi_enum_from_cmd_uvm1p2.sv(17) @ 5: reporter [top] str_q[1]:VAL4 | |
| // UVM_INFO pass_multi_enum_from_cmd_uvm1p2.sv(25) @ 5: reporter [top] enum name:VAL1 | |
| // UVM_INFO pass_multi_enum_from_cmd_uvm1p2.sv(25) @ 5: reporter [top] enum name:VAL4 | |
| // UVM_INFO pass_multi_enum_from_cmd_uvm1p2.sv(29) @ 5: reporter [top] Number of enum passed from command line:2 | |
| // UVM_INFO pass_multi_enum_from_cmd_uvm1p2.sv(30) @ 5: reporter [top] enum queue:'{VAL1, VAL4} | |
| //Simulation command: | |
| // ./simv +VAL_E=VAL1,VAL5 | |
| //Output: | |
| // UVM_INFO pass_multi_enum_from_cmd_uvm1p2.sv(13) @ 5: reporter [top] str get from command line:VAL1,VAL5 | |
| // UVM_INFO pass_multi_enum_from_cmd_uvm1p2.sv(17) @ 5: reporter [top] str_q[0]:VAL1 | |
| // UVM_INFO pass_multi_enum_from_cmd_uvm1p2.sv(17) @ 5: reporter [top] str_q[1]:VAL5 | |
| // UVM_INFO pass_multi_enum_from_cmd_uvm1p2.sv(25) @ 5: reporter [top] enum name:VAL1 | |
| // UVM_ERROR pass_multi_enum_from_cmd_uvm1p2.sv(22) @ 5: reporter [top] Wrong enum value passed from command line | |
| // UVM_INFO pass_multi_enum_from_cmd_uvm1p2.sv(29) @ 5: reporter [top] Number of enum passed from command line:1 | |
| // UVM_INFO pass_multi_enum_from_cmd_uvm1p2.sv(30) @ 5: reporter [top] enum queue:'{VAL1} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment