A semiconductor device for detecting a distribution of physical quantities, the semiconductor device including (a) a matrix of unit elements, each of the unit elements including a charge generator that generates charges corresponding to incident electromagnetic wave and (b) a unit-signal generator that generates an analog unit signal including a reference component and a signal component, the semiconductor device comprising:
- a comparator that compares a signal corresponding to the reference component and a signal corresponding to the signal component with a reference signal for generating digital data of the signal component;
- an asynchronous counter that performs counting in a down-count mode or an up-count mode based on a counter clock, concurrently with the comparison in the comparator, the counter holding a count value at a time of completion of the comparison in the comparator;
- and
- a timing controller that switches mode of counting in the counter according to whether the comparator is performing comparison for the reference component or the signal component,
- wherein,
- the counter includes an initial-value setting processor that sets a count value immediately before switching of count mode as an initial value at a time of the switching of count mode before starting counting after the count mode is switched, and
- the timing controller controls the initial-value setting processor so that counting in a second processing iteration is started from a count value held in a first processing iteration.