In quantum information processing, qudits (d-level systems) are an extension of qubits that could speed up certain computing tasks. We demonstrate the operation of a superconducting phase qudit with a number of levels d up to d = 5 and show how to manipulate and measure the qudit state, including simultaneous control of multiple transitions. We used the qudit to emulate the dynamics of single spins with principal quantum number s = 1/2, 1, and 3/2, allowing a measurement of Berry's phase and the even parity of integer spins (and odd parity of half-integer spins) under 2pi-rotation. This extension of the two-level qubit to a multilevel qudit holds promise for more-complex quantum computational architectures and for richer simulations of quantum mechanical systems.