BACKGROUND OF THE INVENTION-  (1) Field of the Invention 
-  The present invention relates to a semiconductor leakage current detector and a leakage current measurement method for detecting a bit line leakage current of a flash memory and the like at high-speed and for executing on-chip trimming of a reference voltage, to a semiconductor leakage current detector with a voltage trimming function and a reference voltage trimming method, and to a semiconductor integrated circuit thereof. 
-  (2) Description of the Related Art 
-  In recent years, non-volatile memories such as a flash memory and an EEPROM are arranged as a large storage capacity memory array using fine memory cells in addition, as memory cells are finely processed, it has become essential that a non-volatile memory is equipped with a reference voltage source that supplies an accurate internal voltage necessary for rewrite and read-out operations. 
-  One of the problems the recent non-volatile memories are facing is the increase in the leakage current of bit lines due to the development of large storage capacity memory array. This problem particularly results from the increase of the leakage current (bit line leakage current) in each memory cell caused by the fine processing, and the increase in the number of memory cells for each bit line. The increase in the bit line leakage current has an impact on the read-out operation of the memory cell, and degrades the control accuracy of the threshold value of the memory cell and the reliability of the data retention characteristic and the like. The threshold value control process (hereinafter, referred to as a program) of the non-volatile memory cell is controlled by the determination of the width and height of a program pulse and the threshold value, in other words, the repetition of a determination operation (referred to as verify) of the cell current. In the verify operation, the bit line leakage current causes the erroneous determination of the cell current with an error which is as much as the leakage current, results in the excess or insufficiency of charge injection, and impedes the normal threshold value control of a memory cell. 
-  To realize the high reliability of the memory, it is necessary that bit lines in which a leakage is detected during a device test be the object for redundancy replacing, and the relevant device be excluded as a defective device. With regard to such bit line leakage current, a leakage current down to several μA is detected by a sense amplifier which is used for read-out operation. 
-  The measurement of the bit line leakage current by a sense amplifier is described in Patent Reference 1 (Japanese Laid-Open Patent Application No. 06-251593). In addition, a direct measurement method of the leakage current is described in Patent Reference 2 (U.S. Pat. No. 6,201,747 B1); the measurement of the threshold value of a cell is described in Patent Reference 3 (U.S. Pat. No. 6,370,061 B1); the measurement of the on-chip current is described in Patent Reference 4 (United States Patent 2005/0229050 A1). 
SUMMARY OF THE INVENTION-  However, the measurement in the level smaller than μA is required because the accuracy for controlling the threshold value has become essential as a response to the decrease of the cell current caused by fine cell processing, a request for improving the rewritable number of times, and the multileveled threshold value. In the conventional measurement methods, such micro current measurement is directly performed through the external pad by the current measurement option of the test equipment, The test equipment shows the performance for current measurement at the relatively low speed from a few mS to a few tens mS per measurement. In order to measure a few thousands of bit lines constituting a memory array, testing time of around a few tens of seconds is thus required causing a huge impact on the testing cost. 
-  Moreover, for the test equipment, a practical method for reducing the testing time is often used through the improvement the throughput and the parallel test for reducing the cost. However, since such parallel measurement requires a test resource independent for each device of the test equipment, expensive test equipment is required. 
-  Furthermore, with regard to the testing cost, the internal reference voltage source, that controls the accuracy of internal voltage in the device, requires a process (trimming) of adjusting each device at a reference value, contributing to the increase of the testing cost. 
-  As described above, since the measurement of the bit line leakage current and the trimming of the reference voltage source are required for non-volatile memories manufactured through fine processing to maintain high reliability, there is a problem that tests for these non-volatile memories cause increases of the testing time, cost of the test equipment and costs for testing including throughput. 
-  An object of the present invention is to provide a semiconductor leakage current detector, a semiconductor integrated circuit, a leakage current measurement method, and a reference voltage trimming method for detecting a bit line leakage current at high speed in order to reduce the number of necessary tests and for executing on-chip trimming of a reference voltage. 
-  The semiconductor leakage current detector of the present invention for solving the aforementioned problem is a semiconductor leakage current detector which determines whether or not a current to be measured is greater than a reference current The detector includes: a first analog switch which causes the current to be measured to flow or to be cut off; a second analog switch which causes the reference current to flow or to be cut off; an integral capacitor which is connected to the first analog switch and the second analog switch, and is charged with the current to be measured or the reference current; a discharge unit which discharges the integral capacitor; and a comparison unit which compares a reference voltage with each of: an integral voltage generated in the integral capacitor by the reference current after the discharge of the integral capacitor; and an integral voltage generated in the integral capacitor by the current to be measured after the discharge of the integral capacitor, 
-  This configuration allows the semiconductor leakage current detector to make a highly accurate determination of the current to be measured by canceling process variations in integral capacitors among semiconductor leakage current detectors, canceling the offset of the comparator, and removing noises through the integration operation, because the integral capacitor and the comparison unit are the same in the two kinds of comparison between i) an integral voltage of the reference current and the reference voltage and ii) the integral voltage of the current to be measured and the reference voltage. Furthermore, the semiconductor leakage current detector is included in the semiconductor device so that the speed of the measurement of the current to be measured can be increased compared to that of the conventional technologies. 
-  Here, the comparison unit performs a first comparison of comparing the reference voltage with the integral voltage generated in the integral capacitor by the reference current after the discharge of the integral capacitor, and a second comparison of comparing the reference voltage with the integral voltage generated in the integral capacitor by the current to be measured after the discharge of the integral capacitor, and the semiconductor leakage current detector may determine whether or not the current to be measured is greater than the reference current, based on outputs of the comparison unit as results of the first and second comparisons. 
-  This configuration allows the semiconductor leakage current detector to make a highly accurate determination of the current to be measured by canceling variations in integral capacitors for each semiconductor leakage current detector, canceling the offset voltage in the comparison unit, and removing noises superimposed on the reference current and the current to be measured through integral operation performed on the integral capacitors. 
-  Here, in the second comparison, it is determined whether or not the current to be measured is greater than the reference current, based on whether or not the output of the comparison unit is inverted when a predetermined time passes after the discharge of the integral capacitor, and the predetermined time may be equivalent to a time required for the output of the comparison unit to be inverted in the first comparison. 
-  This configuration allows the semiconductor leakage current detector to make a highly accurate determination of the bit line leakage current (current to be measure) at high speed by canceling the variations in the integral capacitors and integration time, canceling the offset of the comparator, and eliminating noises through the integration operation. 
-  Here, the comparison unit is a comparator which periodically takes samples-and compares the samples; the predetermined time is a time required for the comparison unit to take samples, the time being ranged from after the discharge of the integral capacitor until immediately before the inversion of the output of the comparator in the first comparison. The semiconductor leakage current detector may determine that the current to be measured is greater than the reference current, in the case where the output of the comparator is inverted when the predetermined time passes after the discharge of the integral capacitor in the second comparison. 
-  This configuration allows the semiconductor leakage current detector to make a highly accurate determination of the bit line leakage current which exceeds the reference current. 
-  Here, the comparison unit is a comparator which periodically takes samples and compares the samples; the predetermined time is a time required for said comparison unit to take samples, the time being ranged from after the discharge of said integral capacitor until immediately after the inversion of the output of said comparator in the first comparison. The semiconductor leakage current detector may determine that the current to be measured is smaller than the reference current, in the case where the output of the comparator is not inverted when the predetermined time passes after the discharge of the integral capacitor in the second comparison. 
-  This configuration allows the semiconductor leakage current detector to make a highly accurate determination of the bit line leakage current which is smaller than the reference current, and is effective in the case where the bit line leakage current causes the decrease of a cell current. 
-  Here, the predetermined time is equivalent to n-times as long as the time which is ranged from after the discharge of the integral capacitor until the inversion of the output of the comparator in the first comparison. The semiconductor leakage current detector may determine that the current to be measured is greater than 1/n of the reference current in the case where the output of the comparator is inverted when the predetermined time passes after the discharge of the integral capacitor in the second comparison. 
-  This configuration allows the semiconductor leakage current detector to reduce the measurable leakage current by 1/n times. 
-  Here, the semiconductor leakage current detector may include a compensation capacitor which is connected to a line for the reference current and to an upstream of the second analog switch, and has a capacitance value which corresponds to a capacitor connected to the line for the current to be measured. 
-  This configuration allows the semiconductor leakage current detector to make a highly accurate determination of the bit line leakage current with a smaller integral capacitor. 
-  Here, the compensation capacitor may include at least one of a metal option unit and a control option unit. The metal option unit is connectable to a wiring layer during a manufacturing process (mask option, etc.) in order to determine the capacitance value of the compensation capacitor, and the control option unit determines the capacitance value based on a selection by an external control signal. 
-  This configuration allows the semiconductor leakage current detector to obtain extensibility which allows the single design to be adapted to various types of circuit configurations and to finely adjust the compensation capacitor corresponding to the measurement path which differs depending on an operation mode of the circuit to be measured. 
-  Here, in the first comparison, the first and second analog switches are turned on, and a stray capacitor connected to a line for the current to be measured and the integral capacitor are simultaneously charged with the reference current 
-  This configuration allows the semiconductor leakage current detector to turn on the first and second analog switches in the integration operation of the reference current source, charge the capacitor of the current to be measured and the integral capacitor with the reference current simultaneously, and obtain a high determination accuracy without the compensation capacitor in the case where the signal paths of the circuit to be measured resulting from the stray capacitor does not cause a leakage current. In addition, when measuring the leakage current in plural bit lines, this configuration allows the semiconductor leakage current detector to measure one of the plural bit lines as a reference. 
-  Here, the integral capacitor may be an accumulation-type MOS capacitor, 
-  This configuration allows reducing the area of the capacitor significantly in the case where the integral voltage is equal to or less than the threshold value of the MOS structure. 
-  The integral capacitor may be an accumulation-type P-channel MOS capacitor. 
-  This configuration further allows reducing the area of capacitor to be less than that of the Nch accumulation MOS capacitor, in the case where the integral voltage equal to or less than the threshold value of the MOS structure. 
-  The semiconductor leakage current detector may include at least one of a damping capacitor and a damping resistance element, at least one of the damping capacitor and damping resistance being connected to between an input line and a ground line for the reference voltage of the comparison unit. 
-  This configuration allows reducing noises induced on the reference voltage input and generated during the comparator operation, and shortening the dead time in which the comparator output is invalid, by the dumping capacitor and dumping resistance. 
-  The semiconductor leakage current detector further includes a current mirror circuit which outputs the reference current, An output of the current mirror circuit may be connected to the first analog switch, and an input of the current mirror circuit may be connected to an external pad. 
-  This configuration allows the semiconductor leakage current detector to make a highly accurate determination by using the small integral capacitor because an arbitrary reference current is supplied from the test equipment and the capacitor of the semiconductor leakage current detector is separated electrically. 
-  Here, the semiconductor leakage current detector further includes a current mirror circuit which outputs the reference current. An output of the current mirror circuit may be connected to the first analog switch, and an input of the current mirror circuit may be connected to a current source. 
-  This configuration allows creating an electric system with higher reliability because the leakage current (current to be measured) can be measured not only in the test flow but also when the semiconductor leakage current detector is mounted to the system. 
-  Here, the current mirror circuit includes a supply voltage step-down unit, a current mirror connection transistor unit, a third analog switch, and a fourth analog switch. A supply voltage is supplied to the current mirror connection transistor unit via the supply voltage step down unit; an output of the current mirror connection transistor unit is connected to the first analog switch; an input of the current mirror connection transistor unit is connected to the external pad via said third analog switch, and is connected to a power supply via the fourth analog switch; the third and fourth analog switches are exclusively turned on by a shutdown control signal. 
-  This configuration allows realizing low power consumption when the leak detector is inactivated and reducing the output of the parasitic capacitor only to the drain capacitor. 
-  Here, the current mirror connection transistor unit may include a pair of transistors having a single stage current mirror connection. 
-  This configuration allows obtaining current characteristics sufficient for the practical use based on a very simple structure under the condition in which a range of integral voltage is restricted. 
-  Here, the semiconductor leakage current detector further includes a timer which measures an elapsed time after the discharge of the integral capacitor; a memory for storing the predetermined time; and a control unit which controls the first and second comparisons. The control unit may store, into the memory, the elapsed time as the predetermined time, when the output of the comparison unit is inverted in the first comparison, and in the second comparison, it is determined whether or not the current to be measured is greater than the reference current in accordance with the output of the comparison unit, when the elapsed time reaches the predetermined time stored in said memory. 
-  This configuration allows driving the semiconductor leak current detector on chip so as to perform self test. 
-  Here, the semiconductor leakage current detector may further include a reference voltage source which generates the reference voltage. 
-  In this configuration, the semiconductor leak current detector also includes the reference voltage source so that it can be driven on chip independent from the outside and perform self test. 
-  Here, the semiconductor leakage current detector further includes: a reference register which holds trimming data; a reference voltage source which generates a constant voltage in accordance with the trimming data; a first voltage divider circuit which divides the constant voltage and outputs, as the reference voltage, the divided constant voltage to the comparison unit; and an analog multiplexer which connects one of the integral capacitor and an external pad to an integration voltage input of the comparison unit. The control unit may control said comparison unit so as to compare the reference voltage with a signal inputted via the analog multiplexer from the external pad, and update the trimming data in the reference register based on the comparison result. 
-  This configuration allows the semiconductor leakage current detector to realize a self trimming function of the reference current by a small addition of hardware such as an addition of a trimming function to the reference voltage source. 
-  Here, the semiconductor may further include a second voltage divider circuit which is inserted between the external pad and the analog multiplexer, and has the same layout structure as the first voltage divider circuit. 
-  In this configuration, a relatively small-scaled voltage divider circuit can be used because a trimming accuracy can be determined indifferent to the absolute accuracy of a division voltage in the voltage divider circuit, in the case where the voltage divider circuit is used when the integral voltage is smaller than the target voltage. 
-  Here, the analog multiplexer may be an analog switch inserted between the external pad and the integration voltage input of the comparison unit. 
-  This configuration allows the semiconductor leakage current detector to realize a self trimming function of the reference voltage source by a small addition of circuits such as an addition of a trimming function to the reference voltage source. 
-  Here, the semiconductor leakage current detector further includes an inversion analog multiplexer which switches two inputs of said comparison unit, wherein the control unit may control the comparison unit so as to compare the reference voltage with the signal inputted via the analog multiplexer from the external pad, before and after the two inputs of the comparison unit are switched by the inversion analog multiplexer, and update the trimming data in the reference register based on the comparison results. 
-  This configuration allows using an inexpensive small scaled comparator with large offset by adding an inversion analog multiplexer which is inserted to comparator inputs and completely removing the offset of the comparator. 
-  Here, the current to be measured may be a current which flows in a line connected to a source of a memory cell transistor. 
-  This configuration allows the semiconductor leakage current detector to make a highly accurate determination of the bit line leakage current at high speed in a memory cell used for a source-side read-out method. 
-  The semiconductor integrated circuit of the present invention further includes the aforementioned semiconductor leakage current detector. 
-  This configuration allows the semiconductor leakage current detector to make a highly accurate determination of the bit line leakage current (current to be measured) at high speed by canceling the variations of integral capacitors and integral time, and canceling the offset of the comparator, and removing noises through the integral operation. 
-  Here, the semiconductor integrated circuit further includes; an external analog input/output pad; a reference voltage source which generates the reference voltage; and an analog multiplexer which connects one of internal signal lines of the semiconductor integrated circuit exclusively to the external analog input/output pad, wherein the internal signal lines include at least one of a reference voltage line from the reference voltage source, a current line to be measured for the current to be measured, a reference current line from the semiconductor leakage current detector, and an other signal line. 
-  This configuration realizes an effective use of a single analog test pad so that a semiconductor integrated circuit with high performance testability using a small area is provided. 
-  Here, the semiconductor integrated circuit further includes a timer which measures an elapsed time after the discharge of the integral capacitor; a memory for storing the predetermined time; and a control unit which controls the first and second comparisons. The control unit may store, into the memory, the elapsed time as the predetermined time, when the output of the comparison unit is inverted in the first comparison, and in the second comparison, it may be determined whether or not the current to be measured is greater than the reference current in accordance with the output of the comparison unit, when the elapsed time reaches the predetermined time stored in the memory. 
-  This configuration allows obtaining current characteristics sufficient for the practical use based on a very simple structure under the condition in which a range of integral voltage is restricted 
-  Here, the control unit includes a CPU, and a clock generation circuit, and the memory may store a program code and data of the CPU, and a crock generation circuit. 
-  In this configuration, the operation of the semiconductor leakage current detector is controlled by software so that the operation algorithm is easily changed and a design change is not required for a functional change. Furthermore, a CPU, a clock, a timer and the like can use a memory cell together with execution hardware of a general rewrite algorithm so that a high performance detector can be realized with a small area. 
-  Here, the semiconductor integrated circuit includes: a reference voltage source which generates a constant voltage in accordance with voltage data; a voltage divider circuit which divides the constant voltage and outputs, as the reference voltage, the divided constant voltage to the comparison unit; an oscillator which oscillates a operation clock signal; and a holding unit which holds setting data for trimming. The holding unit includes one of a first register for holding the voltage data for setting a voltage of the reference voltage source, a second register for holding data for setting a division ratio of the voltage divider circuit, a third register for holding data for setting a capacitance value of the integral capacitor, a fourth register for holding data for setting a bit-length of the timer, and a fifth register for holding data for setting an oscillation frequency of the oscillator, and the control unit may update the setting data in the holding unit so as to correspond to the current to be measured. 
-  This configuration allows the semiconductor integrated circuit to be easily adaptable to a change to a wider range of the current to be measured by updating software. 
-  Here, the semiconductor integrated circuit further includes: a reference register which holds trimming data; a reference voltage source which generates a constant voltage in accordance with the trimming data; a first voltage divider circuit which divides the constant voltage and outputs, as the reference voltage, the divided constant voltage to the comparison unit; and an analog multiplexer which connects one of the integral capacitor and an external pad to an integration voltage input of the comparison unit. The control unit may control the comparison unit so as to compare the reference voltage with a signal inputted via the analog multiplexer from the external pad, and to update the trimming data in the reference register based on the comparison result. 
-  This configuration allows a realization of a self trimming function of the reference voltage source by a small addition of hardware such as an addition of a trimming function to the reference voltage source. 
-  Here, the semiconductor integrated circuit may further include a second voltage divider circuit which is inserted between the external pad and the analog multiplexer, and have the same layout structure as said first voltage divider circuit. 
-  With this configuration, a relatively small-scaled voltage divider circuit can be used because a trimming accuracy can be determined indifferent to the absolute accuracy of a division voltage in the voltage divider circuit, in the case where the voltage divider circuit is used when the integral voltage is smaller than the target voltage. 
-  The analog multiplexer may include an analog switch which is inserted between the external pad and a wiring which connects the integral capacitor with an integration voltage input of the comparison unit. 
-  This configuration allows a realization of a self trimming function of the reference voltage source with a fewer addition of circuits. 
-  Here, the semiconductor integrated circuit further includes an inversion analog multiplexer which switches two inputs of the comparison unit, wherein the control unit may control the comparison unit so as to compare the reference voltage with the signal inputted via the analog multiplexer from the external pad, before and after the two inputs of said comparison unit are switched by the inversion analog multiplexer, and update the trimming data in the reference register based on the comparison results. 
-  This configuration allows using a small scaled comparator with large offset by completely removing the offset of the comparator. 
-  Here, the semiconductor integrated circuit may further includes a voltage follower which is inserted between the reference voltage source and the first voltage divider circuit; a bypass wiring which bypasses the voltage follower; and a witch circuit which selects one of the voltage follower and the bypass wiring, wherein the switch circuit may select the voltage follower at least in the first and second comparisons. 
-  This configuration allows reducing errors caused by the decrease of the reference voltage when the leak current is detected, and realizing a high-speed rising of the reference voltage when the power is applied to the semiconductor integrated circuit. 
-  Here, the current to be measured may be a current which flows in a line connected to a source of a memory cell transistor. 
-  This configuration allows the semiconductor leakage current detector to make a highly accurate determination of the bit line leakage current at high speed in a memory cell used for a source-side read-out method. 
-  The leakage current measurement method of the present invention is a leakage current measurement method for use in a semiconductor integrated circuit, wherein the semiconductor circuit includes: a first analog switch which causes the current to be measured to flow or to be cut off; a second analog switch which causes the reference current to flow or to be cut off; an integral capacitor which is connected to the first analog switch and the second analog switch, and is charged with the current to be measured or the reference current; a discharge unit which discharges the integral capacitor; and a comparator which compares a reference voltage with each of: an integral voltage generated in the integral capacitor by the reference current after the discharge of the integral capacitor; and an integral voltage generated in the integral capacitor by the current to be measured after the discharge of the integral capacitor. The leakage current measurement method includes: a calibration step of comparing the reference voltage with the integral voltage generated in the integral capacitor by the reference current after the discharge of the integral capacitor, a test step of comparing the reference voltage with the integral voltage generated in the integral capacitor by the current to be measured after the discharge of the integral capacitor, and a determination step of determining whether or not the current to be measured is greater than the reference current, based on results obtained in the calibration step and the test step. 
-  Here, in the calibration step, a time required for the output of the comparator to be inverted after the discharge of the integral capacitor is measured; in the test step, a comparison result obtained by the comparator is checked when the time passes after the discharge of the integral capacitor; in the determination step, it is determined whether or not the integral voltage is greater than the reference voltage, based on whether or not the comparison result is inverted in the test step. 
-  This configuration allows the semiconductor leakage current detector to make a highly accurate determination of the bit line leakage current (current to be measured) at high speed by canceling the variations of integral capacitors and integral time, and canceling the offset of the comparator, and removing noises through the integral operation. 
-  Here, a predetermined time is equivalent to n-times as long as the time which is ranged from after the discharge of the integral capacitor until the inversion of the output of the comparator in the calibration step, and in the determination step, it is determined that the current to be measured is greater than 1/n of the reference current in the case where the output of the comparator is inverted when the predetermined time passes after the discharge of the integral capacitor. 
-  This configuration allows the semiconductor leakage current detector to reduce the measurable leakage current by 1/n times. 
-  Here, the semiconductor integrated circuit further includes a current mirror circuit which outputs the reference current, an output of the current mirror circuit is connected to the first analog switch, and an input of the current mirror circuit is connected to an external pad, The leakage current measurement method further includes: a reference current apply step of applying a reference current from an external pad; and a reference current stabilization step of keeping an operation in the calibration step on standby until the reference current is stabilized as a constant current by charging a parasitic capacitor of the external pad with the reference current 
-  This configuration allows a realization of a highly accurate determination of a leakage current at a software level. 
-  Here, the calibration step includes an initialization step, a start step, a read-out loop, and a storage step that are sequentially executed. In said initialization step, the timer is initialized and the integral capacitor is discharged. In the start step, counting of the timer and charging of the integral capacitor with the reference current are started. In the read-out loop, the comparator is periodically read out during the counting of the timer and the charging of the integral capacitor, and the counting of the timer and the read-out loop is stopped, when the comparator indicates that the integral voltage is greater than the reference voltage. In the storage step, a count value counted by the timer is stored when the read-out loop is stopped. Furthermore, the test step includes a capacitor initialization step, a timer start step, a countdown loop, and a determination step that are sequentially executed. In the capacitor initialization step, loading of the count value into the timer stored in the storage step and discharging of the integral capacitor are executed. In the timer start step, counting-down of the timer and charging of the integral capacitor are started. In the countdown loop, the counting down of the timer and the charging of the integral capacitor are executed, and the countdown loop is stopped when a countdown value counted by the timer reaches a predetermined value. In the determination step, a test for determining whether or not the current to be measured is greater than the reference current is executed. 
-  This configuration allows the semiconductor integrated circuit to realize a self test. 
-  The reference voltage trimming method of the present invention is a reference voltage trimming method for use in the aforementioned semiconductor device, the method includes a target voltage apply step, a first intermediate value search step, a comparator input inversion step, a second intermediate value search step, and a trimming value average step that are sequentially executed. In the target voltage apply step, the reference voltage is applied. In the first intermediate value search step, a first trimming intermediate value is obtained, the first trimming intermediate value being a boundary value at which an output of the comparator is inverted. In the comparator input inversion step, inputs of the comparator are switched by the inversion analog multiplexer. In the second intermediate value search step, a second trimming intermediate value is obtained, the second trimming intermediate value being a boundary value at which an output of the comparator is inverted. In a trimming average step, a trimming value is obtained by taking an average between the first trimming intermediate value and the second trimming intermediate value, as a trimming result of the reference voltage, 
-  This configuration allows removing influences of the input offset of the comparator and trimming the reference voltage. 
-  Here, the first intermediate value search step includes a trimming initial value setting step, a comparator read-out step, and a trimming loop that are sequentially executed. In the trimming initial value setting step, an initial value is set to the reference voltage register which controls an output level of the reference voltage. In the comparator read-out step, the comparator is read out and whether or not an external voltage which is proportional to a voltage of the external pad is greater than the reference voltage is read out. In the trimming loop, the trimming data in the reference voltage register is moved one step down to a high voltage in the case where the external voltage is smaller than the reference voltage and the comparator is repeatedly read out until the external voltage becomes greater than the reference voltage, and in the case where the external voltage is greater than the reference voltage, the reference voltage register is moved one step up and the comparator is repeatedly read out until the external voltage becomes smaller than the reference voltage. 
-  In the second intermediate value search step, the same processes as in the first intermediate value search step may be performed except the following processes of: setting the first trimming intermediate value to the reference voltage register in the trimming initial value setting step; and outputting the second trimming intermediate value in said trimming loop. 
-  This configuration allows removing the influences of the input offset of the comparator, increasing the speed of searching a second trimming intermediate value, and shortening the trimming time. 
-  As described in the above, the semiconductor leakage current detector of the present invention can make a highly accurate determination of the leakage current at high speed using a simple measurement algorithm by canceling errors resulted from the system of measurement such as variations of integral capacitors and input offset voltage of the comparator, and removing noises superimposed on the current to be measured through the integral operation. 
-  As further information about technical background to this application, the disclosure of Japanese Patent Application No. 2005-370915 filed on Dec. 22, 2005 including specification, drawings and claims is incorporated herein by reference in its entirety. 
BRIEF DESCRIPTION OF THE DRAWINGS-  These and other objects, advantages and features of the invention will become apparent from the following description thereof taken in conjunction with the accompanying drawings that illustrate a specific embodiment of the invention. In the Drawings: 
- FIG. 1 is a block diagram showing a semiconductor leakage current detector which includes a control unit, a memory, and a timer according to a ninth embodiment; 
- FIG. 2 is a schematic circuit diagram of a semiconductor leakage detector according to a tenth embodiment; 
- FIG. 3 is a schematic circuit diagram of a semiconductor leakage current detector according to a first embodiment; 
- FIG. 4 is a schematic circuit diagram of a semiconductor leakage current detector according to a second embodiment; 
- FIG. 5 is a schematic diagram showing a configuration of a semiconductor leakage current detector according to a third embodiment; 
- FIGS. 6A and 6B are explanatory diagrams of a P-channel accumulation type MOS capacitor according to a fourth embodiment; 
- FIG. 7 is a schematic circuit diagram of a semiconductor leakage current detector according to a fifth embodiment; 
- FIG. 8 is a schematic circuit diagram of a semiconductor leakage current detector according to a sixth embodiment; 
- FIG. 9 is a schematic circuit diagram of a semiconductor leakage current detector according to a seventh embodiment; 
- FIG. 10 is a block diagram showing a current mirror circuit according to an eighth embodiment; 
- FIG. 11 is a circuit diagram showing the current mirror circuit at a transistor level; 
- FIG. 12 is a partial block diagram showing a semiconductor integrated circuit according to an eleventh embodiment; 
- FIG. 13 is an explanatory diagram of an operation of the semiconductor leakage current detector; 
- FIG. 14 is a partial block diagram of the semiconductor integrated circuit according to a twelfth embodiment; 
- FIG. 15 is a block diagram showing a main unit of a semiconductor integrated circuit according to a thirteenth embodiment; 
- FIG. 16 is an explanatory diagram showing a temporal development of an input voltage of a comparator according to a fourteenth embodiment; 
- FIG. 17 is a block diagram showing a configuration of a main unit of a semiconductor leakage current detector according to a fifteenth embodiment; 
- FIG. 18 is a diagram showing a configuration of a variation of the semiconductor leakage current detector; 
- FIG. 19 is a block diagram showing a configuration of a main unit of a semiconductor leakage current detector according to a sixteenth embodiment; 
- FIG. 20 is a block diagram showing a configuration of a main unit of a semiconductor leakage current detector according to a seventeenth embodiment; 
- FIG. 21 is a block diagram showing a main unit of a semiconductor leakage current detector according to an eighteenth embodiment; 
- FIG. 22 is a flowchart showing details of a calibration operation; 
- FIG. 23 is a flowchart showing details of a test operation; 
- FIG. 24 is a flowchart showing a trimming processing; 
- FIG. 25 is a flowchart showing details of a first intermediate value search step inFIG. 24; 
- FIG. 26 is a flowchart showing details of a second intermediate value search step inFIG. 24; 
- FIG. 27 is a block diagram showing an example of a semiconductor device according to a nineteenth embodiment; and 
- FIG. 28 is an explanatory diagram of a leakage current in bit lines shown inFIG. 27. 
DESCRIPTION OF THE PREFERRED EMBODIMENTS-  Hereinafter, embodiments of the present invention shall be described with reference to the attached drawings. Note that, the embodiments of the present invention show only the examples so that the present invention is not limited to the disclosure of the embodiments. 
First Embodiment- FIG. 3 is a schematic circuit diagram of a semiconductor leakage current detector according to the first embodiment of the present invention. InFIG. 3, a reference voltage Vref is supplied to a reference-side input31 of acomparator30 from areference voltage circuit43, and an integral voltage Vint is supplied to an integral capacitor-side input32 to which theintegral capacitor34 is connected. Adischarge transistor35 is connected in parallel to the integral capacitor34 (Cd), and discharges a charge to a ground level. A measuredcircuit44, which is a circuit to be measured, Is made up of bit lines of a memory and the like, and supplies a current to be measured46 (Ileak) to theintegral capacitor34 through asecond analog switch40. Furthermore, the referencecurrent circuit45 supplies a reference current47 (Iref) to theintegral capacitor34 via afirst analog switch39. A stray capacitor38 (Cs) is connected to a current path of the measuredcircuit44, and a compensation capacitor37 (Cc) having a capacitance value, which is equivalent to thestray capacitor38, is connected to the referencecurrent circuit45. Adischarge transistor36 is connected in parallel to thecompensation capacitor37, and discharges a charge to the ground level. 
-  Hereinafter, it shall be described about a comparison operation between the reference current47 and the current to be measured46. The comparison operation is mainly divided into a calibration operation and the following test operation. 
-  (Calibration Operation) 
-  The calibration operation starts with the discharge operation of theintegral capacitor34 and thecompensation capacitor37 to the ground level. A reference current circuit may be kept activated in the case where a reference current is sufficiently small during the aforementioned discharge operation to the ground level (for example, several μA). Next, a calibrationcircuit selection signal41 is set to be active and a measuredcircuit selection signal42 is set to be inactive. Following that, current integration to the integral capacitor is started by setting thedischarge transistors35 and36 to OFF (T=0). During the current integration, the reference current47 (Iref) charges up the compensation capacitor37 (Cc) and the integral capacitor34 (Cd). The calibration operation is completed with an acquisition of an integral time Tint (T=Tint) which is a duration from the start of the calibration operation to immediately before the inversion of thecomparison output33 of the comparator during the charge. Here, Tint is expressed by the following (Expression 1) according to a conservation law of charge, where the offset of thecomparator30 is defined as Vo.
 Tint=(Vref+Vo)×(Cd+Cc)/Iref  (Expression 1)
 
-  (Test Operation) 
-  The test operation starts with turning on thedischarge transistor35 and discharging theintegral capacitor34 and thestray capacitor38 to the ground level after activating the measuredcircuit selection signal41 and setting the calibrationcircuit selection signal41 as inactive. Next, a (T=0) integration is started by turning off thedischarge transistor35, and whether or not the current to be measured46 is greater than the reference current47 is determined by referring to thecomparison output33 after the integral time Tint. 
-  Note that, in the case where the bit line leakage current is the current to be measured, the test operation may be repeated for a bit line as a measurement unit (single bit line or plural bit lines). 
-  (Determination Algorithm) 
-  When the integration is started, Vint<Vref is satisfied. Therefore, the condition under which the comparator output is inverted is expressed by the followingexpression 2.
 Vint+Vo>Vref+Vo  (Expression 2)
 
-  Furthermore, the followingexpression 3 is established according to the charge conservation law, where time T=Tint.
 Tint=(Vint+Vo)×(Cd+Cs)/Ileak   (Expression 3)
 
-  When theexpressions 1 and 3 are substituted into theexpression 2, the relationship between Ileak and Iref is obtained as shown in the followingexpression 4.
 Ileak>Iref×(1+Cs/Cd)/(1+Cc/Cd)  (Expression 4)
 
-  The input offset voltage Vo of the comparator is irrelevant to theexpression 4. Furthermore, the followingexpression 5 is obtained by setting the stray capacitance value Cs and the compensation capacitance value Cc so as to be identical to each other.
 Ileak>Iref  (Expression 5)
 
-  Specifically, it is indicated that the leakage current exceeds the reference current in the case where the comparator output is inversed after the integral time. Based on theexpression 4, when Cd>>Cs, Cc, the matching accuracy between Cs and Cc has a little influence on the determination result. On the contrary, when the matching accuracy between Cs and Cc is increased, only a small integral capacitor Cd may be used. The smaller the integral capacitance is the shorter the time necessary to reach the reference voltage becomes. Therefore, it is possible to execute a leakage current determination at high speed. 
-  (Regarding Accuracy) 
-  The input offset voltage Vo of the comparator is cancelled because the integral capacitor is always fixed to the comparator input. 
-  Therefore, it is preferred to form the integral capacitor within the chip. Furthermore, the current to be measured such as a reference current and a bit line leakage current has a very small steady-state current value so that noise is likely to be superimposed on the current. However, the noise components can be restrained by integrating a current into the integral capacitance and an SIN (signal to noise ratio) used for the determination can be improved. 
-  Also, the integral time only needs to keep a relative accuracy at the time of repetition, by applying the same value to the integral time and the integral time for determination. 
-  According to the first embodiment, the semiconductor leakage current detector can make a highly accurate determination of a bit line leakage current by canceling the variations of integral capacitors and the errors caused by the measurement system such as an input offset voltage of the comparator and the like, and removing the noise components superimposed on the current to be measured through integration operation. Furthermore, it is possible to make a highly accurate determination of the leakage current at high speed using the compensation capacitor, even with a small integral capacitor, As an embodiment of a circuit, the leakage current as much as 100 nA can be measured in 10 μS, so that a high-speed measurement which is a thousand time higher than the case in which the test equipment directly measures a current from outside the circuit. 
-  Note that, in the case where the value immediately after the inversion of the comparator output is defined as Tint in the calibration operation, the semiconductor leakage current detector can make a highly accurate determination that the bit line leakage current falls below the reference current when detecting, by using the value of Tint, that the output of the comparator is not inverted in the test operation. The Tint may be the time immediately after the inversion because there is a dead area (unstable) of the comparator near the reference voltage. This determination mode is useful in the case where the leakage current to neighboring cells such as a cell current in a virtual ground array used for a read-out in the source side exists as the decrease of the cell current. 
Second Embodiment- FIG. 4 is a schematic circuit diagram of a semiconductor leakage current detector with a greater range of application in which the compensation capacitor is varied, in addition to the configuration described in the first embodiment. InFIG. 4, the compensation capacitor is made up of ametal option unit400 and acontrol option unit401, as a compensation capacitor circuit. Themetal option unit400 sets a gate voltage of the transistor which is connected to the capacitor in series, based on the potential of the metal layer connected to the gate, and sets a fixed value portion of the compensation capacitor. Also, themetal option unit400 is connectable to a wiring layer during a manufacturing process (mask option, etc.) in order to determine the capacitance value of the compensation capacitor. Thecontrol option unit401 selectively sets the potential of the gate of the transistor which is connected to the capacitor in series, and sets the variable portion of the compensation capacitor. Furthermore, thecontrol option unit401 determines the capacitance value based on a selection by an external control signal. 
-  For example, in the case where the measured circuit determines a bit line leakage current, themetal option unit400 absorbs a fixed parasitic capacitance difference due to the array configuration difference such as a bit line length and the number of memory cells per bit line. Thecontrol option unit401 absorbs the variable parasitic capacitance difference (for example, the number of bit lines to be selected) in accordance with a bit line selected by a decoder in an array. 
-  Note that, whereas the selectivity of capacitors is realized by changing the potential of the gate of the transistor in the metal option unit, it is obvious that the same effect can be obtained by directly connecting the capacitors using a metal layer. Furthermore, the metal option unit is unnecessary in the case where the leakage detector is optimized for a single array configuration. 
-  According to the second embodiment, the semiconductor leakage current detector is applicable to the circuit having a different array configuration based on only a single circuit design, and the compensation capacitor can be finely adjusted according to a change of a measurement path caused by a difference in an operation mode by the measured circuit. Therefore, the accuracy of determining the bit line leakage current can be further improved. 
-  Third Embodiment 
- FIG. 5 is a schematic diagram showing a configuration of a semiconductor leakage current detector capable of deleting a compensation capacitor or downsizing the capacitance of the capacitor, in addition to the configuration of the first embodiment. InFIG. 5, the main differences with the first embodiment are the deletion of thecompensation capacitor37 connected to the output of the reference current47, the deletion of thedischarge transistor36, and the range of charging the reference current501 (charge the stray capacitor38). It shall be described about the comparison between the reference current501 and the current to be measured. The comparison operation is mainly divided into the calibration operation and the following test operation. 
-  (Calibration Operation) 
-  The calibration operation starts with the discharge operation of theintegral capacitor34 and thestray capacitor38 to the ground level via thedischarge transistor35, selecting the measuredcircuit selection signal42. In the case where a reference current is sufficiently small (for example, several μA), a reference current circuit may be kept activated. The calibrationcircuit selection signal41 and the measuredcircuit selection signal42 are simultaneously selected, and the (t=t0) integration is started by turning thedischarge transistor35 off. The reference current501 (Iref) charges up the stray capacitor38 (Cs) and the integral capacitor34 (Cd). The calibration operation is completed by obtaining the time Tint2 which is the time immediately before the inversion of thecomparison output33, by referring to thecomparison output33 of the comparator during the aforementioned charging. Here, Tint2 is expressed by the followingexpression 6 based on the charge conservation law when defining the offset of thecomparator30 as Vo.
 Tint2=(Vref+Vo)*(Cd+Cs)/Iref  (Expression 6)
 
-  (Test Operation) 
-  The test operation starts with the discharge of theintegral capacitor34 and thestray capacitor38 to the ground level by turning thedischarge transistor35 on. Next, the measuredcircuit selection signal42 is activated and the calibrationcircuit selection signal41 is set to be inactive. The integration of a leakage current in the (t=t0) measuredcircuit44 is started by turning thedischarge transistor35 off, and determines whether or not the current to be measured is greater than the reference current501 by referring to thecomparison output33 after theintegral time Tint2. 
-  The condition for the comparator to be inverted is expressed by the following expression.
 Vint+Vo>Vref+Vo  (Expression 7)
 
-  The followingexpression 8 is established according to the charge conservation law when time t=Tint2.
 Tint2=(Vint+Vo)*(Cd+Cs)/Ileak  (Expression 8)
 
-  The followingexpression 9 is obtained by substituting theexpressions 6 and 8 into theexpression 7.
 Ileak>Iref  (Expression 9)
 
-  Specifically, it is indicated that the leakage current exceeds the reference current in the case where the comparator output is inversed after the integral time. 
-  The input offset voltage Vo and Cs of the comparator is irrelevant to theexpression 9. The deletion of Cc and the deletion of the matching error between Cd and Cs can be realized by using Cs for the integration of the reference current, so that a smaller integral capacitor Cd can be used. It requires efforts to keep the capacitance matching accuracy between Cd and Cs in a greater range of the integration voltage because Cd and Cs have different voltage dependencies on the capacitances unless Cd and Cs are made of capacitors of the same configuration. On the contrary, Cd and Cs are commonly used for the calibration operation and the test operation in the present embodiment, so that the best capacitance matching accuracy is obtained. 
-  Thecapacitor separation transistor500 is placed in the measuredcircuit44 shown inFIG. 5 so as to separate the measured circuit which is a leakage source. In this case, if the bit lines to be measured are stratified, thecapacitor separation transistor500 is preferred to be connected to the bit line of an upper hierarchy. Furthermore, the compensation capacitor may be placed on the reference side in order to improve accuracy. Here, the compensation capacitor has a capacitance value which corresponds to the capacitance value separated by the capacitor separation transistor, and which is smaller than the original compensation capacitor Cs. Therefore, the compensation capacitor does not give much impact on an accuracy of determining a matching error. In the case where the measured circuit is a memory array, the capacitor separation transistor may be a column selection transistor. 
-  Whereas the integral time Tint of the reference current and the integral time of the current to be measured are the same in the present embodiment, the integral time of the current to be measured may be n-times as much as the Tint. In this case, the reference current is equivalent to 1/n times of Tint. Accordingly, a measurable leakage current can be further reduced. Here, it is necessary to consider the multiple accuracy of time since it affects the measurement accuracy. However, in the case where time is measured by a digital counter, the realization of the leakage current detector is relatively easy. 
-  According to the present embodiment, when a leakage current determination is performed in plural bit lines, it is possible to measure one of the plural bit lines as a reference for a parasitic capacitor. 
-  As described in the above, according to the third embodiment, a highly accurate determination can be performed by a small integral capacitor which does not require a parasitic capacitor in the case where a signal path resulted from the parasitic capacitor of the measured circuit does not involve a leakage current. 
Fourth Embodiment-  The fourth embodiment describes an example of a semiconductor leakage current detector which is reduced in area by using an accumulation-type MOS capacitor for the integral capacitor according to the first embodiment. In the first embodiment, the voltage level of the integral capacitor ranges from several tens mV to several hundreds mV, and is in a range less than a threshold value of the MOS capacitor, in order to increase the determination speed. 
-  In such low voltage area, a substrate of a commonly-used depletion-type CMOS capacitor is in a depletion state, causing a problem that the capacitance value equivalent to a fraction of a capacitance of normal inverted region. In order to solve this problem, it is preferred to use a Pch accumulation-type MOS capacitor as an integral capacitor.FIG. 6 is an explanatory diagram of the Pch accumulation-type MOS capacitor. InFIG. 6, the accumulation capacitor biases the Pch accumulation-type MOS capacitor placed under the gate oxide film Tox so that the Pch-accumulation-type MOS capacitor is set to be in an accumulation mode. In the case of the Pch accumulation-type MOS capacitor, an N-type substrate which is biased at 0V is placed on the GND side of the capacitor, and the gate electrode is biased at a positive voltage so that the substrate is not depleted. As shown in the bias dependence of the Pch accumulation-type MOS capacitor inFIG. 6, in the case where the gate electrode is a positive bias, the capacitance dependence by the bias is small so that it is a desired for an integral capacitor. Since the Pch accumulation-type MOS capacitor has small voltage dependence as a compensation capacitor, it matches well with the stray capacitance parasitic capacitor. Here, it is ideal to use, as a compensation capacitor, a capacitance element having the same configuration as the capacitance of the stray capacitor (same voltage dependence). When being biased at a negative voltage, the gate electrode serves as a PchMOS depletion-type capacitor, and the substrate is depleted together with the bias voltage. The capacitance decreases continuously until an inverted layer is formed when the bias voltage reaches the threshold value of the MOS configuration. Note that, in the case of the CMOS process on the Pch substrate, the Pch accumulation-type MOS capacitor grounds the N well so that an NPN-type parasitic bipolar transistor is formed, Therefore, it is necessary to sufficiently secure a guard band of the P well so that the Pch substrate is not biased to the positive voltage, in terms of the layout. Furthermore, an Nch accumulation-type device is formed by inverting the polarity of the substrate. In this case, the gate electrode is a ground, and the P substrate is a positive potential (N substrate should be biased higher than this positive potential). Aside from the layout such as a contact area of the substrate, the Pch accumulation-type MOS capacitor has the largest capacitance per unit area, The Pch accumulation-type MOS capacitor is the best suitable integral capacitor which has a large capacitance (for example, 10 pF) and is used restrict to a low-speed operation (10 μS) as represented by the semiconductor leakage current detector of the present invention. 
-  According to the fourth embodiment, in the case where the integration voltage is less than the threshold of the MOS configuration, the area occupied by the capacitance element is significantly reduced. Further reduction in the area can be realized by utilizing the Pch accumulation MOS capacitor for the capacitance. Note that, whereas the accumulation capacitor is described as the integral capacitor which requires the largest area in the present embodiment, it is obvious that the similar effect can be obtained even in the case of adapting a compensation capacitor with a relatively large capacitance value when considering that, when a small integral capacitor is used, it becomes greater than the normal depletion-type CMOS capacitor due to overhead of the substrate contact in the layout. 
Fifth Embodiment- FIG. 7 is a schematic circuit diagram of a semiconductor leakage current detector having a configuration in which noise of the comparator input is reduced from the configuration of the first embodiment. InFIG. 7, a dampingcapacitor700 and a dampingresistance701 are connected in parallel to thereference side input31. The dampingcapacitor700 reduces the amplitude of coupling noise generated in Vref at the time of comparator operation (equalization and charging operation), and the dampingresistance701 reduces the induced noise and shortens the dead time of the comparator. Furthermore, the capacitance difference between thecapacitor side input32 and thereference side input31 can be decreased so that resistance to the common mode noise which is AC coupled to the inputs can be improved. Accordingly, it is preferred to match the damping capacitance with the input capacitance of the integralcapacitor side input32 as long as there are available areas. Also, the dampingresistance701 reduces the induced noise and the noise is reduced faster as the resistance is lower. Therefore, it is preferred to set the reference voltage as long as possible within a range in which the reference voltage can be supplied. With reference toFIG. 16, it is described a temporal development of the input voltage of the comparator. In the diagram, a vertical axis indicates a comparator input voltage and a horizontal axis indicates time. Thereference voltage165 is always biased at a certain value Vref. Furthermore, the integration voltage is discharged at 0V during the discharge and theintegration voltage164 is monotonously increased during the integral operation. In the sampling by the comparator, asample clock166 is sampled during the period of H, and is initialized when it falls (equalization of an internal node, pre-charge operation and the like). At the initialization timing, a spike noise is induced into thereference voltage165 by the capacitive coupling of the internal signal for the initialization and the reference voltage input. The relax time of spike noise is equivalent to a dead time of the comparator. 
-  According to the fifth embodiment, a high-speed calibration operation can be realized by reducing the-noise induced in the Vref due to the coupling at the time of comparator operation, and shortening the comparator dead time. Furthermore, the resistance against the common mode noise is improved and the operational reliability in the on-chip environment in which a large amount of noise is produced can be increased. 
-  Note that, whereas noise can be reduced by including a discharge transistor in place of the damping capacitor and the damping resistance, a re-charging time (also referred to as dead time) to reach the Vref level is necessary. 
Sixth Embodiment- FIG. 8 is a schematic circuit diagram of a semiconductor leakage current detector which supplies a reference current from the external pad, according to the configuration of the first embodiment. InFIG. 8, the reference current circuit is made up of acurrent mirror circuit800. Thecurrent mirror circuit800 is used for generating a micro current, and outputs a reference current output801 (Iref) as a 1/N mirror current of thereference input802 which is a sync input from the external pad804. The external pad has a parasitic capacitor803 which is configured as an output capacitance of a detector, a capacitance of a device interface, and the like. The external parasitic capacitor803 is electrically separated from the input node of the comparator in the detector by using thecurrent mirror circuit800. 
-  (Reference Input Sequence) 
-  The input sequence of the reference current to the external pad is described. A constant current source of the test equipment is connected to the external pad, and is waited for the potential of the external pad to be stable. A part of the sync current which flows in the test equipment is used for charging the parasitic capacitor immediately after the current input. Therefore, the potential of the external pad varies causing instability of the reference current. The stability of the referencecurrent output801 can be verified by measuring the potential of the external test pad. As a specific example of such current, when the output current is set at 100 nA and the mirror ratio is N=10, the external pad804 biases the constant current load from the test equipment. The greater current which is biased to the external pad results in a faster current output settling time. On the contrary, when a micro current is necessary, the size of a transistor which constitutes a current mirror circuit is increased. There is thus a tradeoff between a decrease in the size of a transistor and a decrease in current. Note that, it is obvious that the settling time does not affect the test time because the settling time is required only once if the reference current, which is now in operation, in the semiconductor current detector is kept activated. 
-  It is difficult to supply a reference current directly from the external pad because of the following parasitic capacitor relationship. The parasitic capacitor of the external pad is as large as several hundreds pico farad (pF) including the capacitance of the current source of the test equipment, and relies on the test equipment. Accordingly, it is necessary to use an integral capacitor having a capacitance value which is at least larger than a capacitance value, by one order of the magnitude, of the external parasitic capacitor in order to use such large unstable capacitor as a reference current source. However, such large capacitor cannot be allowed to be used on-chip in terms of costs, so that a penalty of placing the capacitor outside the chip needs to be considered. Furthermore, the speed of determining a leakage current is decreased at least down to two orders or more of magnitude so that there is no big difference compared to the case of measuring the leakage current directly using the external pad. Therefore, the high-speed feature of the on-chip detector is faded. The reference current supply method for, use in the current mirror circuit is highly consistent with the semiconductor leakage current detector of the present invention. 
-  According to the sixth embodiment, a reference current with absolute accuracy can be supplied at low cost by supplying the reference current from the external pad. Furthermore, the reference current can be easily changed. In the mirror circuit, the capacitor of the external pad can be electrically separated from the integral capacitor and the compensation capacitor. Therefore, a small integral capacitor can be adapted and a high-speed/high-accurate semiconductor leakage current detector can be provided at low cost. 
Seventh Embodiment- FIG. 9 is a schematic circuit diagram of a semiconductor leakage current detector in which the reference current, which had been supplied from the external pad, is internally generated, according to the configuration of the sixth embodiment. InFIG. 9, the input current of thecurrent mirror circuit900 is supplied from the referencecurrent generation circuit901. As similar to the case of the sixth embodiment, the output capacitor of the referencecurrent generation circuit901 is electrically separated from the integral capacitor and the compensation capacitor, reducing the integral capacitor. The following explains the benefit of equipping the reference current generation circuit even with the increase in the layout area, whereas the degree of freedom of the reference current is degraded compared to the case of the external pad input. In the sixth embodiment, a test equipment and a corresponding circuit are necessary to be placed outside the device for measuring the leakage current, and are used in a limited temperature voltage range during a test flow. In the present embodiment, the leakage current can be measured not only during the test flow but also during the implementation onto a product so that a highly reliable system can be constructed. Furthermore, the more accurate determination can be performed in the case where the temperature characteristics of the leakage current to be measured is predicted, because supply voltage and temperature dependency can be previously set to the reference current by applying the reference current to the device. 
-  According to the seventh embodiment, the more reliable system can be constructed. Because the bit line leakage current is determined during the implementation to a product in various temperature/voltage states and the determination result can be used for a repair with a redundancy in a memory array, an alarm to a user and the like. 
-  Note that, it is obvious that the degree of freedom of the reference current can be realized as similar to the case of the sixth embodiment in a combined use with the external pad in the present embodiment. 
Eighth Embodiment- FIG. 10 is a detailed block diagram showing the current mirror circuit indicated in the sixth and seventh embodiments.FIG. 11 is a circuit diagram showing the current mirror circuit shown inFIG. 10 at a transistor level. 
-  InFIG. 10, a supply voltage step-downcircuit101 which reduces a supply voltage VDD is connected to a currentmirror connection transistor102 utilizing the reduced supply voltage as a power source, in thecurrent mirror circuit100. A reference current output (Iref)106 of the currentmirror connection transistor102 outputs a reference current, and a reference current input107 (N×Iref) is connected to the external pad804 via afirst analog switch103. Furthermore, the reference input (N×Iref) is connected to the supply voltage VDD via asecond analog switch104. 
-  When thesecond analog switch104 Is turned on, the output transistor of the currentmirror connection transistor102 is cut off. Thefirst analog switch103 and thesecond analog switch104 are controlled so as to be exclusively turned on. When the external pad is cut off by the first analog switch, the current output of the current mirror circuit is shut down due to its high impedance state. 
- FIG. 11 shows an example of a circuit configuration under the condition having the process of 0.18 μm, the output current of less than 1 μA, and the supply voltage of 1.8V. InFIG. 11, the supply voltage step-downcircuit101 is made up of an Nch transistor having a one-stage diode connection, The currentmirror connection transistor102 is made up of one stage of a pair of Pch transistors having a mirror current ratio of 1:N. 
-  The supply voltage step-down circuit cuts down a common voltage from the source side of the pair of the current mirror connection transistors. Accordingly, the layout area of the current mirror connection transistor can be reduced, while minimizing the impacts on the matching characteristics of the current mirror connection transistor. Therefore, a smaller current can be provided with a smaller layout. 
-  The first analog switch can utilize the Nch transistor since the voltage level of the external pad is near the ground, and the second analog switch is connected to the power level and can utilize the Pch transistor. Furthermore, the gates of these transistors are connected to the shut downsignal105 so that a complementarily connection operations are realized with a very simple configuration. 
-  According to the eighth embodiment, practical current characteristics can be obtained with the very simple configuration under the condition in which an integration voltage range is restricted. 
Ninth Embodiment- FIG. 1 is a block diagram showing the semiconductor leakage current detector which includes a control unit, a memory, and a timer according to the ninth embodiment. InFIG. 1, the semiconductor leakagecurrent detector1 described in the first embodiment includes: areference voltage input4 connected to the reference voltage input of a comparator, an input of a current to be measured2 inputted to the integral capacitor, and acomparison result output9 which is a referencecurrent input3 inputted to the integral capacitor and the output result of the comparator. 
-  Thereference voltage input4 is supplied from the band gap reference voltage source of the semiconductor integrated circuit which includes the semiconductor leakage current detector. 
-  Thecontrol circuit5 controls the integration operation by referring to the comparison result of the semiconductor leakage current detector in the time measured by thetimer6. Thecontrol circuit5 executes the calibration operation described in the first embodiment, and stores the obtained integral time into thememory7. Furthermore, thecontrol circuit5 executes the test operation described in the first embodiment. In the test operation, the integral value stored in thememory7 is loaded as an initial value into thetimer6, thetimer6 is operated for count down, the integral operation is executed until the count value reaches the initial value, and the leakage current is then determined. 
-  Note that, whereas it was described that the timer is operated for count down in the present embodiment, it is obvious that the counter (timer as a counter) may be count-up operated. 
-  In the ninth embodiment, a memory and a counter for storing an integral value are defined as minimum constituents necessary for executing the measurement algorithm of the semiconductor leakage current detector, and an on-chip self test of the leakage current is realized. Furthermore, in the case where the reference voltage source is placed in the semiconductor leakage current detector, the reference voltage source can be commonly used so that the semiconductor leakage current detector can be manufactured in a smaller area. 
Tenth Embodiment- FIG. 2 is a block diagram showing the semiconductor leakage current detector according to the tenth embodiment. This semiconductor leakage current detector further includes the reference voltage source in thedetector20 compared to the configuration of the semiconductor leakage current detector of the ninth embodiment shown inFIG. 1. InFIG. 2, since the semiconductor leakagecurrent detector20 includes a specific reference voltage source, it does not have thereference voltage input4. By including the reference voltage source within the semiconductor leakage current detector, a reference voltage can be set in a greater range and a reference voltage source of arbitral temperature characteristics, which are different from the temperature characteristics required for the common reference voltage source, can be included so that a reference voltage is applicable to the leakage current characteristics. 
Eleventh Embodiment- FIG. 12 is a partial block diagram of the semiconductor integrated circuit according to the eleventh embodiment. InFIG. 12, the semiconductor integrated circuit adds an external analog input/output pad120 connected to ananalog multiplexer121, to the semiconductor leakagecurrent detector1 described in the ninth embodiment. Theexternal analog multiplexer121 connects, to the external analog input/output pad120, one of a reference current input of the semiconductor leakagecurrent detector1, areference voltage source122, an output current to be measured124, andother signals125 such as an internal voltage source and the like. Thereference voltage source122 and the output current to be measured124 are connected to the semiconductor leakagecurrent detector1. 
-  With this configuration, a single external analog input/output pad can monitor the output currents to be measured such as a cell current and a bit line leakage current, a reference voltage source, and other voltage sources, when the semiconductor integrated circuit is tested. 
-  Next, the operation of the semiconductor leakage current detector shall be described with references toFIG. 12 andFIG. 13. InFIG. 12, dashed lines indicate a flow of signals in the calibration operation.FIG. 13 is a partial block diagram similar toFIG. 12 and shows the semiconductor integrated circuit according to the eleventh embodiment. InFIG. 13, dashed lines indicate a flow of signals in the test operation. In the calibration operation shown inFIG. 12, a semiconductor leakagecurrent detector1 is supplied with the reference current via theanalog multiplexer121, and with the reference voltage from the reference voltage source. Thecontrol circuit5 controls start and stop of the integral operation of the reference current which flows in the semiconductor leakagecurrent detector1, with reference to thecomparison result output9. The integral time is controlled by thetimer6. Thecontrol circuit5 stores, into thememory7, a count threshold value which is obtained bytimer count value1 at the time when the comparison output is transferred, as an integral value. Next, the test operation shown inFIG. 13 is described. The output current to be measured124 and the output of thereference voltage source122 are connected to the semiconductor leakagecurrent detector1. Theanalog multiplexer121 is in a state where the reference current input of the semiconductor leakagecurrent detector1 is activated or a state in which nothing has been activated. Thecontrol circuit5 stores, into thetimer6, a count threshold value stored in thememory7, the current to be measured such as a bit line leakage current and the like until the count value of thetimer6 reaches the count threshold value, and outputs thecomparison result9 when the integration is ended. 
-  In the eleventh embodiment, a small scaled semiconductor integrated circuit with a high functional testability can be provided by effectively utilizing the single analog test pad for an internal current/voltage measurement, an external voltage application, a reference current application to the semiconductor leakage current detector. 
Twelfth Embodiment- FIG. 14 is a partial block diagram of a semiconductor integrated circuit according to the twelfth embodiment. In this diagram, the semiconductor integrated circuit is different from the one shown inFIG. 12 in that acontrol circuit143 is included instead of thecontrol circuit5 and thememory7. In the following, differences are mainly discussed, omitting the descriptions about the same constituents. 
-  Thecontrol circuit143 is an example of a circuit having the same functions as thecontrol circuit5 and thememory7, and includes aCPU140, aclock141, and amemory142. TheCPU140 controls the calibration operation and the test operation. Theclock141 generates operation clocks of theCPU140 and thetimer6. Thememory142 stores data and program codes (micro codes) which describe algorithms for the calibration operation and the test operation. The hardware which corresponds to theCPU140,clock141,memory142, andtimer6 is usually built in the semiconductor integrated circuit such as a flash memory and the like, for executing rewrite, read-out, and deletion of a memory cell. In this case, theCPU140,clock141,memory142 andtimer6 can be used together with the hardware which is usually built in the semiconductor integrated circuit. In the operation of the semiconductor leakage current detector, theCPU140 processes, as software, the feedback loop of the output result obtained by the comparator as described below, so that design modification regarding functional changes are no longer necessary or are reduced at minimum. In addition, the operational algorithm can be easily updated. Therefore, a high-performance semiconductor leak detector can be realized with a small area. 
- FIG. 22 andFIG. 23 are flowcharts, respectively showing details of the calibration operation and the test operation performed by the semiconductor leakage current detector under the control by thecontrol circuit143. The left side ofFIG. 22 shows an entire operation of determining whether or not the current to be measured is greater than the reference current, and the right side ofFIG. 22 shows details of the calibration operation. 
-  As shown in the left side ofFIG. 22, thecontrol circuit143 sequentially executes a reference current apply step, a reference current stabilization standby step, a calibration step, and a test step (S10ato S50a). Specifically, thecontrol circuit143 externally receives a directive to transfer to the test mode; when the reference current is supplied from the external pad in the test mode (S10a), is put on standby until the stable current which charges up the parasitic capacitor of the external pad is supplied to the semiconductor leakage current detector (S20a); executes the reference integral time search step (S30a); writes, into amemory142, a count value of thetimer6 as an integral time which is a duration required for the inversion of the comparison output obtained by the comparator30 (S40a); executes the test step (S50a). 
-  As shown in the right side ofFIG. 22, thecontrol circuit143 sequentially executes, as the calibration steps (S30a, S40a), a counter/integral capacitor initialization step, a timer/integration start step, a comparator readout loop, and a count value storage step of the timer (S31 to S40a) Specifically, thecontrol circuit143 firstly controls initialization of the counter and discharging of the integral capacitor (S31), starts the counting of timer and the discharging of the integral capacitor (S32), periodically reads out a comparator output in the comparator readout loop during the counting by the counter and the discharging of the integral capacitor (S33), stops the counter so as to be out from the loop when the comparator output is inverted, specifically when the integral value input voltage Vint and the reference voltage Vref satisfy Vint>Vref (Yes in S34), and stores the count value into thememory142 as an integral time required for the comparison output of thecomparator30 to be inverted (S35, S40a). 
-  In the right side ofFIG. 23, thecontrol circuit143 sequentially executes, as test steps (S40b, S50b), a counter load/integral capacitor initialization step, a timer countdown/integration start step, a timer countdown loop, and a comparator readout determination step (S51 to S58). Specifically, thecontrol circuit143 executes loading of the count value stored in the count value storage step performed by the timer, and discharging of the integral capacitor (S51), starts simultaneously counting down the timer and charging the integral capacitor (S52), executes the countdown and charging operation of the integral capacitor in the timer countdown loop (S53), and gets out of the loop when the countdown value of the timer reaches a predetermined value (for example, 0) (Yes in S54). Furthermore, thecontrol circuit143 reads out the comparator output (S55), and determines whether or not the current to be measured is greater than the reference current in accordance with the comparator output (S56). In this determination, thecontrol circuit143 determines that the current to be measured is smaller than the reference current (S57) when the readout comparator output is not inverted, specifically when the integral value voltage Vint and the reference voltage Vref do not satisfy Vint>Vref. In this case, the current to be measured passes the test. Furthermore, thecontrol circuit143 determines that the current to be measured is greater than the reference current (S58) when the readout comparator output is inverted, specifically when Vint>Vref is satisfied (S58). In this case, the current to be measured fails to pass the test. 
-  As described above, the semiconductor integrated circuit according to the present embodiment implements a semiconductor leakage current detector, and can realizes a self test by utilizing built-in CPU, memory, timer and the like. In addition, a highly accurate determination of a leakage current can be realized at high speed at the software level of the internal CPU. 
Thirteenth Embodiment-  In the present embodiment, it shall be described a semiconductor device having a semiconductor leakage current detector with a function of trimming reference voltage and the like, 
- FIG. 15 is a block diagram showing a main unit of the semiconductor integrated circuit having a semiconductor leakage current detector with a trimming function according to the thirteenth embodiment. The configuration of the semiconductor integrated circuit inFIG. 15 is different from the one shown inFIG. 14 in that plural registers for trimming and avoltage divider circuit151 are included, and that an adjustment function using a resister for trimming is added to thecontrol circuit143. In the following, differences are mainly discussed, omitting the descriptions about the same constituents. 
-  The plural registers for trimming includes areference voltage register150, a voltagedivision control register152, an integralcapacitance ratio register153, atimer register154, and aclock register155. 
-  Thereference voltage register150 holds data for setting a reference voltage of thereference voltage source122. The reference voltage outputted from thereference voltage source122 is a voltage value based on this data. The voltagedivision control register152 holds data for setting a voltage division ratio for thevoltage divider circuit151. The integralcapacitance ratio register153 holds data for setting a capacitance value for theintegral capacitor34. Theintegral capacitor34 has a capacitance of the capacitance value in accordance with the capacitance ratio indicated by this data. Thetimer register154 holds data for setting the number of stages (bit length) of thetimer6. The number of stages indicated by this data is valid among the total number of stages for thetimer6. Theclock register155 holds data for setting an oscillatory frequency for theclock141. The oscillatory frequency of theclock41 is determined based on this data. 
-  Thevoltage divider circuit151 divides the reference voltage Vref outputted from thereference voltage source122 at the voltage division ratio indicated by the data stored in the voltagedivision control register152, and supplies the divided voltage to thecomparator30. 
-  Thecontrol circuit143 performs fine adjustment on data in each register so that variations at the time of manufacturing each semiconductor integrated circuit are absorbed, using the plural registers for trimming. Furthermore, it previously records a range of data within which the data can be set for each register in accordance with a type of the semiconductor integrated circuit, and sets the data for each register in accordance with the type of the semiconductor integrated circuit. For example, it updates data in the necessary registers and performs calibration again, in the case where calibration is not successfully performed, in the case where the integral time measured for theintegral capacitor34 is very long, or the like. 
-  Accordingly, the semiconductor device of the present embodiment is capable of easily adapting to large scaled changes in the range of a current to be measured by making changes in software used for thecontrol circuit143. 
Fourteenth Embodiment-  The present embodiment describes read-out operation of the comparator output in each embodiment. 
- FIG. 16 describes a temporal development of a voltage inputted to a comparator according to the fourteenth embodiment. InFIG. 16, the horizontal axis indicates time and the vertical axis indicates the input voltage to the comparator. The input voltage indicated by a solid line is On integration voltage Vint, and the input voltage indicated by a dashed line is a reference voltage Vref. Thesample clock166 is inputted to thecomparator30 from thecontrol circuit143 so as to periodically read out the comparison result obtained by thecomparator30. The inputtedsample clock166 opens a gate into which the reference voltage Vref and the integration voltage Vint are inputted. The comparator output167 indicates a comparison result obtained by thecomparator30. The actual comparison result is outputted at the timing of thesample clock166. 
-  The integration voltage Vint indicated by the solid line is 0V during thedischarge period162, increases as the time passes in theintegral time160, and is discharged at 0V during thedischarge period161. Whereas the reference voltage Vref indicated by the dashed line is a constant voltage, noise is superimposed on it being influenced by the pulse of thesample clock166 as shown inFIG. 16. An error is caused between the timing when the integration voltage Vint becomes actually greater than the reference voltage Vref and the timing when the comparator output167 is inverted, as shown in the diagram. This is because thecontrol circuit143 periodically reads out the comparator output167 at the pulse timing of thesample clock166. 
-  Therefore, in the present embodiment, thecontrol circuit143 detects the inverted state of the comparator output167, obtains a time Tint2 of the sampling pulse immediately before the inversion, and defines the time ranged from the start of the integral time to thetime Tint2 as an integral time Tint required for the inversion. 
-  Note that, as described in the above, it is possible to make a highly accurate determination of a bit line leakage current less than the reference current by detecting the non-inversion state of the comparator output and setting, as the value of Tint, the value immediately after the inversion of the comparator output. 
-  Furthermore, the accuracy can be modified by repeating the calibrations while gradually shifting the phase of the sampling clock. The integral time is obtained by adding an offset, which is equivalent to the phase difference, to the count value of the timer. Note that, a cycle of a sampling clock is determined by software, and the offset can be controlled by a dummy cycle of the CPU and the like. A minimum measurement resolution of the integral time is a clock cycle. 
Fifteenth Embodiment-  The present embodiment describes a configuration for realizing a self-trimming function by the reference voltage source in order to improve accuracy of the reference voltage. 
- FIG. 17 is a block diagram showing a configuration of a main unit of a semiconductor leakage current detector having a function of adjusting the reference voltage Vref according to the fifteenth embodiment. The semiconductor leakage current detector in the diagram includes: areference register170 which holds trimming data; areference voltage source171 which generates a constant voltage in accordance with the trimming data; avoltage divider173 which divides the constant voltage (a reference voltage output172) outputted by thereference voltage source172, and outputs, as a reference voltage, the divided constant voltage, to thereference side input31 of thecomparator30; anexternal pad174 for externally inputting a voltage value which is a target level of the reference voltage; and ananalog multiplexer177 which selects one of theleakage measurement path48 of the current source to be measured and theexternal pad174, and connects the selected one to the integralcapacitor side input32 of thecomparator30. Theanalog multiplexer177 selects theexternal pad174 by the external referencevoltage selection input175 outputted by thecontrol circuit143, or selects the leakage measurement path by the leakmeasurement selection input176. 
-  Thecontrol circuit143 controls theanalog multiplexer177 and thecomparator30 so as to compare the target level inputted via theanalog multiplexer177 from theexternal pad174 with the reference voltage from thevoltage divider173, and updates trimming data in thereference register170 in accordance with the comparison result. Here, thecontrol circuit143 updates the trimming data in thereference register170 so that the reference voltage outputted from thevoltage divider173 matches the target level inputted from theexternal pad174. 
-  Accordingly, the semiconductor leakage current detector of the present embodiment can realize a self-trimming function of the reference voltage source by a small addition of hardware, and can improve an absolute accuracy of the reference voltage. The semiconductor leakage current detector of the present embodiment can finely adjust the reference voltage at mV order absolute accuracy. 
- FIG. 18 is a diagram showing a variation of the configuration of the semiconductor leakage current detector shown inFIG. 17. The configuration shown inFIG. 18 includes ananalog switch180 instead of theanalog multiplexer177 included in the configuration shown inFIG. 17. 
-  The analog switch178 is inserted between theexternal pad174 and the integralcapacitor side input32 of thecomparator30, and is controlled by the external referencevoltage selection input175. In other words, when the analog switch178 is being turned on, the target level outputted by theexternal pad174 is inputted to the integralcapacitor side input32 of thecomparator30. When the analog switch178 is being turned off, the current to be measured from theleak measurement path48 is inputted to the integralcapacitor side input32 of thecomparator30. 
-  The configuration shown inFIG. 18 is different from that ofFIG. 17 in that, when the analog switch178 is being turned on, not only theexternal pad174 but also theleakage measurement path48 are connected to the integralcapacitor side input32. In general, this difference does not cause any problems. The influence of theleakage measurement path48 on the target level inputted by theexternal pad174 can be usually ignored because the stray capacitor of theleakage measurement path48 is very small compared to the stray capacitor of theexternal pad174, or when the leakage current, which is as much as several μA, is sufficiently smaller than the current driving performance of the external pad. Whereas abnormalities such as a short in wiring in theleakage measurement path48 cannot be ignored, one or moreleakage measurement path48 is selected out of plural bit lines so that other bit line can be selected even when the abnormalities are found. Therefore, the configuration shown inFIG. 18 is sufficiently useful for a practical use. Accordingly, the configuration shown inFIG. 18 allows a fine adjustment of accuracy of a reference voltage by only adding a circuit which is simpler than the configuration shown inFIG. 17. 
Sixteenth Embodiment-  The present embodiment describes a semiconductor leakage current detector by which absolute accuracy of the reference voltage is further increased. 
- FIG. 19 is a block diagram showing a configuration of a main unit of a semiconductor leakage current detector having a function65 of finely adjusting the reference voltage Vref according to the sixteenth embodiment. InFIG. 19, two equivalentvoltage divider circuits190 are included instead of thevoltage divider173, compared to the configuration shown inFIG. 17. In the following, differences are mainly discussed, omitting the descriptions about the same constituents. 
-  The equivalentvoltage divider circuits190 are a firstvoltage divider circuit191 and a secondvoltage divider circuit192. The firstvoltage divider circuit191 is the same as thevoltage divider173. The secondvoltage divider circuit192 divides the constant voltage inputted by theexternal pad174, and outputs the divided constant voltage as a target level to the integralcapacitor side input32 of thecomparator30 via theanalog switch180. 
-  The first and secondvoltage divider circuits191 and192 are manufactured using the same circuit layout pattern. 
-  Accordingly, differences of the voltage divider circuits in respective chips generated when the chips are manufactured can be cancelled within a single chip. In other words, both thereference voltage output172 and the constant voltage outputted by theexternal pad174 are divided based on the same characteristics so that an absolute accuracy of the voltage divider circuit is not required. Therefore, the accuracy of fine adjustment of the reference voltage can be further improved. 
Seventeenth Embodiment-  The present embodiment describes a semiconductor leakage current detector which increases the speed of raising the reference voltage when the power is applied and which can use the reference voltage to other circuits. 
- FIG. 20 is a block diagram showing a configuration of the main unit of a semiconductor leakage current detector according to the seventeenth embodiment. Compared to the configuration shown inFIG. 19, thevoltage follower circuit200 is added inFIG. 20. In the following, differences are mainly discussed, omitting the descriptions about the same constituents. 
-  Thevoltage follower circuit200 is connected to between thereference voltage source171 and the firstvoltage divider circuit191, and includes a voltage follower amplifier, a bypass wiring which bypasses the voltage follower, and a switch circuit which selects one of the voltage follower and the bypass wiring. The voltage follower is a buffer for driving a current of the constant voltage signal outputted by thereference voltage source171. The bypass wiring is a wiring for inputting the low voltage outputted by thereference voltage source171 directly to thevoltage divider circuit191. The switch circuit selects one of the voltage follower and the bypass wiring. 
-  The switch circuit selects the voltage follower when the power is turned on. This selection shortens the start-up time necessary for the reference voltage Vref to be stable. The switch circuit also selects the voltage follower during the trimming of the reference voltage. This selection allows decreasing the errors caused by the decrease in the reference voltage during the trimming of the reference voltage. Furthermore, the output from the voltage follower or thereference voltage source171 is used for other circuits in the semiconductor integrated circuit. Here, lower power consumption can be realized by turning the voltage follower off with the selection of the bypass wiring. 
-  As described in the above, the semiconductor leakage current detector of the present embodiment can realize a high-speed rising of the reference voltage when the power of the semiconductor integrated circuit is turned on, while decreasing the differences caused by the decrease in the reference voltage during the trimming of the reference voltage. 
Eighteenth Embodiment-  The present embodiment describes a semiconductor leakage current detector which cancels the influence of the input offset in thecomparator30 by mutually changing the input of thecomparator30. 
- FIG. 21 is a block diagram showing a main unit of the semiconductor leakage current detector having an input inversion function of a comparator according to the eighteenth embodiment. InFIG. 21, theinversion analog multiplexer210 is included, compared to the configuration shown inFIG. 19. In the following, differences are mainly discussed, omitting the descriptions about the same constituents. 
-  Theinversion analog multiplexer210 inverts (switches) two inputs to thecomparator30. Specifically, it switches the inputs between (Vref, Vint) and (Vint, Vref) to the input terminal (X, Y) of thecomparator30. The inversion of two inputs performed by theinversion analog multiplexer210 is used for trimming the reference voltage. 
-  FIG,24 is a flowchart showing an example of a trimming process performed by the semiconductor leakage current detector having the input inversion function. This trimming process is a process of finely adjusting the absolute accuracy of the reference voltage Vref. As shown inFIG. 24, thecontrol circuit143 sequentially executes a target voltage apply step, a first intermediate value search step, a comparator input inversion step, a second intermediate value search step, and a trimming value average step (S100 to S800). Specifically, when a setting value (a target level) of the reference voltage is given by the external pad (S100), thecontrol circuit143 obtains, in the first intermediate search step, a trimmingintermediate value1, which is a boundary value of the reference voltage Vref when thecomparison output33 outputted from thecomparator30 is inverted (S200, S300). Thecontrol circuit143 further changes the output to the inversion analog multiplexer210 (S400), and obtains, in the second intermediate search step, a trimmingintermediate value2, which is a boundary value of the reference voltage Vref when thecomparison output33 of thecomparator30 is inverted (S500, S600). After that, thecontrol circuit143 takes an average of the trimmingintermediate values1 and2 (S700), and sets the obtained average value at the reference register as a final trimming value of the reference voltage (S800). 
- FIG. 25 is a flowchart showing a detailed example of the first intermediate search step (S200, S300) shown inFIG. 24. Thecontrol circuit143 sequentially executes, as the first intermediate value search step, a trimming initial value setting step, a comparator read-out step, and a trimming loop (S201 to S300). Specifically, thecontrol circuit143 sets, in the trimming initial value setting step, an initial value at the reference voltage register for controlling an output level of the reference voltage (S201), reads out the comparator output in the comparator read-out step (S202), determines whether or not voltage Vint which is proportional to the voltage of the external pad is greater than the voltage Vref which is proportional to the reference voltage (S203), and executes one of the following two trimming loops in accordance with the determination result. 
-  When the determination result shows Vint>Vref, in the trimming loop shown on the left ofFIG. 25, thecontrol circuit143 decreases the reference voltage register one step down to the higher voltage (S204), reads out the comparator output (S205), and repeats the process of the trimming loop until the result Vint<Vref is satisfied (S206). In this operation of the trimming loop, a trimming value obtained when Vint<Vref is determined as a trimming intermediate value1 (S300). 
-  Furthermore, when the determination result shows Vint<Vref, in the trimming loop shown on the right ofFIG. 25, thecontrol circuit143 increases the reference voltage register one step up to the higher voltage (S207), reads out the comparator output (S208), and repeats the process of the trimming loop until the result Vint>Vref is satisfied (5209). In this operation of the trimming loop, a trimming value obtained when Vint>Vref is determined as a trimming intermediate value1 (S300). 
- FIG. 26 is a flowchart showing a detailed example of the second intermediate value search step inFIG. 24. The flowchart shown inFIG. 26 is the same as the flowchart shown inFIG. 25 except that the trimmingintermediate value1 is set at the reference voltage register in the trimming initial value setting step (S501), and that the trimmingintermediate value2 is finally outputted (S600). 
-  As described in the above, the semiconductor leakage current detector of the present embodiment obtains trimming values of before and after the switching of inputs of the comparator, and uses the average value of the trimming values. Therefore, the influence of the input offset of the comparator can be removed and trimming can be realized at high speed shortening the trimming search time. Since the influence of the offset on thecomparator30 can be completely removed and an inexpensive small comparator with large offset can be used. 
-  Note that, whereas a linear search is used as an algorithm for a trimming loop in the present embodiment, it is obvious that binary search and the like may be used to further speed up the convergence of loops. 
Nineteenth Embodiment-  The present embodiment describes a specific example of a semiconductor integrated circuit equipped with the present semiconductor leakage current detector. 
- FIG. 27 is a block diagram showing an example of a semiconductor device including the semiconductor leakage current detector according to the nineteenth embodiment. As shown in FIG,27, asemiconductor device270 includes aleakage detector271, amemory cell273, anX decoder276, aY gate277, a read-out circuit278, awrite circuit279, and aY decoder300. Thesemiconductor device270 shows an example of a general flash memory except theleakage detector271. 
-  When theleak detector271 determines one or plural bit leakage currents selected from among the plural bit lines when theleak detector271 is connected theY gate277 as shown in the diagram. 
- FIG. 28 is an explanatory diagram showing a leakage current in the bit lines inFIG. 27.FIG. 28 shows a portion of theY gate277 and a portion (for one line) of thememory array272 shown inFIG. 27. The memory cell shown inFIG. 28 is a nonvolatile memory transistor and adapts a source-side read-out method. At the time of reading, a drain bias is applied to the drain of the memory cell selected by an address from thedrain bias313, and a read-out value is determined based on the current which flows toward the source. 
-  As shown in the dashed lines in the diagram, the bit line leakage current flows from theY gate277 towards the drain-side bit line312 and further flows in the source-side bit line311 resulting from the drain bias by thedrain bias313. Such bit line leakage current causes erroneous determination of the cell current with an error as much as the leakage current and excess/insufficient writing, and prevents a normal threshold value control of the memory cell. As described in each of the aforementioned embodiments, theleakage detector271 can perform a highly accurate determination of a small leakage current as much as several μA at high speed. 
-  In the present embodiment, a highly accurate determination of the bit line leakage current can be performed at high speed even in the case of using the source-side read-out method as shown inFIG. 28. 
-  The semiconductor leakage current detector and the semiconductor integrated circuit of the present invention is applicable to a semiconductor device, particularly to a semiconductor device which includes a memory cell array, for example, a nonvolatile memory such as a flash memory, EEPROM, or a ferroelectric memory, and a volatile memory such as a DRAM or a SPRAM. 
-  Although only some exemplary embodiments of this invention have been described in detail above, those skilled in the art will readily appreciate that many modifications are possible in the exemplary embodiments without materially departing from the novel teachings and advantages of this invention. Accordingly, all such modifications are intended to be included within the scope of this invention.