title: How to zero-extend a number if it is valid, or X-extend it otherwise?
body: <p>I have a 16-bit number which might be <code>x</code> (i.e. unknown).<br>
  I would like to zero-extend the number to 32 bits, but if the MSB is <code>x</code>, then I would like it to be <code>x</code>-extended instead of zero-extended. (This helps with my simulation.)</p>
  
  <p>How can I do this?</p>