M
mrfirmware
Guest
Is there a better way to extract a range of chars from a SystemVerilog
string object? I have a string that has a 3 char offset and an 8 char
value packed together like this:
string line = "124DEADBEEF"; // all values in hex
I'd like to split the string into two unsigned integers in the spirit
of this:
int unsigned offset = line[0..2];
int unsigned value = line[3:11];
However, I've only had success with a brute force for-loop like this:
for (int chr = 0; chr < 3; ++chr) begin : get_offset
offset = { offset, line[chr] };
end
for (int chr = 3; chr < 11; ++chr) begin : get_value
value = { value, line[chr] };
end
Thanks,
- Mark
string object? I have a string that has a 3 char offset and an 8 char
value packed together like this:
string line = "124DEADBEEF"; // all values in hex
I'd like to split the string into two unsigned integers in the spirit
of this:
int unsigned offset = line[0..2];
int unsigned value = line[3:11];
However, I've only had success with a brute force for-loop like this:
for (int chr = 0; chr < 3; ++chr) begin : get_offset
offset = { offset, line[chr] };
end
for (int chr = 3; chr < 11; ++chr) begin : get_value
value = { value, line[chr] };
end
Thanks,
- Mark