f



Cast string to ASCII in vector?

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
0
unfrostedpoptart
6/22/2016 10:33:53 PM
comp.lang.verilog 3837 articles. 2 followers. Post Follow

1 Replies
158 Views

Similar Articles

[PageSpeed] 6

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

0
gtwrek
6/22/2016 10:44:52 PM
Reply: