Cast string to ASCII in vector?

U

unfrostedpoptart

Guest
I'm stumped on this problem that only exists because of SystemVerilog's and waveform viewers' issues dealing with dynamic object.
I just want to make a simple function that takes a string as an input and both does a print of it (actually UVM_INFO) and assigns it to a variable I can display in waveforms.

From what I've seen, waveform viewers won't display variables of type string since they're dynamically sized. So, I'm using the old, pre-SystemVerilog cheat of storing strings in bit vectors - e.g.

string. my_string
bit [32*8:1] pseudo_string;

However, I can't figure out how to get the real string into the pseudo-string. I tried $cast:

$cast(pseudo_string, my_string);

But I get a run-time error on this.

Ideas?

Thanks,

David
 
In article <9c512979-6529-4c42-ab36-6b03dec85160@googlegroups.com>,
unfrostedpoptart <david@therogoffs.com> wrote:
I'm stumped on this problem that only exists because of SystemVerilog's and waveform viewers' issues dealing with dynamic object.
I just want to make a simple function that takes a string as an input and both does a print of it (actually UVM_INFO) and
assigns it to a variable I can display in waveforms.

From what I've seen, waveform viewers won't display variables of type string since they're dynamically sized. So, I'm using
the old, pre-SystemVerilog cheat of storing strings in bit vectors - e.g.

string. my_string
bit [32*8:1] pseudo_string;

However, I can't figure out how to get the real string into the pseudo-string. I tried $cast:

$cast is just for classes isn't it?

In any event I think you want a type cast:
typedef bit [32*8:1] my_string_t;

string my_string;
my_string_t pseudo_string;

pseudo_string = my_string_t'( my_string );

Untested. I *think* this should work correctly as long as the my_string is the correct length.
(No promises if it's not the exact length).

Regards,

Mark
 

Welcome to EDABoard.com

Sponsor

Back
Top