Patent Publication Number: US-11664786-B2

Title: Hysteresis comparator, semiconductor device, and power storage device

Description:
TECHNICAL FIELD 
     One embodiment of the present invention relates to a hysteresis comparator, a semiconductor device, and a power storage device. 
     Note that one embodiment of the present invention is not limited to the above technical field. The technical field of the invention disclosed in this specification and the like relates to an object, a method, or a manufacturing method. Alternatively, one embodiment of the present invention relates to a process, a machine, manufacture, or a composition of matter. Therefore, specific examples of the technical field of one embodiment of the present invention disclosed in this specification include a semiconductor device, a display device, a liquid crystal display device, a light-emitting device, a power storage device, an imaging device, a memory device, a signal processing device, a processor, an electronic device, a system, a driving method thereof, a manufacturing method thereof, and a testing method thereof. 
     BACKGROUND ART 
     In general, in secondary batteries provided in electronic devices, such as an electric vehicle and a laptop personal computer, deterioration phenomena, such as a reduction in capacitance and an increase in internal resistance, occur due to repetition of charge and discharge. In addition, an initial failure of a battery, rough handling of a battery, and the like might cause unanticipated accidents, such as ignition of a battery. 
     In recent years, a circuit or a protection circuit for inspecting and/or monitoring the battery has been provided in many cases in terms of safety. Patent Document 1 discloses an invention of a battery pack provided with a circuit in which temperature protection of a battery is performed with high accuracy and appropriate charge control is performed. 
     REFERENCE 
     Patent Document 
     [Patent Document 1] Japanese Published Patent Application No. 2009-152129 
     SUMMARY OF THE INVENTION 
     Problems to be Solved by the Invention 
     For example, the protection circuit includes a hysteresis comparator in some cases. In the case where the hysteresis comparator is driven, in addition to a power supply voltage, reference potentials of a low-level threshold voltage and a high-level threshold voltage are needed. Since one or more of power supply voltages need to be supplied to the protection circuit, a plurality of voltage generation circuits is provided inside the protection circuit or in the periphery of the protection circuit in some cases. 
     An object of one embodiment of the present invention is to provide a novel hysteresis comparator. Another object of one embodiment of the present invention is to provide a hysteresis comparator with reduced power consumption. Another object of one embodiment of the present invention is to provide a novel semiconductor device including the hysteresis comparator. Another object of one embodiment of the present invention is to provide a power storage device including the semiconductor device. 
     Note that the objects of one embodiment of the present invention are not limited to the objects listed above. The objects listed above do not preclude the existence of other objects. Note that the other objects are objects that are not described in this section and will be described below. The objects that are not described in this section will be derived from the descriptions of the specification, the drawings, and the like and can be extracted from these descriptions by those skilled in the art. Note that one embodiment of the present invention is to solve at least one of the objects listed above and the other objects. Note that one embodiment of the present invention does not necessarily solve all the objects listed above and the other objects. 
     Means for Solving the Problems 
     (1) 
     One embodiment of the present invention is a hysteresis comparator including a comparator, a switch, a first capacitor, a second capacitor, and a logic circuit. A first terminal of the switch is electrically connected to one of a pair of conductive regions of the first capacitor, one of a pair of conductive regions of the second capacitor, and a first input terminal of the comparator. An output terminal of the comparator is electrically connected to an input terminal of the logic circuit. An output terminal of the logic circuit is electrically connected to the other of the pair of conductive regions of the second capacitor. The logic circuit has a function of generating an inverted signal of a signal input to the input terminal of the logic circuit and outputting the inverted signal to the output terminal of the logic circuit. 
     (2) 
     One embodiment of the present invention is the hysteresis comparator described in (1), in which the logic circuit includes an inverter circuit, the input terminal of the logic circuit is electrically connected to an input terminal of the inverter circuit, and the output terminal of the logic circuit is electrically connected to an output terminal of the inverter circuit. 
     (3) 
     One embodiment of the present invention is the hysteresis comparator described in (1), in which the logic circuit includes a NAND circuit, the input terminal of the logic circuit is electrically connected to a first input terminal of the NAND circuit, and the output terminal of the logic circuit is electrically connected to an output terminal of the NAND circuit. 
     (4) 
     One embodiment of the present invention is the hysteresis comparator described in (1), in which the logic circuit includes a NOR circuit, the input terminal of the logic circuit is electrically connected to a first input terminal of the NOR circuit, and the output terminal of the logic circuit is electrically connected to an output terminal of the NOR circuit. 
     (5) 
     One embodiment of the present invention is the hysteresis comparator described in any one of (1) to (4), in which the switch includes a transistor and the transistor includes a metal oxide in a channel formation region. 
     (6) 
     One embodiment of the present invention is the hysteresis comparator described in any one of (1) to (5), in which the circuit has a function of switching an on state and an off state of the switch, a function of generating a reference potential to be input to a second terminal of the switch, and a function of generating an input voltage to be input to a second input terminal of the comparator. 
     (7) 
     One embodiment of the present invention is a power storage device including the semiconductor device described in (6) and a cell, in which when a potential of the positive electrode terminal of the cell and a potential of the negative terminal of the cell are input to the circuit, the circuit has a function of generating the reference potential and the input voltage in accordance with the potential of the positive electrode terminal and the potential of the negative electrode terminal. 
     Note that in this specification and the like, a semiconductor device refers to a device that utilizes semiconductor characteristics, and means a circuit including a semiconductor element (a transistor, a diode, a photodiode, and the like), a device including the circuit, and the like. The semiconductor device also means all devices that can function by utilizing semiconductor characteristics. For example, an integrated circuit, a chip including an integrated circuit, and an electronic component including a chip in a package are examples of the semiconductor device. Moreover, a memory device, a display device, a light-emitting device, a lighting device, an electronic device, and the like themselves might be semiconductor devices, or might include semiconductor devices. 
     In the case where there is a description “X and Y are connected” in this specification and the like, the case where X and Y are electrically connected, the case where X and Y are functionally connected, and the case where X and Y are directly connected are regarded as being disclosed in this specification and the like. Accordingly, without being limited to a predetermined connection relation, for example, a connection relation shown in drawings or texts, a connection relation other than one shown in drawings or texts is disclosed in the drawings or the texts. Each of X and Y denotes an object (e.g., a device, an element, a circuit, a wiring, an electrode, a terminal, a conductive film, or a layer). 
     For example, in the case where X and Y are electrically connected, one or more elements that allow electrical connection between X and Y (e.g., a switch, a transistor, a capacitor, an inductor, a resistor, a diode, a display device, a light-emitting device, and a load) can be connected between X and Y. Note that a switch has a function of being controlled to be turned on or off. That is, the switch has a function of being in a conduction state (on state) or a non-conduction state (off state) to determine whether a current flows or not. 
     For example, in the case where X and Y are functionally connected, at least one circuit that enables functional connection between X and Y (e.g., a logic circuit (an inverter, a NAND circuit, a NOR circuit, or the like); a signal converter circuit (a DA converter circuit, an AD converter circuit, a gamma correction circuit, or the like); a potential level converter circuit (a power supply circuit (a step-up circuit, a step-down circuit, or the like), a level shifter circuit for changing the potential level of a signal, or the like); a voltage source; a current source; a switching circuit; an amplifier circuit (a circuit that can increase signal amplitude, the amount of current, or the like, an operational amplifier, a differential amplifier circuit, a source follower circuit, a buffer circuit, or the like); a signal generation circuit; a memory circuit; or a control circuit) can be connected between X and Y. For example, even when another circuit is provided between X and Y, X and Y are regarded as being functionally connected when a signal output from X is transmitted to Y. 
     Note that an explicit description, X and Y are electrically connected, includes the case where X and Y are electrically connected (i.e., the case where X and Y are connected with another element or another circuit provided therebetween), the case where X and Y are functionally connected (i.e., the case where X and Y are functionally connected with another circuit provided therebetween), and the case where X and Y are directly connected (i.e., the case where X and Y are connected without another element or another circuit provided therebetween). That is, the explicit expression “X and Y are electrically connected” is the same as the explicit simple expression “X and Y are connected”. 
     It can be expressed as, for example, “X, Y, a source (or a first terminal or the like) of a transistor, and a drain (or a second terminal or the like) of the transistor are electrically connected to each other, and X, the source (or the first terminal or the like) of the transistor, the drain (or the second terminal or the like) of the transistor, and Y are electrically connected to each other in this order”. Alternatively, it can be expressed as “a source (or a first terminal or the like) of a transistor is electrically connected to X; a drain (or a second terminal or the like) of the transistor is electrically connected to Y; and X, the source (or the first terminal or the like) of the transistor, the drain (or the second terminal or the like) of the transistor, and Y are electrically connected to each other in this order”. Alternatively, it can be expressed as “X is electrically connected to Y through a source (or a first terminal or the like) and a drain (or a second terminal or the like) of a transistor, and X, the source (or the first terminal or the like) of the transistor, the drain (or the second terminal or the like) of the transistor, and Y are provided in this connection order”. When the connection order in a circuit configuration is defined by an expression similar to the above examples, a source (or a first terminal or the like) and a drain (or a second terminal or the like) of a transistor can be distinguished from each other to specify the technical scope. Note that these expressions are examples, and the expression is not limited to these expressions. Here, X and Y each denote an object (e.g., a device, an element, a circuit, a wiring, an electrode, a terminal, a conductive film, or a layer). 
     Even when independent components are electrically connected to each other in a circuit diagram, one component has functions of a plurality of components in some cases. For example, when part of a wiring also functions as an electrode, one conductive film has functions of both components: a function of the wiring and a function of the electrode. Thus, “electrical connection” in this specification includes in its category such a case where one conductive film has functions of a plurality of components. 
     In this specification and the like, a “resistor” can be, for example, a circuit element or a wiring having a resistance value. Therefore, in this specification and the like, a “resistor” sometimes includes a wiring having a resistance value, a transistor in which current flows between the source and the drain, a diode, and a coil. Thus, the term “resistor” can be replaced with the terms “resistance”, “load”, “a region having a resistance”, and the like; inversely, the terms “resistance”, “load”, and a “region having a resistance” can be replaced with the term “resistor” and the like. The resistance value can be, for example, preferably greater than or equal to 1 mΩ and less than or equal to 10Ω, further preferably greater than or equal to 5 mΩ and less than or equal to 5Ω, still further preferably greater than or equal to 10 mΩ and less than or equal to 1Ω. As another example, the resistance value may be greater than or equal to 1Ω and less than or equal to 1×10 9 Ω. 
     In this specification and the like, a “capacitor” is, for example, a circuit element having an electrostatic capacitance value, a region of a wiring having an electrostatic capacitance value, parasitic capacitance, or gate capacitance of a transistor. Therefore, in this specification and the like, a “capacitor” sometimes includes not only a circuit element that has a pair of electrodes and a dielectric between the electrodes, but also parasitic capacitance generated between wirings, gate capacitance generated between a gate and one of a source and a drain of a transistor, and the like. The terms “capacitor”, “parasitic capacitance”, “gate capacitance”, and the like can be replaced with the term “capacitance” and the like; inversely, the term “capacitance” can be replaced with the terms “capacitor”, “parasitic capacitance”, “gate capacitance”, and the like. The term “pair of electrodes” of “capacitor” can be replaced with “pair of conductors”, “pair of conductive regions”, “pair of regions”, and the like. Note that the electrostatic capacitance value can be greater than or equal to 0.05 fF and less than or equal to 10 pF, for example. Alternatively, the electrostatic capacitance value may be greater than or equal to 1 pF and less than or equal to 10 μF, for example. 
     In this specification and the like, a transistor includes three terminals called a gate, a source, and a drain. The gate functions as a control terminal for controlling the conduction state of the transistor. Two terminals functioning as the source and the drain are input/output terminals of the transistor. One of the two input/output terminals serves as the source and the other serves as the drain on the basis of the conductivity type (n-channel type or p-channel type) of the transistor and the levels of potentials applied to the three terminals of the transistor. Thus, the terms “source” and “drain” are interchangeable in this specification and the like. In this specification and the like, expressions “one of a source and a drain” (or a first electrode or a first terminal) and “the other of the source and the drain” (or a second electrode or a second terminal) are used in description of the connection relation of a transistor. Depending on the structure, a transistor may include a back gate in addition to the above three terminals. In that case, in this specification and the like, one of the gate and the back gate of the transistor may be referred to as a first gate and the other of the gate and the back gate of the transistor may be referred to as a second gate. Moreover, the terms “gate” and “back gate” can be replaced with each other in one transistor in some cases. In the case where a transistor includes three or more gates, the gates may be referred to as a first gate, a second gate, and a third gate, for example, in this specification and the like. 
     In this specification and the like, a node can be referred to as a terminal, a wiring, an electrode, a conductive layer, a conductor, an impurity region, or the like depending on the circuit configuration, the device structure, or the like. Furthermore, a terminal, a wiring, or the like can be referred to as a node. 
     In this specification and the like, “voltage” and “potential” can be replaced with each other as appropriate. The “voltage” refers to a potential difference from a reference potential, and when the reference potential is a ground potential, for example, the “voltage” can be expressed as the “potential”. The ground potential does not necessarily mean 0 V. Potentials are relative values, and the potential applied to a wiring or the like is sometimes changed depending on the reference potential. 
     In general, “current” is defined as a charge transfer (electrical conduction) accompanied by transfer of positively charged particles; for example, the description “electrical conduction of positively charged particles occurs” can be rephrased as “electrical conduction of negatively charged particles occurs in the opposite direction”. Therefore, unless otherwise specified, “current” in this specification and the like refers to a charge transfer (electrical conduction) accompanied by carrier movement. Examples of a carrier here include an electron, a hole, an anion, a cation, and a complex ion, and the type of carrier differs between current flow systems (e.g., a semiconductor, a metal, an electrolyte solution, and a vacuum). The direction of a current in a wiring or the like refers to the direction in which a positive carrier moves, and the amount of current is expressed as a positive value. In other words, the direction in which a negative carrier moves is opposite to the direction of a current, and the amount of current is expressed as a negative value. Thus, in the case where the polarity of a current (or the direction of a current) is not specified in this specification and the like, the description “current flows from element A to element B” can be rephrased as “current flows from element B to element A”, for example. The description “current is input to element A” can be rephrased as “current is output from element A”, for example. 
     Ordinal numbers such as “first”, “second”, and “third” in this specification and the like are used in order to avoid confusion among components. Thus, the terms do not limit the number of components. In addition, the terms do not limit the order of components. In this specification and the like, for example, a “first” component in one embodiment can be referred to as a “second” component in other embodiments or claims. Furthermore, in this specification and the like, for example, a “first” component in one embodiment can be omitted in other embodiments or claims. 
     In this specification and the like, terms for describing arrangement, such as “over” and “under”, are sometimes used for convenience to describe the positional relation between components with reference to drawings. The positional relation between components is changed as appropriate in accordance with a direction in which the components are described. Thus, terms for the description are not limited to terms used in the specification and the like, and the description can be made appropriately according to circumstances. For example, the expression “an insulator positioned over (on) a top surface of a conductor” can be replaced with the expression “an insulator positioned on a bottom surface of a conductor” when the direction of a drawing showing these components is rotated by 180°. 
     Furthermore, the term “over” or “under” does not necessarily mean that a component is placed directly on or directly under and in direct contact with another component. For example, the expression “electrode B over insulating layer A” does not necessarily mean that the electrode B is formed on and in direct contact with the insulating layer A, and does not exclude the case where another component is provided between the insulating layer A and the electrode B. 
     In this specification and the like, the terms “film”, “layer”, and the like can be interchanged with each other according to circumstances. For example, the term “conductive layer” can be changed into the term “conductive film” in some cases. Moreover, the term “insulating film” can be changed into the term “insulating layer” in some cases. Alternatively, the term “film”, “layer”, or the like is not used and can be interchanged with another term depending on the case or according to circumstances. For example, the term “conductive layer” or “conductive film” can be changed into the term “conductor” in some cases. Furthermore, for example, the term “insulating layer” or “insulating film” can be changed into the term “insulator” in some cases. 
     In this specification and the like, a term such as an “electrode”, a “wiring”, or a “terminal” does not limit the function of a component. For example, an “electrode” is used as part of a “wiring” in some cases, and vice versa. Furthermore, the term “electrode” or “wiring” can also mean the case where a plurality of “electrodes” or “wirings” are formed in an integrated manner. For example, a “terminal” is used as part of a “wiring” or an “electrode” in some cases, and vice versa. Furthermore, the term “terminal” can also mean the case where a plurality of “electrodes”, “wirings”, “terminals”, or the like are formed in an integrated manner. Therefore, for example, an “electrode” can be part of a “wiring” or a “terminal”, and a “terminal” can be part of a “wiring” or an “electrode”. Moreover, the terms “electrode”, “wiring”, and “terminal” are sometimes replaced with the term “region”, for example. 
     In this specification and the like, the terms “wiring”, “signal line”, “power supply line”, and the like can be interchanged with each other depending on the case or according to circumstances. For example, the term “wiring” can be changed into the term “signal line” in some cases. As another example, the term “wiring” can be changed into the term “power supply line” in some cases. Inversely, the term “signal line”, “power supply line”, or the like can be changed into the term “wiring” in some cases. The term “power supply line” or the like can be changed into the term “signal line” or the like in some cases. Inversely, the term “signal line” or the like can be changed into the term “power supply line” or the like in some cases. The term “potential” that is applied to a wiring can be changed into the term “signal” or the like depending on the case or according to circumstances. Inversely, the term “signal” or the like can be changed into the term “potential” in some cases. 
     In this specification and the like, an impurity in a semiconductor refers to an element other than a main component of a semiconductor layer, for example. For example, an element with a concentration of lower than 0.1 atomic % is an impurity. If a semiconductor contains an impurity, formation of the DOS (Density of States) in the semiconductor, decrease in the carrier mobility, or decrease in the crystallinity may occur, for example. In the case where the semiconductor is an oxide semiconductor, examples of an impurity that changes characteristics of the semiconductor include Group 1 elements, Group 2 elements, Group 13 elements, Group 14 elements, Group 15 elements, and transition metals other than the main components; specific examples are hydrogen (contained also in water), lithium, sodium, silicon, boron, phosphorus, carbon, and nitrogen. In the case of an oxide semiconductor, oxygen vacancies might be formed by entry of impurities such as hydrogen. Furthermore, when the semiconductor is a silicon layer, examples of an impurity that changes characteristics of the semiconductor include oxygen, Group 1 elements except hydrogen, Group 2 elements, Group 13 elements, and Group 15 elements. 
     In this specification and the like, a switch is in a conduction state (on state) or a non-conduction state (off state) to determine whether a current flows or not. Alternatively, a switch has a function of selecting and changing a current path. For example, an electrical switch or a mechanical switch can be used. That is, a switch can be any element capable of controlling a current, and is not limited to a certain element. 
     Examples of an electrical switch include a transistor (e.g., a bipolar transistor and a MOS transistor), a diode (e.g., a PN diode, a PIN diode, a Schottky diode, a MIM (Metal Insulator Metal) diode, a MIS (Metal Insulator Semiconductor) diode, and a diode-connected transistor), and a logic circuit in which such elements are combined. Note that in the case of using a transistor as a switch, a “conduction state” of the transistor refers to a state where a source electrode and a drain electrode of the transistor can be regarded as being electrically short-circuited. Furthermore, a “non-conduction state” of the transistor refers to a state where the source electrode and the drain electrode of the transistor can be regarded as being electrically disconnected. Note that in the case where a transistor operates just as a switch, there is no particular limitation on the polarity (conductivity type) of the transistor. 
     An example of a mechanical switch is a switch formed using a MEMS (micro electro mechanical system) technology, such as a digital micromirror device (DMD). Such a switch includes an electrode that can be moved mechanically, and operates by controlling conduction and non-conduction with movement of the electrode. 
     In this specification, “parallel” indicates a state where the angle formed between two straight lines is greater than or equal to −10° and less than or equal to 10°. Thus, the case where the angle is greater than or equal to −5° and less than or equal to 5° is also included. In addition, the term “approximately parallel” or “substantially parallel” indicates a state where two straight lines are placed at an angle greater than or equal to −30° and less than or equal to 30°. Moreover, “perpendicular” indicates a state where two straight lines are placed at an angle of greater than or equal to 80° and less than or equal to 100°. Thus, the case where the angle is greater than or equal to 85° and less than or equal to 95° is also included. Furthermore, “approximately perpendicular” or “substantially perpendicular” indicates a state where two straight lines are placed at an angle greater than or equal to 60° and less than or equal to 120°. 
     Effect of the Invention 
     According to one embodiment of the present invention, a novel hysteresis comparator can be provided. According to one embodiment of the present invention, a hysteresis comparator with reduced power consumption can be provided. According to one embodiment of the present invention, a semiconductor device including the hysteresis comparator can be provided. According to one embodiment of the present invention, a novel power storage device including the semiconductor device can be provided. 
     Note that the effects of one embodiment of the present invention are not limited to the effects listed above. The effects listed above do not preclude the existence of other effects. Note that the other effects are effects that are not described in this section and will be described below. The effects that are not described in this section will be derived from the descriptions of the specification, the drawings, and the like and can be extracted from these descriptions by those skilled in the art. Note that one embodiment of the present invention has at least one of the effects listed above and the other effects. Accordingly, depending on the case, one embodiment of the present invention does not have the effects listed above in some cases. 
    
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         FIG.  1    is a block diagram illustrating an example of a semiconductor device. 
         FIG.  2 A ,  FIG.  2 B ,  FIG.  2 C , and  FIG.  2 D  are circuit diagrams illustrating examples of hysteresis comparators. 
         FIG.  3    is a timing chart showing an operation example of a hysteresis comparator. 
         FIG.  4 A ,  FIG.  4 B ,  FIG.  4 C , and  FIG.  4 D  are circuit diagrams illustrating examples of hysteresis comparators. 
         FIG.  5    is a timing chart showing an operation example of a hysteresis comparator. 
         FIG.  6    is a timing chart showing an operation example of a hysteresis comparator. 
         FIG.  7    is a block diagram illustrating an example of a semiconductor device. 
         FIG.  8    is a schematic cross-sectional diagram illustrating a structure example of a semiconductor device. 
         FIG.  9    is a schematic cross-sectional diagram illustrating a structure example of a semiconductor device. 
         FIG.  10 A ,  FIG.  10 B , and  FIG.  10 C  are schematic cross-sectional diagrams illustrating a structure example of a transistor. 
         FIG.  11 A  and  FIG.  11 B  are schematic cross-sectional diagrams illustrating a structure example of a transistor. 
         FIG.  12    is a schematic cross-sectional diagram illustrating a structure example of a semiconductor device. 
         FIG.  13 A  and  FIG.  13 B  are schematic cross-sectional diagrams illustrating a structure example of a transistor. 
         FIG.  14    is a schematic cross-sectional diagram illustrating a structure example of a semiconductor device. 
         FIG.  15 A ,  FIG.  15 B , and  FIG.  15 C  are a top view and perspective views illustrating a structure example of a capacitor. 
         FIG.  16 A ,  FIG.  16 B , and  FIG.  16 C  are a top view and perspective views illustrating a structure example of a capacitor. 
         FIG.  17 A ,  FIG.  17 B ,  FIG.  17 C , and  FIG.  17 D  are perspective views illustrating examples of semiconductor wafers and examples of electronic components. 
         FIG.  18 A ,  FIG.  18 B ,  FIG.  18 C , and  FIG.  18 D  are perspective views illustrating examples of power storage devices. 
         FIG.  19 A ,  FIG.  19 B , and  FIG.  19 C  are perspective views illustrating an example of a power storage device. 
         FIG.  20 A ,  FIG.  20 B ,  FIG.  20 C ,  FIG.  20 D ,  FIG.  20 E ,  FIG.  20 F ,  FIG.  20 G ,  FIG.  20 H , and  FIG.  20 I  are perspective views illustrating examples of products. 
     
    
    
     MODE FOR CARRYING OUT THE INVENTION 
     In this specification and the like, a metal oxide is an oxide of metal in a broad sense. Metal oxides are classified into an oxide insulator, an oxide conductor (including a transparent oxide conductor), an oxide semiconductor (also simply referred to as an OS), and the like. For example, in the case where a metal oxide is used in an active layer of a transistor, the metal oxide is referred to as an oxide semiconductor in some cases. That is, when a metal oxide can form a channel formation region of a transistor that has at least one of an amplifying function, a rectifying function, and a switching function, the metal oxide can be referred to as a metal oxide semiconductor or shortly as an OS. Moreover, when an OS FET or an OS transistor is described, it can also be referred to as a transistor including a metal oxide or an oxide semiconductor. 
     Furthermore, in this specification and the like, a metal oxide containing nitrogen is also collectively referred to as a metal oxide in some cases. A metal oxide containing nitrogen may be referred to as a metal oxynitride. 
     In this specification and the like, one embodiment of the present invention can be constituted by appropriately combining a structure described in an embodiment with any of the structures described in the other embodiments. In addition, in the case where a plurality of structure examples are described in one embodiment, the structure examples can be combined as appropriate. 
     Note that a content (or part of the content) described in one embodiment can be applied to, combined with, or replaced with at least one of another content (or part of the content) in the embodiment and a content (or part of the content) described in one or a plurality of different embodiments. 
     Note that in each embodiment, a content described in the embodiment is a content described with reference to a variety of diagrams or a content described with text in the specification. 
     Note that by combining a diagram (or part thereof) described in one embodiment with at least one of another part of the diagram, a different diagram (or part thereof) described in the embodiment, and a diagram (or part thereof) described in one or a plurality of different embodiments, much more diagrams can be formed. 
     Embodiments described in this specification are described with reference to the drawings. Note that the embodiments can be implemented in many different modes, and it will be readily appreciated by those skilled in the art that modes and details can be changed in various ways without departing from the spirit and scope thereof. Therefore, the present invention should not be interpreted as being limited to the description in the embodiments. Note that in the structures of the invention in the embodiments, the same portions or portions having similar functions are denoted by the same reference numerals in different drawings, and repeated description thereof is omitted in some cases. In perspective views and the like, some components might not be illustrated for clarity of the drawings. 
     In this specification and the like, when a plurality of components are denoted by the same reference signs, and in particular need to be distinguished from each other, an identification numeral such as “_1”, “[n]”, or “[m,n]” is sometimes added to the reference signs. 
     In the drawings in this specification, the size, the layer thickness, or the region is exaggerated for clarity in some cases. Therefore, they are not limited to the illustrated scale. The drawings are schematic views showing ideal examples, and embodiments of the present invention are not limited to shapes or values shown in the drawings. For example, variation in signal, voltage, or current due to noise, variation in signal, voltage, or current due to difference in timing, or the like can be included. 
     Embodiment 1 
     Described in this embodiment is a semiconductor device which detects overcharge or overdischarge when it occurs in a battery and transmits a detection signal. Not only in a battery but also in an assembled battery in which a plurality of batteries (cells) are connected in series, the semiconductor device can similarly detect overcharge or overdischarge in each cell. 
     A semiconductor device illustrated in  FIG.  1    capable of detecting overcharge or overdischarge in a cell is described. 
     A semiconductor device  100  includes a plurality of circuits CNC and a plurality of hysteresis comparators HCMP. The semiconductor device  100  has a function of detecting overcharge or overdischarge in each of a plurality of cells CE included in an assembled battery BAT. 
     The plurality of cells CE in the assembled battery BAT are electrically connected in series. 
     The number of circuits CNC can be the same as the number of cells CE included in the assembled battery BAT, for example. The number of hysteresis comparators HCMP can be the same as the number of cells CE included in the assembled battery BAT, for example. 
     The circuit CNC includes an input terminal CI 1 , an input terminal CI 2 , an output terminal CO 1 , and an output terminal CO 2 , for example. The hysteresis comparator HCMP includes an input terminal IT, a reference potential input terminal RT, and an output terminal OT, for example. 
     In one of the plurality of cells CE, a positive electrode terminal of the cell CE is electrically connected to the input terminal CI 1  of the circuit CNC, a negative electrode terminal of the cell CE is electrically connected to the input terminal CI 2  of the circuit CNC. The output terminal CO 1  of the circuit CNC is electrically connected to the input terminal IT of the hysteresis comparator HCMP, and the output terminal CO 2  of the circuit CNC is electrically connected to the reference potential input terminal RT of the hysteresis comparator HCMP. 
     For example, the circuit CNC has a function of obtaining a voltage between a positive electrode and a negative electrode of the cell CE and converting the voltage to information (e.g., a voltage, a current, or a resistance value) in accordance with the voltage, a function of generating a voltage to be input to the reference potential input terminal RT of the hysteresis comparator HCMP, and a function of detecting overdischarge and overcharge in the cell CE on the basis of a potential output from the output terminal OT of the hysteresis comparator HCMP. Note that the details of the circuit CNC will be described in Embodiment 2. 
     The hysteresis comparator HCMP is a kind of comparators, and has a function of comparing a potential input to the input terminal IT with a reference potential input to the reference potential input terminal RT and outputting a potential in accordance with the comparison result from the output terminal OT. 
     In general, a comparator can output a high-level potential from an output terminal when a potential input to an input terminal is higher than a reference potential input to a reference potential input terminal, and can output a low-level potential from the output terminal when the potential input to the input terminal is lower than the reference potential input to the reference potential input terminal, for example. Depending on a circuit configuration of the comparator, the comparator can output a low-level potential from the output terminal when the potential input to an input terminal is higher than the reference potential input to the reference potential input terminal, and can output a high-level potential from the output terminal when the potential input to the input terminal is lower than the reference potential input to the reference potential input terminal, for example. 
     The hysteresis comparator includes, for example, two reference potential input terminals in some cases. In the case where a sufficiently low potential is increased as a potential input to the input terminal IT, a potential input to one of the reference potential input terminals is used as the reference potential, and in the case where a sufficiently high potential is decreased as the potential input to the input terminal IT, a potential input to the other of the reference potential input terminals is used as the reference potential. Note that the potential input to the one reference potential input terminal is preferably higher than the potential input to the other reference potential input terminal. 
     For detecting overcharge or overdischarge in a cell, a hysteresis comparator can be used, for example. 
     In the case where overcharge in a cell is detected by a hysteresis comparator and a state where the voltage of the cell is higher than a voltage V 1  is regarded as an overcharge state, the voltage V 1  is set as a high-level-side threshold voltage of the hysteresis comparator (refers to as a high-level reference potential in some cases) and a desired voltage V 2  is set as a low-level-side threshold voltage of the hysteresis comparator (refers to as a low-level reference potential in some cases). At this time, for example, when the voltage V 1  is 4.35 V, the voltage V 2  can be 4.0 V, and preferably 4.1 V. Here, when the voltage V 1  is 4.35 V, the voltage V 2  is 4.1 V, and overcharge voltage of the cell exceeds 4.35 V, the output potential of the hysteresis comparator is changed from the high-level potential to the low-level potential (or from the low-level potential to the high-level potential). The change in the output potential (hereinafter referred to as a detection signal in some cases) is detected by a control circuit separately provided or the like, whereby the cell can be detected as being in an overcharge state and charge to the cell can be stopped. After that, when the cell performs discharge and the voltage of the cell is lower than 4.1 V, the output potential of the hysteresis comparator is changed from the low-level potential to the high-level potential (or from the high-level potential to the low-level potential). When the voltage of the cell is lower than 4.1 V, the cell is not in the overcharge state and thus can be charged. That is, the control circuit separately provided or the like detects the change in the output potential, and thus can detect the state of the cell capable of being charged; accordingly, charging of the cell can be performed. 
     In the case where overdischarge of the cell is detected by a hysteresis comparator, when the cell having a voltage lower than the voltage V 2  is regarded as being in an overdischarge state, the voltage V 2  may be set as the low-level-side threshold voltage of the hysteresis comparator and the desired voltage V 1  may be set as the high-level-side threshold voltage of the hysteresis comparator. At this time, as an example, when the voltage V 2  is set to 2.5 V, the voltage V 1  can be set to 3.2 V, preferably set to 3.0 V. Here, when the voltage V 1  is set to 3.0 V, the voltage V 2  is set to 2.5 V, and the overdischarge voltage of the cell is lower than 2.5 V, the output potential of the hysteresis comparator is transited from the high-level potential to the low-level potential (or from the low-level potential to the high-level potential). The change in the output potential (hereinafter referred to as a detection signal in some cases) is detected by a control circuit separately provided or the like, whereby the cell can be detected as being in an overdischarge state and discharge of the cell can be stopped. After that, when the cell performs charge and the voltage of the cell exceeds 3.0 V, the output potential of the hysteresis comparator is changed from the low-level potential to the high-level potential (or from the high-level potential to the low-level potential). When the voltage of the cell is higher than 3.0 V, the cell is not in the overdischarge state and thus discharge can be performed. That is, the control circuit separately provided or the like detects the change in the output potential, and thus can detect the state of the cell capable of being discharged; accordingly, discharging of the cell can be performed. 
     As described above, the high-level-side threshold voltage and the low-level-side threshold voltage of the hysteresis comparator are set with respect to one cell, and a detection signal output from the output terminal of the hysteresis comparator is obtained; whereby whether overcharge or overdischarge occurs or not in the cell can be determined. Note that setting of the high-level-side threshold voltage and the low-level-side threshold voltage of the hysteresis comparator is preferably performed in accordance with either the overcharge state or the overdischarge state which is desired to be detected, as described above. 
     In the case of using a hysteresis comparator, two constant voltages the high-level-side threshold voltage and the low-level-side threshold voltage are necessary as described above. For this reason, the number of circuits that generate constant voltage needs to be increased in the case of using a hysteresis comparator as compared with in the case of using a comparator; accordingly, the circuit area might be increased and the power consumption might be high. 
     One embodiment of the present invention is a hysteresis comparator having one reference potential input terminal in view of above, and can be performed by input of one reference potential. 
     Configuration Example 1 
       FIG.  2 A  illustrates a hysteresis comparator of one embodiment of the present invention. A hysteresis comparator HCMP 1  includes a comparator CMP 1 , a switch SW 1 , a capacitor C 1 , a capacitor C 2 , and a logic circuit LC. 
     The comparator CMP 1  includes a plus-side input terminal, a minus-side input terminal, and an output terminal. Note that in this specification and the like, the plus-side input terminal is rephrased as one of a first input terminal and a second input terminal and the minus-side input terminal is rephrased as the other of the first input terminal and the second input terminal in some cases. 
     The input terminal IT is electrically connected to a plus-side input terminal of the comparator CMP 1 , the reference potential input terminal RT is electrically connected to a first terminal of the switch SW 1 , and the output terminal OT is electrically connected to an output terminal of the comparator CMP 1  and a terminal VIT of the logic circuit LC. A second terminal of the switch SW 1  is electrically connected to one of a pair of conductive regions of the capacitor C 1 , one of a pair of conductive regions of the capacitor C 2 , and a minus-side input terminal of the comparator CMP 1 . The other of the pair of conductive regions of the capacitor C 1  is electrically connected to a wiring VGE, and the other of the pair of conductive regions of the capacitor C 2  is electrically connected to a terminal VOT of the logic circuit LC. 
     Note that in  FIG.  2 A , a point at which the second terminal of the switch SW 1 , the one of the pair of conductive regions of the capacitor C 1 , the one of the pair of conductive regions of the capacitor C 2 , and the minus-side input terminal of the comparator CMP 1  are electrically connected is illustrated as a node ND 1  (referred to as a first potential hold portion in some cases), and a point at which the other of the pair of conductive regions of the capacitor C 2  and the terminal VOT of the logic circuit LC are electrically connected is illustrated as a node ND 2  (referred to as a second potential hold portion in some cases). An electrostatic capacitance value of each of the capacitor C 1  and the capacitor C 2  is greater than or equal to 0.01 fF and less than or equal to 100 pF, preferably greater than or equal to 0.05 fF and less than or equal to 10 pF, further preferably greater than or equal to 0.1 fF and less than or equal to 1 pF. 
     The wiring VGE functions as a wiring for supplying a constant voltage, for example. In particular, a constant voltage supplied through the wiring VGE can be, for example, a ground potential (GND). Other than the ground potential (GND), for example, a positive potential or a negative potential can be employed. 
     The logic circuit LC includes the terminal VIT and the terminal VOT. The logic circuit LC has a function as an inverter circuit, and specifically has a function of outputting an inverted signal of a signal input to the terminal VIT to the terminal VOT. Thus, the logic circuit LC may include an inverter circuit, for example. A hysteresis comparator HCMP 2  illustrated in  FIG.  2 B  has a configuration in which the logic circuit LC included in the hysteresis comparator HCMP 1  in  FIG.  2 A  includes an inverter circuit INV. The logic circuit LC may be a circuit in which an inverter circuit, a NAND circuit, a NOR circuit, an XOR circuit, and the like are combined, for example. 
     In this specification and the like, the switch SW 1  is brought into an on state when a high-level potential is applied to the control terminal, and is brought into an off state when a low-level potential is applied to the control terminal. Note that in  FIG.  2 A , the control terminal of the switch SW 1  is electrically connected to a wiring SHE. 
     As the switch SW 1 , an electrical switch such as an analog switch or a transistor can be used, for example. As the switch SW 1 , a mechanical switch such as MEMS (micro electro mechanical systems) can be used, for example. 
     A hysteresis comparator HCMP illustrated in  FIG.  2 C  has a configuration in which the switch SW 1  included in the hysteresis comparator HCMP 1  in  FIG.  2 A  is replaced with a transistor TrS 1 . The transistor TrS 1  can be, for example, an OS transistor or a transistor including silicon in a channel formation region (hereinafter referred to as a Si transistor). As silicon, single-crystal silicon, amorphous silicon (hydrogenated amorphous silicon), microcrystalline silicon, or polycrystalline silicon can be used, for example. As transistors other than the OS transistor and the Si transistor, it is possible to use, for example, a transistor containing a compound semiconductor in an active layer; a transistor containing a carbon nanotube in an active layer; and a transistor containing an organic semiconductor in an active layer. 
     In particular, the off-state current of the transistor TrS 1  is preferably low because the transistor TrS 1  holds electrical charges accumulated in the capacitor C 1  and the capacitor C 2 . For this reason, the transistor TrS 1  is preferably an OS transistor. In particular, in the case where an OS transistor is used as the transistor TrS 1 , the OS transistor preferably has a structure described particularly in Embodiment 3. 
     For example, it is further preferable that a metal oxide in the channel formation region of an OS transistor be an oxide containing at least one of indium, an element M (examples of the element M include aluminum, gallium, yttrium, and tin), and zinc. The off-state current per micrometer of channel width of the OS transistor including the metal oxide in the channel formation region can be lower than or equal to 10 aA (1×10 −17  A), preferably lower than or equal to 1 aA (1×10 −18  A), further preferably lower than or equal to 10 zA (1×10 −20  A), further preferably lower than or equal to 1 zA (1×10 −21  A), further preferably lower than or equal to 100 yA (1×10 −22  A). The OS transistor has a low carrier concentration of the metal oxide; when the temperature of the OS transistor changes, the off-state current keeps low. For example, even when the temperature of the OS transistor is 150° C., the off-state current per micrometer of channel width of the OS transistor can be 100 zA. 
     Although the transistor TrS 1  included in the hysteresis comparator HCMP 3  in  FIG.  2 C  is an n-channel transistor, it may be a p-channel transistor. 
     Although the transistor TrS 1  included in the hysteresis comparator HCMP 3  has a single-gate structure, the transistor TrS 1  may be a multi-gate n-channel transistor. The transistor TrS 1  in a hysteresis comparator HCMP 4  illustrated in  FIG.  2 D  is a multi-gate n-channel transistor and includes a first gate and a second gate. Note that in this specification and the like, for convenience, the first gate is referred to as a gate (referred to as a front gate in some cases) and the second gate is referred to as a back gate so that they are distinguished from each other; however, the first gate and the second gate can be replaced with each other. Therefore, in this specification and the like, the term “gate” can be replaced with the term “back gate”. Similarly, the term “back gate” can be replaced with the term “gate”. As a specific example, a connection configuration in which “a gate is electrically connected to a first wiring and a back gate is electrically connected to a second wiring” can be replaced with a connection configuration in which “a back gate is electrically connected to a first wiring and a gate is electrically connected to a second wiring”. 
     In addition, the hysteresis comparator of one embodiment of the present invention does not depend on the connection configuration of a back gate of a transistor. In the transistor TrS 1  illustrated in  FIG.  2 D , the back gate is illustrated and the connection configuration of the back gate is not illustrated; however, a target to which the back gate is electrically connected can be determined at the design stage. For example, in a transistor including a back gate, a gate and the back gate may be electrically connected to each other to increase the on-state current of the transistor. In other words, the gate and the back gate of the transistor TrS 1  may be electrically connected to each other, for example. Alternatively, for example, in a transistor including a back gate, a wiring electrically connected to an external circuit or the like may be provided and a potential may be supplied to the back gate of the transistor by the external circuit or the like to change the threshold voltage of the transistor or to reduce the off-state current of the transistor. Note that the same applies to another transistor described in other parts of the specification and another transistor illustrated in other drawings, not only to that in  FIG.  2 D . 
     In the hysteresis comparator HCMP 4  in  FIG.  2 D , the aforementioned OS transistor can be used as the transistor TrS 1  including a back gate, for example. 
     In the case where the comparator CMP 1  and/or the logic circuit LC illustrated in  FIG.  2 A  includes a transistor, the transistor is preferably an OS transistor. That is, the comparator CMP 1  and/or the logic circuit LC may be a unipolar circuit composed of OS transistors. The OS transistor included in the comparator CMP 1  and/or the logic circuit LC may be a multi-gate transistor, a transistor including a back gate, or the like. 
     Note that for the metal oxides in the semiconductor layers of OS transistors, n-type semiconductors of a metal oxide containing indium (e.g., In oxide) and a metal oxide containing zinc (e.g., Zn oxide) have been manufactured but p-type semiconductors thereof are difficult to manufacture in terms of mobility and reliability in some cases. For this reason, in the case where the comparator CMP 1  and/or the logic circuit LC are/is CMOS circuits/a CMOS circuit, an n-channel transistor included in the comparator CMP 1  and/or the logic circuit LC may be an OS transistor as an example and a p-channel transistor may be a Si transistor as an example. 
     As a transistor described in this specification and the like, for example, transistors with a variety of structures can be used. Thus, there is no limitation on the type of transistors used. Examples of the transistor include a Si transistor (a transistor including single crystal silicon and a transistor including a non-single-crystal semiconductor film typified by amorphous silicon, polycrystalline silicon, microcrystalline (also referred to as microcrystal, nanocrystal, or semi-amorphous) silicon, or the like). Alternatively, a thin film transistor (TFT) in which a semiconductor is thinned can be used, for example. The use of the TFT has various advantages. For example, since the TFT can be manufactured at a lower temperature than the case of using single crystal silicon, manufacturing costs can be reduced or a larger manufacturing apparatus can be used. Since a larger manufacturing apparatus can be used, TFTs can be manufactured over a large substrate. This enables a large number of display devices to be manufactured at a time, resulting in low cost manufacturing. Alternatively, a low manufacturing temperature allows the use of a low heat-resistance substrate. Thus, transistors can be manufactured over a light-transmitting substrate. Transmission of light in a display element can be controlled using the transistor over a light-transmitting substrate. Alternatively, some of the films included in the transistor can transmit light because the transistor is thin. Accordingly, the aperture ratio can be improved. 
     For example, a transistor including a compound semiconductor (e.g., Ge, ZnSe, CdS, GaAs, InP, GaN, or SiGe) or an oxide semiconductor (e.g., Zn—O, In—Ga—Zn—O, In—Zn—O, In—Sn—O (ITO), Sn—O, Ti—O, Al—Zn—Sn—O (AZTO), or In—Sn—Zn—O) can be used. Alternatively, a thin film transistor including a thin film of such a compound semiconductor or oxide semiconductor can be used. Accordingly, manufacturing temperature can be lowered and, for example, such a transistor can be manufactured at room temperature. As a result, the transistor can be formed directly on a substrate having low heat resistance, such as a plastic substrate or a film substrate. Note that such a compound semiconductor or oxide semiconductor can be used not only for a channel portion of the transistor but also for other applications. For example, such a compound semiconductor or oxide semiconductor can be used for a wiring, a resistor, a pixel electrode, or a light-transmitting electrode. Since such components can be deposited or formed at the same time as the transistor, the cost can be reduced. 
     As another example, a transistor formed by an inkjet method or a printing method can be used. The transistor can be manufactured at room temperature, manufactured at a low vacuum degree, or manufactured over a large substrate. Accordingly, the transistor can be manufactured without using a mask (reticle), so that the layout of the transistor can be easily changed. Alternatively, since the transistor can be manufactured without using a resist, the material cost is reduced and the number of steps can be reduced. Alternatively, since a film can be formed only where needed, a material is not wasted as compared with a manufacturing method by which etching is performed after the film is formed over the entire surface; thus, the cost can be reduced. 
     As another example, a transistor containing an organic semiconductor or a carbon nanotube can be used. Thus, a transistor can be formed over a bendable substrate. A device using a transistor containing an organic semiconductor or a carbon nanotube can be highly resistant to impact. 
     Note that as an example of the transistor, a transistor including a layered material which functions as a semiconductor can be used. In this specification and the like, the layered material is a group of materials having a layered crystal structure. In the layered crystal structure, layers formed by covalent bonding or ionic bonding are stacked with bonding such as the Van der Waals force, which is weaker than covalent bonding or ionic bonding. The layered material has high electrical conductivity in a monolayer, that is, high two-dimensional electrical conductivity. When a material that functions as a semiconductor and has high two-dimensional electrical conductivity is used for a channel formation region, the transistor can have a high on-state current. Examples of the layered material include graphene, silicene, and chalcogenide. Chalcogenide is a compound containing chalcogen. Chalcogen is a general term of elements belonging to Group 16, which includes oxygen, sulfur, selenium, tellurium, polonium, and livermorium. Examples of chalcogenide include transition metal chalcogenide and chalcogenide of Group 13 elements. 
     As an example of the transistor, transition metal chalcogenide functioning as a semiconductor can be used. Specific examples of the transition metal chalcogenide include molybdenum sulfide (typically MoS 2 ), molybdenum selenide (typically MoSe 2 ), molybdenum telluride (typically MoTe 2 ), tungsten sulfide (typically WS 2 ), tungsten selenide (typically WSe 2 ), tungsten telluride (typically WTe 2 ), hafnium sulfide (typically HfS 2 ), hafnium selenide (typically HfSe 2 ), zirconium sulfide (typically ZrS 2 ), and zirconium selenide (typically ZrSe 2 ). 
     Note that a transistor with any of a variety of other structures can also be used. For example, a MOS transistor, a junction transistor, a bipolar transistor, or the like can be used as the transistor. By using a MOS transistor as the transistor, the size of the transistor can be reduced. Thus, a large number of transistors can be mounted. By using a bipolar transistor as the transistor, a large amount of current can flow therethrough. Thus, a circuit can operate at high speed. Note that a MOS transistor and a bipolar transistor may be formed over one substrate. Thus, a reduction in power consumption, a reduction in size, high-speed operation, and the like can be achieved. 
     As another example, it is possible to use a transistor having a structure where gate electrodes are positioned above and below an active layer. With the structure where the gate electrodes are positioned above and below the active layer, a circuit configuration is such that a plurality of transistors are connected in parallel. Thus, a channel formation region is increased, so that the amount of current can be increased. Alternatively, with the structure where the gate electrodes are positioned above and below the active layer, a depletion layer can be easily formed, so that subthreshold swing can be improved. 
     As another example, it is possible to use a transistor having a structure where a gate electrode is positioned above an active layer, a structure where a gate electrode is positioned below an active layer, a staggered structure, an inverted staggered structure, a structure where a channel region is divided into a plurality of regions, a structure where active layers are connected in parallel, a structure where active layers are connected in series, or the like. Alternatively, a transistor can have a variety of structures such as a planar type, a FIN-type, a TRI-GATE type, a top-gate type, a bottom-gate type, and a double-gate type (with gates placed above and below a channel). 
     As another example, it is possible to use a transistor having a structure where a source electrode or a drain electrode overlaps with an active layer (or part thereof). Employing the structure where the source electrode or the drain electrode overlaps with the active layer (or part thereof) can prevent unstable operation due to charge accumulation in part of the active layer. 
     As another example, it is possible to use a transistor having a structure where an LDD region is provided. By providing the LDD region, it is possible to achieve a reduction in off-state current or an increase in withstand voltage (an improvement in reliability) of the transistor. Alternatively, by providing the LDD region, in the case of operation in a saturation region, the drain current does not change much even if the drain-source voltage changes, and thus the voltage-current characteristics having a flat slope can be obtained. 
     In this specification and the like, a transistor can be formed using a variety of substrates, for example. The type of the substrate is not limited to a certain type. Examples of the substrate include a semiconductor substrate (e.g., a single crystal substrate or a silicon substrate), an SOI substrate, a glass substrate, a quartz substrate, a plastic substrate, a sapphire glass substrate, a metal substrate, a stainless steel substrate, a substrate including stainless steel foil, a tungsten substrate, a substrate including tungsten foil, a flexible substrate, an attachment film, paper including a fibrous material, and a base material film. Examples of the glass substrate include barium borosilicate glass, aluminoborosilicate glass, and soda lime glass. As examples of the flexible substrate, the attachment film, the base material film, and the like, the following can be given. The examples include plastics typified by polyethylene terephthalate (PET), polyethylene naphthalate (PEN), polyether sulfone (PES), and polytetrafluoroethylene (PTFE). Another example is a synthetic resin such as acrylic. Other examples are polypropylene, polyester, polyvinyl fluoride, and polyvinyl chloride. Other examples are polyamide, polyimide, aramid, an epoxy resin, an inorganic vapor deposition film, and paper. In particular, the use of a semiconductor substrate, a single crystal substrate, an SOI substrate, or the like enables the manufacture of small-sized transistors with a small variation in characteristics, size, shape, or the like and with high current capability. When a circuit is formed with such transistors, lower power consumption of the circuit or higher integration of the circuit can be achieved. 
     Alternatively, a flexible substrate may be used as the substrate, and the transistor may be directly formed over the flexible substrate. Alternatively, a separation layer may be provided between the substrate and the transistor. After part or the whole of a semiconductor device is completed over the separation layer, the separation layer can be used for separation from the substrate and transfer to another substrate. In that case, the transistor can be transferred to even a substrate having low heat resistance or a flexible substrate. As the separation layer, a stacked-layer structure of inorganic films of a tungsten film and a silicon oxide film, or a structure in which an organic resin film of polyimide or the like is formed over a substrate can be used, for example. 
     In other words, the transistor may be formed using one substrate and then transferred to another substrate; thus, the transistor may be positioned over another substrate. Examples of the substrate to which the transistor is transferred include, in addition to the above-described substrates over which the transistor can be formed, a paper substrate, a cellophane substrate, an aramid film substrate, a polyimide film substrate, a stone substrate, a wood substrate, a cloth substrate (including a natural fiber (silk, cotton, or hemp), a synthetic fiber (nylon, polyurethane, or polyester), a regenerated fiber (acetate, cupra, rayon, or regenerated polyester), or the like), a leather substrate, and a rubber substrate. When such a substrate is used, forming a transistor with excellent characteristics, forming a transistor with low power consumption, manufacturing a device with high durability, providing high heat resistance, reducing weight, or reducing thickness can be achieved. 
     Note that all the circuits necessary to achieve a predetermined function can be formed over one substrate (e.g., a glass substrate, a plastic substrate, a single crystal substrate, or an SOI substrate). In this manner, the cost can be reduced by a reduction in the number of components or the reliability can be improved by a reduction in the number of connection points to circuit components. 
     Note that a structure is possible in which not all the circuits necessary to achieve a predetermined function are formed over one substrate. That is, it is possible to form part of the circuits necessary to achieve the predetermined function over a given substrate and form the other part of the circuits necessary to achieve the predetermined function over another substrate. For example, part of the circuits necessary to achieve the predetermined function can be formed over a glass substrate, and the other part of the circuits necessary to achieve the predetermined function can be formed over a single crystal substrate (or an SOI substrate). The single crystal substrate where the other part of the circuits necessary to achieve the predetermined function (also referred to as an IC chip) can be connected to the glass substrate by COG (Chip On Glass), and the IC chip can be provided over the glass substrate. Alternatively, the IC chip can be connected to the glass substrate by TAB (Tape Automated Bonding), COF (Chip On Film), or SMT (Surface Mount Technology), or using a printed circuit board, for example. When part of the circuits is formed over the same substrate as a pixel portion in this manner, the cost can be reduced by a reduction in the number of components or the reliability can be improved by a reduction in the number of connection points to circuit components. In particular, a circuit in a portion where the driving voltage is high, a circuit in a portion where the driving frequency is high, or the like consumes much power in many cases. In view of this, such a circuit is formed over a substrate (e.g., a single crystal substrate) different from a substrate where a pixel portion is formed, whereby an IC chip is formed. The use of this IC chip can prevent the increase in power consumption. 
     Operation Example 1 
     Next, an example of the operation of the hysteresis comparator HCMP 1  illustrated in  FIG.  2 A  is described. Note that for the hysteresis comparators in  FIG.  2 B  to  FIG.  2 D , description of the operation example of the hysteresis comparator in  FIG.  2 A  is referred to. 
       FIG.  3    is a timing chart showing changes in a voltage input to the input terminal IT, a voltage input to the reference potential input terminal RT, a voltage output from the output terminal OT, a voltage input to the wiring SHE, and a potential of each of the node ND 1  and the node ND 2  during or near a period from Time T 1  to Time T 10 . Note that “high” described in  FIG.  3    indicates a high-level potential and “low” indicates a low-level potential. 
     In the timing chart in  FIG.  3   , V GND  is input to the input terminal IT and the reference potential input terminal RT in a period from Time T 1  to Time T 2 . A low-level potential is input to the wiring SHE. The V GND  can be a ground potential, for example. Alternatively, the V GND  can be a reference potential lower than or higher than the ground potential, for example. 
     In a period from Time T 1  to Time T 3 , the voltage output from the output terminal OT is undefined. Accordingly, the potential of the node ND 2  is also undefined. Note that in the timing chart in  FIG.  3   , the potentials of the output terminal OT and the node ND 2  before Time T 1  and during the period from Time T 1  to Time T 3  are hatched. 
     In the period from Time T 1  to Time T 2 , a low-level potential is input to the wiring SHE. Thus, a low-level potential is input to the control terminal of the switch SW 1 , whereby the switch SW 1  is brought into an off state. When the switch SW 1  is in an off state, the reference potential input terminal RT and the minus-side input terminal of the comparator CMP 1  are brought out of conduction, so that the potential input to the reference potential input terminal RT is not input to the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  in the period from Time T 1  to Time T 2 . 
     A voltage V ref1  is input to the reference potential input terminal RT in a period from Time T 2  to Time T 3 . The V ref1  can be a potential higher than the V GND , for example. Since the switch SW 1  is in an off state in the period from Time T 2  to Time T 3 , the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  is not changed. 
     In a period from Time T 3  to Time T 4 , a high-level potential is input to the wiring SHE. Thus, a high-level potential is input to the control terminal of the switch SW 1 ; whereby the switch SW 1  is brought into an on state. When the switch SW 1  is in an on state, the reference potential input terminal RT and the minus-side input terminal of the comparator CMP 1  are brought into conduction, so that the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  becomes the V ref1 . 
     At this time, the V GND  is input to the plus-side input terminal of the comparator CMP 1  and the V ref1  is input to the minus-side input terminal thereof, so that a low-level potential is output from the output terminal of the comparator CMP 1 . That is, a low-level potential is output from the output terminal OT. A low-level potential is input to the terminal VIT of the logic circuit LC, so that a high-level potential is output from the terminal VOT of the logic circuit LC. Accordingly, a potential of the other of the pair of conductive regions (the node ND 2 ) of the capacitor C 2  becomes a high-level potential. 
     In a period from Time T 4  to Time T 5 , a low-level potential is input to the wiring SHE. Thus, a low-level potential is input to the control terminal of the switch SW 1 , whereby the switch SW 1  is brought into an off state. When the switch SW 1  is in an off state, the reference potential input terminal RT and the minus-side input terminal of the comparator CMP 1  are brought out of conduction. In addition, a power supply potential is not supplied from the inside of the comparator CMP 1  to the minus-side input terminal (the node ND 1 ), whereby the node ND 1  is into an electrically floating state. Accordingly, the potential V ref1  of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  is held by one of the pair of conductive regions of the capacitor C 1  and one of the pair of conductive regions of the capacitor C 2 . 
     The voltage V GND  is input to the reference potential input terminal RT in a period from Time T 5  to Time T 6 . Since the switch SW 1  is in an off state in the period from Time T 5  to Time T 6 , the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  is not changed and kept V ref1 . 
     In a period from Time T 6  to Time T 8 , a potential input from the input terminal IT increases from the V GND  to V MAX  with time. That is, in the period from Time T 6  to Time T 8 , the potential input to the plus-side input terminal of the comparator CMP 1  increases up to the V MAX  with time. Note that the V MAX  is a potential higher than the V ref1 . 
     In the case where the potential input from the input terminal IT reaches the V ref1  in Time T 7 , the potential input to the plus-side input terminal of the comparator CMP 1  (the potential input from the input terminal IT) becomes higher than the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  in a period from Time T 7  to Time T 8 , so that a high-level potential is output from the output terminal of the comparator CMP 1 . That is, a high-level potential is output from the output terminal OT. 
     A high-level potential is input to the terminal VIT of the logic circuit LC, so that a low-level potential is output from the terminal VOT of the logic circuit LC. Accordingly, a potential of the other of the pair of conductive regions (the node ND 2 ) of the capacitor C 2  becomes a low-level potential. Since the node ND 1  is in an electrically floating state, at this time, the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  is changed in accordance with a change in the potential of the other of the pair of conductive regions (the node ND 2 ) of the capacitor C 2  and the values of electrostatic capacitance of the capacitor C 1  and the capacitor C 2 . Thus, the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  in this operation example is changed from the V ref1  to the V ref2 . 
     Specifically, when a high-level potential of the other of the pair of conductive regions (the node ND 2 ) of the capacitor C 2  in a period from Time T 3  to Time T 7  is set to V H , a low-level potential of the other of the pair of conductive regions (the node ND 2 ) of the capacitor C 2  in the period from Time T 7  to Time T 8  is set to V L , and the values of electrostatic capacitance of the capacitor C 1  and the capacitor C 2  are set to C 1  and C 2 , respectively, the V ref2  can be expressed by the following formula. 
     
       
         
           
             
               
                 
                   
                     V 
                     
                       ref 
                       ⁢ 
                       2 
                     
                   
                   = 
                   
                     
                       V 
                       
                         ref 
                         ⁢ 
                         1 
                       
                     
                     - 
                     
                       
                         
                           C 
                           2 
                         
                         
                           
                             C 
                             1 
                           
                           + 
                           
                             C 
                             2 
                           
                         
                       
                       ⁢ 
                       
                         ( 
                         
                           
                             V 
                             H 
                           
                           - 
                           
                             V 
                             L 
                           
                         
                         ) 
                       
                     
                   
                 
               
               
                 
                   [ 
                   
                     Formula 
                     ⁢ 
                         
                     1 
                   
                   ] 
                 
               
             
           
         
       
     
     In a period from Time T 8  to Time T 10 , the potential input from the input terminal IT decreases from the V MAX  to V GND  with time. That is, in the period from Time T 8  to Time T 10 , the potential input to the plus-side input terminal of the comparator CMP 1  decreases to the V GND  with time. 
     In the case where the potential input from the input terminal IT lowers to the V ref2  in Time T 9 , the potential input to the plus-side input terminal of the comparator CMP 1  (the potential input from the input terminal IT) becomes lower than the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  in a period from Time T 9  to Time T 10 , so that a low-level potential is output from the output terminal of the comparator CMP 1 . That is, a low-level potential is output from the output terminal OT. 
     A low-level potential is input to the terminal VIT of the logic circuit LC, so that a high-level potential is output from the terminal VOT of the logic circuit LC. Accordingly, a potential of the other of the pair of conductive regions (the node ND 2 ) of the capacitor C 2  becomes a high-level potential. Since the node ND 1  is in an electrically floating state, at this time, the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  is changed in accordance with a change in the potential of the other of the pair of conductive regions (the node ND 2 ) of the capacitor C 2  and the values of electrostatic capacitance of the capacitors C 1  and C 2 . Note that the potential of the other of the pair of conductive regions (the node ND 2 ) of the capacitor C 2  in the period from Time T 9  to Time T 10  is a high-level potential the same as the potential of the other of the pair of conductive regions (the node ND 2 ) of the capacitor C 2  in the period from Time T 6  to Time T 7 , and thus the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  in the period from Time T 9  to Time T 10  is V ref1 . 
     As described in the above operation example, the circuit configuration in  FIG.  2 A  can achieve a hysteresis comparator with a hysteresis width of V ref1 −V ref2 . 
     The values C 1  and C 2  of electrostatic capacitance of the capacitor C 1  and the capacitor C 2  are determined in the design phase of the hysteresis comparator HCMP 1 , whereby the hysteresis width of the hysteresis comparator HCMP 1  can be determined by the formula (E1). For example, when the values C 1  and C 2  of electrostatic capacitance are 0.1 fF, the hysteresis width is (V H −V L )/2. For example, when the values C 1  and C 2  of electrostatic capacitance are 0.3 fF and 0.1 fF, respectively, the hysteresis width is (V H −V L )/4. 
     Configuration Example 2 
     One embodiment of the present invention is not limited to the hysteresis comparator HCMP 1  to the hysteresis comparator HCMP 4  illustrated in  FIG.  2 A  to  FIG.  2 D . The configuration of any one of the hysteresis comparator HCMP 1  to the hysteresis comparator HCMP 4  may be changed in accordance with circumstances. 
     For example, the logic circuit LC in the hysteresis comparator HCMP 1  in  FIG.  2 A  may include a NAND circuit. For example, a hysteresis comparator HCMP 5  illustrated in  FIG.  4 A  has a configuration in which the terminal VIT and the terminal VOT of the hysteresis comparator HCMP 1  in  FIG.  2 A  are a first input terminal and an output terminal, respectively, of a NAND circuit LCNA. Note that a wiring EN is electrically connected to a second input terminal of the NAND circuit LCNA. 
     The wiring EN functions as a wiring that supplies a high-level potential or a low-level potential, for example. 
     Operation Example 2 
     An example of the operation of the hysteresis comparator HCMP 5  illustrated in  FIG.  4 A  is described. 
       FIG.  5    is a timing chart showing changes in a voltage input to the input terminal IT, a voltage input to the reference potential input terminal RT, a voltage output from the output terminal OT, a voltage input to the wiring SHE, a voltage input to the wiring EN, and a potential of each of the node ND 1  and the node ND 2  during or near a period from Time T 11  to Time T 20 . Note that “high” described in  FIG.  5    indicates a high-level potential and “low” indicates a low-level potential. 
     In the timing chart in  FIG.  5   , V GND  is input to the input terminal IT and the reference potential input terminal RT in a period from Time T 11  to Time T 12 . A low-level potential is input to the wiring SHE. For the V GND , the description of the V GND  in Operation example 1 is referred to. 
     In general, a NAND circuit outputs a high-level potential from an output terminal by receiving a low-level potential at one of a first terminal and a second terminal. In the period from Time T 11  to Time T 12 , since a low-level potential is input to the wiring EN, a low-level potential is input to the second terminal of the NAND circuit LCNA and the output terminal of the NAND circuit LCNA outputs a high-level potential. 
     Note that although the output terminal OT is electrically connected to the first terminal of the NAND circuit LCNA, voltage output from the output terminal of the NAND circuit LCNA does not depend on a voltage input to the first terminal of the NAND circuit LCNA because a low-level potential is input to the second terminal of the NAND circuit LCNA. In a period from Time T 11  to Time T 13  in this operation example, the voltage output from the output terminal OT is undefined, and in the timing chart in  FIG.  5   , the potential of the output terminal OT is hatched. 
     In the period from Time T 11  to Time T 12 , a low-level potential is input to the wiring SHE. Thus, a low-level potential is input to the control terminal of the switch SW 1 , whereby the switch SW 1  is brought into an off state. When the switch SW 1  is in an off state, the reference potential input terminal RT and the minus-side input terminal of the comparator CMP 1  are brought out of conduction, so that the potential input to the reference potential input terminal RT is not input to the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  in the period from Time T 11  to Time T 12 . 
     A voltage V ref1  is input to the reference potential input terminal RT in a period from Time T 12  to Time T 13 . The V ref1  can be a potential higher than the V GND , for example. Since the switch SW 1  is in an off state in the period from Time T 12  to Time T 13 , the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  is not changed. 
     In a period from Time T 13  to Time T 14 , a high-level potential is input to the wiring SHE. Thus, a high-level potential is input to the control terminal of the switch SW 1 ; whereby the switch SW 1  is brought into an on state. When the switch SW 1  is in an on state, the reference potential input terminal RT and the minus-side input terminal of the comparator CMP 1  are brought into conduction, so that the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  becomes the V ref1 . 
     At this time, the V GND  is input to the plus-side input terminal of the comparator CMP 1  and the V ref1  is input to the minus-side input terminal thereof, so that a low-level potential is output from the output terminal of the comparator CMP 1 . That is, a low-level potential is output from the output terminal OT. Although a low-level potential is input to the first terminal of the NAND circuit LCNA, a high-level potential is continuously output from the output terminal of the NAND circuit LCNA since before Time T 13 . 
     In a period from Time T 14  to Time T 15 , a low-level potential is input to the wiring SHE. Thus, a low-level potential is input to the control terminal of the switch SW 1 , whereby the switch SW 1  is brought into an off state. When the switch SW 1  is in an off state, the reference potential input terminal RT and the minus-side input terminal of the comparator CMP 1  are brought out of conduction. In addition, a power supply potential is not supplied from the inside of the comparator CMP 1  to the minus-side input terminal (the node ND 1 ), whereby the node ND 1  is into an electrically floating state. Accordingly, the potential V ref1  of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  is held by one of the pair of conductive regions of the capacitor C 1  and one of the pair of conductive regions of the capacitor C 2 . 
     The voltage V GND  is input to the reference potential input terminal RT in a period from Time T 15  to Time T 16 . Since the switch SW 1  is in an off state in the period from Time T 15  to Time T 16 , the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  is not changed and kept V ref1 . 
     In the period from Time T 15  to Time T 16 , a high-level potential is input to the wiring EN. Note that a low-level potential is input to the first terminal of the NAND circuit LCNA, and a high-level potential is continuously output from the output terminal of the NAND circuit LCNA since before Time T 15 . 
     In a period from Time T 16  to Time T 18 , a potential input from the input terminal IT increases from the V GND  to V MAX  with time. That is, in the period from Time T 16  to Time T 18 , the potential input to the plus-side input terminal of the comparator CMP 1  increases up to the V MAX  with time. Note that the V MAX  is a potential higher than the V ref1 . 
     In the case where the potential input from the input terminal IT reaches the V ref1  in Time T 17 , the potential input to the plus-side input terminal of the comparator CMP 1  (the potential input from the input terminal IT) becomes higher than the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  in a period from Time T 17  to Time T 18 , so that a high-level potential is output from the output terminal of the comparator CMP 1 . That is, a high-level potential is output from the output terminal OT. 
     A high-level potential is input to the first terminal of the NAND circuit LCNA. In the period from Time T 17  to Time T 18 , a high-level potential is input to the second terminal of the NAND circuit LCNA, so that a low-level potential is output from the output terminal of the NAND circuit LCNA. Accordingly, a potential of the other of the pair of conductive regions (the node ND 2 ) of the capacitor C 2  becomes a low-level potential. Since the node ND 1  is in an electrically floating state, at this time, the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  is changed in accordance with a change in the potential of the other of the pair of conductive regions (the node ND 2 ) of the capacitor C 2  and the values of electrostatic capacitance of the capacitor C 1  and the capacitor C 2 . Thus, the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  in this operation example is changed from the V ref1  to the V ref2 , as in Operation example 1. 
     Note that for the relation between the V ref1  and the V ref2 , the description in Operation example 1 is referred to. 
     In a period from Time T 18  to Time T 20 , the potential input from the input terminal IT decreases from the V MAX  to V GND  with time. That is, in the period from Time T 18  to Time T 20 , the potential input to the plus-side input terminal of the comparator CMP 1  decreases to the V GND  with time. 
     In the case where the potential input from the input terminal IT lowers to the V ref2  in Time T 19 , the potential input to the plus-side input terminal of the comparator CMP 1  (the potential input from the input terminal IT) becomes lower than the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  in a period from Time T 19  to Time T 20 , so that a low-level potential is output from the output terminal of the comparator CMP 1 . That is, a low-level potential is output from the output terminal OT. 
     A high-level potential is input to the second terminal of the NAND circuit LCNA, so that a high-level potential is output from the output terminal of the NAND circuit LCNA. Accordingly, a potential of the other of the pair of conductive regions (the node ND 2 ) of the capacitor C 2  becomes a high-level potential. Since the node ND 1  is in an electrically floating state, at this time, the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  is changed in accordance with a change in the potential of the other of the pair of conductive regions (the node ND 2 ) of the capacitor C 2  and the values of electrostatic capacitance of the capacitors C 1  and C 2 . Note that the potential of the other of the pair of conductive regions (the node ND 2 ) of the capacitor C 2  in the period from Time T 19  to Time T 20  is a high-level potential the same as the potential of the other of the pair of conductive regions (the node ND 2 ) of the capacitor C 2  in the period from Time T 16  to Time T 17 , and thus the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  in the period from Time T 19  to Time T 20  is V ref1 . 
     As described in the above operation example, the circuit configuration in  FIG.  4 A  can achieve a hysteresis comparator with a hysteresis width of V ref1 −V ref2 . 
     Configuration Example 3 
     Here, a hysteresis comparator with a configuration different from those in  FIG.  2 B  to  FIG.  2 D  and  FIG.  4 A  is described. 
     A hysteresis comparator HCMP 6  in  FIG.  4 B  has a configuration different from those of the hysteresis comparators in  FIG.  2 B  to  FIG.  2 D  and  FIG.  4 A , and has a configuration in which the logic circuit LC in the hysteresis comparator HCMP 1  in  FIG.  2 A  includes a NOR circuit. In the configuration, the terminal VIT is a first input terminal of a NOR circuit LCNO, and the terminal VOT is an output terminal of the NOR circuit LCNO. Note that the wiring EN is electrically connected to a second input terminal of the NOR circuit LCNO. 
     Note that for the wiring EN, the description of the wiring EN in Configuration example 2 is referred to. 
     Operation Example 3 
     An example of the operation of the hysteresis comparator HCMP 6  illustrated in  FIG.  4 B  is described. 
       FIG.  6    is a timing chart showing changes in a voltage input to the input terminal IT, a voltage input to the reference potential input terminal RT, a voltage output from the output terminal OT, a voltage input to the wiring SHE, a voltage input to the wiring EN, and a potential of each of the nodes ND 1  and ND 2  during or near a period from Time T 21  to Time T 30 . Note that “high” described in  FIG.  6    indicates a high-level potential and “low” indicates a low-level potential. 
     In the timing chart in  FIG.  6   , V MAX  is input to the input terminal IT and V GND  is input to the reference potential input terminal RT in a period from Time T 21  to Time T 22 . A low-level potential is input to the wiring SHE. For the V MAX  and the V GND , the description of the V MAX  and the V GND  in Operation example 1 is referred to. 
     In general, a NOR circuit outputs a low-level potential from an output terminal by receiving a high-level potential at one of a first terminal and a second terminal. In the period from Time T 21  to Time T 22 , since a high-level potential is input to the wiring EN, a high-level potential is input to the second terminal of the NOR circuit LCNO and the output terminal of the NOR circuit LCNO outputs a low-level potential. 
     Note that although the output terminal OT is electrically connected to the first terminal of the NOR circuit LCNO, voltage output from the output terminal of the NOR circuit LCNO does not depend on a voltage input to the first terminal of the NOR circuit LCNO because a low-level potential is input to the second terminal of the NOR circuit LCNO. In a period from Time T 21  to Time T 23  in this operation example, the voltage output from the output terminal OT is undefined, and in the timing chart in  FIG.  6   , the potential of the output terminal OT is hatched. 
     In the period from Time T 21  to Time T 22 , a low-level potential is input to the wiring SHE. Thus, a low-level potential is input to the control terminal of the switch SW 1 , whereby the switch SW 1  is brought into an off state. When the switch SW 1  is in an off state, the reference potential input terminal RT and the minus-side input terminal of the comparator CMP 1  are brought out of conduction, so that the potential input to the reference potential input terminal RT is not input to the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  in the period from Time T 21  to Time T 22 . 
     A voltage V ref1  is input to the reference potential input terminal RT in a period from Time T 22  to Time T 23 . The V ref1  can be a potential higher than the V GND  and lower than the V MAX , for example. Since the switch SW 1  is in an off state in the period from Time T 22  to Time T 23 , the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  is not changed. 
     In a period from Time T 23  to Time T 24 , a high-level potential is input to the wiring SHE. Thus, a high-level potential is input to the control terminal of the switch SW 1 ; whereby the switch SW 1  is brought into an on state. When the switch SW 1  is in an on state, the reference potential input terminal RT and the minus-side input terminal of the comparator CMP 1  are brought into conduction, so that the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  becomes the V ref1 . 
     At this time, the V MAX  is input to the plus-side input terminal of the comparator CMP 1  and the V ref1  is input to the minus-side input terminal thereof, so that a high-level potential is output from the output terminal of the comparator CMP 1 . That is, a high-level potential is output from the output terminal OT. Although a high-level potential is input to the first terminal of the NOR circuit LCNO, a low-level potential is continuously output from the output terminal of the NOR circuit LCNO since before Time T 23 . 
     In a period from Time T 24  to Time T 25 , a low-level potential is input to the wiring SHE. Thus, a low-level potential is input to the control terminal of the switch SW 1 , whereby the switch SW 1  is brought into an off state. When the switch SW 1  is in an off state, the reference potential input terminal RT and the minus-side input terminal of the comparator CMP 1  are brought out of conduction. In addition, a power supply potential is not supplied from the inside of the comparator CMP 1  to the minus-side input terminal (the node ND 1 ), whereby the node ND 1  is into an electrically floating state. Accordingly, the potential V ref1  of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  is held by one of the pair of conductive regions of the capacitor C 1  and one of the pair of conductive regions of the capacitor C 2 . 
     The voltage V GND  is input to the reference potential input terminal RT in a period from Time T 25  to Time T 26 . Since the switch SW 1  is in an off state in the period from Time T 25  to Time T 26 , the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  is not changed and kept V ref1 . 
     In the period from Time T 25  to Time T 26 , a low-level potential is input to the wiring EN. Note that a high-level potential is input to the first terminal of the NOR circuit LCNO, and a low-level potential is continuously output from the output terminal of the NAND circuit LCNA since before Time T 25 . 
     In the period from Time T 26  to Time T 28 , a potential input from the input terminal IT decreases from the V MAX  to the V GND  with time. That is, in the period from Time T 26  to Time T 28 , the potential input to the plus-side input terminal of the comparator CMP 1  decreases to the V GND  with time. 
     In the case where the potential input from the input terminal IT decreases to the V ref1  in Time T 27 , the potential input to the plus-side input terminal of the comparator CMP 1  (the potential input from the input terminal IT) becomes lower than the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  in the period from Time T 27  to Time T 28 , so that a low-level potential is output from the output terminal of the comparator CMP 1 . That is, a low-level potential is output from the output terminal OT. 
     A low-level potential is input to the first terminal of the NOR circuit LCNO. In the period from Time T 27  to Time T 28 , a low-level potential is input to the second terminal of the NOR circuit LCNO, so that a high-level potential is output from the output terminal of the NOR circuit LCNO. Accordingly, a potential of the other of the pair of conductive regions (the node ND 2 ) of the capacitor C 2  becomes a high-level potential. Since the node ND 1  is in an electrically floating state, at this time, the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  is changed in accordance with a change in the potential of the other of the pair of conductive regions (the node ND 2 ) of the capacitor C 2  and the values of electrostatic capacitance of the capacitor C 1  and the capacitor C 2 . Thus, the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  in this operation example is changed from the V ref1  to the V ref3 . 
     Specifically, when a low-level potential of the other of the pair of conductive regions (the node ND 2 ) of the capacitor C 2  in a period from Time T 23  to Time T 27  is set to V L , a high-level potential of the other of the pair of conductive regions (the node ND 2 ) of the capacitor C 2  in the period from Time T 27  to Time T 28  is set to V H , and the values of electrostatic capacitance of the capacitor C 1  and the capacitor C 2  are set to C 1  and C 2 , respectively, the V ref3  can be expressed by the following formula. 
     
       
         
           
             
               
                 
                   
                     V 
                     
                       ref 
                       ⁢ 
                       3 
                     
                   
                   = 
                   
                     
                       V 
                       
                         ref 
                         ⁢ 
                         1 
                       
                     
                     + 
                     
                       
                         
                           C 
                           2 
                         
                         
                           
                             C 
                             1 
                           
                           + 
                           
                             C 
                             2 
                           
                         
                       
                       ⁢ 
                       
                         ( 
                         
                           
                             V 
                             H 
                           
                           - 
                           
                             V 
                             L 
                           
                         
                         ) 
                       
                     
                   
                 
               
               
                 
                   [ 
                   
                     Formula 
                     ⁢ 
                         
                     2 
                   
                   ] 
                 
               
             
           
         
       
     
     In a period from Time T 28  to Time T 30 , a potential input from the input terminal IT increases from the V GND  to V MAX  with time. That is, in the period from Time T 28  to Time T 30 , the potential input to the plus-side input terminal of the comparator CMP 1  increases up to the V MAX  with time. 
     In the case where the potential input from the input terminal IT reaches the V ref3  in Time T 29 , the potential input to the plus-side input terminal of the comparator CMP 1  (the potential input from the input terminal IT) becomes higher than the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  in a period from Time T 29  to Time T 30 , so that a high-level potential is output from the output terminal of the comparator CMP 1 . That is, a high-level potential is output from the output terminal OT. 
     A low-level potential is input to the second terminal of the NOR circuit LCNO, so that a high-level potential is output from the output terminal of the NOR circuit LCNO. Accordingly, a potential of the other of the pair of conductive regions (the node ND 2 ) of the capacitor C 2  becomes a low-level potential. Since the node ND 1  is in an electrically floating state, at this time, the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  is changed in accordance with a change in the potential of the second terminal (the node ND 2 ) of the capacitor C 2  and the values of electrostatic capacitance of the capacitors C 1  and C 2 . Note that the potential of the other of the pair of conductive regions (the node ND 2 ) of the capacitor C 2  in the period from Time T 29  to Time T 30  is a high-level potential the same as the potential of the other of the pair of conductive regions (the node ND 2 ) of the capacitor C 2  in the period from Time T 26  to Time T 27 , and thus the potential of the minus-side input terminal (the node ND 1 ) of the comparator CMP 1  in the period from Time T 29  to Time T 30  is V ref1 . 
     As described in the above operation example, the circuit configuration in  FIG.  4 B  can achieve a hysteresis comparator with a hysteresis width of V ref3 −V ref1 . 
     Configuration Example 4 
     In the hysteresis comparator HCMP 1  to the hysteresis comparator HCMP 6  described above in Configuration example 1 to Configuration example 3, the input terminal IT is electrically connected to the plus-side input terminal and the reference potential input terminal RT is electrically connected to the minus-side input terminal through the switch SW 1 ; however, one embodiment of the present invention is not limited to this. For example, the hysteresis comparator of one embodiment of the present invention may have a configuration in which the reference potential input terminal RT is electrically connected to the plus-side input terminal of the comparator CMP 1  through the switch SW 1  and the input terminal IT is electrically connected to the minus-side input terminal of the comparator CMP 1 , like a hysteresis comparator HCMP 7  illustrated in  FIG.  4 C . 
     Although the hysteresis comparator HCMP 1  to the hysteresis comparator HCMP 7  each have a configuration in which a potential in accordance with a potential input to the input terminal IT and a potential of the node ND 1  is output from the output terminal OT, one embodiment of the present invention is not limited to this. For example, the hysteresis comparator of one embodiment of the present invention may have a configuration in which an output terminal OTB electrically connected to the terminal VOT of the logic circuit LC may be additionally provided as an output terminal, like a hysteresis comparator HCMP 8  illustrated in  FIG.  4 D . Although the hysteresis comparator HCMP 8  in  FIG.  4 D  includes two output terminals the output terminal OT and the output terminal OTB, the hysteresis comparator of one embodiment of the present invention may include only the output terminal OTB as an output terminal. 
     As described above, any one of the hysteresis comparator HCMP 1  to the hysteresis comparator HCMP 8  can be employed. The hysteresis comparator HCMP 1  to the hysteresis comparator HCMP 8  can be used for a semiconductor device detecting overcharge or overdischarge of the cell CE. In some cases, the semiconductor device can detect overcharge or overdischarge of each of the plurality of cells CE electrically connected in series which are included in the assembled battery BAT. Operation of a conventional hysteresis comparator needs two constant voltages a high-level-side threshold voltage and a low-level-side threshold voltage as reference potentials, whereas the hysteresis comparator HCMP 1  to the hysteresis comparator HCMP 8  can be operated by input of one constant voltage to the reference potential input terminal. That is, supply of only one constant voltage as the reference potential is adequate for operation of the hysteresis comparator HCMP 1  to the hysteresis comparator HCMP 8 , which can reduce the area of a voltage generation circuit that is needed for generating the reference potential. The hysteresis comparator HCMP 1  to the hysteresis comparator HCMP 8  can each have a smaller circuit area and lower power consumption than a conventional hysteresis comparator. 
     Note that this embodiment can be combined with any of the other embodiments in this specification as appropriate. 
     Embodiment 2 
     In this embodiment, a specific example of the circuit CNC included in the semiconductor device  100  will be described. 
       FIG.  7    illustrates a configuration example of the circuit CNC. Note that  FIG.  7    also illustrates a hysteresis comparator HCMP to which the hysteresis comparator HCMP 1  to the hysteresis comparator HCMP 8  which have been described in Embodiment 1 can be applied and the cell CE, in addition to the circuit CNC.  FIG.  7    also illustrates a circuit CADC as a circuit having a function of controlling discharge and/or charge in the cell CE. 
     The hysteresis comparator HCMP includes the input terminal IT, the reference potential input terminal RT, and the output terminal OT, as described in Embodiment 1. The hysteresis comparator HCMP further includes a control terminal SH. The control terminal SH is a terminal electrically connected to the wiring SHE in each of the hysteresis comparator HCMP 1  to the hysteresis comparator HCMP 8  described in Embodiment 1. 
     The circuit CNC includes a control circuit CTL, a circuit CNV, and a circuit RPG. 
     The control circuit CTL is electrically connected to the circuit CNV, the circuit RPG, and the control terminal SH and the output terminal OT of the hysteresis comparator HCMP. In the case where the hysteresis comparator HCMP 8  is used as the hysteresis comparator HCMP, the control circuit CTL may be electrically connected to the output terminal OTB. 
     The input terminal CI 1  of the circuit CNC is electrically connected to the circuit CNV and the circuit RPG. The input terminal CI 2  of the circuit CNC is electrically connected to the circuit CNV and the circuit RPG. The input terminal CI 1  of the circuit CNC is electrically connected to a positive electrode terminal of the cell CE and the input terminal CI 2  of the circuit CNC is electrically connected to a negative electrode terminal of the cell CE, as described in Embodiment 1. That is, a potential of the positive electrode terminal and a potential of the negative electrode terminal of the cell CE are input to each of the circuit CNV and the circuit RPG. 
     The circuit CNV is electrically connected to the output terminal CO 1  of the circuit CNC, and the circuit RPG is electrically connected to the output terminal CO 2  of the circuit CNC. As described in Embodiment 1, the output terminal CO 1  of the circuit CNC is electrically connected to the input terminal IT of the hysteresis comparator HCMP, and the output terminal CO 2  of the circuit CNC is electrically connected to the reference potential input terminal RT of the hysteresis comparator HCMP. That is, the circuit CNV is electrically connected to the input terminal IT of the hysteresis comparator HCMP, and the circuit RPG is electrically connected to the reference potential input terminal RT of the hysteresis comparator HCMP. 
     The circuit CNV has a function of generating an input voltage to be input to the input terminal IT of the hysteresis comparator HCMP on the basis of a potential of the positive electrode terminal and a potential of the negative electrode terminal of the cell CE which are input to the circuit CNV. As the circuit CNV, a divider circuit or a converter circuit such as an analog-to-digital converter circuit (ADC), a digital-to-analog converter circuit (DAC), or a potential level converter circuit can be used, for example. The circuit CNV may have a function of holding a generated input voltage. 
     The circuit RPG is a circuit having a function of generating a reference potential to be input to the reference potential input terminal RT of the hysteresis comparator HCMP. For example, the circuit RPG can generate the reference potential on the basis of a potential of the positive electrode terminal and a potential of the negative electrode terminal of the cell CE which are input to the circuit RPG. That is, the circuit RPG can generate the reference potential corresponding to the cell CE and input the reference potential to the reference potential input terminal of the hysteresis comparator HCMP. The circuit RPG may have a function of holding the generated reference potential. 
     The control circuit CTL has a function of obtaining a change in a potential output from the output terminal OT of the hysteresis comparator HCMP and detecting overdischarge or overcharge in the cell CE. When the control circuit CTL detects overdischarge in the cell CE, the control circuit CTL may have a function of transmitting a certain signal for stopping discharge operation to the circuit CADC that controls discharge in the cell CE. When the control circuit CTL detects overcharge in the cell CE, the control circuit CTL may have a function of transmitting a certain signal for stopping charge operation to the circuit CADC that controls charge in the cell CE. 
     The control circuit CTL may have a function of controlling each of the hysteresis comparator HCMP, the circuit CNV, and the circuit RPG. Specifically, for example, the control circuit CTL can bring a switch SW 1  (a transistor TrS 1 ) included in the hysteresis comparator HCMP into one of an on state and an off state by supplying one of a high-level potential and a low-level potential to the control terminal SH of the hysteresis comparator HCMP. When the control circuit CTL temporarily stops the semiconductor device  100 , the control circuit CTL can stop the supply of power supply voltage to the circuit CNV and the circuit RPG by transmitting a certain signal to the circuit CNV and the circuit RPG, for example. In the case where the circuit CNV has a function of holding a generated input voltage, the control circuit CTL may have a function of transmitting a control signal for holding the input voltage to the circuit CNV, for example. In the case where the circuit RPG has a function of holding a generated reference potential, the control circuit CTL may have a function of transmitting a control signal for holding the reference potential to the circuit RPG, for example. 
     When the circuit CNC in the semiconductor device  100  has a configuration of the circuit CNC illustrated in  FIG.  7   , the semiconductor device  100  can detect an overcharge state or an overdischarge state in the cell CE using the reference potential based on a potential of the positive electrode terminal and a potential of the negative electrode terminal of the cell CE. 
     Note that this embodiment can be combined with any of the other embodiments in this specification as appropriate. 
     Embodiment 3 
     In this embodiment, structure examples of the semiconductor device described in the above embodiment and structure examples of a transistor that can be used in the semiconductor device will be described. 
     &lt;Structure Examples of Semiconductor Device&gt; 
     A semiconductor device illustrated in  FIG.  8    includes a transistor  300 , a transistor  500 , and a capacitor  600 .  FIG.  10 A  is a cross-sectional view of the transistor  500  in the channel length direction,  FIG.  10 B  is a cross-sectional view of the transistor  500  in the channel width direction, and  FIG.  10 C  is a cross-sectional view of the transistor  300  in the channel width direction. 
     The transistor  500  is a transistor including a metal oxide in its channel formation region (an OS transistor). Since the off-state current of the transistor  500  is low, the use of the transistor  500  in a semiconductor device, such as the transistor TrS 1  of the hysteresis comparator, enables long-term retention of written data. In other words, the frequency of refresh operation is low or refresh operation is not required; thus, power consumption of the semiconductor device can be reduced. 
     The semiconductor device described in this embodiment includes the transistor  300 , the transistor  500 , and the capacitor  600  as illustrated in  FIG.  8   . The transistor  500  is provided above the transistor  300 , and the capacitor  600  is provided above the transistor  300  and the transistor  500 . Note that the capacitor  600  can be the capacitor C 1 , the capacitor C 2 , or the like in the hysteresis comparator HCMP and the hysteresis comparator HCMP 1  to the hysteresis comparator HCMP 8  described in the above embodiments. 
     The transistor  300  is provided on a substrate  311  and includes a conductor  316 , an insulator  315 , a semiconductor region  313  that is part of the substrate  311 , and a low-resistance region  314   a  and a low-resistance region  314   b  functioning as a source region and a drain region. Note that the transistor  300  can be used as the transistor included in the comparator CMP 1  described in the above embodiment, for example. 
     A semiconductor substrate (e.g., a single crystal substrate or a silicon substrate) is preferably used as the substrate  311 . 
     As shown in  FIG.  10 C , in the transistor  300 , a top surface and a side surface in the channel width direction of the semiconductor region  313  are covered with the conductor  316  with the insulator  315  therebetween. Such a Fin-type transistor  300  can have an increased effective channel width, and thus the transistor  300  can have improved on-state characteristics. In addition, contribution of electric fields of the gate electrode can be increased, so that the off-state characteristics of the transistor  300  can be improved. 
     Note that the transistor  300  can be a p-channel transistor or an n-channel transistor. 
     A region of the semiconductor region  313  where a channel is formed, a region in the vicinity thereof, the low-resistance region  314   a  and the low-resistance region  314   b  functioning as the source region and the drain region, and the like preferably contain a semiconductor such as a silicon-based semiconductor, further preferably contain single crystal silicon. Alternatively, the regions may be formed using a material containing Ge (germanium), SiGe (silicon germanium), GaAs (gallium arsenide), GaAlAs (gallium aluminum arsenide), or the like. Silicon whose effective mass is adjusted by applying stress to the crystal lattice and thereby changing the lattice spacing may be used. Alternatively, the transistor  300  may be an HEMT (High Electron Mobility Transistor) with GaAs and GaAlAs, or the like. 
     The low-resistance region  314   a  and the low-resistance region  314   b  contain an element that imparts n-type conductivity, such as arsenic or phosphorus, or an element that imparts p-type conductivity, such as boron, in addition to a semiconductor material used for the semiconductor region  313 . 
     For the conductor  316  functioning as a gate electrode, a semiconductor material such as silicon containing an element that imparts n-type conductivity, such as arsenic or phosphorus, or an element that imparts p-type conductivity, such as boron, or a conductive material such as a metal material, an alloy material, or a metal oxide material can be used. 
     Note that the work function depends on a material used for a conductor; therefore, the threshold voltage of the transistor can be adjusted by selecting the material for the conductor. Specifically, it is preferable to use a material such as titanium nitride or tantalum nitride for the conductor. Moreover, in order to ensure both conductivity and embeddability, it is preferable to use stacked layers of metal materials such as tungsten and aluminum for the conductor, and it is particularly preferable to use tungsten in terms of heat resistance. 
     Note that the transistor  300  illustrated in  FIG.  8    is an example and the structure is not limited thereto; a transistor appropriate for a circuit structure or a driving method is used. For example, when a semiconductor device is a single-polarity circuit using only OS transistors, the transistor  300  has a structure similar to that of the transistor  500  using an oxide semiconductor, as illustrated in  FIG.  9   . Note that the details of the transistor  500  will be described later. 
     An insulator  320 , an insulator  322 , an insulator  324 , and an insulator  326  are stacked in this order to cover the transistor  300 . 
     For the insulator  320 , the insulator  322 , the insulator  324 , and the insulator  326 , silicon oxide, silicon oxynitride, silicon nitride oxide, silicon nitride, aluminum oxide, aluminum oxynitride, aluminum nitride oxide, or aluminum nitride can be used, for example. 
     Note that in this specification, silicon oxynitride refers to a material that has a higher oxygen content than a nitrogen content, and silicon nitride oxide refers to a material that has a higher nitrogen content than an oxygen content. Moreover, in this specification, aluminum oxynitride refers to a material that has a higher oxygen content than a nitrogen content, and aluminum nitride oxide refers to a material that has a higher nitrogen content than an oxygen content. 
     The insulator  322  may have a function of a planarization film for eliminating a level difference caused by the transistor  300  or the like provided below the insulator  322 . For example, the top surface of the insulator  322  may be planarized by planarization treatment using a chemical mechanical polishing (CMP) method or the like to improve planarity. 
     As the insulator  324 , it is preferable to use a film having a barrier property that prevents diffusion of hydrogen or impurities from the substrate  311 , the transistor  300 , or the like into a region where the transistor  500  is provided. 
     For the film having a barrier property against hydrogen, silicon nitride formed by a CVD method can be used, for example. The diffusion of hydrogen into a semiconductor element including an oxide semiconductor, such as the transistor  500 , may result in degradation of the characteristics of the semiconductor element. Therefore, a film that inhibits hydrogen diffusion is preferably used between the transistor  500  and the transistor  300 . The film that inhibits hydrogen diffusion is specifically a film from which a small amount of hydrogen is released. 
     The amount of released hydrogen can be measured by thermal desorption spectroscopy (TDS), for example. The amount of hydrogen released from the insulator  324  that is converted into hydrogen atoms per unit area of the insulator  324  is less than or equal to 10×10 15  atoms/cm 2 , preferably less than or equal to 5×10 15  atoms/cm′ in TDS analysis in a film-surface temperature range of 50° C. to 500° C., for example. 
     Note that the permittivity of the insulator  326  is preferably lower than that of the insulator  324 . For example, the relative permittivity of the insulator  326  is preferably lower than 4, further preferably lower than 3. The relative permittivity of the insulator  326  is, for example, preferably 0.7 times or less, further preferably 0.6 times or less that of the insulator  324 . The use of a material having a low permittivity for an interlayer film can reduce the parasitic capacitance between wirings. 
     A conductor  328 , a conductor  330 , and the like that are connected to the capacitor  600  or the transistor  500  are embedded in the insulator  320 , the insulator  322 , the insulator  324 , and the insulator  326 . Note that the conductor  328  and the conductor  330  have a function of a plug or a wiring. A plurality of conductors having a function of a plug or a wiring are collectively denoted by the same reference numeral in some cases. Furthermore, in this specification and the like, a wiring and a plug connected to the wiring may be a single component. That is, in some cases, part of a conductor functions as a wiring or part of a conductor functions as a plug. 
     As a material of each of plugs and wirings (e.g., the conductor  328  and the conductor  330 ), a single layer or a stacked layer of a conductive material such as a metal material, an alloy material, a metal nitride material, or a metal oxide material can be used. It is preferable to use a high-melting-point material that has both heat resistance and conductivity, such as tungsten or molybdenum, and it is particularly preferable to use tungsten. Alternatively, a low-resistance conductive material such as aluminum or copper is preferably used. The use of a low-resistance conductive material can reduce wiring resistance. 
     A wiring layer may be provided over the insulator  326  and the conductor  330 . For example, in  FIG.  8   , an insulator  350 , an insulator  352 , and an insulator  354  are provided to be stacked in this order. Furthermore, a conductor  356  is formed in the insulator  350 , the insulator  352 , and the insulator  354 . The conductor  356  has a function of a plug or a wiring that is connected to the transistor  300 . Note that the conductor  356  can be provided using a material similar to those for the conductor  328  and the conductor  330 . 
     As the insulator  350 , it is preferable to use, for example, an insulator having a barrier property against hydrogen, like the insulator  324 . Furthermore, the conductor  356  preferably includes a conductor having a barrier property against hydrogen. The conductor having a barrier property against hydrogen is formed particularly in an opening of the insulator  350  having a barrier property against hydrogen. With this structure, the transistor  300  and the transistor  500  can be separated by the barrier layer, so that the diffusion of hydrogen from the transistor  300  into the transistor  500  can be inhibited. 
     Note that as the conductor having a barrier property against hydrogen, tantalum nitride can be used, for example. Stacking tantalum nitride and tungsten having high conductivity can inhibit the diffusion of hydrogen from the transistor  300  while the conductivity of a wiring is ensured. In this case, a tantalum nitride layer having a barrier property against hydrogen is preferably in contact with the insulator  350  having a barrier property against hydrogen. 
     A wiring layer may be provided over the insulator  354  and the conductor  356 . For example, in  FIG.  8   , an insulator  360 , an insulator  362 , and an insulator  364  are provided to be stacked in this order. Moreover, a conductor  366  is formed in the insulator  360 , the insulator  362 , and the insulator  364 . The conductor  366  has a function of a plug or a wiring. Note that the conductor  366  can be provided using a material similar to those for the conductor  328  and the conductor  330 . 
     As the insulator  360 , it is preferable to use, for example, an insulator having a barrier property against hydrogen, like the insulator  324 . Furthermore, the conductor  366  preferably includes a conductor having a barrier property against hydrogen. The conductor having a barrier property against hydrogen is formed particularly in an opening of the insulator  360  having a barrier property against hydrogen. With this structure, the transistor  300  and the transistor  500  can be separated by the barrier layer, so that the diffusion of hydrogen from the transistor  300  into the transistor  500  can be inhibited. 
     A wiring layer may be provided over the insulator  364  and the conductor  366 . For example, in  FIG.  8   , an insulator  370 , an insulator  372 , and an insulator  374  are provided to be stacked in this order. Furthermore, a conductor  376  is formed in the insulator  370 , the insulator  372 , and the insulator  374 . The conductor  376  has a function of a plug or a wiring. Note that the conductor  376  can be provided using a material similar to those for the conductor  328  and the conductor  330 . 
     As the insulator  370 , it is preferable to use, for example, an insulator having a barrier property against hydrogen, like the insulator  324 . Furthermore, the conductor  376  preferably includes a conductor having a barrier property against hydrogen. The conductor having a barrier property against hydrogen is formed particularly in an opening of the insulator  370  having a barrier property against hydrogen. With this structure, the transistor  300  and the transistor  500  can be separated by the barrier layer, so that the diffusion of hydrogen from the transistor  300  into the transistor  500  can be inhibited. 
     A wiring layer may be provided over the insulator  374  and the conductor  376 . For example, in  FIG.  8   , an insulator  380 , an insulator  382 , and an insulator  384  are provided to be stacked in this order. Moreover, a conductor  386  is formed in the insulator  380 , the insulator  382 , and the insulator  384 . The conductor  386  has a function of a plug or a wiring. Note that the conductor  386  can be provided using a material similar to those for the conductor  328  and the conductor  330 . 
     As the insulator  380 , it is preferable to use, for example, an insulator having a barrier property against hydrogen, like the insulator  324 . Furthermore, the conductor  386  preferably includes a conductor having a barrier property against hydrogen. The conductor having a barrier property against hydrogen is formed particularly in an opening of the insulator  380  having a barrier property against hydrogen. With this structure, the transistor  300  and the transistor  500  can be separated by the barrier layer, so that the diffusion of hydrogen from the transistor  300  into the transistor  500  can be inhibited. 
     Although the wiring layer including the conductor  356 , the wiring layer including the conductor  366 , the wiring layer including the conductor  376 , and the wiring layer including the conductor  386  are described above, the semiconductor device of this embodiment is not limited thereto. The number of wiring layers similar to the wiring layer including the conductor  356  may be three or less, or the number of wiring layers similar to the wiring layer including the conductor  356  may be five or more. 
     An insulator  510 , an insulator  512 , an insulator  514 , and an insulator  516  are stacked in this order over the insulator  384 . A material with a barrier property against oxygen or hydrogen is preferably used for any of the insulator  510 , the insulator  512 , the insulator  514 , and the insulator  516 . 
     For example, as the insulator  510  and the insulator  514 , it is preferable to use a film having a barrier property that prevents diffusion of hydrogen or impurities from the substrate  311 , a region where the transistor  300  is provided, or the like into the region where the transistor  500  is provided. Therefore, a material similar to that for the insulator  324  can be used. 
     For the film having a barrier property against hydrogen, silicon nitride formed by a CVD method can be used, for example. The diffusion of hydrogen into a semiconductor element including an oxide semiconductor, such as the transistor  500 , may result in degradation of the characteristics of the semiconductor element. Therefore, a film that inhibits hydrogen diffusion is preferably used between the transistor  500  and the transistor  300 . The film that inhibits hydrogen diffusion is specifically a film from which a small amount of hydrogen is released. 
     For the film having a barrier property against hydrogen used for the insulator  510  and the insulator  514 , a metal oxide such as aluminum oxide, hafnium oxide, or tantalum oxide is preferably used, for example. 
     In particular, aluminum oxide has an excellent blocking effect that prevents transmission of oxygen and impurities such as hydrogen and moisture which would cause a change in the electrical characteristics of the transistor. Accordingly, the use of aluminum oxide can prevent entry of impurities such as hydrogen and moisture into the transistor  500  in and after the manufacturing process of the transistor. In addition, release of oxygen from the oxide included in the transistor  500  can be inhibited. Therefore, aluminum oxide is suitably used for a protective film of the transistor  500 . 
     For the insulator  512  and the insulator  516 , a material similar to that for the insulator  320  can be used, for example. The use of a material with a relatively low permittivity for these insulators can reduce the parasitic capacitance generated between wirings. A silicon oxide film or a silicon oxynitride film can be used for the insulator  512  and the insulator  516 , for example. 
     A conductor  518 , a conductor included in the transistor  500  (e.g., a conductor  503 ), and the like are embedded in the insulator  510 , the insulator  512 , the insulator  514 , and the insulator  516 . Note that the conductor  518  has a function of a plug or a wiring that is connected to the capacitor  600  or the transistor  300 . The conductor  518  can be provided using a material similar to those for the conductor  328  and the conductor  330 . 
     In particular, a region of the conductor  518  that is in contact with the insulator  510  and the insulator  514  is preferably a conductor having a barrier property against oxygen, hydrogen, and water. With this structure, the transistor  300  and the transistor  500  can be separated by the layer having a barrier property against oxygen, hydrogen, and water; hence, the diffusion of hydrogen from the transistor  300  into the transistor  500  can be inhibited. 
     The transistor  500  is provided over the insulator  516 . 
     As illustrated in  FIG.  10 A  and  FIG.  10 B , the transistor  500  includes the conductor  503  positioned to be embedded in the insulator  514  and the insulator  516 , an insulator  520  positioned over the insulator  516  and the conductor  503 , an insulator  522  positioned over the insulator  520 , an insulator  524  positioned over the insulator  522 , an oxide  530   a  positioned over the insulator  524 , an oxide  530   b  positioned over the oxide  530   a , a conductor  542   a  and a conductor  542   b  positioned apart from each other over the oxide  530   b , an insulator  580  that is positioned over the conductor  542   a  and the conductor  542   b  and is provided with an opening formed to overlap with a region between the conductor  542   a  and the conductor  542   b , an oxide  530   c  positioned on a bottom surface and a side surface of the opening, an insulator  550  positioned on the formation surface of the oxide  530   c , and a conductor  560  positioned on the formation surface of the insulator  550 . 
     As illustrated in  FIG.  10 A  and  FIG.  10 B , an insulator  544  is preferably provided between the insulator  580  and the oxide  530   a , the oxide  530   b , the conductor  542   a , and the conductor  542   b . As illustrated in  FIG.  10 A  and  FIG.  10 B , the conductor  560  preferably includes a conductor  560   a  provided inside the insulator  550  and a conductor  560   b  provided to be embedded inside the conductor  560   a . As illustrated in  FIG.  10 A  and  FIG.  10 B , an insulator  574  is preferably provided over the insulator  580 , the conductor  560 , and the insulator  550 . 
     Hereinafter, the oxide  530   a , the oxide  530   b , and the oxide  530   c  may be collectively referred to as an oxide  530 . 
     The transistor  500  has a structure in which the three layers of the oxide  530   a , the oxide  530   b , and the oxide  530   c  are stacked in the region where the channel is formed and its vicinity; however, the present invention is not limited to this. For example, the transistor may have a single-layer structure of the oxide  530   b , a two-layer structure of the oxide  530   b  and the oxide  530   a , a two-layer structure of the oxide  530   b  and the oxide  530   c , or a stacked-layer structure of four or more layers. Although the conductor  560  is shown to have a two-layer structure in the transistor  500 , the present invention is not limited to this. For example, the conductor  560  may have a single-layer structure or a stacked-layer structure of three or more layers. Moreover, the transistor  500  illustrated in  FIG.  8    and  FIG.  10 A  is an example and the structure is not limited thereto; an appropriate transistor is used in accordance with a circuit structure or a driving method. 
     Here, the conductor  560  functions as a gate electrode of the transistor, and the conductor  542   a  and the conductor  542   b  function as a source electrode and a drain electrode. As described above, the conductor  560  is embedded in an opening of the insulator  580  and the region sandwiched between the conductor  542   a  and the conductor  542   b . The positions of the conductor  560 , the conductor  542   a , and the conductor  542   b  are selected in a self-aligned manner with respect to the opening in the insulator  580 . That is, in the transistor  500 , the gate electrode can be positioned between the source electrode and the drain electrode in a self-aligned manner. Thus, the conductor  560  can be formed without an alignment margin, resulting in a reduction in the area occupied by the transistor  500 . Accordingly, miniaturization and high integration of the semiconductor device can be achieved. 
     Since the conductor  560  is formed in the region between the conductor  542   a  and the conductor  542   b  in a self-aligned manner, the conductor  560  has neither a region overlapping with the conductor  542   a  nor a region overlapping with the conductor  542   b . Thus, parasitic capacitance formed between the conductor  560  and each of the conductor  542   a  and the conductor  542   b  can be reduced. As a result, the transistor  500  can have increased switching speed and excellent frequency characteristics. 
     The conductor  560  functions as a first gate (also referred to as top gate) electrode in some cases. The conductor  503  functions as a second gate (also referred to as bottom gate) electrode in some cases. In that case, the threshold voltage of the transistor  500  can be controlled by changing a potential applied to the conductor  503  independently of a potential applied to the conductor  560 . In particular, when a negative potential is applied to the conductor  503 , the threshold voltage of the transistor  500  can be higher than 0 V, and the off-state current can be reduced. Thus, a drain current at the time when a potential applied to the conductor  560  is 0 V can be smaller in the case where a negative potential is applied to the conductor  503  than in the case where a negative potential is not applied to the conductor  503 . 
     The conductor  503  is positioned to overlap with the oxide  530  and the conductor  560 . Thus, when potentials are applied to the conductor  560  and the conductor  503 , an electric field generated from the conductor  560  and an electric field generated from the conductor  503  are connected and can cover the channel formation region formed in the oxide  530 . In this specification and the like, a transistor structure in which a channel formation region is electrically surrounded by electric fields of a first gate electrode and a second gate electrode is referred to as a surrounded channel (S-channel) structure. 
     The conductor  503  has a structure similar to that of the conductor  518 ; a conductor  503   a  is formed in contact with an inner wall of the opening in the insulator  514  and the insulator  516 , and a conductor  503   b  is formed further inside. Although the transistor  500  in which the conductor  503   a  and the conductor  503   b  are stacked is illustrated, the present invention is not limited thereto. For example, the conductor  503  may be provided as a single layer or to have a stacked-layer structure of three or more layers. 
     Here, for the conductor  503   a , a conductive material that has a function of inhibiting diffusion of impurities such as a hydrogen atom, a hydrogen molecule, a water molecule, and a copper atom (through which the impurities are less likely to pass) is preferably used. Alternatively, it is preferable to use a conductive material that has a function of inhibiting diffusion of oxygen (e.g., at least one of an oxygen atom, an oxygen molecule, and the like) (through which oxygen is less likely to pass). Note that in this specification, a function of inhibiting diffusion of impurities or oxygen means a function of inhibiting diffusion of any one or all of the above impurities and the above oxygen. 
     For example, when the conductor  503   a  has a function of inhibiting diffusion of oxygen, a reduction in conductivity of the conductor  503   b  due to oxidation can be inhibited. 
     When the conductor  503  also functions as a wiring, for the conductor  503   b , it is preferable to use a conductive material that has high conductivity and contains tungsten, copper, or aluminum as its main component. In that case, a conductor  505  is not necessarily provided. Note that the conductor  503   b  is a single layer in the diagram but may have a stacked-layer structure, for example, a stack of any of the above conductive materials and titanium or titanium nitrided. 
     The insulator  520 , the insulator  522 , and the insulator  524  have a function of a second gate insulating film. 
     Here, as the insulator  524  in contact with the oxide  530 , an insulator containing more oxygen than that in the stoichiometric composition is preferably used. That is, an excess-oxygen region is preferably formed in the insulator  524 . When such an insulator containing excess oxygen is provided in contact with the oxide  530 , oxygen vacancies in the oxide  530  can be reduced, and the reliability of the transistor  500  can be improved. 
     As the insulator including an excess-oxygen region, specifically, an oxide material that releases part of oxygen by heating is preferably used. An oxide that releases oxygen by heating is an oxide film in which the amount of released oxygen converted into oxygen atoms is greater than or equal to 1.0×10 18  atoms/cm 3 , preferably greater than or equal to 1.0×10 19  atoms/cm 3 , further preferably greater than or equal to 2.0×10 19  atoms/cm 3  or greater than or equal to 3.0×10 20  atoms/cm 3  in TDS (Thermal Desorption Spectroscopy) analysis. Note that the temperature of the film surface in the TDS analysis is preferably in the range of 100° C. to 700° C. or 100° C. to 400° C. 
     One or more of heat treatment, microwave treatment, and RF treatment may be performed in a state in which the insulator including the excess-oxygen region and the oxide  530  are in contact with each other. By the treatment, water or hydrogen in the oxide  530  can be removed. For example, in the oxide  530 , dehydrogenation can be performed when a reaction in which a bond of V O H is cut occurs, i.e., a reaction of “V O H→V O +H” occurs. Part of hydrogen generated at this time is bonded to oxygen to be H 2 O, and removed from the oxide  530  or an insulator in the vicinity of the oxide  530  in some cases. Part of hydrogen is diffused into or gettered (also referred to as gettering) by the conductor  542   a  and the conductor  542   b  in some cases. 
     For the microwave treatment, for example, an apparatus including a power supply that generates high-density plasma or an apparatus including a power supply that applies RF to the substrate side is suitably used. For example, the use of an oxygen-containing gas and high-density plasma enables high-density oxygen radicals to be generated, and application of the RF to the substrate side allows the oxygen radicals generated by the high-density plasma to be efficiently introduced into the oxide  530  or an insulator in the vicinity of the oxide  530 . The pressure in the microwave treatment is higher than or equal to 133 Pa, preferably higher than or equal to 200 Pa, further preferably higher than or equal to 400 Pa. As a gas introduced into an apparatus for performing the microwave treatment, for example, oxygen and argon are used and the oxygen flow rate (O 2 /(O 2 +Ar)) is lower than or equal to 50%, preferably higher than or equal to 10% and lower than or equal to 30%. 
     In a manufacturing process of the transistor  500 , the heat treatment is preferably performed with the surface of the oxide  530  exposed. The heat treatment is performed at higher than or equal to 100° C. and lower than or equal to 450° C., preferably higher than or equal to 350° C. and lower than or equal to 400° C. Note that the heat treatment is performed in a nitrogen gas or inert gas atmosphere, or an atmosphere containing an oxidizing gas at 10 ppm or more, 1% or more, or 10% or more. For example, the heat treatment is preferably performed in an oxygen atmosphere. Accordingly, oxygen can be supplied to the oxide  530  to reduce oxygen vacancies (V O ). Alternatively, the heat treatment may be performed under reduced pressure. Alternatively, the heat treatment may be performed in such a manner that heat treatment is performed in a nitrogen gas or inert gas atmosphere, and then another heat treatment is performed in an atmosphere containing an oxidizing gas at 10 ppm or more, 1% or more, or 10% or more in order to compensate for released oxygen. Alternatively, the heat treatment may be performed in such a manner that heat treatment is performed in an atmosphere containing an oxidizing gas at 10 ppm or more, 1% or more, or 10% or more, and then another heat treatment is performed in a nitrogen gas or inert gas atmosphere. 
     Note that the oxygen adding treatment performed on the oxide  530  can promote a reaction in which oxygen vacancies in the oxide  530  are filled with supplied oxygen, i.e., a reaction of “V O +O→null”. Furthermore, hydrogen remaining in the oxide  530  reacts with supplied oxygen, so that the hydrogen can be removed as H 2 O (dehydration). This can inhibit recombination of hydrogen remaining in the oxide  530  with oxygen vacancies and formation of V O H. 
     When the insulator  524  includes an excess-oxygen region, it is preferable that the insulator  522  have a function of inhibiting diffusion of oxygen (e.g., oxygen atoms and oxygen molecules) (or that the insulator  522  be less likely to transmit the above oxygen). 
     The insulator  522  preferably has a function of inhibiting diffusion of oxygen or impurities, in which case diffusion of oxygen contained in the oxide  530  to the insulator  520  side is prevented. Furthermore, the conductor  503  can be prevented from reacting with oxygen in the insulator  524  or the oxide  530 . 
     The insulator  522  is preferably a single layer or stacked layers using an insulator containing a high-k material such as aluminum oxide, hafnium oxide, an oxide containing aluminum and hafnium (hafnium aluminate), tantalum oxide, zirconium oxide, lead zirconate titanate (PZT), strontium titanate (SrTiO 3 ), or (Ba,Sr)TiO 3  (BST). As miniaturization and high integration of transistors progress, a problem such as leakage current may arise because of a thinner gate insulating film. When a high-k material is used for an insulator functioning as the gate insulating film, a gate potential at the time when the transistor operates can be lowered while the physical thickness of the gate insulating film is maintained. 
     It is particularly preferable to use an insulator containing an oxide of one or both of aluminum and hafnium, which is an insulating material having a function of inhibiting diffusion of impurities, oxygen, and the like (i.e., an insulating material through which the above oxygen is less likely to pass). As the insulator containing an oxide of one or both of aluminum and hafnium, aluminum oxide, hafnium oxide, an oxide containing aluminum and hafnium (hafnium aluminate), or the like is preferably used. In the case where the insulator  522  is formed using such a material, the insulator  522  functions as a layer that inhibits release of oxygen from the oxide  530  and entry of impurities such as hydrogen from the periphery of the transistor  500  into the oxide  530 . 
     Alternatively, aluminum oxide, bismuth oxide, germanium oxide, niobium oxide, silicon oxide, titanium oxide, tungsten oxide, yttrium oxide, or zirconium oxide may be added to these insulators, for example. Alternatively, these insulators may be subjected to nitriding treatment. Silicon oxide, silicon oxynitride, or silicon nitride may be stacked over the above insulator. 
     It is preferable that the insulator  520  be thermally stable. For example, silicon oxide and silicon oxynitride, which have thermal stability, are suitable. Furthermore, when an insulator that is a high-k material is combined with silicon oxide or silicon oxynitride, the insulator  520  having a stacked-layer structure that has thermal stability and a high relative permittivity can be obtained. 
     Note that the transistor  500  in  FIG.  10 A  and  FIG.  10 B  includes the insulator  520 , the insulator  522 , and the insulator  524  as the second gate insulating film having a three-layer structure; however, the second gate insulating film may have a single-layer structure, a two-layer structure, or a stacked-layer structure of four or more layers. In such cases, without limitation to a stacked-layer structure formed of the same material, a stacked-layer structure formed of different materials may be employed. 
     In the transistor  500 , a metal oxide functioning as an oxide semiconductor is preferably used as the oxide  530  including a channel formation region. For example, as the oxide  530 , a metal oxide such as an In-M-Zn oxide (the element M is one or more selected from aluminum, gallium, yttrium, copper, vanadium, beryllium, boron, titanium, iron, nickel, germanium, zirconium, molybdenum, lanthanum, cerium, neodymium, hafnium, tantalum, tungsten, magnesium, and the like) is used. In particular, the In-M-Zn oxide which can be used for the oxide  530  is preferably a CAAC-OS (C-Axis Aligned Crystalline Oxide Semiconductor) or a CAC-OS (Cloud-Aligned Composite Oxide Semiconductor). Alternatively, an In—Ga oxide or an In—Zn oxide may be used as the oxide  530 . 
     Furthermore, a metal oxide with a low carrier concentration is preferably used for the transistor  500 . In the case where the carrier concentration of the metal oxide is reduced, the concentration of impurities in the metal oxide is reduced so that the density of defect states is reduced. In this specification and the like, a state with a low impurity concentration and a low density of defect states is referred to as a highly purified intrinsic or substantially highly purified intrinsic state. As examples of the impurities in the metal oxide, hydrogen, nitrogen, alkali metal, alkaline earth metal, iron, nickel, silicon, and the like are given. 
     In particular, hydrogen contained in a metal oxide reacts with oxygen bonded to a metal atom to be water, and thus forms oxygen vacancies in the metal oxide in some cases. In the case where hydrogen enters an oxygen vacancy in the oxide  530 , the oxygen vacancy and the hydrogen are bonded to each other to form V O H in some cases. The V O H serves as a donor and an electron that is a carrier is generated in some cases. In other cases, bonding of part of hydrogen to oxygen bonded to a metal atom generates electrons serving as carriers. Thus, a transistor using a metal oxide containing much hydrogen is likely to have normally-on characteristics. Moreover, hydrogen in a metal oxide easily moves by stress such as heat and an electric field; thus, the reliability of a transistor may be low when the metal oxide contains a plenty of hydrogen. In one embodiment of the present invention, V O H in the oxide  530  is preferably reduced as much as possible so that the oxide  530  becomes a highly purified intrinsic or substantially highly purified intrinsic oxide. It is important to remove impurities such as moisture and hydrogen in a metal oxide (sometimes described as dehydration or dehydrogenation treatment) and to compensate for oxygen vacancies by supplying oxygen to the metal oxide (sometimes described as oxygen supplying treatment) to obtain a metal oxide whose V O H is reduced enough. When a metal oxide in which impurities such as V O H are sufficiently reduced is used for a channel formation region of a transistor, stable electrical characteristics can be given. 
     A defect in which hydrogen has entered an oxygen vacancy can function as a donor of the metal oxide. However, it is difficult to evaluate the defects quantitatively. Thus, the metal oxide is sometimes evaluated by not its donor concentration but its carrier concentration. Therefore, in this specification and the like, the carrier concentration assuming the state where an electric field is not applied is sometimes used, instead of the donor concentration, as the parameter of the metal oxide. That is, “carrier concentration” in this specification and the like can be replaced with “donor concentration” in some cases. 
     Therefore, when a metal oxide is used as the oxide  530 , hydrogen in the metal oxide is preferably reduced as much as possible. Specifically, the hydrogen concentration of the metal oxide, which is measured by secondary ion mass spectrometry (SIMS), is lower than 1×10 20  atoms/cm 3 , preferably lower than 1×10 19  atoms/cm 3 , further preferably lower than 5×10 18  atoms/cm 3 , still further preferably lower than 1×10 18  atoms/cm 3 . When a metal oxide with sufficiently reduced concentration of impurities such as hydrogen is used for a channel formation region of a transistor, stable electrical characteristics can be given. 
     In the case where a metal oxide is used as the oxide  530 , the metal oxide is an intrinsic (also referred to as i-type) or substantially intrinsic semiconductor that has a large band gap, and the carrier concentration of the metal oxide in the channel formation region is preferably lower than 1×10 18  cm −3 , further preferably lower than 1×10 17  cm −3 , still further preferably lower than 1×10 16  cm −3 , yet further preferably lower than 1×10 13  cm −3 , yet still further preferably lower than 1×10 12  cm −3 . Note that the lower limit of the carrier concentration of the metal oxide in the channel formation region is not particularly limited and can be, for example, 1×10 −9  cm −3 . 
     When a metal oxide is used as the oxide  530 , contact between the oxide  530  and each of the conductor  542   a  and the conductor  542   b  may diffuse oxygen in the oxide  530  into the conductor  542   a  and the conductor  542   b , resulting in oxidation of the conductor  542   a  and the conductor  542   b . It is highly possible that oxidation of the conductor  542   a  and the conductor  542   b  lowers the conductivity of the conductor  542   a  and the conductor  542   b . Note that diffusion of oxygen from the oxide  530  into the conductor  542   a  and the conductor  542   b  can be interpreted as absorption of oxygen in the oxide  530  by the conductor  542   a  and the conductor  542   b.    
     When oxygen in the oxide  530  is diffused into the conductor  542   a  and the conductor  542   b , a layer is sometimes formed between the conductor  542   a  and the oxide  530   b  and between the conductor  542   b  and the oxide  530   b . Since the layer contains a larger amount of oxygen than the conductor  542   a  and the conductor  542   b , the layer seems to have an insulating property. In this case, a three-layer structure of the conductor  542   a  or the conductor  542   b , the layer, and the oxide  530   b  can be regarded as a three-layer structure of a metal, an insulator, and a semiconductor and is sometimes referred to as a MIS (Metal-Insulator-Semiconductor) structure or referred to as a diode-connected structure mainly formed of the MIS structure. 
     The above layer is not necessarily formed between the oxide  530   b  and each of the conductor  542   a  and the conductor  542   b ; for example, the layer may be formed between the oxide  530   c  and each of the conductor  542   a  and the conductor  542   b , or between the oxide  530   b  and each of the conductor  542   a  and the conductor  542   b  and between the oxide  530   c  and each of the conductor  542   a  and the conductor  542   b.    
     The metal oxide functioning as the channel formation region in the oxide  530  has a band gap of preferably 2 eV or higher, further preferably 2.5 eV or higher. The use of a metal oxide having a wide band gap can reduce the off-state current of the transistor. 
     By including the oxide  530   a  under the oxide  530   b , the oxide  530  can inhibit diffusion of impurities into the oxide  530   b  from the components formed below the oxide  530   a . Moreover, including the oxide  530   c  over the oxide  530   b  makes it possible to inhibit diffusion of impurities into the oxide  530   b  from the components formed above the oxide  530   c.    
     The oxide  530  preferably has a stacked-layer structure of a plurality of oxide layers that differ in the atomic ratio of metal atoms. Specifically, the atomic proportion of the element M to the constituent elements in the metal oxide used as the oxide  530   a  is preferably greater than the atomic proportion of the element M to the constituent elements in the metal oxide used as the oxide  530   b . The atomic proportion of the element M to In in the metal oxide used as the oxide  530   a  is preferably greater than the atomic proportion of the element M to In in the metal oxide used as the oxide  530   b . The atomic proportion of In to the element M in the metal oxide used as the oxide  530   b  is preferably greater than the atomic proportion of In to the element M in the metal oxide used as the oxide  530   a . As the oxide  530   c , a metal oxide that can be used as the oxide  530   a  or the oxide  530   b  can be used. 
     Specifically, as the oxide  530   a , a metal oxide with In:Ga:Zn=1:3:4 [atomic ratio] or 1:1:0.5 [atomic ratio] is used. As the oxide  530   b , a metal oxide with In:Ga:Zn=4:2:3 [atomic ratio] or 1:1:1 [atomic ratio] is used. As the oxide  530   c , a metal oxide with In:Ga:Zn=1:3:4 [atomic ratio], Ga:Zn=2:1 [atomic ratio], or Ga:Zn=2:5 [atomic ratio] is used. Specific examples of the oxide  530   c  having a stacked-layer structure include a stacked-layer structure of In:Ga:Zn=4:2:3 [atomic ratio] and In:Ga:Zn=1:3:4 [atomic ratio], a stacked-layer structure of Ga:Zn=2:1 [atomic ratio] and In:Ga:Zn=4:2:3 [atomic ratio], a stacked-layer structure of Ga:Zn=2:5 [atomic ratio] and In:Ga:Zn=4:2:3 [atomic ratio] and, and a stacked-layer structure of gallium oxide and In:Ga:Zn=4:2:3 [atomic ratio]. 
     The energy of the conduction band minimum of the oxide  530   a  and the oxide  530   c  is preferably higher than the energy of the conduction band minimum of the oxide  530   b . In other words, the electron affinity of the oxide  530   a  and the oxide  530   c  is preferably smaller than the electron affinity of the oxide  530   b.    
     Here, the energy level of the conduction band minimum is gradually varied at junction portions of the oxide  530   a , the oxide  530   b , and the oxide  530   c . In other words, the energy level of the conduction band minimum at the junction portions of the oxide  530   a , the oxide  530   b , and the oxide  530   c  is continuously varied or continuously connected. To vary the energy level gradually, the density of defect states in a mixed layer formed at the interface between the oxide  530   a  and the oxide  530   b  and the interface between the oxide  530   b  and the oxide  530   c  is decreased. 
     Specifically, when the oxide  530   a  and the oxide  530   b  or the oxide  530   b  and the oxide  530   c  contain the same element (as a main component) in addition to oxygen, a mixed layer with a low density of defect states can be formed. For example, in the case where the oxide  530   b  is an In—Ga—Zn oxide, it is preferable to use an In—Ga—Zn oxide, a Ga—Zn oxide, gallium oxide, or the like as the oxide  530   a  and the oxide  530   c.    
     At this time, the oxide  530   b  serves as a main carrier path. When the oxide  530   a  and the oxide  530   c  have the above structure, the density of defect states at the interface between the oxide  530   a  and the oxide  530   b  and the interface between the oxide  530   b  and the oxide  530   c  can be made low. Thus, the influence of interface scattering on carrier conduction is small, and the transistor  500  can have a high on-state current. 
     The conductor  542   a  and the conductor  542   b  functioning as the source electrode and the drain electrode are provided over the oxide  530   b . For the conductor  542   a  and the conductor  542   b , it is preferable to use a metal element selected from aluminum, chromium, copper, silver, gold, platinum, tantalum, nickel, titanium, molybdenum, tungsten, hafnium, vanadium, niobium, manganese, magnesium, zirconium, beryllium, indium, ruthenium, iridium, strontium, and lanthanum; an alloy containing any of the above metal elements; an alloy containing a combination of the above metal elements; or the like. For example, it is preferable to use tantalum nitride, titanium nitride, tungsten, a nitride containing titanium and aluminum, a nitride containing tantalum and aluminum, ruthenium oxide, ruthenium nitride, an oxide containing strontium and ruthenium, an oxide containing lanthanum and nickel, or the like. Tantalum nitride, titanium nitride, a nitride containing titanium and aluminum, a nitride containing tantalum and aluminum, ruthenium oxide, ruthenium nitride, an oxide containing strontium and ruthenium, and an oxide containing lanthanum and nickel are preferable because they are oxidation-resistant conductive materials or materials that hold their conductivity even after absorbing oxygen. Furthermore, a metal nitride film of tantalum nitride or the like is preferable because it has a barrier property against hydrogen or oxygen. 
     In addition, although the conductor  542   a  and the conductor  542   b  each having a single-layer structure are illustrated in  FIG.  10 A  and  FIG.  10 B , a stacked-layer structure of two or more layers may be employed. For example, a tantalum nitride film and a tungsten film can be stacked. Alternatively, a titanium film and an aluminum film may be stacked. Alternatively, a two-layer structure in which an aluminum film is stacked over a tungsten film, a two-layer structure in which a copper film is stacked over a copper-magnesium-aluminum alloy film, a two-layer structure in which a copper film is stacked over a titanium film, or a two-layer structure in which a copper film is stacked over a tungsten film may be employed. 
     Other examples include a three-layer structure in which a titanium film or a titanium nitride film is formed, an aluminum film or a copper film is stacked over the titanium film or the titanium nitride film, and a titanium film or a titanium nitride film is formed over the aluminum film or the copper film; and a three-layer structure in which a molybdenum film or a molybdenum nitride film is formed, an aluminum film or a copper film is stacked over the molybdenum film or the molybdenum nitride film, and a molybdenum film or a molybdenum nitride film is formed over the aluminum film or the copper film. Note that a transparent conductive material containing indium oxide, tin oxide, or zinc oxide may be used. 
     As illustrated in  FIG.  10 A , a region  543   a  and a region  543   b  are sometimes formed as low-resistance regions in the oxide  530  at and around the interface with the conductor  542   a  (the conductor  542   b ). In this case, the region  543   a  functions as one of a source region and a drain region, and the region  543   b  functions as the other of the source region and the drain region. The channel formation region is formed in a region between the region  543   a  and the region  543   b.    
     When the conductor  542   a  (the conductor  542   b ) is provided in contact with the oxide  530 , the oxygen concentration of the region  543   a  (the region  543   b ) sometimes decreases. In addition, a metal compound layer that contains the metal contained in the conductor  542   a  (the conductor  542   b ) and the component of the oxide  530  is sometimes formed in the region  543   a  (the region  543   b ). In such a case, the carrier concentration of the region  543   a  (the region  543   b ) increases, and the region  543   a  (the region  543   b ) becomes a low-resistance region. 
     The insulator  544  is provided to cover the conductor  542   a  and the conductor  542   b  and inhibits oxidation of the conductor  542   a  and the conductor  542   b . Here, the insulator  544  may be provided to cover the side surface of the oxide  530  and to be in contact with the insulator  524 . 
     A metal oxide containing one or more selected from hafnium, aluminum, gallium, yttrium, zirconium, tungsten, titanium, tantalum, nickel, germanium, neodymium, lanthanum, magnesium, and the like can be used as the insulator  544 . Moreover, silicon nitride oxide, silicon nitride, or the like can be used as the insulator  544 . 
     It is particularly preferable to use an insulator containing an oxide of one or both of aluminum and hafnium, such as aluminum oxide, hafnium oxide, or an oxide containing aluminum and hafnium (hafnium aluminate), as the insulator  544 . In particular, hafnium aluminate has higher heat resistance than a hafnium oxide film. Therefore, hafnium aluminate is preferable because it is less likely to be crystallized by heat treatment in a later step. Note that the insulator  544  is not an essential component when the conductor  542   a  and the conductor  542   b  are oxidation-resistant materials or do not significantly lose the conductivity even after absorbing oxygen. Design is appropriately determined in consideration of required transistor characteristics. 
     With the insulator  544 , diffusion of impurities such as water and hydrogen contained in the insulator  580  into the oxide  530   b  through the oxide  530   c  and the insulator  550  can be inhibited. Moreover, oxidation of the conductor  560  due to excess oxygen contained in the insulator  580  can be inhibited. 
     The insulator  550  functions as a first gate insulating film. The insulator  550  is preferably provided in contact with the inner side (the top surface and the side surface) of the oxide  530   c . Like the insulator  524  described above, the insulator  550  is preferably formed using an insulator that contains excess oxygen and releases oxygen by heating. 
     Specifically, it is possible to use any of silicon oxide, silicon oxynitride, silicon nitride oxide, silicon nitride, silicon oxide to which fluorine is added, silicon oxide to which carbon is added, silicon oxide to which carbon and nitrogen are added, and porous silicon oxide, each of which contains excess oxygen. In particular, silicon oxide and silicon oxynitride, which have thermal stability, are preferable. 
     When an insulator from which oxygen is released by heating is provided as the insulator  550  in contact with the top surface of the oxide  530   c , oxygen can be effectively supplied from the insulator  550  to the channel formation region of the oxide  530   b  through the oxide  530   c . Furthermore, as in the insulator  524 , the concentration of impurities such as water or hydrogen in the insulator  550  is preferably lowered. The thickness of the insulator  550  is preferably greater than or equal to 1 nm and less than or equal to 20 nm. 
     In order to efficiently supply excess oxygen of the insulator  550  to the oxide  530 , a metal oxide may be provided between the insulator  550  and the conductor  560 . The metal oxide preferably inhibits oxygen diffusion from the insulator  550  into the conductor  560 . Providing the metal oxide that inhibits oxygen diffusion suppresses diffusion of excess oxygen from the insulator  550  into the conductor  560 . That is, a reduction in the amount of excess oxygen supplied to the oxide  530  can be inhibited. Moreover, oxidation of the conductor  560  due to excess oxygen can be suppressed. For the metal oxide, a material that can be used for the insulator  544  is used. 
     Note that the insulator  550  may have a stacked-layer structure like the second gate insulating film. As miniaturization and high integration of transistors progress, a problem such as leakage current may arise because of a thinner gate insulating film; for that reason, when the insulator functioning as a gate insulating film has a stacked-layer structure of a high-k material and a thermally stable material, a gate potential at the time when the transistor operates can be lowered while the physical thickness of the gate insulating film is maintained. Furthermore, the stacked-layer structure can be thermally stable and have a high relative permittivity. 
     Although the conductor  560  functioning as the first gate electrode has a two-layer structure in  FIG.  10 A  and  FIG.  10 B , the conductor  560  may have a single-layer structure or a stacked-layer structure of three or more layers. 
     For the conductor  560   a , it is preferable to use a conductive material having a function of inhibiting diffusion of impurities such as a hydrogen atom, a hydrogen molecule, a water molecule, a nitrogen atom, a nitrogen molecule, a nitrogen oxide molecule (e.g., N 2 O, NO, and NO 2 ), and a copper atom. Alternatively, it is preferable to use a conductive material having a function of inhibiting diffusion of oxygen (e.g., at least one of oxygen atoms, oxygen molecules, and the like). When the conductor  560   a  has a function of inhibiting diffusion of oxygen, it is possible to inhibit a reduction in conductivity of the conductor  560   b  due to oxidation of the conductor  560   b  caused by oxygen in the insulator  550 . As a conductive material having a function of inhibiting oxygen diffusion, tantalum, tantalum nitride, ruthenium, or ruthenium oxide is preferably used, for example. In addition, for the conductor  560   a , the oxide semiconductor that can be used as the oxide  530  can be used. In that case, when the conductor  560   b  is deposited by a sputtering method, the conductor  560   a  can have a reduced electric resistance to be a conductor. This can be referred to as an OC (Oxide Conductor) electrode. 
     For the conductor  560   b , it is preferable to use a conductive material containing tungsten, copper, or aluminum as its main component. The conductor  560   b  also functions as a wiring and thus a conductor having high conductivity is preferably used. For example, a conductive material containing tungsten, copper, or aluminum as its main component can be used. The conductor  560   b  may have a stacked-layer structure, for example, a stacked-layer structure of titanium or titanium nitride and any of the above conductive materials. 
     The insulator  580  is provided over the conductor  542   a  and the conductor  542   b  with the insulator  544  positioned therebetween. The insulator  580  preferably includes an excess-oxygen region. For example, the insulator  580  preferably contains silicon oxide, silicon oxynitride, silicon nitride oxide, silicon nitride, silicon oxide to which fluorine is added, silicon oxide to which carbon is added, silicon oxide to which carbon and nitrogen are added, porous silicon oxide, a resin, or the like. Silicon oxide and silicon oxynitride are particularly preferable in terms of high thermal stability. Silicon oxide and porous silicon oxide are particularly preferable because an excess-oxygen region can be formed easily in a later step. 
     The insulator  580  preferably includes an excess-oxygen region. When the insulator  580  from which oxygen is released by heating is provided in contact with the oxide  530   c , oxygen in the insulator  580  can be efficiently supplied to the oxide  530  through the oxide  530   c . The concentration of impurities such as water or hydrogen in the insulator  580  is preferably lowered. 
     The opening of the insulator  580  overlaps with the region between the conductor  542   a  and the conductor  542   b . Accordingly, the conductor  560  is formed to be embedded in the opening of the insulator  580  and the region sandwiched between the conductor  542   a  and the conductor  542   b.    
     For miniaturization of the semiconductor device, the gate length needs to be short, but it is necessary to prevent a reduction in conductivity of the conductor  560 . When the conductor  560  is made thick to achieve this, the conductor  560  might have a shape with a high aspect ratio. Even when the conductor  560  has a shape with a high aspect ratio, the conductor  560  can be formed without collapsing during the process because the conductor  560  is provided to be embedded in the opening of the insulator  580  in this embodiment. 
     The insulator  574  is preferably provided in contact with the top surface of the insulator  580 , the top surface of the conductor  560 , and the top surface of the insulator  550 . When the insulator  574  is deposited by a sputtering method, an excess-oxygen region can be provided in the insulator  550  and the insulator  580 . Thus, oxygen can be supplied from the excess-oxygen regions to the oxide  530 . 
     For example, a metal oxide containing one or more selected from hafnium, aluminum, gallium, yttrium, zirconium, tungsten, titanium, tantalum, nickel, germanium, magnesium, and the like can be used as the insulator  574 . 
     In particular, aluminum oxide has a high barrier property, and even a thin aluminum oxide film having a thickness of greater than or equal to 0.5 nm and less than or equal to 3.0 nm can inhibit diffusion of hydrogen and nitrogen. Accordingly, an aluminum oxide film deposited by a sputtering method can serve both as an oxygen supply source and as a barrier film against impurities such as hydrogen. 
     An insulator  581  functioning as an interlayer film is preferably provided over the insulator  574 . As in the insulator  524  and the like, the concentration of impurities such as water or hydrogen in the insulator  581  is preferably lowered. 
     A conductor  540   a  and a conductor  540   b  are provided in openings formed in the insulator  581 , the insulator  574 , the insulator  580 , and the insulator  544 . The conductor  540   a  and the conductor  540   b  are provided to face each other with the conductor  560  sandwiched therebetween. The conductor  540   a  and the conductor  540   b  each have a structure similar to that of a conductor  546  and a conductor  548  that will be described later. 
     An insulator  582  is provided over the insulator  581 . A material having a barrier property against oxygen and hydrogen is preferably used for the insulator  582 . Thus, the insulator  582  can be provided using a material similar to that for the insulator  514 . For example, a metal oxide such as aluminum oxide, hafnium oxide, or tantalum oxide is preferably used for the insulator  582 . 
     In particular, aluminum oxide has an excellent blocking effect that prevents transmission of oxygen and impurities such as hydrogen and moisture which would cause a change in the electrical characteristics of the transistor. Accordingly, the use of aluminum oxide can prevent entry of impurities such as hydrogen and moisture into the transistor  500  in and after the manufacturing process of the transistor. In addition, release of oxygen from the oxide included in the transistor  500  can be inhibited. Therefore, aluminum oxide is suitably used for a protective film of the transistor  500 . 
     An insulator  586  is provided over the insulator  582 . The insulator  586  can be provided using a material similar to that for the insulator  320 . The use of a material with a relatively low permittivity for these insulators can reduce the parasitic capacitance generated between wirings. For example, a silicon oxide film or a silicon oxynitride film can be used for the insulator  586 . 
     The conductor  546 , the conductor  548 , and the like are embedded in the insulator  520 , the insulator  522 , the insulator  524 , the insulator  544 , the insulator  580 , the insulator  574 , the insulator  581 , the insulator  582 , and the insulator  586 . 
     The conductor  546  and the conductor  548  function as plugs or wirings that are connected to the capacitor  600 , the transistor  500 , or the transistor  300 . The conductor  546  and the conductor  548  can be provided using a material similar to those for the conductor  328  and the conductor  330 . 
     Note that after the transistor  500  is formed, an opening may be formed to surround the transistor  500  and an insulator having a high barrier property against hydrogen or water may be formed to cover the opening. Surrounding the transistor  500  by the insulator having a high barrier property can prevent entry of moisture and hydrogen from the outside. Alternatively, a plurality of transistors  500  may be collectively surrounded by the insulator having a high barrier property against hydrogen or water. When an opening is formed to surround the transistor  500 , for example, the formation of an opening reaching the insulator  514  or the insulator  522  and the formation of the insulator having a high barrier property in contact with the insulator  514  or the insulator  522  are suitable because these formation steps can also serve as some of the manufacturing steps of the transistor  500 . The insulator having a high barrier property against hydrogen or water is provided using a material similar to that for the insulator  522 , for example. 
     The capacitor  600  is provided above the transistor  500 . The capacitor  600  includes a conductor  610 , a conductor  620 , and an insulator  630 . 
     A conductor  612  may be provided over the conductor  546  and the conductor  548 . The conductor  612  has a function of a plug or a wiring that is connected to the transistor  500 . The conductor  610  has a function of an electrode of the capacitor  600 . The conductor  612  and the conductor  610  can be formed at the same time. 
     As the conductor  612  and the conductor  610 , it is possible to use a metal film containing an element selected from molybdenum, titanium, tantalum, tungsten, aluminum, copper, chromium, neodymium, and scandium; a metal nitride film containing any of the above elements as its component (a tantalum nitride film, a titanium nitride film, a molybdenum nitride film, or a tungsten nitride film); or the like. Alternatively, it is possible to use a conductive material such as indium tin oxide, indium oxide containing tungsten oxide, indium zinc oxide containing tungsten oxide, indium oxide containing titanium oxide, indium tin oxide containing titanium oxide, indium zinc oxide, or indium tin oxide to which silicon oxide is added. 
     The conductor  612  and the conductor  610  each have a single-layer structure in  FIG.  8   ; however, the structure is not limited thereto, and a stacked-layer structure of two or more layers may be employed. For example, between a conductor having a barrier property and a conductor having high conductivity, a conductor that is highly adhesive to the conductor having a barrier property and the conductor having high conductivity may be formed. 
     The conductor  620  is provided so as to overlap with the conductor  610  with the insulator  630  therebetween. For the conductor  620 , a conductive material such as a metal material, an alloy material, or a metal oxide material can be used. It is preferable to use a high-melting-point material that has both heat resistance and conductivity, such as tungsten or molybdenum, and it is particularly preferable to use tungsten. In the case where the conductor  620  is formed concurrently with another component such as a conductor, Cu (copper), Al (aluminum), or the like, which is a low-resistance metal material, can be used. 
     An insulator  650  is provided over the conductor  620  and the insulator  630 . The insulator  650  can be provided using a material similar to that for the insulator  320 . The insulator  650  may function as a planarization film that covers an uneven shape thereunder. 
     With the use of this structure, a change in electrical characteristics can be reduced and the reliability can be improved in a semiconductor device using a transistor including an oxide semiconductor. Alternatively, a semiconductor device using a transistor including an oxide semiconductor can be miniaturized or highly integrated. 
     Next, other structure examples of the OS transistor illustrated in  FIG.  8    and  FIG.  9    are described.  FIG.  11 A  and  FIG.  11 B  illustrate a modification example of the transistor  500  illustrated in  FIG.  10 A  and  FIG.  10 B .  FIG.  11 A  is a cross-sectional diagram of the transistor  500  in the channel length direction and  FIG.  11 B  is a cross-sectional diagram of the transistor  500  in the channel width direction. Note that the structure illustrated in  FIG.  11 A  and  FIG.  11 B  can be employed for other transistors, such as the transistor  300 , included in the semiconductor device of one embodiment of the present invention. 
     The transistor  500  illustrated in  FIG.  11 A  and  FIG.  11 B  includes the insulator  402  and the insulator  404 , which is different from the transistor  500  illustrated in  FIG.  10 A  and  FIG.  10 B . In addition, insulators  552  are provided in contact with a side surface of the conductor  540   a  and a side surface of the conductor  540   b , which are also different from the transistor  500  illustrated in  FIG.  10 A  and  FIG.  10 B . Furthermore, the insulator  520  is not included, which is different from the transistor  500  illustrated in  FIG.  10 A  and  FIG.  10 B . 
     In the transistor  500  illustrated in  FIG.  11 A  and  FIG.  11 B , the insulator  402  is provided over the insulator  512 . The insulator  404  is provided over the insulator  574  and the insulator  402 . 
     In the transistor  500  having the structure illustrated in  FIG.  11 A  and  FIG.  11 B , the insulator  514 , the insulator  516 , the insulator  522 , the insulator  524 , the insulator  544 , the insulator  580 , and the insulator  574  are provided and covered with the insulator  404 . That is, the insulator  404  is in contact with the top surface of the insulator  574 , the side surface of the insulator  574 , the side surface of the insulator  580 , the side surface of the insulator  544 , the side surface of the insulator  524 , the side surface of the insulator  522 , the side surface of the insulator  516 , the side surface of the insulator  514 , and the top surface of the insulator  402 . Thus, the oxide  530  and the like are isolated from the outside by the insulator  404  and the insulator  402 . 
     The insulator  402  and the insulator  404  preferably have high capability of inhibiting diffusion of hydrogen (e.g., at least one of a hydrogen atom, a hydrogen molecule, and the like) or a water molecule. For example, as the insulator  402  and the insulator  404 , silicon nitride or silicon nitride oxide that is a material having a high hydrogen barrier property is preferably used. This can inhibit diffusion of hydrogen or the like into the oxide  530 , thereby suppressing the degradation of the characteristics of the transistor  500 . Consequently, the reliability of the semiconductor device of one embodiment of the present invention can be increased. 
     The insulator  552  is provided in contact with the insulator  581 , the insulator  404 , the insulator  574 , the insulator  580 , and the insulator  544 . The insulator  552  preferably has a function of inhibiting diffusion of hydrogen or water molecules. For example, as the insulator  552 , an insulator such as silicon nitride, aluminum oxide, or silicon nitride oxide that is a material having a high hydrogen barrier property is preferably used. In particular, silicon nitride is suitably used for the insulator  552  because of its high hydrogen barrier property. The use of a material having a high hydrogen barrier property for the insulator  552  can inhibit diffusion of impurities such as water and hydrogen from the insulator  580  and the like into the oxide  530  through the conductor  540   a  and the conductor  540   b . Furthermore, oxygen contained in the insulator  580  can be inhibited from being absorbed by the conductor  540   a  and the conductor  540   b . As described above, the reliability of the semiconductor device of one embodiment of the present invention can be increased. 
       FIG.  12    is a cross-sectional diagram illustrating a structure example of the semiconductor device in the case where the transistor  500  and the transistor  300  have the structure illustrated in  FIG.  11 A  and  FIG.  11 B . The insulator  552  is provided on the side surface of the conductor  546 . 
     The structure of the transistor  500  illustrated in  FIG.  11 A  and  FIG.  11 B  may be changed according to the circumstances. For example, a transistor illustrated in  FIG.  13    can be employed as a modification example of the transistor  500  illustrated in  FIG.  11 A  and  FIG.  11 B .  FIG.  13 A  is a cross-sectional diagram of the transistor in the channel length direction, and  FIG.  13 B  is a cross-sectional diagram of the transistor in the channel width direction. The transistor illustrated in  FIG.  13 A  and  FIG.  13 B  is different from the transistor illustrated in  FIG.  11 A  and  FIG.  11 B  in that the oxide  530   c  has a two-layer structure of an oxide  530   c   1  and an oxide  530   c   2 . 
     The oxide  530   c   1  is in contact with the top surface of the insulator  524 , the side surface of the oxide  530   a , the top surface and the side surface of the oxide  530   b , the side surfaces of the conductor  542   a  and the conductor  542   b , the side surface of the insulator  544 , and the side surface of the insulator  580 . The oxide  530   c   2  is in contact with the insulator  550 . 
     An In—Zn oxide can be used as the oxide  530   c   1 , for example. As the oxide  530   c   2 , it is possible to use a material similar to a material that can be used for the oxide  530   c  when the oxide  530   c  has a single-layer structure. As the oxide  530   c   2 , a metal oxide with n:Ga:Zn=1:3:4 [atomic ratio], Ga:Zn=2:1 [atomic ratio], or Ga:Zn=2:5 [atomic ratio] can be used, for example. 
     When the oxide  530   c  has a two-layer structure of the oxide  530   c   1  and the oxide  530   c   2 , the on-state current of the transistor can be increased as compared with the case where the oxide  530   c  has a single-layer structure. Thus, a transistor can be a power MOS transistor, for example. Note that the oxide  530   c  included in the transistor illustrated in  FIG.  10 A  and  FIG.  10 B  can also have a two-layer structure of the oxide  530   c   1  and the oxide  530   c   2 . 
     The transistor illustrated in  FIG.  13 A  and  FIG.  13 B  can be used as the transistor  300  illustrated in  FIG.  8    or  FIG.  9   , for example. As described above, the transistor  300  can be employed as a transistor included in the comparator CMP 1 , for example. Note that the transistor illustrated in  FIG.  13 A  and  FIG.  13 B  can be employed as a transistor other than the transistor  300  and the transistor  500  which are included in the semiconductor device of one embodiment of the present invention. 
       FIG.  14    is a cross-sectional diagram illustrating a structure example of a semiconductor device in which the transistor illustrated in  FIG.  10 A  is used as the transistor  500  and the transistor illustrated in  FIG.  13 A  is used as the transistor  300 . Note that as in  FIG.  12   , the insulator  552  is provided on a side surface of the conductor  546 . As illustrated in  FIG.  14   , in the semiconductor device of one embodiment of the present invention, the transistor  300  and the transistor  500  can have different structures while both the transistor  300  and the transistor  500  can be OS transistors. 
     Next, a capacitor that can be used for the semiconductor device illustrated in  FIG.  8    or  FIG.  9    will be described. 
       FIGS.  15 A to  15 C  illustrate a capacitor  600 A as an example of the capacitor  600  that can be used in the semiconductor device shown in  FIG.  8   .  FIG.  15 A  is a top view of the capacitor  600 A,  FIG.  15 B  is a perspective view illustrating a cross section of the capacitor  600 A along the dashed-dotted line L 3 -L 4 , and  FIG.  15 C  is a perspective view illustrating a cross section of the capacitor  600 A along the dashed-dotted line W 3 -L 4 . 
     The conductor  610  functions as one of a pair of electrodes of the capacitor  600 A, and the conductor  620  functions as the other of the pair of electrodes of the capacitor  600 A. The insulator  630  functions as a dielectric between the pair of electrodes. 
     The bottom portion of the conductor  610  in the capacitor  600 A is electrically connected to the conductor  546  and the conductor  548 . The conductor  546  and the conductor  548  function as plugs or wirings for connecting to another circuit element. In  FIG.  15   , the conductor  546  and the conductor  548  are collectively denoted as a conductor  540 . 
     For clarification of the drawing, the insulator  586  in which the conductor  546  and the conductor  548  are embedded and the insulator  650  that covers the conductor  620  and the insulator  630  are omitted in  FIG.  15   . 
     Although the capacitor  600  in  FIG.  8    and  FIG.  9    and the capacitor  600 A in  FIG.  15 A  to  FIG.  15 C  are planar capacitors, the shape of the capacitor is not limited thereto. For example, the capacitor  600  (capacitor  600 A) may be a cylindrical capacitor  600 B illustrated in  FIG.  16 A  to  FIG.  16 C . 
       FIG.  16 A  is a top view of the capacitor  600 B,  FIG.  16 B  is a perspective view illustrating a cross section of the capacitor  600 B along the dashed-dotted line L 3 -L 4 , and  FIG.  16 C  is a perspective view illustrating a cross section of the capacitor  600 B along the dashed-dotted line W 3 -L 4 . 
     In  FIG.  16 B , the capacitor  600 B includes an insulator  631  over the insulator  586  in which the conductor  540  is embedded, an insulator  651  having an opening, the conductor  610  functioning as one of a pair of electrodes, and the conductor  620  functioning as the other of the pair of electrodes. 
     For clarification of the drawing, the insulator  586 , an insulator  650 , and the insulator  651  are omitted in  FIG.  16 C . 
     For the insulator  631 , a material similar to that for the insulator  586  can be used, for example. 
     A conductor  611  is embedded in the insulator  631  to be electrically connected to the conductor  540 . For the conductor  611 , a material similar to those for the conductor  330  and the conductor  518  can be used, for example. 
     For the insulator  651 , a material similar to that for the insulator  586  can be used, for example. 
     The insulator  651  has an opening as described above, and the opening overlaps with the conductor  611 . 
     The conductor  610  is formed on the bottom portion and the side surface of the opening. In other words, the conductor  610  overlaps with the conductor  611  and is electrically connected to the conductor  611 . 
     The conductor  610  is formed in such a manner that an opening is formed in the insulator  651  by an etching method or the like, and then the conductor  610  is deposited by a sputtering method, an ALD method, or the like. After that, the conductor  610  deposited over the insulator  651  is removed by a CMP (Chemical Mechanical Polishing) method or the like while the conductor  610  deposited in the opening is left. 
     The insulator  630  is positioned over the insulator  651  and over the formation surface of the conductor  610 . Note that the insulator  630  functions as a dielectric between the pair of electrodes in the capacitor. 
     The conductor  620  is formed over the insulator  630  so as to fill the opening of the insulator  651 . 
     The insulator  650  is formed to cover the insulator  630  and the conductor  620 . 
     The capacitance value of the cylindrical capacitor  600 B illustrated in  FIG.  16    can be higher than that of the planar capacitor  600 A. Thus, when the capacitor  600 B is used as the capacitor C 1 , the capacitor C 2 , and the like described in the above embodiment, for example, a voltage between the terminals of the capacitor can be maintained for long time. 
     Note that this embodiment can be combined with any of the other embodiments in this specification as appropriate. 
     Embodiment 4 
     In this embodiment, the compositions of a CAC-OS (Cloud-Aligned Composite Oxide Semiconductor) and a CAAC-OS (c-axis Aligned Crystalline Oxide Semiconductor) which are metal oxides that can be used in the OS transistor described in the above embodiment is described. Note that in this specification and the like, CAC refers to an example of a function or a material composition and CAAC refers to an example of a crystal structure. 
     &lt;Composition of Metal Oxide&gt; 
     A CAC-OS or a CAC-metal oxide has a conducting function in part of the material and has an insulating function in another part of the material; as a whole, the CAC-OS or the CAC-metal oxide has a function of a semiconductor. In the case where the CAC-OS or the CAC-metal oxide is used in an active layer of a transistor, the conducting function is a function of allowing electrons (or holes) serving as carriers to flow, and the insulating function is a function of not allowing electrons serving as carriers to flow. By the complementary action of the conducting function and the insulating function, a switching function (On/Off function) can be given to the CAC-OS or the CAC-metal oxide. In the CAC-OS or the CAC-metal oxide, separation of the functions can maximize each function. 
     The CAC-OS or the CAC-metal oxide includes conductive regions and insulating regions. The conductive regions have the above-described conducting function, and the insulating regions have the above-described insulating function. Furthermore, in some cases, the conductive regions and the insulating regions in the material are separated at the nanoparticle level. Furthermore, in some cases, the conductive regions and the insulating regions are unevenly distributed in the material. Furthermore, in some cases, the conductive regions are observed to be coupled in a cloud-like manner with their boundaries blurred. 
     In the CAC-OS or the CAC-metal oxide, the conductive regions and the insulating regions each have a size greater than or equal to 0.5 nm and less than or equal to 10 nm, preferably greater than or equal to 0.5 nm and less than or equal to 3 nm and are dispersed in the material in some cases. 
     The CAC-OS or the CAC-metal oxide includes components having different band gaps. For example, the CAC-OS or the CAC-metal oxide includes a component having a wide gap due to the insulating region and a component having a narrow gap due to the conductive region. In the case of the structure, when carriers flow, carriers mainly flow in the component having a narrow gap. Furthermore, the component having a narrow gap complements the component having a wide gap, and carriers also flow in the component having a wide gap in conjunction with the component having a narrow gap. Therefore, in the case where the above-described CAC-OS or CAC-metal oxide is used in a channel region of a transistor, high current driving capability in the on state of the transistor, that is, a high on-state current and high field-effect mobility can be obtained. 
     In other words, the CAC-OS or the CAC-metal oxide can also be referred to as a matrix composite or a metal matrix composite. 
     &lt;Structure of Metal Oxide&gt; 
     Oxide semiconductors can be classified into a single crystal oxide semiconductor and a non-single-crystal oxide semiconductor. Examples of a non-single-crystal oxide semiconductor include a CAAC-OS (c-axis aligned crystal crystalline oxide semiconductor), a polycrystalline oxide semiconductor, an nc-OS (nanocrystalline oxide semiconductor), an amorphous-like oxide semiconductor (a-like OS), and an amorphous oxide semiconductor. 
     The CAAC-OS has c-axis alignment, a plurality of nanocrystals are connected in the a-b plane direction, and its crystal structure has distortion. Note that the distortion refers to a portion where the direction of a lattice arrangement changes between a region with a regular lattice arrangement and another region with a regular lattice arrangement in a region where the plurality of nanocrystals are connected. 
     The nanocrystal is basically a hexagon but is not always a regular hexagon and is a non-regular hexagon in some cases. Furthermore, a pentagonal or heptagonal lattice arrangement, for example, is included in the distortion in some cases. Note that a clear crystal grain boundary (also referred to as grain boundary) cannot be observed even in the vicinity of distortion in the CAAC-OS. That is, formation of a crystal grain boundary is inhibited by the distortion of lattice arrangement. This is probably because the CAAC-OS can tolerate distortion owing to the low density of oxygen atom arrangement in the a-b plane direction, a change in interatomic bond distance by replacement of a metal element, and the like. 
     The CAAC-OS tends to have a layered crystal structure (also referred to as a layered structure) in which a layer containing indium and oxygen (hereinafter, In layer) and a layer containing the element M, zinc, and oxygen (hereinafter, (M,Zn) layer) are stacked. Note that indium and the element M can be replaced with each other, and when the element M in the (M,Zn) layer is replaced with indium, the layer can also be referred to as an (In,M,Zn) layer. Furthermore, when indium in the In layer is replaced with the element M, the layer can be referred to as an (In,M) layer. 
     The CAAC-OS is an oxide semiconductor with high crystallinity. Meanwhile, in the CAAC-OS, a reduction in electron mobility due to a crystal grain boundary is less likely to occur because a clear crystal grain boundary cannot be observed. Entry of impurities, formation of defects, or the like might decrease the crystallinity of the oxide semiconductor; thus, the CAAC-OS can be regarded as an oxide semiconductor that has small amounts of impurities and defects (e.g., oxygen vacancies). Thus, an oxide semiconductor including the CAAC-OS is physically stable. Therefore, the oxide semiconductor including the CAAC-OS is resistant to heat and has high reliability. In addition, the CAAC-OS is stable with respect to high temperature in the manufacturing process (what is called thermal budget). Accordingly, the use of the CAAC-OS for the OS transistor can extend the degree of freedom of the manufacturing process. 
     In the nc-OS, a microscopic region (e.g., a region with a size greater than or equal to 1 nm and less than or equal to 10 nm, in particular, a region with a size greater than or equal to 1 nm and less than or equal to 3 nm) has a periodic atomic arrangement. Furthermore, there is no regularity of crystal orientation between different nanocrystals in the nc-OS. Thus, the orientation in the whole film is not observed. Accordingly, the nc-OS cannot be distinguished from an a-like OS or an amorphous oxide semiconductor by some analysis methods. 
     The a-like OS is an oxide semiconductor having a structure between those of the nc-OS and the amorphous oxide semiconductor. The a-like OS includes a void or a low-density region. That is, the a-like OS has low crystallinity as compared with the nc-OS and the CAAC-OS. 
     An oxide semiconductor has various structures with different properties. Two or more of the amorphous oxide semiconductor, the polycrystalline oxide semiconductor, the a-like OS, the nc-OS, and the CAAC-OS may be included in an oxide semiconductor of one embodiment of the present invention. 
     &lt;Transistor Including Oxide Semiconductor&gt; 
     Next, the case where the above oxide semiconductor is used for a transistor is described. 
     When the above oxide semiconductor is used for a transistor, a transistor with high field-effect mobility can be achieved. In addition, a transistor having high reliability can be achieved. 
     An oxide semiconductor with a low carrier concentration is preferably used for a transistor. In the case where the carrier concentration of an oxide semiconductor film is lowered, the impurity concentration in the oxide semiconductor film is lowered to decrease the density of defect states. In this specification and the like, having low impurity concentration and low density of defect states are referred to as being highly purified intrinsic or substantially highly purified intrinsic in some cases or being intrinsic or substantially intrinsic in some cases. 
     A highly purified intrinsic or substantially highly purified intrinsic oxide semiconductor film has a low density of defect states and thus has a low density of trap states in some cases. 
     Charge trapped by the trap states in the oxide semiconductor takes a long time to disappear and might behave like fixed charge. Thus, a transistor whose channel formation region is formed in an oxide semiconductor with a high density of trap states has unstable electrical characteristics in some cases. 
     Accordingly, in order to stabilize the electrical characteristics of the transistor, reducing the impurity concentration in the oxide semiconductor is effective. In order to reduce the impurity concentration in the oxide semiconductor, it is preferable that the impurity concentration in an adjacent film be also reduced. Examples of impurities include hydrogen, nitrogen, an alkali metal, an alkaline earth metal, iron, nickel, and silicon. 
     &lt;Impurities&gt; 
     Here, the influence of each impurity in the oxide semiconductor is described. 
     When silicon or carbon, which is one of Group 14 elements, is contained in the oxide semiconductor, defect states are formed in the oxide semiconductor. Thus, the concentration of silicon or carbon in the oxide semiconductor and the concentration of silicon or carbon in the vicinity of an interface with the oxide semiconductor (the concentration obtained by secondary ion mass spectrometry (SIMS)) are set lower than or equal to 2×10 18  atoms/cm 3 , preferably lower than or equal to 2×10 17  atoms/cm 3 . 
     When the oxide semiconductor contains an alkali metal or an alkaline earth metal, defect states are formed and carriers are generated in some cases. Thus, a transistor using an oxide semiconductor that contains an alkali metal or an alkaline earth metal is likely to have normally-on characteristics. Accordingly, it is preferable to reduce the concentration of an alkali metal or an alkaline earth metal in the oxide semiconductor. Specifically, the concentration of an alkali metal or an alkaline earth metal in the oxide semiconductor that is obtained by SIMS is set lower than or equal to 1×10 18  atoms/cm 3 , preferably lower than or equal to 2×10 16  atoms/cm 3 . 
     Furthermore, when the oxide semiconductor contains nitrogen, the oxide semiconductor easily becomes n-type by generation of electrons serving as carriers and an increase in carrier concentration. As a result, a transistor using an oxide semiconductor containing nitrogen as a semiconductor is likely to have normally-on characteristics. Hence, nitrogen in the oxide semiconductor is preferably reduced as much as possible; the nitrogen concentration in the oxide semiconductor that is obtained by SIMS is set, for example, lower than 5×10 19  atoms/cm 3 , preferably lower than or equal to 5×10 18  atoms/cm 3 , further preferably lower than or equal to 1×10 18  atoms/cm 3 , still further preferably lower than or equal to 5×10 17  atoms/cm 3 . 
     Hydrogen contained in the oxide semiconductor reacts with oxygen bonded to a metal atom to be water, and thus forms an oxygen vacancy in some cases. Entry of hydrogen into the oxygen vacancy generates an electron serving as a carrier in some cases. Furthermore, bonding of part of hydrogen to oxygen bonded to a metal atom causes generation of an electron serving as a carrier in some cases. Thus, a transistor using an oxide semiconductor containing hydrogen is likely to have normally-on characteristics. Accordingly, hydrogen in the oxide semiconductor is preferably reduced as much as possible. Specifically, the hydrogen concentration in the oxide semiconductor that is obtained by SIMS is set lower than 1×10 20  atoms/cm 3 , preferably lower than 1×10 19  atoms/cm 3 , further preferably lower than 5×10 18  atoms/cm 3 , still further preferably lower than 1×10 18  atoms/cm 3 . 
     When an oxide semiconductor with sufficiently reduced impurities is used for the channel formation region of the transistor, stable electrical characteristics can be given. 
     Note that this embodiment can be combined with any of the other embodiments in this specification as appropriate. 
     Embodiment 5 
     In this embodiment, examples of a semiconductor wafer where the semiconductor device or the like described in the above embodiment is formed and electronic components incorporating the semiconductor device will be described. 
     &lt;Semiconductor Wafer&gt; 
     First, an example of a semiconductor wafer where a semiconductor device or the like is formed is described with reference to  FIG.  17 A . 
     A semiconductor wafer  4800  illustrated in  FIG.  17 A  includes a wafer  4801  and a plurality of circuit portions  4802  provided on the top surface of the wafer  4801 . A portion without the circuit portion  4802  on the top surface of the wafer  4801  is a spacing  4803  that is a region for dicing. 
     The semiconductor wafer  4800  can be fabricated by forming the plurality of circuit portions  4802  on the surface of the wafer  4801  by a pre-process. After that, a surface of the wafer  4801  opposite to the surface provided with the plurality of circuit portions  4802  may be ground to thin the wafer  4801 . Through this step, warpage or the like of the wafer  4801  is reduced and the size of the component can be reduced. 
     A dicing step is performed as the next step. The dicing is performed along scribe lines SCL 1  and scribe lines SCL 2  (referred to as dicing lines or cutting lines in some cases) indicated by dashed-dotted lines. Note that to perform the dicing step easily, it is preferable that the spacing  4803  be provided so that the plurality of scribe lines SCL 1  are parallel to each other, the plurality of scribe lines SCL 2  are parallel to each other, and the scribe lines SCL 1  are perpendicular to the scribe line SCL 2 . 
     With the dicing step, a chip  4800   a  as illustrated in  FIG.  17 B  can be cut out from the semiconductor wafer  4800 . The chip  4800   a  includes a wafer  4801   a , the circuit portion  4802 , and a spacing  4803   a . Note that it is preferable to make the spacing  4803   a  small as much as possible. In this case, the width of the spacing  4803  between adjacent circuit portions  4802  is substantially the same as a cutting allowance of the scribe line SCL 1  or a cutting allowance of the scribe line SCL 2 . 
     Note that the shape of the element substrate of one embodiment of the present invention is not limited to the shape of the semiconductor wafer  4800  illustrated in  FIG.  17 A . The element substrate may be a rectangular semiconductor wafer, for example. The shape of the element substrate can be changed as appropriate, depending on a manufacturing process of an element and an apparatus for manufacturing the element. 
     &lt;Electronic Components&gt; 
     Next, examples of electronic components incorporating the chip  4800   a  are described with reference to  FIG.  17 C  and  FIG.  17 D . 
       FIG.  17 C  is a perspective view of an electronic component  4700  and a substrate (a mounting board  4704 ) on which the electronic component  4700  is mounted. The electronic component  4700  illustrated in  FIG.  17 C  includes a lead  4701  and the above-described chip  4800   a , and functions as an IC chip or the like. 
     The electronic component  4700  can be formed by, for example, a wire bonding step of electrically connecting the lead  4701  of a lead frame to an electrode on the chip  4800   a  with a metal fine line (wire), a molding step of performing sealing with an epoxy resin or the like, a plating step on the lead  4701  of the lead frame, and a printing step on a surface of the package. Ball bonding or wedge bonding, for example, can be used in the wire bonding step. Although a QFP (Quad Flat Package) is used as the package of the electronic component  4700  in  FIG.  17 C , the mode of the package is not limited thereto. 
     The electronic component  4700  is mounted on a printed circuit board  4702 , for example. A plurality of such IC chips are combined and electrically connected to each other on the printed circuit board  4702 , whereby the mounting board  4704  is completed. 
       FIG.  17 D  is a perspective view of an electronic component  4730 . The electronic component  4730  is an example of a SiP (System in package) or an MCM (Multi Chip Module). In the electronic component  4730 , an interposer  4731  is provided on a package substrate  4732  (a printed circuit board), and a semiconductor device  4735  and a plurality of semiconductor devices  4710  are provided on the interposer  4731 . 
     The electronic component  4730  includes the semiconductor devices  4710 . Examples of the semiconductor devices  4710  include the semiconductor device described in the above embodiment and a high bandwidth memory (HBM). An integrated circuit (a semiconductor device) such as a CPU, a GPU, an FPGA, or a memory device can be used as the semiconductor device  4735 . 
     As the package substrate  4732 , a ceramic substrate, a plastic substrate, a glass epoxy substrate, or the like can be used. As the interposer  4731 , a silicon interposer, a resin interposer, or the like can be used. 
     The interposer  4731  includes a plurality of wirings and has a function of electrically connecting a plurality of integrated circuits with different terminal pitches. The plurality of wirings are provided in a single layer or multiple layers. Moreover, the interposer  4731  has a function of electrically connecting an integrated circuit provided on the interposer  4731  to an electrode provided on the package substrate  4732 . Accordingly, the interposer is referred to as a “redistribution substrate” or an “intermediate substrate” in some cases. A through electrode is provided in the interposer  4731  and the through electrode is used to electrically connect an integrated circuit and the package substrate  4732  in some cases. For a silicon interposer, a TSV (Through Silicon Via) can also be used as the through electrode. 
     A silicon interposer is preferably used as the interposer  4731 . A silicon interposer can be manufactured at lower cost than an integrated circuit because it is not necessary to provide an active element. Meanwhile, since wirings of a silicon interposer can be formed through a semiconductor process, formation of minute wirings, which is difficult for a resin interposer, is easy. 
     In order to achieve a wide memory bandwidth, many wirings need to be connected to HBM. Therefore, formation of minute and high-density wirings is required for an interposer on which HBM is mounted. For this reason, a silicon interposer is preferably used as the interposer on which HBM is mounted. 
     In a SiP, an MCM, or the like using a silicon interposer, the decrease in reliability due to a difference in expansion coefficient between an integrated circuit and the interposer is less likely to occur. Furthermore, the surface of a silicon interposer has high planarity, so that a poor connection between the silicon interposer and an integrated circuit provided on the silicon interposer is less likely to occur. It is particularly preferable to use a silicon interposer for a 2.5 D package (2.5-dimensional mounting) in which a plurality of integrated circuits are arranged side by side on an interposer. 
     A heat sink (a radiator plate) may be provided to overlap with the electronic component  4730 . In the case of providing a heat sink, the heights of integrated circuits provided on the interposer  4731  are preferably equal to each other. For example, in the electronic component  4730  described in this embodiment, the heights of the semiconductor devices  4710  and the semiconductor device  4735  are preferably equal to each other. 
     To mount the electronic component  4730  on another substrate, an electrode  4733  may be provided on the bottom portion of the package substrate  4732 .  FIG.  17 D  illustrates an example in which the electrode  4733  is formed of a solder ball. Solder balls are provided in a matrix on the bottom portion of the package substrate  4732 , whereby BGA (Ball Grid Array) mounting can be achieved. Alternatively, the electrode  4733  may be formed of a conductive pin. When conductive pins are provided in a matrix on the bottom portion of the package substrate  4732 , PGA (Pin Grid Array) mounting can be achieved. 
     The electronic component  4730  can be mounted on another substrate by various mounting methods not limited to BGA and PGA. For example, a mounting method such as SPGA (Staggered Pin Grid Array), LGA (Land Grid Array), QFP (Quad Flat Package), QFJ (Quad Flat J-leaded package), or QFN (Quad Flat Non-leaded package) can be employed. 
     Note that this embodiment can be combined with any of the other embodiments in this specification as appropriate. 
     Embodiment 6 
     In this embodiment, structures of a power storage device and a power storage system to which the semiconductor device and the electronic component including the semiconductor device, which are described in the above embodiments, can be applied will be described. 
     [Cylindrical Secondary Battery] 
     An example of a cylindrical secondary battery is described with reference to  FIG.  18 A . A cylindrical secondary battery  1400  includes, as illustrated in  FIG.  18 A , a positive electrode cap (battery lid)  1401  on the top surface and a battery can (outer can)  1402  on the side and bottom surfaces. The positive electrode cap  1401  and the battery can (outer can)  1402  are insulated from each other by a gasket (insulating packing)  1410 . 
       FIG.  18 B  is a schematic cross-sectional view of a cylindrical secondary battery. As illustrated in  FIG.  18 B , the cylindrical secondary battery includes a positive electrode cap (battery lid)  1601  on a top surface and a battery can (outer can)  1602  on a side surface and a bottom surface. The positive electrode cap and the battery can (outer can)  1602  are insulated from each other by a gasket (insulating packing)  1610 . 
     Inside the battery can  1602  having a hollow cylindrical shape, a battery element in which a belt-like positive electrode  1604  and a belt-like negative electrode  1606  are wound with a separator  1605  located therebetween is provided. Although not illustrated, the battery element is wound centering around a center pin. One end of the battery can  1602  is closed and the other end thereof is open. For the battery can  1602 , a metal having a corrosion-resistant property to an electrolyte solution, such as nickel, aluminum, or titanium, an alloy of such a metal, or an alloy of such a metal and another metal (e.g., stainless steel) can be used. Alternatively, the battery can  1602  is preferably covered with nickel, aluminum, or the like in order to prevent corrosion due to the electrolyte solution. Inside the battery can  1602 , the battery element in which the positive electrode, the negative electrode, and the separator are wound is sandwiched between a pair of insulating plates  1608  and  1609  that face each other. Furthermore, a nonaqueous electrolyte (not illustrated) is injected inside the battery can  1602  provided with the battery element. As the nonaqueous electrolyte, a nonaqueous electrolyte that is similar to that for the coin-type secondary battery can be used. 
     Since a positive electrode and a negative electrode that are used for a cylindrical storage battery are wound, active materials are preferably formed on both surfaces of a current collector. A positive electrode terminal (positive electrode current collector lead)  1603  is connected to the positive electrode  1604 , and a negative electrode terminal (negative electrode current collector lead)  1607  is connected to the negative electrode  1606 . For both the positive electrode terminal  1603  and the negative electrode terminal  1607 , a metal material such as aluminum can be used. The positive electrode terminal  1603  and the negative electrode terminal  1607  are resistance-welded to a safety valve mechanism  1613  and the bottom of the battery can  1602 , respectively. The safety valve mechanism  1613  is electrically connected to the positive electrode cap  1601  through a PTC (Positive Temperature Coefficient) element  1611 . The safety valve mechanism  1613  cuts off electrical connection between the positive electrode cap  1601  and the positive electrode  1604  when the internal pressure of the battery exceeds a predetermined threshold. In addition, the PTC element  1611  is a thermally sensitive resistor whose resistance increases as temperature rises, and limits the amount of current by increasing the resistance to prevent abnormal heat generation. Barium titanate (BaTiO 3 )-based semiconductor ceramics or the like can be used for the PTC element. 
       FIG.  18 C  illustrates an example of a power storage system  1415 . The power storage system  1415  includes a plurality of secondary batteries  1400 . Positive electrodes of the secondary batteries are in contact with conductors  1424  isolated by an insulator  1425  and are electrically connected. The conductor  1424  is electrically connected to a control circuit  1420  through a wiring  1423 . Negative electrodes of the secondary batteries are electrically connected to the control circuit  1420  through a wiring  1426 . As the control circuit  1420 , the semiconductor device (or an electronic component including the semiconductor device) described in the above embodiments can be used. 
       FIG.  18 D  illustrates an example of the power storage system  1415 . The power storage system  1415  includes the plurality of secondary batteries  1400 , and the plurality of secondary batteries  1400  are sandwiched between a conductive plate  1413  and a conductive plate  1414 . The plurality of secondary batteries  1400  are electrically connected to the conductive plate  1413  and the conductive plate  1414  through a wiring  1416 . The plurality of secondary batteries  1400  may be connected parallel to each other, connected in series, or connected in series after being connected parallel to each other. With the power storage system  1415  including the plurality of secondary batteries  1400 , large electric power can be extracted. 
     A temperature control device may be provided between the plurality of secondary batteries  1400 . When the secondary batteries  1400  are heated excessively, the temperature control device can cool them, and when the secondary batteries  1400  are cooled too much, the temperature control device can heat them. Thus, the performance of the power storage system  1415  is not easily influenced by the outside air temperature. 
     In  FIG.  18 D , the power storage system  1415  is electrically connected to the control circuit  1420  through a wiring  1421  and a wiring  1422 . As the control circuit  1420 , the battery control circuit described in the above embodiment can be used. The wiring  1421  is electrically connected to the positive electrodes of the plurality of the secondary batteries  1400  through the conductive plate  1413 , and the wiring  1422  is electrically connected to the negative electrodes of the plurality of the secondary batteries  1400  through the conductive plate  1414 . 
     [Secondary Battery Pack] 
     Next, an example of the power storage system of one embodiment of the present invention is described with reference to  FIG.  19   . 
       FIG.  19 A  is an external view of a secondary battery pack  1531 .  FIG.  19 B  illustrates the structure of the secondary battery pack  1531 . The secondary battery pack  1531  includes a circuit board  1501  and a secondary battery  1513 . A label  1509  is attached onto the secondary battery  1513 . The circuit board  1501  is fixed by a sealant  1515 . The secondary battery pack  1531  includes an antenna  1517 . 
     The circuit board  1501  includes a control circuit  1590 . As the control circuit  1590 , the battery control circuit described in the above embodiment can be used. For example, as illustrated in  FIG.  19 B , the control circuit  1590  is provided over the circuit board  1501 . The circuit board  1501  is electrically connected to a terminal  1511 . The circuit board  1501  is electrically connected to the antenna  1517 , one  1551  of a positive electrode lead and a negative electrode lead of the secondary battery  1513 , and the other  1552  of the positive electrode lead and the negative electrode lead. 
     Alternatively, as illustrated in  FIG.  19 C , a circuit system  1590   a  provided over the circuit board  1501  and a circuit system  1590   b  electrically connected to the circuit board  1501  through the terminal  1511  may be included. For example, a part of the control circuit of one embodiment of the present invention is provided in the circuit system  1590   a , and another part thereof is provided in the circuit system  1590   b.    
     The shape of the antenna  1517  is not limited to a coil shape and may be a linear shape or a plate shape. An antenna such as a planar antenna, an aperture antenna, a traveling-wave antenna, an EH antenna, a magnetic-field antenna, or a dielectric antenna may be used. Alternatively, the antenna  1517  may be a flat-plate conductor. This flat-plate conductor can serve as one of conductors for electric field coupling. That is, the antenna  1517  can serve as one of two conductors of a capacitor. Thus, electric power can be transmitted and received not only by an electromagnetic field or a magnetic field but also by an electric field. 
     The secondary battery pack  1531  includes a layer  1519  between the antenna  1517  and the secondary battery  1513 . The layer  1519  has a function of blocking an electromagnetic field from the secondary battery  1513 , for example. As the layer  1519 , for example, a magnetic body can be used. 
     The secondary battery  1513  includes a wound battery element  1593  as illustrated in  FIG.  19 C . The battery element  1593  includes a negative electrode  1594 , a positive electrode  1595 , and separator  1596 . The battery element  1593  is obtained by winding a sheet of a stack in which the negative electrode  1594  overlaps with the positive electrode  1595  with the separator  1596  provided therebetween. 
     Note that this embodiment can be combined with any of the other embodiments in this specification as appropriate. 
     Embodiment 7 
     In this embodiment, examples of electronic devices, which can include the semiconductor device described in the above embodiment, an electronic component including the semiconductor device, or the power storage device described in the above embodiment, will be described. 
     [Mobile Phone] 
     An information terminal  5500  illustrated in  FIG.  20 A  is a mobile phone (smartphone), which is a type of information terminal. The information terminal  5500  includes a housing  5510  and a display portion  5511 , and as input interfaces, a touch panel is provided in the display portion  5511  and a button is provided in the housing  5510 . 
     With use of the semiconductor device described in the above embodiment for the information terminal  5500 , overcharge and/or overdischarge of a battery provided in the information terminal  5500  can be prevented. 
     [Wearable Terminal] 
       FIG.  20 B  illustrates a wearable terminal  5900  as an example of an information terminal. The wearable terminal  5900  includes a housing  5901 , a display portion  5902 , operation buttons  5903 , an operator  5904 , a band  5905 , and the like. 
     Like the aforementioned information terminal  5500 , the wearable terminal  5900  can prevent overcharge and/or overdischarge of a battery provided in the wearable terminal by using the semiconductor device described in the above embodiment. 
     [Personal Computer] 
       FIG.  20 C  illustrates a laptop personal computer  5300  which is a kind of information terminals. The laptop personal computer  5300  includes a housing  5301 , a display portion  5302 , a keyboard  5303 , and a trackpad-type pointing device  5304 . In accordance with user&#39;s preference, a mouse-type pointing device  5305  can be used for the laptop personal computer  5300 . 
     Like the aforementioned electronic device, the laptop personal computer  5300  can prevent overcharge and/or overdischarge of a battery provided in the laptop personal computer  5300  by using the semiconductor device described in the above embodiment. The semiconductor device described in the above embodiment can be used also for the mouse-type pointing device  5305 , and overcharge or overdischarge in a battery provided in the mouse-type pointing device  5305  can be prevented similarly. 
     [Game Machine] 
       FIG.  20 D  illustrates a portable game machine  5200  as an example of a game machine. The portable game machine  5200  includes a housing  5201 , a display portion  5202 , buttons  5203 , and the like. 
       FIG.  20 E  illustrates a stationary game machine  7500  as another example of a game machine. The stationary game machine  7500  includes a main body  7520  and a controller  7522 . The controller  7522  can be connected to the main body  7520  with or without a wire. Although not illustrated in  FIG.  20 E , the controller  7522  can include a display portion that displays a game image, and an input interface besides a button, such as a touch panel, a stick, a rotating knob, and a sliding knob, for example. The shape of the controller  7522  is not limited to that in  FIG.  20 E  and may be changed variously in accordance with the genres of games. For example, for a shooting game such as an FPS (First Person Shooter) game, a gun-shaped controller having a trigger button can be used. As another example, for a music game or the like, a controller having a shape of a musical instrument, audio equipment, or the like can be used. Furthermore, the stationary game machine may include a camera, a depth sensor, a microphone, and the like so that the game player can play a game using a gesture and/or a voice instead of a controller. 
     Videos displayed on the game machine can be output with a display device such as a television device, a personal computer display, a game display, or a head-mounted display. 
     Like the aforementioned electronic device, the portable game machine  5200  can prevent overcharge and/or overdischarge of a battery provided in the portable game machine  5200  by using the semiconductor device described in the above embodiment. In the case where the controller  7522  is wirelessly connected to the stationary game machine  7500 , a battery is provided in some cases in order that the controller  7522  communicates with the stationary game machine  7500  via radio waves. Thus, like the aforementioned electronic device, the controller  7522  can prevent overcharge and/or overdischarge of a battery provided in the controller  7522  by using the semiconductor device described in the above embodiment. 
     [Moving Vehicle] 
     The semiconductor device described in the above embodiment can be used for an automobile, which is a moving vehicle. 
       FIG.  20 F  illustrates an automobile  5700  as an example of a moving vehicle. 
     An instrument panel that provides various kinds of information such as a speedometer, a tachometer, a mileage, a fuel meter, a gearshift indicator, and air-conditioning settings is provided around the driver&#39;s seat in the automobile  5700 . In addition, a display device showing the above information can be provided around the driver&#39;s seat. 
     In particular, in the case where the automobile  5700  is an electric vehicle provided with a battery, when the semiconductor device described in the above embodiment is applied to the automobile  5700 , overcharge or overdischarge of the battery provided in the controller  7522  can be prevented in a manner similar to those in the case of the above-described electronic devices. 
     Although an automobile is described above as an example of a moving vehicle, moving vehicles are not limited to an automobile. Examples of moving vehicles include a train, a monorail train, a ship, and a flying object (a helicopter, an unmanned aircraft (a drone), an airplane, and a rocket). 
     [Camera] 
     The semiconductor device described in the above embodiment can be applied to a camera. 
       FIG.  20 G  illustrates a digital camera  6240  as an example of an imaging device. The digital camera  6240  includes a housing  6241 , a display portion  6242 , operation buttons  6243 , a shutter button  6244 , and the like, and an attachable lens  6246  is attached to the digital camera  6240 . Here, the lens  6246  of the digital camera  6240  is detachable from the housing  6241  for replacement; alternatively, the lens  6246  may be incorporated into the housing  6241 . A stroboscope, a viewfinder, or the like may be additionally provided in the digital camera  6240 . 
     When the semiconductor device described in the above embodiment is applied to the digital camera  6240 , overcharge or overdischarge of a battery provided in the digital camera  6240  can be prevented in a manner similar to those in the case of the above-described electronic devices. 
     [Video Camera] 
     The semiconductor device described in the above embodiment can be applied to a video camera. 
       FIG.  20 H  illustrates a video camera  6300  as an example of an imaging device. The video camera  6300  includes a first housing  6301 , a second housing  6302 , a display portion  6303 , operation keys  6304 , a lens  6305 , a joint  6306 , and the like. The operation keys  6304  and the lens  6305  are provided in the first housing  6301 , and the display portion  6303  is provided in the second housing  6302 . The first housing  6301  and the second housing  6302  are connected to each other with the joint  6306 , and the angle between the first housing  6301  and the second housing  6302  can be changed with the joint  6306 . Images displayed on the display portion  6303  may be changed in accordance with the angle at the joint  6306  between the first housing  6301  and the second housing  6302 . 
     When the semiconductor device described in the above embodiment is applied to the video camera  6300 , overcharge or overdischarge of a battery provided in the video camera  6300  can be prevented in a manner similar to those in the case of the above-described electronic devices. 
     [ICD] 
     The semiconductor device described in the above embodiment can be applied to an implantable cardioverter-defibrillator (ICD). 
       FIG.  20 I  is a schematic cross-sectional view illustrating an example of an ICD. An ICD body  5400  includes at least a battery  5401 , a memory device  5407 , a regulator, a control circuit, an antenna  5404 , a wire  5402  reaching a right atrium, and a wire  5403  reaching a right ventricle. 
     The ICD body  5400  is implanted in the body by surgery, and the two wires pass through a subclavian vein  5405  and a superior vena cava  5406  of the human body, with the end of one of the wires placed in the right ventricle and the end of the other wire placed in the right atrium. 
     The ICD body  5400  functions as a pacemaker and paces the heart when the heart rate is not within a predetermined range. When the heart rate is not recovered by pacing (e.g., when ventricular tachycardia or ventricular fibrillation occurs), treatment with an electrical shock is performed. 
     The ICD body  5400  needs to monitor the heart rate all the time in order to perform pacing and deliver electrical shocks as appropriate. For that reason, the ICD body  5400  includes a sensor for measuring the heart rate. In the ICD body  5400 , data on the heart rate obtained by the sensor, the number of times the treatment with pacing is performed, and the time taken for the treatment, for example, can be stored in the memory device  5407 . 
     The antenna  5404  can receive power, and the power is charged into the battery  5401 . When the ICD body  5400  includes a plurality of batteries, the safety can be improved. Specifically, even if one of the batteries in the ICD body  5400  is dead, the other batteries can work properly; hence, the batteries also function as an auxiliary power source. 
     When the semiconductor device described in the above embodiment is applied to the ICD body  5400 , overcharge or overdischarge of the battery  5401  can be prevented in a manner similar to those in the case of the above-described electronic devices. 
     Other than the antenna  5404  capable of receiving electric power, an antenna that can transmit physiological signals may be included. For example, a system that monitors the cardiac activity so as to check physiological signals such as a pulse, a respiratory rate, a heart rate, and body temperature with an external monitoring device may be constructed. 
     Note that this embodiment can be combined with any of the other embodiments in this specification as appropriate. 
     REFERENCE NUMERALS 
     BAT: assembled battery, CNC: circuit, HCMP: hysteresis comparator, HCMP 1 : hysteresis comparator, HCMP 2 : hysteresis comparator, HCMP 3 : hysteresis comparator, HCMP 4 : hysteresis comparator, HCMP 5 : hysteresis comparator, HCMP 6 : hysteresis comparator, HCMP 7 : hysteresis comparator, HCMP 8 : hysteresis comparator, LC: logic circuit, CTL: control circuit, CNV: circuit, RPG: circuit, CE: cell, CADC: circuit, SW 1 : switch, TrS 1 : transistor, C 1 : capacitor, C 2 : capacitor, ND 1 : node, ND 2 : node, CMP 1 : comparator, INV: inverter circuit, LCNA: NAND circuit, LCNO: NOR circuit, CI 1 : input terminal, CI 2 : input terminal, CO 1 : output terminal, CO 2 : output terminal, IT: input terminal, RT: reference potential input terminal, VIT: terminal, VOT: terminal, OT: output terminal, OTB: output terminal, SH: control terminal, SHE: wiring, VGE: wiring, EN: wiring,  100 : semiconductor device,  300 : transistor,  311 : substrate,  313 : semiconductor region,  314   a : low-resistance region,  314   b : low-resistance region,  315 : insulator,  316 : conductor,  320 : insulator,  322 : insulator,  324 : insulator,  326 : insulator,  328 : conductor,  330 : conductor,  350 : insulator,  352 : insulator,  354 : insulator,  356 : conductor,  360 : insulator,  362 : insulator,  364 : insulator,  366 : conductor,  370 : insulator,  372 : insulator,  374 : insulator,  376 : conductor,  380 : insulator,  382 : insulator,  384 : insulator,  386 : conductor,  402 : insulator,  404 : insulator,  500 : transistor,  503 : conductor,  503   a : conductor,  503   b : conductor,  505 : conductor,  510 : insulator,  512 : insulator,  514 : insulator,  516 : insulator,  518 : conductor,  520 : insulator,  522 : insulator,  524 : insulator,  530 : oxide,  530   a : oxide,  530   b : oxide,  530   c : oxide,  530   c   1 : oxide,  530   c   2 : oxide,  540 : conductor,  540   a : conductor,  540   b : conductor,  542   a : conductor,  542   b : conductor,  543   a : region,  543   b : region,  544 : insulator,  546 : conductor,  548 : conductor,  550 : insulator,  552 : insulator,  560 : conductor,  560   a : conductor,  560   b : conductor,  574 : insulator,  580 : insulator,  581 : insulator,  582 : insulator,  586 : insulator,  600 : capacitor,  600 A: capacitor,  600 B: capacitor,  610 : conductor,  611 : conductor,  612 : conductor,  620 : conductor,  621 : conductor,  630 : insulator,  631 : insulator,  650 : insulator,  651 : insulator,  1400 : secondary battery,  1401 : positive electrode cap,  1413 : conductive plate,  1414 : conductive plate,  1415 : power storage system,  1416 : wiring,  1420 : control circuit,  1421 : wiring,  1422 : wiring,  1423 : wiring,  1424 : conductor,  1425 : insulator,  1426 : wiring,  1501 : circuit board,  1509 : label,  1511 : terminal,  1513 : secondary battery,  1515 : sealant,  1517 : antenna,  1519 : layer,  1531 : secondary battery pack,  1551 : one,  1552 : the other,  1590 : control circuit,  1590   a : circuit system,  1590   b : circuit system,  1593 : battery element,  1594 : negative electrode,  1595 : positive electrode,  1596 : separator,  1601 : positive electrode cap,  1602 : battery can,  1603 : positive electrode terminal,  1604 : positive electrode,  1605 : separator,  1606 : negative electrode,  1607 : negative electrode terminal,  1608 : insulating plate,  1609 : insulating plate,  1611 : PTC element,  1613 : safety valve mechanism,  4700 : electronic component,  4701 : lead,  4702 : printed circuit board,  4704 : mounting board,  4710 : semiconductor device,  4730 : electronic component,  4731 : interposer,  4732 : package substrate,  4733 : electrode,  4735 : semiconductor device,  4800 : semiconductor wafer,  4800   a : chip,  4801 : wafer,  4801   a : wafer,  4802 : circuit portion,  4803 : spacing,  4803   a : spacing,  5200 : portable game machine,  5201 : housing,  5202 : display portion,  5203 : button,  5300 : laptop personal computer,  5301 : housing,  5302 : display portion,  5303 : keyboard,  5304 : pointing device,  5305 : pointing device,  5400 : ICD main body,  5401 : battery,  5402 : wire,  5403 : wire,  5404 : antenna,  5405 : subclavian vein,  5406 : superior vena cava,  5407 : memory device,  5500 : information terminal,  5510 : housing,  5511 : display portion,  5700 : automobile,  5900 : wearable terminal,  5901 : housing,  5902 : display portion,  5903 : operation button,  5904 : operator,  5905 : band,  6240 : digital camera,  6241 : housing,  6242 : display portion,  6243 : operation button,  6244 : shutter button,  6246 : lens,  6300 : video camera,  6301 : first housing,  6302 : second housing,  6303 : display portion,  6304 : operation key,  6305 : lens,  6306 : joint,  7500 : stationary game machine,  7520 : main body,  7522 : controller