Reputation: 35
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.
Upvotes: 0
Views: 6552
Reputation: 19104
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:
dataout = {dataout,$sformatf("%b", ci.dout)};
dataout = $sformatf("%s%b", dataout, ci.dout);
$sformat(dataout, "%s%b", dataout, ci.dout);
Upvotes: 3