0
if(ci.busy) begin// writing
    **dataout** = {dataout,string'(**ci.dout**)};
    $sformat( request,"%b",req.dout );
    $fwrite(data, request);
end

here ci.dout is bit and dataout is string. This is the code I was using to convert bit to string using static casting. But the output of dataout at the end of test is 0. I would really appreciate help.

toolic
  • 57,801
  • 17
  • 75
  • 117
Raviteja
  • 35
  • 1
  • 6

1 Answers1

3

Casting with string'() will use ci.dout as the ASCII code of a string. For example, string'(8'h41) is "A", and string'(88'h48656C6C6F20576F726C64) is "Hello World"

Any of the following will work for you:

  1. dataout = {dataout,$sformatf("%b", ci.dout)};
  2. dataout = $sformatf("%s%b", dataout, ci.dout);
  3. $sformat(dataout, "%s%b", dataout, ci.dout);
Greg
  • 18,111
  • 5
  • 46
  • 68