The circuit 664a has a function of comparing the potential of an analog signal (imaging data) input from the wiring 623 with that of a reference potential signal (e.g., a ramp wave signal) input from the wiring 667 and outputting an H potential or an L potential. A clock signal from a wiring 668 and the H potential or the L potential output from the circuit 664a are input to the counter circuit 664b. The counter circuit 664b measures the length of a period in which the H potential or the L potential is input and outputs the measurement result to the latch circuit 664c as an N-bit digital signal. A set signal or a reset signal is input from a wiring 665 to the counter circuit 664b. The latch circuit 664c has a function of holding the digital signal. A set signal or a reset signal is input from a wiring 666 to the latch circuit 664c.
The column driver circuit 662 is also referred to as a column selection circuit, a horizontal driver circuit, or the like. The column driver circuit 662 generates a selection signal for selecting a column from which the imaging data held in the latch circuit 664c is to be read. The column driver circuit 662 can be formed using a shift register or the like. Columns are sequentially selected by the column driver circuit 662, and the imaging data output from the latch circuit 664c in the selected column is input to the output circuit 663 via a wiring 669. The wiring 669 can function as a horizontal transfer line.