An vector expression may be explicitly coerced to a vector of a given length by applying the ``bin'' function. The expression
bin(n,val)
causes the vector ``val'' to be either shortened to length n, or padded with
zeros to length n. If ``val'' is an integer, is is first coerced to a
32 bit vector, and then truncated or padded.
Thus, for example
bin(3,17) = [0,0,1]
bin(4,17) = [1,0,0,1]
and
[0,1,1] + bin(4,17)
is equal to
[0,0,1,1]
+ [1,0,0,1]
= [1,1,0,0]
Note that coercing a negative integer to longer than 32 bits will not produce the intuitively correct result, since ``bin'' treats its argument as an unsigned number. The ``sbin'' operator is equivalent to ``bin'', except that it sign extends rather than zero extending. Thus, for example ``sbin(64,-1)'' is a string of 64 ones.