def matches(self, *patterns):
        """Pattern matching.

        Matches against a set of patterns, recognizing the same grammar as :py:`with m.Case()`.
        The pattern syntax is described in the :ref:`language guide <lang-matchop>`.

        Each of the :py:`patterns` may be a :class:`str` or a :ref:`constant-castable object
        <lang-constcasting>`.

        Returns
        -------
        :class:`Value`, :py:`unsigned(1)`

        Raises
        ------
        :exc:`SyntaxError`
            If a pattern has invalid syntax.
        """
        matches = []
        for pattern in _normalize_patterns(patterns, self.shape()):
            if isinstance(pattern, str):
                mask    = int("0" + pattern.replace("0", "1").replace("-", "0"), 2)
                pattern = int("0" + pattern.replace("-", "0"), 2)
                matches.append((self & mask) == pattern)
            else:
                matches.append(self == pattern)
        if not matches:
            return Const(0)
        elif len(matches) == 1:
            return matches[0]
        else:
            return Cat(*matches).any()
Pattern matching.

        Matches against a set of patterns, recognizing the same grammar as :py:`with m.Case()`.
        The pattern syntax is described in the :ref:`language guide <lang-matchop>`.

        Each of the :py:`patterns` may be a :class:`str` or a :ref:`constant-castable object
        <lang-constcasting>`.

        Returns
        -------
        :class:`Value`, :py:`unsigned(1)`

        Raises
        ------
        :exc:`SyntaxError`
            If a pattern has invalid syntax.
        
amaranth/hdl/_ast.py