-
Notifications
You must be signed in to change notification settings - Fork 627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid cast from type ‘std::__cxx11::basic_string<char>’ to type ‘QData’ {aka ‘long unsigned int’} #4921
Comments
@tudortimi you could be also interested in this |
It's something related to setting positive/negative in the sources. Can you please take all of the relevant SVUnit verilog code going into verilator (e.g. run with debug and can likely use obj_dir/*__inputs.vpp to start what to feed into Verilator, and simplify as much as possible to recreate this? |
P.S. Verilator is misinterpreting or not giving a lint error on code somewhere code like |
I've copypasted some code from svunit to create a reproducer. test.svmodule test;
class filter_for_single_pattern;
local static const string error_msg = "Expected the filter to be of the type '<test_case>.<test>[:<test_case>.<test>]'";
local const string testcase;
local const string test;
function new(string pattern);
int unsigned dot_idx = get_dot_idx(pattern);
testcase = pattern.substr(0, dot_idx-1);
disallow_partial_wildcards("testcase", testcase);
test = pattern.substr(dot_idx+1, pattern.len()-1);
disallow_partial_wildcards("test", test);
endfunction
local function int unsigned get_dot_idx(string pattern);
int unsigned first_dot_idx = get_first_dot_idx(pattern);
ensure_no_more_dots(pattern, first_dot_idx);
return first_dot_idx;
endfunction
local function int unsigned get_first_dot_idx(string pattern);
for (int i = 0; i < pattern.len(); i++)
if (pattern[i] == ".")
return i;
$fatal(0, error_msg);
endfunction
local function void ensure_no_more_dots(string pattern, int unsigned first_dot_idx);
for (int i = first_dot_idx+1; i < pattern.len(); i++)
if (pattern[i] == ".")
$fatal(0, error_msg);
endfunction
local function void disallow_partial_wildcards(string field_name, string field_value);
if (field_value != "*")
if (str_contains_char(field_value, "*"))
$fatal(0, $sformatf("Partial wildcards in %s names aren't currently supported", field_name));
endfunction
local static function bit str_contains_char(string s, string c);
if (c.len() != 1)
$fatal(0, "Expected a single character");
foreach (s[i])
if (s[i] == c[0])
return 1;
return 0;
endfunction
local function bit is_match(string filter_val, string val);
return (filter_val == "*") || (filter_val == val);
endfunction
endclass
class string_utils;
/* local */ typedef string array_of_string[];
static function array_of_string split_by_char(string c, string s);
string parts[$];
int last_char_position = -1;
if (c.len() != 1)
$fatal(0, "Internal error: expected a single character string");
for (int i = 0; i < s.len(); i++) begin
if (i == s.len()-1)
parts.push_back(s.substr(last_char_position+1, i));
if (string'(s[i]) == c) begin
parts.push_back(s.substr(last_char_position+1, i-1));
last_char_position = i;
end
end
return parts;
endfunction
endclass
class filter;
/* local */ typedef filter_for_single_pattern array_of_filters[];
/* local */ typedef string array_of_string[];
/* local */ typedef struct {
string positive;
string negative;
} filter_expression_parts;
local static filter single_instance;
local const filter_for_single_pattern positive_subfilters[];
local const filter_for_single_pattern negative_subfilters[];
static function filter get();
if (single_instance == null)
single_instance = new();
return single_instance;
endfunction
local function new();
string raw_filter = get_filter_value_from_run_script();
filter_expression_parts parts = get_filter_expression_parts(raw_filter);
positive_subfilters = get_subfilters(parts.positive);
if (parts.negative != "")
negative_subfilters = get_subfilters(parts.negative);
endfunction
local function string get_filter_value_from_run_script();
string result;
if (!$value$plusargs("SVUNIT_FILTER=%s", result))
result = "*";
return result;
endfunction
local function filter_expression_parts get_filter_expression_parts(string raw_filter);
string parts[];
if (raw_filter[0] == "-")
raw_filter = { "*", raw_filter };
parts = string_utils::split_by_char("-", raw_filter);
if (parts.size() > 2)
$fatal(0, "Expected at most a single '-' character.");
if (parts.size() == 1)
return '{ parts[0], "" };
return '{ parts[0], parts[1] };
endfunction
local function array_of_filters get_subfilters(string raw_filter);
filter_for_single_pattern result[$];
string patterns[];
if (raw_filter == "*") begin
filter_for_single_pattern filter_that_always_matches = new("*.*");
return '{ filter_that_always_matches };
end
patterns = string_utils::split_by_char(":", raw_filter);
foreach (patterns[i])
result.push_back(get_subfilter_from_non_trivial_expr(patterns[i]));
return result;
endfunction
local function filter_for_single_pattern get_subfilter_from_non_trivial_expr(string pattern);
filter_for_single_pattern result;
result = new(pattern);
return result;
endfunction
endclass
endmodule How I run it: verilator --binary test.sv && ./obj_dir/Vtest Using this I get the same error. It is located within |
Hi! I'm getting strange error when I'm trying to compile SVUnit:
Could you please help figuring out what could be a root cause of this?
I've reported reproducer to SVUnit issues, but below are the main things to consider:
Vtestrunner_svunit_pkg__03a__03afilter__Vclpkg__DepSet_h2ac5c5c3__0.cpp
Verilator version: Verilator 5.020 2024-01-01 rev v5.020
However, I've tried more versions:
OS: Ubuntu 22.04.4 LTS
The text was updated successfully, but these errors were encountered: