fix size of empty strings to be one byte

This commit is contained in:
Zachary Snow 2021-05-30 22:07:51 -04:00
parent a293002ad7
commit 0aa59165a1
3 changed files with 9 additions and 1 deletions

View File

@ -225,7 +225,7 @@ typeof (String str) =
return $ IntegerVector TBit Unspecified [r]
where
r = (RawNum $ len - 1, RawNum 0)
len = if null str then 1 else 8 * unescapedLength str
len = if null str then 8 else 8 * unescapedLength str
typeof other = lookupTypeOf other
-- length of a string literal in characters

View File

@ -34,6 +34,10 @@ module top;
$display($size(Ram[0]));
$display($bits(foo));
$display("bits %0d", $bits("AB"));
$display("bits %0d", $bits("A"));
$display("bits %0d", $bits(""));
$display("args %b", $size(RamPair, 1));
$display("args %b", $size(RamPair, 1'b1));
$display("args %b", $size(RamPair, '1));

View File

@ -31,6 +31,10 @@ module top;
$display(16);
$display(3);
$display("bits %0d", $bits("AB"));
$display("bits %0d", $bits("A"));
$display("bits %0d", $bits(""));
$display("args %b", 2);
$display("args %b", 2);
$display("args %b", 2);