Abstract:
A counting method and a counter using an integrated circuit memory area, including at least one step of storage of partial values in several words of identical memory sizes, the result of the counting being obtained by arithmetically adding the values contained in the different words.

Description:
FIELD OF THE INVENTION  
       [0001]    The present invention generally relates to electronic counters and, more specifically, to counters formed by means of a set of memory cells, the respective states of which condition the counter value. 
         [0002]    The present invention more specifically applies to so-called event counters which are used to count the number of occurrences of a specific event (for example, the execution of a given step of a program) and having their value exploited in relation to one or several thresholds. These may be for example automobile vehicle odometers. 
       DISCUSSION OF THE RELATED ART  
       [0003]    Event counters, especially in so-called security applications where the correct execution of a program or the number of occurrences of a given operation is for example desired to be monitored, generally exploit a non-volatile memory to store the current value of the counter. This memory is, for example, an EEPROM having its cells updated on each counter incrementation or decrementation. 
         [0004]      FIG. 1  is a schematic block diagram of an example of an integrated processor  1  of the type to which the present invention applies. Such an integrated circuit  1  comprises a central processing unit  11  (CPU) which communicates via one or several data, address, and control signal buses  12 , with one or several memories  131  (MEM) and  132  (EEPROM) among which at least one non-volatile memory  132 . All or part of buses  12  are connected to an input/output circuit  14  (I/O) for communicating with the outside of circuit  1 . Functionally, circuit  1  comprises at least one counter  15  (CNT) formed in hardware or software fashion and exploiting an area of non-volatile memory  132  to store the counter value. Circuit  1  is, for example, contained in a smart card. 
         [0005]      FIG. 2  very schematically shows a conventional example of a counter  15  using cells of a memory. Such a counter uses a set  132  of cells Ci (for example, n cells, with i ranging between 1 and n) to store the value of the counter over n bits. These cells are accessible in read mode R and in write mode W by a control circuit  151  (CTRL) receiving an increment or decrement instruction INC/DEC originating, for example, from central unit  11  to update the value contained in the cells of set  132 . The circuits or programs conditioning the updating of the counter value and exploiting its result may be of various natures. 
         [0006]    Circuit  151  provides, after a reading of the cell content, value VAL of the counter. This value is then exploited, for example, to be compared with a threshold to detect a possible overflow of the event counter by an appropriate program. In applications more specifically aimed at by the present invention, the result of the counter value is generally exploited to start a specific action (for example, a blocking of a smart card, the transmission of an alarm signal, etc.) when the counter value reaches a so-called security threshold. This value however generally does not need be accurate to within one unit to detect an operation considered as abnormal in an integrated circuit. Examples of application are the limitation of the number of dialings of a confidential code, the limitation of the number of uses of an application, etc. 
         [0007]    The representation of  FIG. 2  is functional and simplified. In practice, circuits of cell addressing and selection in a memory plane are required. 
         [0008]    A problem linked to the use of memories, especially non-volatile, is that the multiple programmings of the cells of these memories may cause wear and that cells become defective along the product lifetime. 
         [0009]    The current solution to solve this problem is to provide so-called redundancy cells to replace cells which have become defective. Such redundancy cells are also used to correct manufacturing defects of the product. A disadvantage is that as the number of used redundancy cells increases, the counter updating time also increases. Conventionally, in non-volatile memories, the writing takes more time than in other memories. 
         [0010]    A difficulty is to detect that a cell has become unusable during the product lifetime. This requires periodically testing all the memory plane cells. The cells considered as defective are eliminated from a functional point of view and are no longer used by the integrated circuit. 
         [0011]    Another difficulty is to organize the redundancy with specific addressing mechanisms. 
         [0012]    A disadvantage of conventional techniques is that they lead to oversizing the memory planes to form event counters, to provide a sufficient redundancy. 
         [0013]    Another problem is the processing of possible frauds. Indeed, a cell of an event counter (be it in the volatile or non-volatile memory) may become functionally defective under the effect of attacks aimed at preventing the counter from reaching the threshold from which a specific procedure is implemented. Such attacks may be electric, thermal, or radiation disturbances. 
         [0014]    Such attacks are difficult to detect, except if they amount to considering the cell(s) providing erroneous results as defective. In this case, these cells are replaced with redundant cells even though they would be capable of operating properly afterwards (once the disturbance has disappeared). This uselessly consumes redundancy cells. 
       SUMMARY OF THE INVENTION  
       [0015]    The present invention aims at overcoming all or part of the disadvantages of known counters. 
         [0016]    The present invention more specifically aims at providing an event counter totally or partly avoiding the use of redundancy cells along the product lifetime. 
         [0017]    The present invention also aims at providing a solution capable of taking into account both defective cells and cells temporarily stressed by a fraudulent attack. 
         [0018]    The present invention also aims at enabling possible reuse of cells detected as being defective at a given time of the product lifetime. 
         [0019]    To achieve all or part of these objects, as well as others, the present invention provides a counting method using a memory area in an integrated circuit, comprising at least one step of storage of partial values in several words of identical sizes of the memory, the result of the counting being obtained by arithmetically adding the values contained in the different words. 
         [0020]    According to an embodiment of the present invention, the method comprises the step of incrementing or decrementing one of the words by selecting it so that all the words contain values present within a given range. 
         [0021]    According to an embodiment of the present invention, said range is set according to the tolerance desired for the counter result. 
         [0022]    According to an embodiment of the present invention, the increment or the decrement is one. 
         [0023]    According to an embodiment of the present invention, if a word does not contain one of the range values, an updating of this word to one of these values is attempted. 
         [0024]    The present invention also provides an integrated circuit counter comprising a memory area to store the counter value, comprising: 
         [0025]    means for comparing partial values contained in different memory words of identical sizes with respect to a range of possible values; 
         [0026]    means for assigning to words having their value outside the range one of the values of this range; and 
         [0027]    means for arithmetically summing the respective values of the words to provide the counter value. 
         [0028]    According to an embodiment of the present invention, the range of values is selected according to the maximum interval desired between the resulting values of the counter. 
         [0029]    The foregoing and other objects, features, and advantages of the present invention will be discussed in detail in the following non-limiting description of specific embodiments in connection with the accompanying drawings. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS  
         [0030]      FIG. 1 , previously described, very schematically shows in the form of blocks an example of an integrated processor comprising a counter of the type to which the present invention applies; 
           [0031]      FIG. 2 , previously described, very schematically shows in the form of blocks a conventional example of a counter; 
           [0032]      FIG. 3  very schematically shows in the form of blocks an embodiment of an event counter according to the present invention; 
           [0033]      FIG. 4  is a simplified flowchart of the reading of a counter according to an embodiment of the present invention; 
           [0034]      FIG. 5  is a simplified flowchart of an updating of the value of a counter according to an embodiment of the present invention; and 
           [0035]      FIG. 6  is a simplified flowchart of a mechanism for checking the counter according to an embodiment of the present invention. 
       
    
    
     DETAILED DESCRIPTION 
       [0036]    The same elements have been designated with the same reference numerals in the different drawings. For clarity, only those circuit elements and method steps which are useful to the understanding of the present invention have been shown in the drawings and will be described hereafter. In particular, the circuit or program conditioning the updating of the counter value has not been described in detail, the present invention being compatible with any conventional circuit or program triggering an increment or a decrement of an event counter. Further, the exploitation that is made of the counter value, be it per se or with respect to a threshold, has not been described, the present invention being here again compatible with all conventional exploitations of an event counter. 
         [0037]    A feature of an embodiment of the present invention is to divide the set of memory cells of the counter into words of several cells of identical sizes and to obtain the result of the counter value by an arithmetic summing of the respective values of the different words. 
         [0038]    Another feature of an embodiment of the present invention is to organize the updating of the values of the different words so as to keep between one another a fixed interval (preferably, unity). As will be seen hereafter, this interval conditions the tolerance of the counter result. 
         [0039]    Another feature of an embodiment of the present invention is to consider any word having a value which does not respect the given interval with respect to the other words as containing a functionally defective cell, and to then consider, at least in read mode, that it contains one of the two end values of the range of values set by this interval. 
         [0040]    The present invention takes advantage from the fact that, in most event counter applications, it is not necessary to be accurate to within one. 
         [0041]      FIG. 3  very schematically shows in the form of blocks an embodiment of an event counter  2  according to the present invention. This counter uses several groups or words of memory cells W 1  to Wm. These different words are exploited by an interpretation circuit  21  containing at least one function  211  of arithmetic summing (Σ) of the values contained in the different words. The result of this summing provides value VAL of the counter. Circuit  21  receives an increment or decrement signal INC/DEC (for example originating from a central processing unit ( 11 ,  FIG. 1 )). Functionally, circuit  21  comprises a function  212  (AFFECT) for assigning to possible words containing one or several defective cells (even temporarily), one of the values contained by the other valid words. The detection is performed by a block  213  (ERR DET) which scans the different values of words Wi (i ranging between 1 and m) to compare this value with a range of values conditioned by the tolerance desired by the counter. For example, for a counter having unity as an increment or decrement step, and since the updating of the different words is organized so that their respective contents do not differ by more than one with respect to one another, a word is considered as defective if its reading does not provide one of the two possible values taken by the other words. 
         [0042]    In the example of  FIG. 3 , it is assumed that the valid counter words (for example W 1 , W 2 , and Wm in the representation) respectively contain values A+1, A, and A, where A represents an integer, and that word W 3  comprises a defective cell resulting in that the read value DEFECT corresponds neither to A nor to A+1. Word W 3  is detected by circuit  213 , which compares the respective contents of the different words with respect to values A and A+1. 
         [0043]    The fact for a word to contain an erroneous value does not prevent its taking into account for the counter result. Indeed, as will be better understood hereafter in relation with  FIGS. 4 and 5 , according to whether the result of the counter is exploited in relation to a decrease or an increase in the number of events, circuit  212  assigns to the erroneous word (W 3  in this example), either value A or value A+1 to take it into account in summing  211 . 
         [0044]    Number m of words Wi conditions the counter tolerance on the provided general result. Noting ERR the number of words considered as containing defective cells on reading and PAS the increment or decrement step of the counter, value VAL represents the result plus or minus ERR*PAS. 
         [0045]    The implementation of the present invention theoretically requires a number of memory cells greater than that of a conventional counter. Indeed, to form the equivalent of a counter over n bits (counting up to 2 n ), the implementation of the present invention requires k*n bits, where k is a constant which determines the number of defective or incompletely-updated cells. The economy in redundancy cells and the simplification of the defective cell management justifies, in practice, this size increase. 
         [0046]    The present invention will be described hereafter with an example of a unity step of the counter. It should however be noted that it more generally applies to increment or decrement values different from unity provided that this value is compatible with the desired tolerance on the variation of the general value. 
         [0047]      FIG. 4  very schematically illustrates in a simplified flowchart an embodiment of the present invention in a mode of reading of the value of a counter such as shown in  FIG. 3 . 
         [0048]    It is started (block  41 , ERR=0, R=0, i=1, DETERMINE A) by initializing the reading by setting to zero the value of an accumulator R (for example, a register), the value of a defective word counter ERR, a word index i, and by determining the current value A of some of the valid words. Value A varies along with the counter incrementation or decrementation but all the valid words contain either value A, or value A+1. Value A varies along with the counter lifetime. If all valid words Wi contain a same value, this value is considered as represented by A. If valid words contain a value and the other valid words this value plus 1, the lowest value is considered as represented by A. The determination of value A is performed, for example, by searching the most frequent pair of consecutive values (A, A+1) from among words Wi and by taking the smallest value A in the pair. The maximum of the possible values may also be searched and this value can be considered as being A+1. If no value A exists among words Wi, it is then considered that value A is the encountered maximum. 
         [0049]    Once the initializations are over, several iterations of a loop for reading different words aiming at accumulating their respective results are performed. On each iteration of this loop, it is started by reading (block  42 , READ Wi) the value contained by word Wi. It is then checked (block  43 , Wi=A OR A+1) whether this value is contained in the authorized range set by the current value A. If so (output Y of block  43 ), the value A or A+1 contained in word Wi is added to result register R (block  44 , R=R+Wi). If not (output N of block  43 ), erroneous word counter ERR is incremented (block  45 , ERR=ERR+1). This counter is, for example, contained in a register. 
         [0050]    As long as total number m of words has not been read (block  46 , i=m?), word index i is incremented (block  47 , i=i+1) and it is returned to read step  42 . Once all words Wi have been scanned (output Y of block  46 ), value VAL of the counter is given as ranging between R+(ERR*A) and R+(ERR*(A+1)). 
         [0051]    As a variation, the result (block  47 ) of value VAL is directly estimated by setting for the words containing a defective cell an increment by A or A+1 according to whether it is desired to monitor an upward or downward exceeding of a threshold of the counter. In this case, counter ERR may be omitted and step  45  is replaced with a step of addition of value A or A+1 to result register R. 
         [0052]    In practice, the interpretation of the counter words may be performed in parallel or successively with hardware and/or software means. 
         [0053]      FIG. 5  shows, in the form of a simplified flowchart, an embodiment of the method of the present invention for the updating by increment or decrement of a counter such as illustrated in  FIG. 3 . 
         [0054]    It is started (block  51 , EXIST Wi OK?) by making sure that there exists a non-defective word (that there exists at least one readable word). 
         [0055]    If not (output N of block  51 ), an error processing (ERROR) is implemented, the counter being unusable. 
         [0056]    If such a word exists (output Y of block  71 ), as for the reading, the value A contained in the non-defective words is determined (block  52 , DETERMINE A). 
         [0057]    According to instruction INC/DEC received by circuit  21  (block  53 , WAY?), the counter is incremented or decremented. 
         [0058]    For an increment (output INC of block  53 ), one of the words Wi of the counter containing value A is randomly selected (block  54 , RANDOMLY SELECT Wi=A). There necessarily exists such a word from the moment that all the words are not defective. This word is updated (block  55 , UPDATE Wi←A+1) by being incremented by 1 so that it contains value A+1. The write process is then over (block  56  END). 
         [0059]    To decrement the counter (output DEC of block  53 ), it is started by determining whether there exists a defective word Wi (block  57  EXIST Wi NOT OK?). 
         [0060]    If so, one of the defective words is randomly selected (block  58 , RANDOMLY SELECT Wi NOT OK) and it is attempted to repair it by updating it to value A (block  59 , UPDATE Wi←A). Then, the repair is verified by reading the content of the word which has just been written (block  60 , READ Wi) and by comparing its content with value A (block  61 , Wi=A?). If the word contains value A (output Y of block  61 ), the write process is then over (block  56 ). In the opposite case (output N of block  61 ), the word is excluded (block  62 , EXCLUDE Wi) from the word range taken into account for the current write operation. 
         [0061]    If all words are correct (output N of block  57 ), it is checked (block  63 , EXIST Wi=A+1) whether one of the words contains value A+1. If so (output Y of block  63 ), one of these words is selected (block  64 , RANDOMLY SELECT Wi=A+1) to be updated (block  65 , UPDATE Wi←A) to value A by decrementing it. The decrement operation is then over (block  56 ). If no word contains value A+1 (output N of block  63 ), this means that all the words contain the same value (A). Any of the words is selected (block  66 , RANDOMLY SELECT Wi=A) and updated (block  67 , UPDATE Wi←A−1) to value A−1 and the decrement operation is ended (block  56 ). In this last case, at the next determination of value A, said value is decreased by 1. 
         [0062]    Optionally (and if the available execution time enables it), each counter decrement goes along with an attempt to repair all defective words (block  70 , REPAIR). 
         [0063]      FIG. 6  is an example of a simplified flowchart of a sub-program  70  for attempting to systematically repair defective or incoherent words. This sub-program can be executed, for example, at the end of a decrement operation ( FIG. 5 ) and/or periodically independently from the operations on the counter. 
         [0064]    It is started (block  71 , EXIST Wi OK?) by scanning the counter words to determine whether there exists at least one readable word. 
         [0065]    If not (output N of block  71 ), an error processing (ERROR) is implemented, the counter being unusable. 
         [0066]    If such a word exists (output Y of block  71 ), the value A contained in the non-defective words is determined (block  72 , DETERMINE A). 
         [0067]    Then, it is determined, by scanning all the words, whether there exists a defective word Wi (block  73 , EXIST Wi NOT OK?). 
         [0068]    If not (output N of block  73 ), the subprogram is ended (block  74 , END). 
         [0069]    If such a word exists (output Y of block  73 ), it is attempted to repair the found defective word by updating it to value A+1 (block  75 , UPDATE Wi←A+1). Then, the repair is verified by reading the content of the word which has just been written (block  76 , READ Wi) and by comparing said content with value A+1 (block  77 , Wi=A+1?). If the word contains value A+ 1  (output Y of block  77 ), the repair has been effective and it is returned to the entrance of block  73  to end the word scanning. In the opposite case (output N of block  77 ), the current word is excluded (block  78 , EXCLUDE Wi) from the word range taken into account for the current write operation or is replaced with a redundant word and it is returned to the entrance of block  73  to end the word scanning. 
         [0070]    An advantage of the present invention is that the counter operates even with defective cells since the words containing defective cells are self-compensated by those containing operative cells. An advantage of the present invention is that it, in a way, virtually increases the redundancy capacity of the non-volatile memory. 
         [0071]    Another advantage of the present invention is that it improves the lifetime of event counters without requiring an increase in the number of possible redundancy cells. The present invention however remains compatible with the use of redundant cells. Indeed, if a cell considered as defective cannot be repaired by a writing, a conventional redundancy method can then be implemented. In this case, an advantage of the present invention is that it decreases the number of redundancy cells required for the same counter capacity. 
         [0072]    Another advantage of the present invention is that the event counter is protected against possible fraud attempts or incidental disturbances. 
         [0073]    Another advantage of the present invention is that it simplifies the detection of a possible defective cell by bringing this detection down to the word level. 
         [0074]    Of course, the present invention is likely to have various alterations, modifications, and improvements which will readily occur to those skilled in the art. In particular, the present invention applies to an increment different than one, the only consequence being that this increases the counter tolerance. The maximum error then corresponds to the number of words of the counter multiplied by the possible interval between the two extreme values likely to be contained in each word. 
         [0075]    Further, although the present invention has been described in relation with an example applied to the case where the total result of the counter is overestimated, that is, by assigning value A+1 (more generally, the upper value of the range of values of the words considered as defective), it of course also applies to an overestimation of the total result by assigning value A (more generally, the lowest value of the range of values) to the words considered as defective. 
         [0076]    Moreover, the implementation of the present invention, be it by software or hardware means, is within the abilities of those skilled in the art based on the functional explanations given hereabove.