Hello,
I am struggling with a compilation error about the following task which is meant to convert every character of a given string into their ASCII equivalent:
task StoH(input string str_in, output logic [4096] hex_out);
begin
static int i=0;
while(str_in[i]!="\0")
begin
CtoH(str_in[i],hbyte);
temp = ~(~hbyte<<(8*i));
hex_out|=8'hFF<<(8*i);
i++;
end
end
endtask
endtask
task CtoH(input string char_in, output logic [7:0] hex_out);
begin
case (char_in)
"A" : hex_out = 8'h41;
"B" : hex_out = 8'h42;
[...]
"Z" : hex_out = 8'h5A;
endcase
end
endtask
The error triggers when I call CtoH in StoH… any idea of what I am doing wrong?
Also, any idea on how to make hex_out a more ‘flexible’ size instead of a hardcoded one?
Many thanks in advance!