I am trying to write a function that takes as input a logic[:] value of arbitrary length to a string. But I am unable to find a correct way of implementing it.
I have tried the following approach:
function string bin_to_string (input logic _bin_ [] );
automatic string _str_;
_str_ = "";
for(int i=0; i< size; i++) begin
automatic string tmpstr;
tmpstr.bintoa(_bin_[i]);
_str_ = {_str_, tmpstr };
end
return _str_;
endfunction : bin_to_string
Which raises the following error:
Arg. 'bin' of 'bin_to_string': Cannot assign a packed type 'reg[3:0]' to an unpacked type 'reg $[]'.
Is such a thing i.e., creating a generic cast function for arbitrary length registers possible?
Thanks in advance