code: func ParseBit(s string, width int) (Bit, error) {
  	if len(s) == 0 {
  		return Bit{}, errors.Errorf("invalid empty string for parsing bit type")
  	}
  
  	if s[0] == 'b' || s[0] == 'B' {
  		// format is b'val' or B'val'
  		s = strings.Trim(s[1:], "'")
  	} else if strings.HasPrefix(s, "0b") {
  		s = s[2:]
  	} else {
  		// here means format is not b'val', B'val' or 0bval.
  		return Bit{}, errors.Errorf("invalid bit type format %s", s)
  	}
  
  	if width == UnspecifiedBitWidth {
  		width = (len(s) + 7) & ^7
  	}
  
  	if width == 0 {
  		width = MinBitWidth
  	}
  
  	if width < MinBitWidth || width > MaxBitWidth {
  		return Bit{}, errors.Errorf("invalid display width for bit type, must in [1, 64], but %d", width)
  	}
  
  	n, err := strconv.ParseUint(s, 2, 64)
  	if err != nil {
  		return Bit{}, errors.Trace(err)
  	}
  
  	if n > (uint64(1)<<uint64(width))-1 {
  		return Bit{}, errors.Errorf("bit %s is too long for width %d", s, width)
  	}
  
  	return Bit{Value: n, Width: width}, nil
  }
docs: // ParseBit parses bit string.
  // The string format can be b'val', B'val' or 0bval, val must be 0 or 1.
  // Width is the display width for bit representation. -1 means calculating
  // width dynamically, using following algorithm: (len("011101") + 7) & ^7,
  // e.g, if bit string is 0b01, the above will return 8 for its bit width.