SPOILER ALERT: I figured this one out, but since I'd already typed up most of the question, here it is anyhow posted to the public domain. Comments welcome.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
Who can tell me how to pass a hex value into Systemverilog using uvm_cmdline_processor?
My current code is shown below as well as the command line option that is supplied.
code snippet:
bit [31:0] stimulus_xyz_min = 32'h12121212; // *** setting default here works fine
`uvm_info(get_type_name(), $psprintf("1st TEST-SETTINGS. xyz_min=%8h",stimulus_xyz_min), UVM_LOW)
if (cmdline_proc.get_arg_values(.match("+xyz_min="), .values(arg_values))) begin
stimulus_xyz_min = arg_values[$];
end
`uvm_info(get_type_name(), $psprintf("2nd TEST-SETTINGS. xyz_min=%8h",stimulus_xyz_min), UVM_LOW)
command line option: //** this value passed in from cmdline is not properly recognized
+xyz_min=09090909
The edited (for clarity) output is here (where you can see that the above +xyz_min did not 'take'):
1st TEST-SETTINGS. xyz_min=12121212
2nd TEST-SETTINGS. xyz_min=30393039
More +options/results data points listed here:
+xyz_min=09090909
2nd TEST-SETTINGS. xyz_min=30393039
+xyz_min=00000000
2nd TEST-SETTINGS. xyz_min=30303030
+xyz_min=00000001
2nd TEST-SETTINGS. xyz_min=30303031
+xyz_min=00000002
2nd TEST-SETTINGS. xyz_min=30303032
+xyz_min=00000020
2nd TEST-SETTINGS. xyz_min=30303230
Woo-hoo. I looked at some other code I was using, which used
stimulus_lkj = arg_values[$].atoi();
and then in the sv spec found atohex.
Using the following worked (emphasis on .atohex()).
`uvm_info(get_type_name(), $psprintf("1st TEST-SETTINGS. xyz_min=%8h",stimulus_xyz_min), UVM_LOW)
if (cmdline_proc.get_arg_values(.match("+xyz_min="), .values(arg_values))) begin
stimulus_xyz_min = arg_values[$].atohex();
end
`uvm_info(get_type_name(), $psprintf("2nd TEST-SETTINGS. xyz_min=%8h",stimulus_xyz_min), UVM_LOW)
+xyz_min=1ACECAFE
2nd TEST-SETTINGS. xyz_min=1acecafe
Even thoe I initially thought I was seeing the ASCII values, I mistakenly looked at an ASCII table of decimal-to-char, instead of hex-to-char, which further confused me.
I'd even tried this (as a wild hope that cmdline_processor would recognize it):
+xyz_min=0x12121212
+xyz_min=32'h12121212