Abstract:
A memory device connected to a CPU and including a plurality of memory elements selectable between a writable state and an unwritable state, the CPU outputting an address signal for selecting at least one of the plurality of memory elements, data to be stored in the plurality of memory elements, and a write signal for selecting the writable state or the unwritable state of the plurality of memory elements to the memory device. The memory device includes an address decoder element for generating at least two select signals in response to the address signal; a first memory for storing first data outputted from the CPU in response to a first state select signal having a specified level for selecting the writable state or the unwritable state when a first two select signal is at a specified level; a second memory for storing and outputting second data outputted from the CPU in response to a second state select signal having a specified level for selecting the writable state or the unwritable state when a second select signal is at a specified level, the second data putting the first and the second memories into the unwritable state; and a logic operation element for performing logic operations of the write signal and the second data outputted from the second memory and outputting signals indicating results of the logic operations to the first and the second memories respectively. These signals are the first and the second state select signals.

Description:
BACKGROUND OF THE INVENTION 
     1. Field of the Invention: 
     The present invention relates to a memory device to be mounted on, for example, an IC card, and in particular, to a memory device in which data writing is prohibited by means of hardware and a method for prohibiting writing to such a memory device. 
     2. Description of the Related Art: 
     In a conventional memory device, such as conventional EEPROM (electrically erasable programmable read only memory), erroneous writing caused by misoperation when an apparatus in which the EEPROM is used is operated at a low voltage is prevented by detecting the voltage applied to the EEPROM and prohibiting writing until the voltage reaches a normal operation level. In such a system configuration, in other words, writing to the EEPROM is prohibited by means of hardware when the operating voltage is low, but no such prohibition is performed when the operating voltage is high. 
     An IC card, on which this type of EEPROM is mounted, requires a high degree of security. Accordingly, a conventional IC card has a configuration in which writing to an EEPROM is prohibited by means of software when the IC card is operated at a normal voltage. Namely, writing prohibition which is usually controlled by application software is controlled by programming software in such an IC card. 
     More partically, in the case when the validity of the IC card has expired, writing to an EEPROM is prohibited by programming software based on data stored in a built-in timer or data concerning dates sent from an external terminal, or rewriting of the registration of an issuer or the like is prohibited by means of software once such registration is made. 
     However, writing prohibition to an EEPROM only by programming software has a limit since writing to an EEPROM becomes possible when writing is commanded by runaway of the program or when the program is revised. Accordingly, a conventional memory device such an IC card including this type of EEPROM has a limit in improving the security thereof. 
     SUMMARY OF THE INVENTION 
     A memory device according to the present invention includes a memory array for storing data; a writing restriction register for prohibiting writing to the memory array and outputting a signal having a specified level; and a logic operation element for putting the writing restriction register into an unwritable state in response to a signal outputted from the writing restriction register and putting the memory array into the unrewritable state. 
     Alternatively, a memory device according to the present invention, connected to a CPU and including a plurality of memory elements selectable between a writable state and an unwritable state, the CPU outputting an address signal for selecting at least one of the plurality of memory elements, data to be stored in the plurality of memory elements, and a write signal for selecting one of the writable state and the unwritable state of the plurality of memory elements to the memory device, includes an address decoding element for generating at least two select signals in response to the address signal; a first memory element storing first data outputted from the CPU in response to a first state select signal having a specified level for selecting one of the writable state and the unwritable state when a first one of the two select signals is at a specified level; a second memory element for storing and outputting second data outputted from the CPU in response to a second state select signal having a specified level for selecting one of the writable state and the unwritable state when a second one of the two select signals is at a specified level, the second data putting the first and the second memory elements into the unwritable state; and a logic operation element for performing logic operations of the write signal and the second data outputted from the second memory element and outputting signals indicating results of the logic operations to the first and the second memory elements respectively, the signals indicating the results being the first and the second state select signals. 
     A method for prohibiting rewriting of data stored in a memory device according to the present invention, connected to a CPU and including first and second memory elements each selectable between a writable state and an unwritable state, the CPU outputting an address signal for selecting one of the plurality of memory elements, data to be stored in the plurality of memory elements, and a write signal for selecting one of the writable state and the unwritable state of the plurality of memory elements to the memory device includes the steps of setting initial data in the second memory element, the initial data having a specified level for putting the first memory element into the writable state before receiving the address signal, data to be stored, and the write signal from the CPU, and outputting the initial data from the second memory element; performing a first logic operation of the initial data and the write signal; outputting a state select signal indicating a result of the first logic operation for putting the second memory element into the writable state; writing first data to the first memory element when a first select signal is at a specified level; writing second data having a level inverse to the level of the initial data to the second memory element when a second select signal is at a specified level, and then outputting the second data; performing a second logic operation of the write signal and the second data; and outputting a writing prohibit signal indicating a result of the second logic operation and prohibiting writing to the first and the second memory elements, thereby putting the first and the second memory elements into the unwritable state. 
     Thus, the invention described herein makes possible the advantages of providing a memory device in which writing prohibition is performed by means of hardware thus to improve security thereof and a method for reliably prohibiting writing to the memory device. 
     These and other advantages of the present invention will become apparent to those skilled in the art upon reading and understanding the following detailed description with reference to the accompanying figures. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1 is a view illustrating a system configuration of a memory device according to an example of the present invention. 
     FIG. 2a is a view illustrating an example of a circuit diagram constituting a writing restriction register shown in FIG. 1. 
     FIG. 2b is a truth table of a D-type flip-flop of the circuit shown in FIG. 2a. 
     FIG. 3 is a view illustrating an example of a diagram of an initial state setting signal generation circuit in the memory device of the present invention. 
     FIG. 4a is a view showing a signal waveform of a supply voltage of the initial state setting signal generation circuit shown in FIG. 3. 
     FIG. 4b is a view showing a signal waveform at a node A of the initial state setting signal generation circuit shown in FIG. 3. 
     FIG. 4c is a view showing a signal waveform of a signal outputted from the Schmitt trigger inverter of the initial state setting signal generation circuit shown in FIG. 3. 
     FIG. 5 is a timing chart of signals inputted and outputted through terminals of the second writing restriction register and terminals of the D-type flip-flop shown in FIGS. 1 and 2a. 
    
    
     DESCRIPTION OF THE PREFERRED EMBODIMENTS 
     Hereinafter, the present invention will be described by way of illustrating examples with reference to the accompanying drawing. 
     Data &#34;0&#34; and &#34;1&#34; denote signals levels according to positive logic. 
     FIG. 1 shows a system configuration of an EEPROM as an example of a memory device according to the present invention. The EEPROM includes an address decoder 1, a first writing restriction register 2, a first memory array 3, a second writing restriction register 4, and a second memory array 5 as circuit elements. The EEPROM further includes negative logic AND circuits 10, 11 and 12. The EEPROM is connected to a CPU (central processing unit) 100. In FIG. 1, the first and the second writing restriction registers 2 and 4, as well as the memory arrays 3 and 5, are allocated in a part of an address space of a memory of a computer system with the CPU 100. Control signals for reading data are omitted. 
     A detailed configuration of the EEPROM will be explained together with an operation thereof. 
     When an address signal is inputted from the CPU 100 to the address decoder 1 through an address bus 6, the address decoder 1 outputs select signals 20, 30, 40 and 50 to select signal input terminals of the first writing restriction register 2, the first memory array 3, the second writing restriction register 4, and the second memory array 5, respectively. Depending on the level of the select signals, one of the circuit elements is selected. Since there are four circuit elements from which one is selected in this example, the address bus 6 is a two-bit address bus. 
     Data is inputted from the CPU 100 to data input terminals Data of the first and the second writing restriction registers 2 and 4, and the first and the second memory arrays 3 and 5 through a data bus 7. A write signal is inputted from the CPU 100 to a write enable terminal WE of the first writing restriction register 2 through a control signal line 8. 
     The signal line 8 is also connected to first input terminals of the negative logic AND circuits 10, 11 and 12. A second input terminal of the negative logic AND circuit 10 is connected to an output terminal of the first writing restriction register 2. Second input terminals of the negative logic AND circuits 11 and 12 are both connected to an output terminal of the second writing restriction register 4. Output terminals of the negative logic AND circuits 10, 11 and 12 are connected to the write enable terminals WE of the first memory array 3, the second writing restriction register 4, and the second memory array 5, respectively. 
     The first writing restriction register 2, the first memory array 3, the second writing restriction register 4, and the second memory array 5 are put into a rewritable state when the select signals 20, 30, 40 and 50 inputted to the select signal input terminals thereof are at a high level and the write signals inputted to the write enable terminals WE thereof are at a low level. 
     In the above-mentioned system configuration, the first writing restriction register 2 is always in a rewritable state, and had a function of restricting writing to the first memory array 3 through the negative logic AND circuit 10. 
     The first memory array 3 is put into a rewritable state by writing data &#34;0&#34;, which allows writing, to the first writing restriction register 2 so that data &#34;0&#34; will be outputted to the second input terminal of the negative logic AND circuit 10 from the first writing restriction register 2. In this state, when the level of the write signal also becomes low, the level of a signal outputted from the negative logic AND circuit 10 becomes low. The first memory array 3 is put into a rewritable state upon receiving such a low level signal at the write enable terminal WE thereof. 
     The first memory array 3 is put into an unrewritable state, namely, a write protect state by writing data &#34;1&#34; (a high level signal) to the first writing restriction register 2 so that data &#34;1&#34; will be outputted to the second input terminal of the negative logic AND circuit 10 from the first writing restriction register 2. In this state, even though the level of the write signal is low, data &#34;1&#34; (a high level signal) for prohibiting writing to the first memory array 3 is inputted to the write enable terminal WE thereof from the output terminal of the negative logic AND circuit 10. Thus, the first memory array 3 is put into a write protect state. 
     The above write protect state is released by writing data &#34;0&#34; to the first writing restriction register 2. 
     In the second writing restriction register 4, data &#34;0&#34; is set in an initial state to allow writing. In the initial state, when the write signal is at a low level, data &#34;0&#34; is inputted to the second input terminals of the negative logic AND circuits 11 and 12. Accordingly, signals outputted from the negative logic AND circuits 11 and 12 are at a low level, thereby putting the second memory array 5 into a writable state. 
     FIG. 2a shows an example of a circuit diagram constituting each of the first and the second writing restriction registers 2 and 4. Such a circuit includes a D-type flip-flop, a NAND gate circuit, and an inverter. The D-type flip-flop has a date input terminal D, a clock input terminal CLK, an output terminal Q, and a reset input terminal RESET. Data is inputted to the D-type flip-flop through the data input terminal Data of the second writing restriction register 4. A select signal is inputted to a first input terminal of the NAND circuit. A write signal is inputted to a second input terminal of the NAND circuit through the inverter. A signal outputted from the NAND circuit is inputted to the clock input terminal CLK of the D-type flip-flop. A reset signal is inputted to the reset input terminal RESET. In FIG. 1, the reset input terminal RESET is not shown. A signal from the second writing restriction register 4 is outputted from the output terminal Q. 
     FIG. 2b is a truth table of the D-type flip-flop of the circuit shown in FIG. 2a. A symbol &#34;0&#34; denotes a zero in binary notation. A symbol &#34;1&#34; denotes a numeral one in binary notation. A symbol &#34;X&#34; denotes an undefined signal level. A symbol &#34; &#34; denotes a transition of a signal level from &#34;0&#34; (low) to &#34;1&#34; (high). A symbol &#34; &#34; denotes a transition of a signal level from &#34;1&#34; to &#34;0&#34;. A symbol &#34;Q n-1  &#34; denotes a signal level to which a signal level in a previous state is unchanged. Symbols &#34;RESET&#34;, &#34;D&#34;, &#34;CLK&#34;, and &#34;Q&#34; are the terminals of the D-type flip-flop. 
     FIG. 3 shows an example diagram of an initial state setting signal generation circuit for generating data &#34;0&#34; to be written to the second writing restriction register 4. The initial state setting signal generation circuit includes a capacitor C, a resistor R, and a Schmitt trigger inverter INV. A junction of the capacitor C and the resistor R is referred to as a node A. A node A is connected to an input terminal of the Schmitt trigger inverter INV. A terminal of the capacitor C opposite to the node A is connected to an anode (+) terminal of a DC power source, and a terminal of the resistor R opposite to the node A is connected to a cathode (-) terminal of the DC power source. An output terminal of the Schmitt trigger inverter INV is connected to the reset input terminal RESET of the D-type flip-flop shown in FIG. 2a. 
     FIG. 4a shows a signal waveform of a supply voltage of the intial state setting signal generation circuit. FIG. 4b shows a signal waveform at the node A of the initial state setting signal generation circuit. FIG. 4c shows a waveform of a signal outputted from the Schmitt trigger inverter INV of the initial state setting signal generation circuit. 
     FIG. 5 is a timing chart of signals inputted and outputted through the terminals of the second writing restriction register 4 and the terminals of the D-type flip-flop. 
     An example of a circuit configuration and a circuit operation for putting the second writing restriction register 4 into an initial state will be described. 
     When a supply voltage is applied to the initial state setting signal generation circuit shown in FIG. 3 after the power is turned on (for example, after battery exchange), the node A obtains a potential substantially identical with the supply voltage, thereby allowing a charging current to flow to the capacitor C for a specified period. The amount of the charging current is gradually reduced until no charging current is allowed to flow after the specified period, whereby the potential of node A nearly becomes zero. When the level of the potential of the node A crosses a threshold voltage V th  of the Schmitt trigger inverter INV at a time t during the specified period, the level of a signal outputted from the Schmitt trigger inverter INV is changed from low to high. Such a low level signal from the Schmitt trigger inverter INV is outputted to the reset input terminal RESET of the second writing restriction register 4. The data stored in the second writing restriction register 4 becomes &#34;0&#34; in response to such a low level signal. 
     When the level of the select signal 40 outputted from the address decoder 1 becomes high, the second writing restriction register 4 is selected. When data &#34;1&#34; is inputted from the CPU 100 to the second writing restriction register 4, the second input terminals of the negative logic AND circuits 11 and 12 receive data &#34;1&#34;. Accordingly, the level of a signal outputted from the negative logic AND circuit 11 becomes high. Since such a high level signal is inputted to the write enable terminal WE of the second writing restriction register 4, the second writing restriction register 4 is put into an unrewritable state. In the same manner, the second memory array 5 is also put into an unrewritable state. 
     When the data stored in the second writing restriction register 4 is &#34;1&#34;, the level of a signal outputted therefrom becomes high. Since such a high level signal is inputted to the second input terminal of the negative logic AND circuit 11, the level of a signal outputted therefrom becomes high irrespective of the level of a signal inputted to the first input terminal of the negative logic AND circuit 11. Since such a high level signal is inputted to the write enable terminal WE of the second writing restriction register 4, the second writing restriction register 4 is put into an unrewritable state, whereby data outputted therefrom is maintained &#34;1&#34; (a high level signal). Since such a high level signal from the second writing restriction register 4 is also inputted to the second input terminal of the negative logic AND circuit 12, the level of a signal outputted therefrom also becomes high. Since such a high level signal is inputted to the write enable terminal WE of the second memory array 5, the second memory array 5 is put into an unrewritable state. 
     In this manner, once the second writing restriction register 4 is put into an unrewritable state, data &#34;0&#34; cannot be written to the second writing restriction register 4 thereafter. Accordingly, writing to the second memory array 5 is permanently prohibited. In other words, the EEPROM having the abovementioned system configuration has a function of restricting writing by means of hardware. 
     In the case when such an EEPROM is mounted on an IC card, writing prohibition is still valid even when writing is commanded by runaway of the program or when the program is revised. 
     The D-type flip-flop shown in FIG. 2a may be replaced with a non-volatile memory device including a data input terminal D, a clock pulse input terminal CLK, an output terminal Q, and a test signal input terminal TST. The test signal input terminal TST corresponds to the write enable terminal WE of the D-type flip-flop. 
     In the case when the non-volatile memory device is used instead of the D-type flip-flop, desirable data is written to a memory array after data &#34;0&#34; is inputted to the D-type flip-flop through the test signal input terminal TST in a production process of the EEPROM. By inputting data &#34;1&#34; through the test signal input terminal TST after the completion of writing to the second memory array 5, data for prohibiting writing to the second memory array 5 is set in the second writing restriction register 4 in an initial state. 
     The above writing restriction register can be constituted by a RAM, another EEPROM, or any other logic circuit. Although writing to the second memory array 5 is prohibited in the above example, the region of the memory array into which writing is prohibited, the number of memory arrays, and the size of the address are not limited to the one mentioned in the above example. 
     According to a memory device and a method for prohibiting writing to the memory device according to the present invention, a writing restriction register is put into an unrewritable state by a logic circuit, thereby putting a memory array into an unrewritable state. In such a system, once the writing restriction register is put into an unrewritable state, writing to the memory array is permanently prohibited. In other words, data writing is prohibited by means of hardware. 
     In the case when such a memory device is mounted on an IC card, writing prohibition is still valid even when writing is commanded by runaway of the program or when the program is revised. Thus, security of the IC card is significantly improved. 
     Various other modifications will be apparent to and can be readily made by those skilled in the art without departing from the scope and spirit of this invention. Accordingly, it is not intended that the scope of the claims appended hereto be limited to the description as set forth herein, but rather that the claims be broadly construed.