In reply to __viking:
Hi,
A small workaround using static casting can be done to fulfill your requirement. Please find the below example. Please look at the way in which typedef enums are declared and how $value$plusargs and static casting is used. Instead of supplying string through the command line, I am supplying integer values. The command-line options can be like “+end_type=1 +data_type=2 +mode=0”. With this workaround, I am getting your expected output.
// Example compiled by Putta Satish
// Command line options can be as shown below.
// +end_type=1 +data_type=2 +mode=0
module top;
`include "uvm_macros.svh"
import uvm_pkg::*;
typedef enum { EOT=0, DELAY=1} end_type;
typedef enum { RANDOM=0, INCR=1, LOAD=2} data_type;
typedef enum { FAST=0, SLOW=1} mode;
class config_db extends uvm_object;
end_type e_t;
data_type d_t;
mode m_e;
function new(string name = "config_db");
super.new(name);
endfunction
endclass
class drv extends uvm_driver #(uvm_sequence_item);
config_db cfg_h;
function new(string name = "drv", uvm_component parent = null);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
if(!uvm_config_db#(config_db)::get(this, "", "STR", cfg_h))
`uvm_fatal(get_type_name,"getting failed");
endfunction
task run_phase(uvm_phase phase);
phase.raise_objection(this);
$display("end_type = %s", cfg_h.e_t);
$display("data_type = %s", cfg_h.d_t);
$display("mode = %s", cfg_h.m_e);
#1;
$display("Current simulation time is %t", $time);
phase.drop_objection(this);
endtask
endclass
config_db cfg_h_top;
int end_i, data_i, mode_i;
drv drv_h;
initial
begin
drv_h = new("drv_h");
if ($value$plusargs("end_type=%d", end_i))
$display("got the end_type value");
if ($value$plusargs("data_type=%d", data_i))
$display("got the data_type value");
if ($value$plusargs("mode=%d", mode_i))
$display("got the mode value");
cfg_h_top = new("cfg_h_top");
cfg_h_top.e_t = end_type'(end_i);
cfg_h_top.d_t = data_type'(data_i);
cfg_h_top.m_e = mode'(mode_i);
uvm_config_db#(config_db)::set(null, "", "STR", cfg_h_top);
run_test();
end
endmodule