def csr_read(csr_val, csr_mask):
  """
  Performs a CSR read.

  Args:
    csr_val: A bitarray containing the current CSR value.
    csr_mask: A bitarray containing the CSR's mask.

  Returns:
    A bitarray of the logical AND of csr_val and csr_mask.
  """
  return csr_val & csr_mask