JP2011180963A - Semiconductor integrated circuit device - Google Patents

Semiconductor integrated circuit device Download PDF

Info

Publication number
JP2011180963A
JP2011180963A JP2010046453A JP2010046453A JP2011180963A JP 2011180963 A JP2011180963 A JP 2011180963A JP 2010046453 A JP2010046453 A JP 2010046453A JP 2010046453 A JP2010046453 A JP 2010046453A JP 2011180963 A JP2011180963 A JP 2011180963A
Authority
JP
Japan
Prior art keywords
page
data
function
ram
physical
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Withdrawn
Application number
JP2010046453A
Other languages
Japanese (ja)
Inventor
Shigeo Kurakata
繁男 倉形
Shinsuke Asari
信介 浅利
Shinichi Fukazawa
真一 深澤
Hideyuki Tanaka
英幸 田中
Yuji Asano
勇二 浅野
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Renesas Electronics Corp
Original Assignee
Renesas Electronics Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Renesas Electronics Corp filed Critical Renesas Electronics Corp
Priority to JP2010046453A priority Critical patent/JP2011180963A/en
Publication of JP2011180963A publication Critical patent/JP2011180963A/en
Withdrawn legal-status Critical Current

Links

Images

Abstract

<P>PROBLEM TO BE SOLVED: To improve overall performance of writing data to a nonvolatile memory. <P>SOLUTION: A semiconductor integrated circuit device (10) includes a nonvolatile memory (108), a control unit (101), and a RAM (107). The control unit forms an address conversion table on the RAM on the basis of initial settings at power-on, and refers to the address conversion table to control writing data to a block in the nonvolatile memory. Since the RAM includes a logical/physical address conversion table, there is no need to write data to the nonvolatile memory in order to update the address conversion table in the nonvolatile memory, thereby reducing the time required for writing data in the nonvolatile memory. <P>COPYRIGHT: (C)2011,JPO&INPIT

Description

本発明は、不揮発性メモリを内蔵した半導体集積回路装置における電源遮断対策技術に関し、例えば非接触式ICカードに搭載されるカード用マイクロコンピュータに適用して有効な技術に関する。   The present invention relates to a power cutoff countermeasure technique in a semiconductor integrated circuit device incorporating a nonvolatile memory, and relates to a technique effective when applied to a card microcomputer mounted on, for example, a non-contact type IC card.

不揮発性メモリを内蔵した半導体集積回路装置の一例として、非接触式ICカードに搭載されるカード用マイクロコンピュータを挙げることができる。非接触式ICカードは、カードの内部にアンテナを持ち、外部装置(リーダライタ)との間で、電波を利用したデータ通信を行うことができる。非接触式ICカードの動作用電源も電波から生成することができるため、バッテリー無しで動作可能になっているが、書き込み最中にカードを磁界から遠ざけた場合には、電源遮断により書き込みが不完全となる虞れがある。   As an example of a semiconductor integrated circuit device incorporating a nonvolatile memory, a card microcomputer mounted on a non-contact IC card can be cited. The non-contact type IC card has an antenna inside the card, and can perform data communication using radio waves with an external device (reader / writer). The power supply for operating the contactless IC card can also be generated from radio waves, so it can be operated without a battery. However, if the card is moved away from the magnetic field during writing, writing is not possible due to power interruption. There is a risk of becoming perfect.

特許文献1には、消去及び書き込み処理中に動作電源が遮断されても記憶情報が不所望に消失しないメモリカードが記載されている。それによれば、不揮発性メモリは、そのメモリ領域の物理アドレス毎に空き情報フラグを対応付けた消去テーブルと、論理アドレス毎にメモリ領域の物理アドレスを対応付けたアドレス変換テーブルとを有し、空き情報フラグは対応メモリ領域が消去許可か否かを示す。制御回路は、消去テーブルの空き情報フラグを参照して書き換えデータを書き込むメモリ領域を決定し、データを書き込んだメモリ領域の物理アドレスと論理アドレスとを対応をアドレス変換テーブルに反映し、消去テーブルの空き情報フラグを更新する。書き換えデータを書き込むメモリ領域は消去テーブルの空き情報フラグを参照して決定し、書き換え前のメモリ領域と同じメモリ領域で書き換えを行わない。   Patent Document 1 describes a memory card in which stored information is not lost undesirably even when an operating power supply is interrupted during erasing and writing processes. According to this, the non-volatile memory has an erasure table in which a free information flag is associated with each physical address in the memory area, and an address conversion table in which a physical address in the memory area is associated with each logical address. The information flag indicates whether or not the corresponding memory area is erasable. The control circuit refers to the empty information flag in the erase table to determine the memory area to which the rewrite data is written, reflects the correspondence between the physical address and logical address of the memory area in which the data is written in the address conversion table, and Update the free / busy flag. The memory area to which the rewrite data is written is determined with reference to the empty information flag in the erase table, and rewriting is not performed in the same memory area as the memory area before rewriting.

特許文献2には、仮想的なセクタ消去の最中に電源が切れてしまっても、差分のデータが損なわれることのない記録技術が記載されている。それによれば、複数のブロック化された記録単位領域を有する不揮発記録媒体に対し、その各記録単位領域に連続的な書込み動作を行い、かつ記録単位領域毎に一括消去動作を行う。そして新たにファイルを上書き保存する際に、記録単位領域の既に書き込まれた既存ファイル直後の空き領域から書込み動作を開始するとともに、かかる書込み動作終了するまでの間、記録単位領域に書き込まれている上書きファイル対応のファイルを保持するようにしている。   Patent Document 2 describes a recording technique in which even if the power is cut off during virtual sector erasure, the difference data is not impaired. According to this, for a nonvolatile recording medium having a plurality of blocked recording unit areas, a continuous writing operation is performed in each recording unit area, and a batch erasing operation is performed for each recording unit area. When a new file is overwritten and saved, the writing operation starts from the empty area immediately after the already written file in the recording unit area and is written in the recording unit area until the end of the writing operation. The file corresponding to the overwrite file is retained.

特開2004−127185号公報JP 2004-127185 A 特開2008−077669号公報JP 2008-076669 A

非接触インタフェースを有するOS(Operating System;オペレーティングシステム)規格では、デバイスとして書き込み最中に電源遮断(Tear off)が発生した場合、中途半端な状態で不揮発性メモリ上のデータを放置することはデバイスの信頼性低下となると考え、書込みが正常に終了しなかった場合、次に同アドレスの読み出し要求があったときは書込み実施前のデータを出力するよう規定されている。   In the OS (Operating System) standard having a non-contact interface, if a power-off occurs during writing as a device, it is not possible to leave the data in the nonvolatile memory in a halfway state. Therefore, if the writing is not normally completed, the next data read request is made to output the data before the writing is performed.

特許文献1によれば、データ書き込み要求の発生時には不揮発性メモリの空き領域への書き込みを実施し、旧データへの上書きを実施しないようにしている。そして、論理アドレスと物理アドレスとの変換に用いられるアドレス変換テーブルが不揮発性メモリ内に形成され、不揮発性メモリへのデータ書き込み処理時に、不揮発性メモリ内のアドレス変換テーブル更新が行われる。つまり、不揮発性メモリへのデータ書き込み毎に、不揮発性メモリへのデータ書き込みと、当該不揮発性メモリ内のアドレス変換テーブル更新のために、結果的に不揮発性メモリへの書き込み動作が2度必要とされる。不揮発性メモリへの書き込み処理について本願発明者が検討したところ、不揮発性メモリとは別のメモリ例えばRAM(Random Access Memory)にアドレス変換テーブルを形成すれば、不揮発性メモリ内のアドレス変換テーブル更新のための不揮発性メモリへの書き込み動作が不要になるため、不揮発性メモリへのデータ書き込み処理全体としてのパフォーマンスの向上が図れることを見いだした。しかし、RAMにアドレス変換テーブルを形成する場合には、電源遮断によりRAM内のアドレス変換テーブルが失われてしまうため、それについての対策が不可欠となる。   According to Patent Document 1, when a data write request occurs, writing to an empty area of a nonvolatile memory is performed, and overwriting to old data is not performed. An address conversion table used for conversion between a logical address and a physical address is formed in the nonvolatile memory, and the address conversion table in the nonvolatile memory is updated at the time of data writing processing to the nonvolatile memory. That is, every time data is written to the nonvolatile memory, the writing operation to the nonvolatile memory is required twice in order to write the data to the nonvolatile memory and update the address conversion table in the nonvolatile memory. Is done. The inventor of the present application examined the writing process to the non-volatile memory. If the address conversion table is formed in a memory different from the non-volatile memory, for example, a RAM (Random Access Memory), the address conversion table in the non-volatile memory is updated. Therefore, it has been found that the performance of the entire data writing process to the nonvolatile memory can be improved because the writing operation to the nonvolatile memory becomes unnecessary. However, when the address conversion table is formed in the RAM, the address conversion table in the RAM is lost due to power interruption, and measures against it are indispensable.

特許文献2においては、論理アドレスと物理アドレスとの変換に用いられるアドレス変換テーブルが用いられていないため、電源遮断とRAM内のアドレス変換テーブルとの関係については考慮されていない。   In Patent Document 2, since an address conversion table used for conversion between a logical address and a physical address is not used, the relationship between the power shutdown and the address conversion table in the RAM is not considered.

本発明の目的は、不揮発性メモリへのデータ書き込み処理全体としてのパフォーマンスの向上を図るための技術を提供することにある。   An object of the present invention is to provide a technique for improving the performance of the entire data writing process to the nonvolatile memory.

本発明の前記並びにその他の目的と新規な特徴は本明細書の記述及び添付図面から明らかになるであろう。   The above and other objects and novel features of the present invention will be apparent from the description of this specification and the accompanying drawings.

本願において開示される発明のうち代表的なものの概要を簡単に説明すれば下記の通りである。   The following is a brief description of an outline of typical inventions disclosed in the present application.

すなわち、不揮発性メモリと、上記不揮発性メモリへのデータ書き込み及び上記不揮発性メモリからのデータ読み出しを制御可能な制御部と、上記制御部によってランダムアクセス可能なRAMとを設ける。上記不揮発性メモリは、書き込み単位とされるページを含み、上記ページは、それぞれデータを記憶可能な複数のブロックと、上記複数のブロックに書き込まれたデータを上記ページ単位で管理するためのページ管理情報とを含む。上記制御部は、上記不揮発性メモリについての論理アドレスを物理アドレスに変換するためのアドレス変換テーブルを、電源投入時の初期設定により上記RAMの第1記憶エリアに形成するアドレス変換テーブル形成機能と、上記RAMの第1記憶エリアに形成された上記アドレス変換テーブルを参照して、上記不揮発性メモリにおけるブロックへのデータ書き込みを制御するデータ書き込み機能とを含む。上記データ書き込み機能は、データ書き込みの対象となるブロックを含むページの記憶データを上記RAMの第2記憶エリアにコピーする第1機能と、上記RAMの第2記憶エリアに対して、上記データ書き込みの対象となるブロックへのデータ書き込みを行う第2機能とを含む。さらに上記データ書き込み機能は、上記第2機能によるデータ書き込みに対応して、上記RAMの第2記憶エリアのページ管理情報を更新する第3機能と、上記ページ管理情報が更新された後に、上記RAMの第2記憶エリアの記憶データを、上記アドレス変換テーブルで空きページとされる上記不揮発性メモリの物理ページに書き込む第4機能とを含む。   That is, a nonvolatile memory, a control unit that can control data writing to the nonvolatile memory and data reading from the nonvolatile memory, and a RAM that can be randomly accessed by the control unit are provided. The non-volatile memory includes a page as a unit of writing, and the page includes a plurality of blocks each capable of storing data, and page management for managing data written in the plurality of blocks in units of the page. Information. An address conversion table forming function for forming an address conversion table for converting a logical address of the nonvolatile memory into a physical address in a first storage area of the RAM by an initial setting at power-up; A data writing function for controlling data writing to the block in the nonvolatile memory with reference to the address conversion table formed in the first storage area of the RAM. The data writing function includes a first function for copying stored data of a page including a block to which data is to be written to a second storage area of the RAM, and writing the data to the second storage area of the RAM. And a second function for writing data to the target block. Further, the data writing function includes a third function for updating page management information in the second storage area of the RAM in response to data writing by the second function, and the RAM after the page management information is updated. And a fourth function for writing data stored in the second storage area into a physical page of the nonvolatile memory that is a free page in the address conversion table.

本願において開示される発明のうち代表的なものによって得られる効果を簡単に説明すれば下記のとおりである。   The effects obtained by the representative ones of the inventions disclosed in the present application will be briefly described as follows.

すなわち、不揮発性メモリへのデータ書き込み処理全体としてのパフォーマンスの向上を図るための技術を提供することができる。   That is, it is possible to provide a technique for improving the performance of the entire data writing process to the nonvolatile memory.

本発明にかかる半導体集積回路装置の一例とされるカード用マイクロコンピュータの構成例ブロック図である。1 is a block diagram illustrating a configuration example of a card microcomputer as an example of a semiconductor integrated circuit device according to the present invention; FIG. 上記カード用マイクロコンピュータに含まれるEEPROMの初期状態の説明図である。It is explanatory drawing of the initial state of EEPROM contained in the said microcomputer for cards. 上記カード用マイクロコンピュータの動作の流れを示すフローチャートである。It is a flowchart which shows the flow of operation | movement of the said microcomputer for cards. 上記カード用マイクロコンピュータにおいて書き込み命令が受信された場合の動作の流れを示すフローチャートである。It is a flowchart which shows the flow of operation | movement when the write command is received in the said microcomputer for cards. 上記カード用マイクロコンピュータにおいて読み出し命令が受信された場合の動作の流れを示すフローチャートである。It is a flowchart which shows the flow of operation | movement when the read command is received in the said microcomputer for cards. 上記EEPROMにおけるメモリフォーマットと論理/物理アドレス変換テーブルとの関係説明図である。FIG. 3 is an explanatory diagram of a relationship between a memory format and a logical / physical address conversion table in the EEPROM. 上記EEPROMに含まれるブロックのデータ書き換えを目的とする書き込み命令が受信された場合の主要部の状態説明図である。It is state explanatory drawing of the principal part when the write command for the purpose of data rewriting of the block contained in the said EEPROM is received. 旧データがRAM内の所定エリアにコピーされた状態の説明図である。It is explanatory drawing of the state in which old data was copied to the predetermined area in RAM. 上記カード用マイクロコンピュータに含まれるRAM内の書き込み用エリアにコピーされたデータの更新後の状態説明図である。It is state explanatory drawing after the update of the data copied to the writing area in RAM contained in the said microcomputer for cards. 上記EEPROMにおける空きページへのデータ書き込みの説明図である。It is explanatory drawing of the data writing to the empty page in the said EEPROM. 上記EEPROMにおけるデータと、上記RAMの書き込み用エリアのデータとの比較の説明図である。It is explanatory drawing of the comparison with the data in the said EEPROM, and the data of the area for writing of the said RAM. 上記RAM内の書き込み用エリアにおける確認フラグの変更と当該確認フラグの上記EEPROMへのオーバーライトの説明図である。It is explanatory drawing of the change of the confirmation flag in the writing area in the said RAM, and the overwriting to the said EEPROM of the said confirmation flag. 上記RAM内の論理/物理アドレス変換テーブルの更新の説明図である。It is explanatory drawing of the update of the logical / physical address conversion table in the said RAM. 空きページの判定基準を説明するための説明図である。It is explanatory drawing for demonstrating the determination criteria of an empty page. 空きページの判定基準を説明するための説明図である。It is explanatory drawing for demonstrating the determination criteria of an empty page. 空きページの判定基準を説明するための説明図である。It is explanatory drawing for demonstrating the determination criteria of an empty page. 空きページの判定基準を説明するための説明図である。It is explanatory drawing for demonstrating the determination criteria of an empty page. EEPROMの書き換え単位と、書き換えにかかるデータサイズとの関係の説明図である。It is explanatory drawing of the relationship between the rewriting unit of EEPROM, and the data size concerning rewriting. EEPROMの書き換え単位と、書き換えにかかるデータサイズとの関係の説明図である。It is explanatory drawing of the relationship between the rewriting unit of EEPROM, and the data size concerning rewriting. 上記カード用マイクロコンピュータが搭載された非接触式ICカードの使用例説明図である。It is explanatory drawing of the usage example of the non-contact-type IC card in which the said microcomputer for cards was mounted. 上記カード用マイクロコンピュータを搭載する非接触式ICカードに対応するリーダライタに結合されるホストシステムでの処理の流れを示すフローチャートである。It is a flowchart which shows the flow of a process in the host system couple | bonded with the reader / writer corresponding to the non-contact-type IC card carrying the said microcomputer for cards.

1.実施の形態の概要
先ず、本願において開示される発明の代表的な実施の形態について概要を説明する。代表的な実施の形態についての概要説明で括弧を付して参照する図面中の参照符号はそれが付された構成要素の概念に含まれるものを例示するに過ぎない。
1. First, an outline of a typical embodiment of the invention disclosed in the present application will be described. Reference numerals in the drawings referred to in parentheses in the outline description of the representative embodiments merely exemplify what are included in the concept of the components to which the reference numerals are attached.

〔1〕本発明の代表的な実施の形態に係る半導体集積回路装置(10)は、不揮発性メモリ(108)と、上記不揮発性メモリへのデータ書き込み及び上記不揮発性メモリからのデータ読み出しを制御可能な制御部(101)と、上記制御部によってランダムアクセス可能なRAM(107)とを含む。上記不揮発性メモリは、書き込み単位とされるページを含み、上記ページは、それぞれデータを記憶可能な複数のブロックと、上記複数のブロックに書き込まれたデータを上記ページ単位で管理するためのページ管理情報とを含む。上記制御部は、上記不揮発性メモリについての論理アドレスを物理アドレスに変換するためのアドレス変換テーブルを、電源投入時の初期設定により上記RAMの第1記憶エリアに形成するアドレス変換テーブル形成機能と、上記RAMの第1記憶エリアに形成された上記アドレス変換テーブルを参照して、上記不揮発性メモリにおけるブロックへのデータ書き込みを制御するデータ書き込み機能とを含む。上記データ書き込み機能は、データ書き込みの対象となるブロックを含むページの記憶データを上記RAMの第2記憶エリアにコピーする第1機能と、上記RAMの第2記憶エリアに対して、上記データ書き込みの対象となるブロックへのデータ書き込みを行う第2機能とを含む。さらに上記データ書き込み機能は、上記第2機能によるデータ書き込みに対応して、上記RAMの第2記憶エリアのページ管理情報を更新する第3機能と、上記ページ管理情報が更新された後に、上記RAMの第2記憶エリアの記憶データを、上記アドレス変換テーブルで空きページとされる上記不揮発性メモリの物理ページに書き込む第4機能とを含む。   [1] A semiconductor integrated circuit device (10) according to a typical embodiment of the present invention controls a nonvolatile memory (108), data writing to the nonvolatile memory, and data reading from the nonvolatile memory. And a RAM (107) that can be randomly accessed by the control unit. The non-volatile memory includes a page as a unit of writing, and the page includes a plurality of blocks each capable of storing data, and page management for managing data written in the plurality of blocks in units of the page. Information. An address conversion table forming function for forming an address conversion table for converting a logical address of the nonvolatile memory into a physical address in a first storage area of the RAM by an initial setting at power-up; A data writing function for controlling data writing to the block in the nonvolatile memory with reference to the address conversion table formed in the first storage area of the RAM. The data writing function includes a first function for copying stored data of a page including a block to which data is to be written to a second storage area of the RAM, and writing the data to the second storage area of the RAM. And a second function for writing data to the target block. Further, the data writing function includes a third function for updating page management information in the second storage area of the RAM in response to data writing by the second function, and the RAM after the page management information is updated. And a fourth function for writing data stored in the second storage area into a physical page of the nonvolatile memory that is a free page in the address conversion table.

論理/物理アドレス変換テーブルが不揮発性メモリ内に設けられている場合には、当該不揮発性メモリへのデータ書き込み毎に、不揮発性メモリへのデータ書き込みと、当該不揮発性メモリ内のアドレス変換テーブル更新のために、結果的に不揮発性メモリへの書き込み動作が2度必要とされる。   When the logical / physical address conversion table is provided in the nonvolatile memory, the data writing to the nonvolatile memory and the address conversion table update in the nonvolatile memory are performed every time the data is written to the nonvolatile memory. Therefore, as a result, the write operation to the nonvolatile memory is required twice.

これに対して、上記構成の半導体集積回路装置においては、論理/物理アドレス変換テーブルがRAM内に設けられているため、不揮発性メモリ内のアドレス変換テーブル更新のための不揮発性メモリへの書き込み動作が不要になる。RAM内の論理/物理アドレス変換テーブルの更新は、不揮発性メモリの場合に比べて高速に行うことができる。このため、不揮発性メモリへのデータ書き込み処理全体としてのパフォーマンスの向上を図ることができる。   On the other hand, in the semiconductor integrated circuit device having the above configuration, since the logical / physical address conversion table is provided in the RAM, the write operation to the nonvolatile memory for updating the address conversion table in the nonvolatile memory is performed. Is no longer necessary. The logical / physical address conversion table in the RAM can be updated at a higher speed than in the case of the nonvolatile memory. For this reason, it is possible to improve the performance of the entire data writing process to the nonvolatile memory.

また制御部は、上記不揮発性メモリについての論理アドレスを物理アドレスに変換するためのアドレス変換テーブルを、電源投入時の初期設定により上記RAMの第1記憶エリアに形成するため、電源投入毎に適切なアドレス変換テーブルを得ることができる。   In addition, the control unit forms an address conversion table for converting the logical address of the nonvolatile memory into a physical address in the first storage area of the RAM by the initial setting when the power is turned on. A simple address conversion table can be obtained.

〔2〕上記〔1〕において、上記ページ管理情報は、データが正常に書き込まれたことを示す確認フラグを含む。上記データ書き込み機能は、上記アドレス変換テーブルで空きページとされる上記不揮発性メモリの物理ページに書き込まれたデータと、それに対応する上記RAMの第2エリアのデータとが一致するか否かを判別する第5機能を含む。また、上記データ書き込み機能は、上記アドレス変換テーブルで空きページとされる上記不揮発性メモリの物理ページに書き込まれたデータと、それに対応する上記RAMの第2記憶エリアのデータとが一致する場合に、上記RAMの第2記憶エリアの上記確認フラグの値を変更してから、その確認フラグを、上記不揮発性メモリにおいて対応する物理ページへ上書きすることで、当該物理ページにおける確認フラグを更新する第6機能を含む。   [2] In the above [1], the page management information includes a confirmation flag indicating that data has been normally written. The data write function determines whether or not the data written in the physical page of the non-volatile memory, which is an empty page in the address conversion table, matches the data in the second area of the RAM corresponding thereto. Including a fifth function. Further, the data writing function is used when the data written in the physical page of the non-volatile memory, which is an empty page in the address conversion table, and the corresponding data in the second storage area of the RAM match. After the value of the confirmation flag in the second storage area of the RAM is changed, the confirmation flag in the physical page is updated by overwriting the confirmation flag on the corresponding physical page in the nonvolatile memory. Includes 6 functions.

第5機能により、上記不揮発性メモリの物理ページに書き込まれたデータと、それに対応する上記RAMの第2エリアのデータとが一致するか否かの判別が行われ、上記両データが一致する場合には、第6機能により、上記RAMの第2記憶エリアの上記確認フラグの値を変更してから、その確認フラグを、上記不揮発性メモリにおいて対応する物理ページへ上書きすることで、当該物理ページにおける確認フラグが更新される。確認フラグの値に基づいて、データの有効性を判別することができるので、データの信頼性の向上を図ることができる。さらには、上書き処理においては、通常のデータ書き込みと比べてデータ消去処理を実施していないため、データ書き込み機能においては、全体として短時間で処理を完了することが可能となる。このため、非接触通信が行われる場合においても、従来技術のような不揮発性メモリへの2度の書き込み動作を行う場合に比べて、より早く必要なデータ通信を完了させることが可能となり、データ書き込み中に電源遮断が発生する可能性を小さくすることが可能となる。   When the fifth function determines whether the data written in the physical page of the non-volatile memory matches the corresponding data in the second area of the RAM, and the two data match The sixth function changes the value of the confirmation flag in the second storage area of the RAM, and then overwrites the corresponding physical page in the nonvolatile memory with the physical page. The confirmation flag at is updated. Since the validity of the data can be determined based on the value of the confirmation flag, the reliability of the data can be improved. Furthermore, since the data erasing process is not performed in the overwriting process as compared with the normal data writing, the data writing function can be completed in a short time as a whole. For this reason, even when non-contact communication is performed, it is possible to complete the necessary data communication earlier than in the case of performing the write operation twice in the nonvolatile memory as in the prior art. It is possible to reduce the possibility of power interruption during writing.

〔3〕上記〔2〕において、上記ページ管理情報には、タイムスタンプを含めることができる。このとき、上記第3機能には、上記第2機能によるデータ書き込みに対応して、上記タイムスタンプの現在の値に、1を加算することで上記タイムスタンプを更新する機能を設けることができる。   [3] In the above [2], the page management information can include a time stamp. At this time, the third function can be provided with a function of updating the time stamp by adding 1 to the current value of the time stamp, corresponding to the data writing by the second function.

上記タイムスタンプにより、データの有効性を判別することができるので、データの信頼性の向上を図ることができる。   Since the validity of the data can be determined from the time stamp, the reliability of the data can be improved.

〔4〕上記〔3〕において、上記ページ管理情報には、当該ページ管理情報を含むページの論理ページナンバーと、上記ページ管理情報についてのチェックサムとを含めることができる。   [4] In the above [3], the page management information can include a logical page number of a page including the page management information and a checksum for the page management information.

論理ページナンバーと、上記ページ管理情報についてのチェックサムとに基づいて、データの有効性を判別することができるので、データの信頼性の向上を図ることができる。   Since the validity of the data can be determined based on the logical page number and the checksum for the page management information, the reliability of the data can be improved.

〔5〕上記〔4〕において、上記アドレス変換テーブル形成機能には、上記制御部のリセットにより起動され、同じ論理ページナンバーを持つ物理ページが複数存在する場合に、当該物理ページにおけるページ管理情報に基づいて上記空きページを判定する第7機能を含めることができる。   [5] In the above [4], when there are a plurality of physical pages having the same logical page number that are activated by the reset of the control unit in the address conversion table forming function, the page conversion information in the physical page is displayed. A seventh function for determining the empty page based on the above can be included.

第7機能により、空きページの判定が行われることにより、上記第4機能による書き込み先(空きページ)を決定することができる。   By determining the empty page by the seventh function, the writing destination (empty page) by the fourth function can be determined.

〔6〕上記〔5〕において、上記第7機能には、同じ論理ページナンバーを持つ複数の物理ページ間で、上記チェックサム及び上記確認フラグが共に正常であり、上記タイムスタンプが互いに異なる場合に、上記タイムスタンプの値が小さいほうを上記空きページと判定する機能を含めることができる。上記第7機能には、同じ論理ページナンバーを持つ複数の物理ページのうち、上記タイムスタンプ、上記論理ページナンバー、上記確認フラグ、及び上記チェックサムの少なくともひとつが異常であると判断された物理ページを上記空きページと判定する機能を含めることができる。上記第7機能には、同じ論理ページナンバーを持つ複数の物理ページのうち、データが正常に書き込まれたか否かの確認が済んでいないと判断された物理ページを上記空きページと判定する機能を含めることができる。上記第7機能には、同じ論理ページナンバーを持つ複数の物理ページのうち、確認フラグ以外のデータは正常と判断された物理ページは有効とし、それとは異なる物理ページを上記空きページと判定する機能を含めることができる。   [6] In the above [5], the seventh function includes a case where both the checksum and the confirmation flag are normal and the time stamps are different between a plurality of physical pages having the same logical page number. The function of determining the smaller value of the time stamp as the empty page can be included. The seventh function includes a physical page in which at least one of the time stamp, the logical page number, the confirmation flag, and the checksum among a plurality of physical pages having the same logical page number is determined to be abnormal. Can be included as a free page. The seventh function includes a function of determining, from among a plurality of physical pages having the same logical page number, a physical page for which it has been determined that data has not been normally written or not, as a free page. Can be included. The seventh function is a function that, among a plurality of physical pages having the same logical page number, a physical page for which data other than the confirmation flag is determined to be normal is valid and a different physical page is determined as the free page Can be included.

以上の空きページ判定機能によれば、電源遮断の発生タイミング、すなわち書き込みのどの段階で電源遮断が発生したかを考慮してデータの有効性を判断して空きページを決定するようにしているため、不揮発性メモリ内の旧データ及び書き込みにかかる新データの何れかが必ず有効と判断され、それによって適切な空きページ判定を行うことができる。   According to the above empty page determination function, the empty page is determined by determining the validity of the data in consideration of the occurrence timing of power interruption, that is, at which stage of writing the power interruption has occurred. Therefore, it is determined that either the old data in the nonvolatile memory or the new data to be written is always valid, thereby making it possible to perform appropriate empty page determination.

2.実施の形態の詳細
実施の形態について更に詳述する。
2. Details of Embodiments Embodiments will be further described in detail.

<実施の形態1>
図1には、本発明にかかる半導体集積回路装置の一例とされるカード用マイクロコンピュータが示される。
<Embodiment 1>
FIG. 1 shows a card microcomputer as an example of a semiconductor integrated circuit device according to the present invention.

図1に示されるカード用マイクロコンピュータ10は、特に制限されないが、公知の半導体集積回路製造技術により、単結晶シリコン基板などの一つの半導体基板に形成され、非接触式ICカードに搭載されるシングルチップマイクロコンピュータである。   The card microcomputer 10 shown in FIG. 1 is not particularly limited, but is formed on a single semiconductor substrate such as a single crystal silicon substrate by a known semiconductor integrated circuit manufacturing technique, and is mounted on a non-contact IC card. It is a chip microcomputer.

カード用マイクロコンピュータ10は、それぞれ所定の機能を有する複数の機能モジュールを含み、それらは、アドレス信号を伝達するためのアドレスバスABUSや、データを伝達するためのデータバスDBUSを介して各種信号のやり取りが可能に結合されている。   The card microcomputer 10 includes a plurality of functional modules each having a predetermined function, which are used to transmit various signals via an address bus ABUS for transmitting an address signal and a data bus DBUS for transmitting data. The exchanges are coupled so that they can be exchanged.

カード用マイクロコンピュータ10には、CPU(中央処理装置、制御部)101、I/O(入出力)ポート102、ウォッチドッグタイマ(WDT)103、システムコントロールロジック104、セキュリティロジック105、ROM(Read Only Memory;リードオンリーメモリ)106、RAM(Random Access Memory;ランダムアクセスメモリ)107が設けられる。CPU101は、所定のプログラムを実行することで、カード用マイクロコンピュータ10全体の動作を制御する。I/Oポート102は、2チャンネルのI/O外部割り込み兼用ポート(I/O−1/IRQ,I/O−2/IRQ)を有する。ウォッチドッグタイマ(WDT)103は、CPU101で実行されるプログラムがハングアップなどの不正な状態に陥ってしまい規則的なウォッチドッグ操作が行なわれなかった場合を検出する。システムコントロールロジック104は、CPU101の制御下でカード用マイクロコンピュータシステムの動作を制御する。セキュリティロジック105は、システムの安全を維持することを目的とするファイアウォールマネージメントなどを含む。ROM106には、CPU101で実行されるプログラムが格納される。RAM107は、CPU101によってランダムアクセス可能なメモリとされ、特に制限されないが、ダイナミック型RAMやスタティック型RAMとされる。このRAM107には、後に詳述するように、CPU101の制御下で、アドレス変換テーブルが形成される。   The card microcomputer 10 includes a CPU (central processing unit, control unit) 101, an I / O (input / output) port 102, a watchdog timer (WDT) 103, a system control logic 104, a security logic 105, and a ROM (Read Only). A memory (read only memory) 106 and a RAM (random access memory) 107 are provided. The CPU 101 controls the overall operation of the card microcomputer 10 by executing a predetermined program. The I / O port 102 has a 2-channel I / O external interrupt shared port (I / O-1 / IRQ, I / O-2 / IRQ). A watchdog timer (WDT) 103 detects a case where a regular watchdog operation is not performed because a program executed by the CPU 101 falls into an illegal state such as a hang-up. The system control logic 104 controls the operation of the card microcomputer system under the control of the CPU 101. The security logic 105 includes firewall management for the purpose of maintaining the safety of the system. The ROM 106 stores a program executed by the CPU 101. The RAM 107 is a memory that can be randomly accessed by the CPU 101 and is not particularly limited, but is a dynamic RAM or a static RAM. As will be described later in detail, an address conversion table is formed in the RAM 107 under the control of the CPU 101.

またカード用マイクロコンピュータ10には、EEPROM(電気的に消去可能なプログラマブルROM、不揮発性メモリ)108、複数のタイマ(TMR1,TMR2,TMR3)109、剰余乗算コプロセッサ110、DESコプロセッサ111、AESコプロセッサ112が設けられる。EEPROM108は、不揮発性メモリの一例とされる。このEEPROM108へのデータ書き込み動作やEEPROM108からのデータ読み出し動作は、CPU101によって制御される。このような意味で、CPU101を「制御部」とも称する。複数のタイマ(TMR1,TMR2,TMR3)109は、それぞれクロックを数えることで一定時間の経過を知るのに用いられる。剰余乗算コプロセッサ110、DESコプロセッサ111、AESコプロセッサ112は、暗号演算処理等、所定の演算処理を実行する。本例では、コプロセッサでの演算処理の作業領域に使用されるRAM(CRAM)が剰余乗算コプロセッサ110に設けられている。   The card microcomputer 10 includes an EEPROM (electrically erasable programmable ROM, nonvolatile memory) 108, a plurality of timers (TMR1, TMR2, TMR3) 109, a remainder multiplication coprocessor 110, a DES coprocessor 111, and an AES. A coprocessor 112 is provided. The EEPROM 108 is an example of a nonvolatile memory. The data write operation to the EEPROM 108 and the data read operation from the EEPROM 108 are controlled by the CPU 101. In this sense, the CPU 101 is also referred to as a “control unit”. A plurality of timers (TMR1, TMR2, TMR3) 109 are used to know the passage of a fixed time by counting clocks. The remainder multiplication coprocessor 110, the DES coprocessor 111, and the AES coprocessor 112 execute predetermined arithmetic processing such as cryptographic operation processing. In this example, the remainder multiplication coprocessor 110 is provided with a RAM (CRAM) used as a work area for arithmetic processing in the coprocessor.

さらにカード用マイクロコンピュータ10には、乱数生成回路(RNG)113、擬似乱数発生回路(DNG)114、接触インタフェース(UART)115、非接触インタフェース116、アナログ制御回路117が設けられる。乱数生成回路(RNG)113は乱数を発生する。擬似乱数発生回路(DNG)114は擬似乱数を発生する。接触インタフェース(UART)115は、外部装置(リーダライタ)に接触された状態で各種信号のやり取りを可能にする。非接触インタフェース116は、外部装置(リーダライタ)と非接触状態で各種信号のやり取りを可能にする。本例では、データ入出力のための通信バッファ(BUF)が非接触インタフェース116内に設けられる。アナログ制御回路117は、入力切り替え機能を有し、外部装置(リーダライタ)に接触された状態では、非接触式ICカードに設けられた接触インタフェース端子を介して、リセット信号RES、クロック信号CLK、電源電圧Vcc,Vssの取り込みを可能にする。電源電圧Vcc,Vssは、カード用マイクロコンピュータ10の動作用電源とされる。リセット信号RESによって、カード用マイクロコンピュータ10をリセットすることができる。また、カード用マイクロコンピュータ10への電源投入により、アナログ制御回路117によって、パワーオンリセット信号が形成されるようになっている。カード用マイクロコンピュータ10への電源投入時には、上記パワーオンリセット信号によってカード用マイクロコンピュータ10が初期化されるようになっている。また、アナログ制御回路117は、外部装置(リーダライタ)に接触されていない状態では、電波を介して外部装置(リーダライタ)との間の通信を可能にする。この場合、カード用マイクロコンピュータ10の電源は、アンテナ118を介して受信する外部装置(非接触リーダー/ライター装置)のRFキャリア信号の整流・平滑によって生成される。この場合においても、カード用マイクロコンピュータ10への電源投入時には、上記パワーオンリセット信号によってカード用マイクロコンピュータ10が初期化される。   Further, the card microcomputer 10 is provided with a random number generation circuit (RNG) 113, a pseudo random number generation circuit (DNG) 114, a contact interface (UART) 115, a non-contact interface 116, and an analog control circuit 117. A random number generation circuit (RNG) 113 generates a random number. A pseudo random number generation circuit (DNG) 114 generates pseudo random numbers. The contact interface (UART) 115 enables various signals to be exchanged while being in contact with an external device (reader / writer). The non-contact interface 116 allows various signals to be exchanged with an external device (reader / writer) in a non-contact state. In this example, a communication buffer (BUF) for data input / output is provided in the non-contact interface 116. The analog control circuit 117 has an input switching function. When the analog control circuit 117 is in contact with an external device (reader / writer), the reset signal RES, the clock signal CLK, and the like are connected via a contact interface terminal provided in the non-contact IC card. The power supply voltages Vcc and Vss can be captured. The power supply voltages Vcc and Vss are used as power supplies for operating the card microcomputer 10. The card microcomputer 10 can be reset by the reset signal RES. Further, a power-on reset signal is generated by the analog control circuit 117 when the card microcomputer 10 is turned on. When the power to the card microcomputer 10 is turned on, the card microcomputer 10 is initialized by the power-on reset signal. In addition, the analog control circuit 117 enables communication with an external device (reader / writer) via radio waves when not in contact with the external device (reader / writer). In this case, the power supply of the card microcomputer 10 is generated by rectification and smoothing of the RF carrier signal of an external device (non-contact reader / writer device) that receives via the antenna 118. Also in this case, when the power to the card microcomputer 10 is turned on, the card microcomputer 10 is initialized by the power-on reset signal.

データ書き込み最中の電源遮断とは、例えば、非接触通信を行っている最中に、カード用マイクロコンピュータ10が実装された非接触ICカードを外部装置の磁界から遠ざけた場合に、RFキャリア信号を十分に受信することが不可能となり、結果として、RFキャリア信号を整流・平滑化することによって生成されるはずの電源が十分に生成されなくなることで、通信最中に電源遮断が発生してしまうことである。   For example, when the non-contact IC card on which the card microcomputer 10 is mounted is moved away from the magnetic field of the external device during the non-contact communication, the power cut-off during the data writing is the RF carrier signal. As a result, the power supply that should be generated by rectifying and smoothing the RF carrier signal is not generated sufficiently, and the power supply is cut off during communication. It is to end.

図2には、上記EEPROM108の初期状態が示される。   FIG. 2 shows the initial state of the EEPROM 108.

EEPROM108は、特に制限されないが、電源遮断対策領域202と、電源遮断対策対象外領域(電源遮断非対策領域)203,204を含む。電源遮断対策領域202へのデータ書き込みの最中に電源が遮断された場合でも、デバイスの信頼性低下を生じないような対策がとられている。しかし、電源遮断対策対象外領域203,204へのデータ書き込みについては、そのような対策はとられていない。電源遮断対策対象外領域203,204(その他のデータエリア)は、書き換えが不要とされるデータの格納に利用できる。   Although not particularly limited, the EEPROM 108 includes a power shutdown countermeasure area 202 and power shutdown countermeasure non-target areas (power shutdown non-measure areas) 203 and 204. Measures are taken to prevent a decrease in device reliability even when the power is shut off during data writing to the power shutdown countermeasure area 202. However, such measures are not taken for data writing to the non-power-off countermeasure target areas 203 and 204. The areas 203 and 204 (other data areas) that are not subject to power shutdown measures can be used for storing data that does not need to be rewritten.

CPU101は、EEPROM108における物理メモリ空間および論理メモリ空間を、基本的に一定サイズのページと呼ばれる単位に分割して管理を行う。ページは、物理ページナンバー(以降、ナンバーを「No.」と略記する場合もある)や論理ページナンバーで識別される。論理ページナンバーと物理ページナンバーとの対応付けは、論理/物理アドレス変換テーブルで実現される。EEPROM108におけるページは、複数のデータが格納されるブロック(データブロック)「Block」とページ管理情報が格納されるページ管理情報エリア201とを含む。EEPROM108へのデータ書き込みはページ単位で行われる。   The CPU 101 manages the physical memory space and logical memory space in the EEPROM 108 by basically dividing them into units called pages of a certain size. A page is identified by a physical page number (hereinafter, the number may be abbreviated as “No.”) or a logical page number. The association between the logical page number and the physical page number is realized by a logical / physical address conversion table. A page in the EEPROM 108 includes a block (data block) “Block” in which a plurality of data is stored, and a page management information area 201 in which page management information is stored. Data writing to the EEPROM 108 is performed in units of pages.

図6には、上記EEPROM108におけるメモリフォーマットと論理/物理アドレス変換テーブルとの関係が示される。   FIG. 6 shows the relationship between the memory format in the EEPROM 108 and the logical / physical address conversion table.

図6(A)に示されるように、書き込み最中の電源遮断対策のため、EEPROM108における複数のページのうちのひとつが必ず空きページとされ、新たなデータ書き込みは、この空きページに対して行われる。図6に示される例では、物理ページNo.H’70が空きページとされ、当該空きページに属するブロックは、「Vacant Block(空きブロック)」とされることで、他のページのブロックと区別されている。   As shown in FIG. 6A, as a countermeasure against power interruption during writing, one of the plurality of pages in the EEPROM 108 is always an empty page, and new data is written to this empty page. Is called. In the example shown in FIG. H'70 is an empty page, and a block belonging to the empty page is distinguished from a block of another page by being a "vacant block (empty block)".

ページ管理情報エリア201に記録されるページ管理情報は、図6(C)に拡大して示されるように、タイムスタンプ(TS)、論理ページNo.(H’00)、確認フラグ(H’81)、ページ管理情報に対する第1チェックサム(CS1)、データブロックに対する第2チェックサム(CS2)を含む。タイムスタンプは、後述するように空きページの判断に用いられる。論理ページNo.は、EEPROM108における論理ページNo.である。確認フラグは、データが正常に書き込まれたことを示すためのフラグである。ページ管理情報に対する第1チェックサムは、タイムスタンプと論理ページNo.とのワードの総計値とされ、データブロックに対する第2チェックサムは、当該ページにおけるデータブロックのワードの総計値とされる。第1チェックサム及び第2チェックサムは、それぞれ誤り検出に用いられる。   The page management information recorded in the page management information area 201 includes a time stamp (TS), a logical page number, and the like as shown in an enlarged view in FIG. (H'00), a confirmation flag (H'81), a first checksum (CS1) for the page management information, and a second checksum (CS2) for the data block. The time stamp is used to determine a free page as will be described later. Logical page No. Is a logical page number in the EEPROM 108. It is. The confirmation flag is a flag for indicating that data has been normally written. The first checksum for the page management information includes a time stamp and a logical page number. And the second checksum for the data block is the total value of the words of the data block in the page. The first checksum and the second checksum are each used for error detection.

論理/物理アドレス変換テーブルは、図6(B)に示されるように、論理ページNo.と物理ページNo.とが対応付けられており、この論理/物理アドレス変換テーブル601を参照することで、論理アドレスに対する物理アドレスが得られる。また、この論理/物理アドレス変換テーブル601を参照することで、EEPROM108における空きページの物理ページNo.が得られるようになっている。このような論理/物理アドレス変換テーブル601は、このカード用マイクロコンピュータ10のパワーオンリセット後の初期化処理により、RAM107に形成される。   As shown in FIG. 6B, the logical / physical address conversion table includes a logical page No. And physical page No. , And a physical address for the logical address is obtained by referring to the logical / physical address conversion table 601. Also, by referring to this logical / physical address conversion table 601, the physical page number of the empty page in the EEPROM 108 is displayed. Can be obtained. Such a logical / physical address conversion table 601 is formed in the RAM 107 by initialization processing after power-on reset of the card microcomputer 10.

図3には、カード用マイクロコンピュータ10の動作の流れが示される。   FIG. 3 shows an operation flow of the card microcomputer 10.

カード用マイクロコンピュータ10に電源電圧Vcc,Vssが投入されたとき、又はアンテナ118を介して電源電圧が供給されたとき(301)、アナログ制御回路117において、パワーオンリセット信号が発生され、それによってカード用マイクロコンピュータ10が初期化される。すなわち、CPU101によって、所定のリセット処理プログラムが実行されることにより、カード用マイクロコンピュータ10におけるハードウェア(H/W)の初期化処理及びソフトウェア(S/W)の初期化処理が行われ(302,303)、論理/物理アドレス変換テーブルの作成が実行される(304)。論理/物理アドレス変換テーブルは、EEPROM108における電源遮断対策対象領域202(図2参照)の全体がCPU101によってスキャンされ、そのスキャン結果に基づいてRAM107の所定エリアに構築される。論理/物理アドレス変換テーブルには、空きページの物理ページNo.も含まれる。尚、空きページの判定基準については後に詳述する。論理/物理アドレス変換テーブルが作成された後に、カード用マイクロコンピュータ10は、命令の受信待ち状態となる(305)。この状態で、書き込み命令や読み出し命令が受信された場合には、当該命令に応じた処理がCPU101の制御下で行われる(306)。   When the power supply voltages Vcc and Vss are input to the card microcomputer 10 or when the power supply voltage is supplied via the antenna 118 (301), a power-on reset signal is generated in the analog control circuit 117, thereby The card microcomputer 10 is initialized. That is, by executing a predetermined reset processing program by the CPU 101, hardware (H / W) initialization processing and software (S / W) initialization processing in the card microcomputer 10 are performed (302). 303), the logical / physical address conversion table is created (304). In the logical / physical address conversion table, the entire power shutdown countermeasure target area 202 (see FIG. 2) in the EEPROM 108 is scanned by the CPU 101, and is constructed in a predetermined area of the RAM 107 based on the scan result. In the logical / physical address conversion table, the physical page number of the empty page is displayed. Is also included. The determination criteria for empty pages will be described in detail later. After the logical / physical address conversion table is created, the card microcomputer 10 enters a command reception waiting state (305). In this state, when a write command or a read command is received, processing corresponding to the command is performed under the control of the CPU 101 (306).

図4には、カード用マイクロコンピュータ10において書き込み命令が受信された場合の動作の流れが示される。   FIG. 4 shows a flow of operation when a write command is received by the card microcomputer 10.

以下、図4に基づいて、カード用マイクロコンピュータ10の動作を説明する。尚、書き込み命令は、外部装置とされるリーダライタから発行され、このリーダライタから発行された書き込み命令には、データを書き換えたいブロック番号、及び書き換えにかかるデータが含まれるものとする。   Hereinafter, the operation of the card microcomputer 10 will be described with reference to FIG. The write command is issued from a reader / writer serving as an external device, and the write command issued from the reader / writer includes a block number for which data is to be rewritten and data related to rewrite.

書き込み命令が受信されると(401)、当該命令がCPU101でデコードされ、そのデコード結果に基づいて、先ず、アドレス変換処理が行われる(402)。図7には、ブロック1(Block1)のデータ書き換えを目的とする書き込み命令が受信された場合の主要部の状態が示される。この例では、EEPROM108におけるH’00〜H’70までが電源遮断対策対象領域とされる。また、特に制限されないが、EEPROM108の書き換え単位(ページのサイズ)は64バイト、書き換えにかかるデータサイズ(ブロックのサイズ)は16バイトとされる。   When a write command is received (401), the command is decoded by the CPU 101, and address conversion processing is first performed based on the decoding result (402). FIG. 7 shows the state of the main part when a write command intended to rewrite data in block 1 (Block 1) is received. In this example, H′00 to H′70 in the EEPROM 108 are set as power cutoff countermeasure target areas. Although not particularly limited, the rewrite unit (page size) of the EEPROM 108 is 64 bytes, and the data size (block size) required for rewriting is 16 bytes.

ブロック1(Block1)に対応する論理ページNo.から物理ページNo.への変換は、RAM107内の論理/物理アドレス変換テーブル601を参照して行われる。   Logical page No. corresponding to block 1 (Block 1). To physical page No. Conversion to is performed with reference to the logical / physical address conversion table 601 in the RAM 107.

次に、ステップ402でのアドレス変換結果に基づいて、旧データがRAM107の所定エリアにコピーされる(403)。図8には、旧データがRAM107の所定エリアにコピーされた状態が示される。この例では、データ書き換えの対象とされるブロック1(Block1)が含まれるページ(物理ページNo.H’00)の記憶データがRAM107の書き込み用エリア801にコピーされる。   Next, based on the address conversion result in step 402, the old data is copied to a predetermined area of the RAM 107 (403). FIG. 8 shows a state where old data has been copied to a predetermined area of the RAM 107. In this example, the stored data of the page (physical page No. H′00) including the block 1 (Block 1) to be rewritten is copied to the write area 801 of the RAM 107.

次に、ステップ403でRAM107の書き込み用エリア801にコピーされたデータの更新が行われる(404)。図9には、ステップ403でRAM107の書き込み用エリア801にコピーされたデータの更新後の状態が示される。この例では、書き込み用エリア801におけるブロック1(Block1)のデータが、書き込み命令にかかるデータ(Block1’)に変更される。この変更に伴い、タイムスタンプが、「TS」から「TS+1」に更新され、確認フラグが「H’81」から「H’FF」に更新され、さらに、第1チェックサムの値が「CS1」から「CS1’」に更新され、第2チェックサムの値が「CS2」から「CS2’」に更新される。   Next, in step 403, the data copied to the write area 801 of the RAM 107 is updated (404). FIG. 9 shows a state after the data copied in the write area 801 of the RAM 107 in step 403 is updated. In this example, the data of block 1 (Block 1) in the write area 801 is changed to data (Block 1 ') related to the write command. Along with this change, the time stamp is updated from “TS” to “TS + 1”, the confirmation flag is updated from “H′81” to “H′FF”, and the value of the first checksum is “CS1”. To “CS1 ′” and the value of the second checksum is updated from “CS2” to “CS2 ′”.

次に、EEPROM108における空きページへのデータ書き込みが行われる(405)。つまり、論理/物理アドレス変換テーブル601を参照してEEPROM108における空きページの物理ページNo.が求められ(この例では「H’70」)、図10に示されるように、この空きページに、RAM107の書き込み用エリア801のデータ(ステップ404で更新されたもの)が書き込まれる。   Next, data is written to an empty page in the EEPROM 108 (405). That is, referring to the logical / physical address conversion table 601, the physical page number of the empty page in the EEPROM 108 is displayed. Is obtained ("H'70" in this example), and as shown in FIG. 10, the data in the write area 801 of the RAM 107 (updated in step 404) is written in this empty page.

上記ステップ405のデータ書き込みが行われた後、そのデータ書き込みが正しく行われたか否かを確認するため、図11に示されるように、EEPROM108における物理ページNo.H’70のデータ(ステップ405で書き込まれたデータ)と、RAM107の書き込み用エリア801のデータ(書き込み元のデータ)との比較が行われる(406)。   After the data is written in step 405, the physical page No. in the EEPROM 108 is checked as shown in FIG. 11 to confirm whether the data has been written correctly. The H'70 data (data written in step 405) is compared with the data in the write area 801 of the RAM 107 (write source data) (406).

上記ステップ406のデータ比較の結果、両データが一致すると判断された場合、それは上記ステップ405でのデータ書き込みが正しく行われたことを意味するから、その場合には、確認フラグのオーバーライトが行われる(407)。つまり、上記ステップ406のデータ比較の結果、両データが一致すると判断された場合には、図12に示されるように、RAM107の書き込み用エリア801における確認フラグが、それまでの「H’FF」から、確認完了を示すデータ、例えば「H’81」に変更され、この変更後の確認フラグが、EEPROM108における物理ページNo.H’70のデータにオーバーライト(上書き)される。このオーバーライトでは、確認フラグ以外のデータの書き込みは不要であるため、RAM107の書き込み用エリア801における確認フラグ以外のデータは、全て「H’FF」に変更される。ステップ407におけるオーバーライトは、上記ステップ405のデータ書き込みと比べてデータ消去処理を実施していない分、短時間で完了する。つまり、上記ステップ407では、確認フラグ以外のデータは「H‘FF」でオーバーライトするため、RAM107の書き込み用エリア801は、結果的に、確認完了を示すデータのみが更新されている。   If it is determined as a result of the data comparison in step 406 that both data match, this means that the data writing in step 405 has been performed correctly. In this case, the confirmation flag is overwritten. (407). That is, as a result of the data comparison in step 406, if it is determined that the two data match, as shown in FIG. 12, the confirmation flag in the write area 801 of the RAM 107 is “H′FF”. To the data indicating confirmation completion, for example, “H′81”, and the confirmation flag after the change is changed to a physical page No. in the EEPROM 108. The data of H'70 is overwritten (overwritten). In this overwriting, data other than the confirmation flag need not be written, and therefore all data other than the confirmation flag in the write area 801 of the RAM 107 is changed to “H′FF”. The overwriting in step 407 is completed in a short time because the data erasing process is not performed as compared with the data writing in step 405. In other words, in step 407, data other than the confirmation flag is overwritten with “H′FF”, and as a result, only data indicating confirmation completion is updated in the write area 801 of the RAM 107.

尚、上記ステップ406のデータ比較の結果、両データが一致しないと判断された場合には、それは上記ステップ405でのデータ書き込みが正しく行われていないことを意味するから、書き込み失敗とし処理を終了する。   If it is determined as a result of the data comparison in step 406 that the two data do not match, this means that the data writing in step 405 has not been performed correctly. To do.

上記ステップ407のオーバーライト後に、論理/物理アドレス変換テーブル601の更新が行われる(408)。つまり、図13に示されるように、論理/物理アドレス変換テーブル601の内容を、EEPROM108の状態に整合させるため、論理/物理アドレス変換テーブル601において、論理ページNo.H’00の物理ページNo.が、それまでの「H’00」から「H’70」に変更され、空きページの物理ページNo.が、それまでの「H’70」から「H’00」に変更される。   After overwriting in step 407, the logical / physical address conversion table 601 is updated (408). That is, as shown in FIG. 13, in order to match the contents of the logical / physical address conversion table 601 with the state of the EEPROM 108, the logical page No. H'00 physical page No. Is changed from “H′00” to “H′70”, and the physical page number of the empty page is changed. Is changed from “H′70” to “H′00”.

以上により、受信された書き込み命令に対応するデータ書き換えが終了する。   The data rewriting corresponding to the received write command is thus completed.

次に、図3におけるステップ304の論理/物理アドレス変換テーブル作成で行われる空きページの判定について詳述する。互いに等しい論理ページNo.を有する物理ページが二つ存在する場合、CPU101は以下の判定基準に従って空きページを決定する。   Next, the empty page determination performed in the logical / physical address conversion table creation in step 304 in FIG. 3 will be described in detail. Logical page numbers equal to each other. When there are two physical pages having “”, the CPU 101 determines a free page according to the following criteria.

空きページの判定基準として、以下の4ケースを挙げることができる。   The following four cases can be given as criteria for determining the free page.

《ケース1》
先ず、ケース1について説明する。
<< Case 1 >>
First, Case 1 will be described.

図14に示されるように、互いに等しい論理ページNo.H’00を有する二つの物理ページにおいて、それぞれ第1チェックサム(CS1,CS1’)および第2チェックサム(CS2,CS2’)が正しく、且つ、確認フラグ(H’81)も正常にオーバーライトされているが、タイムスタンプが互いに異なる場合がある。かかる場合は、タイムスタンプの大きいほうが有効データとされる。つまり、タイムスタンプは、RAM107の書き込み用エリア801にコピーされたデータがステップ404で更新(図9参照)された結果、それまでの「TS」から「TS+1」に変更されているはずであるから、このタイムスタンプの大きいほうが有効データである。従って、「TS+1」のタイムスタンプを有する物理ページNo.H‘70が有効ページと判定され、「TS」のタイムスタンプを有する物理ページNo.H’00が空きページと判定され、その判定結果が、論理/物理アドレス変換テーブル601に書き込まれる。   As shown in FIG. 14, logical page numbers equal to each other. In the two physical pages having H′00, the first checksum (CS1, CS1 ′) and the second checksum (CS2, CS2 ′) are correct, and the confirmation flag (H′81) is overwritten normally. However, the time stamps may be different from each other. In such a case, the data with the larger time stamp is regarded as valid data. That is, the time stamp should have been changed from “TS” to “TS + 1” as a result of the data copied to the write area 801 of the RAM 107 being updated in step 404 (see FIG. 9). The larger time stamp is the valid data. Therefore, a physical page No. having a time stamp of “TS + 1” is stored. H'70 is determined to be a valid page, and a physical page No. having a time stamp of “TS”. H′00 is determined as an empty page, and the determination result is written in the logical / physical address conversion table 601.

本ケースは、ステップ408の論理/物理アドレス変換テーブルの更新後に電源が遮断された場合であり、最も一般的なケースである(図4参照)。   This case is a case where the power is turned off after the logical / physical address conversion table is updated in step 408, and is the most general case (see FIG. 4).

《ケース2》
ケース2について説明する。
<< Case 2 >>
Case 2 will be described.

図15に示されるように、例えば物理ページNo.70のページ管理情報において、タイムスタンプ、論理ページNo.、確認フラグ、第1チェックサムおよび第2チェックサムのうち、少なくともひとつが、あり得ない値(異常値)の場合、それは無効データ(Invalid data)と判断され、当該物理ページNo.70が空きページと判定され、その判定結果が、論理/物理アドレス変換テーブル601に書き込まれる。   As shown in FIG. 15, for example, the physical page No. 70 page management information, time stamp, logical page No. If at least one of the confirmation flag, the first checksum, and the second checksum is an impossible value (abnormal value), it is determined to be invalid data (Invalid data). 70 is determined to be an empty page, and the determination result is written in the logical / physical address conversion table 601.

本ケースは、ステップ405の物理ページNo.70へのデータ書き込みの最中に電源が遮断されることにより、データが異常値となってしまった可能性があるため、当該データ書き込み以前のデータ(EEPROM108の旧データであり、本例では物理ページNo.H’00のデータ)が有効(有効データページ)とされる(図4参照)。   In this case, the physical page No. Since there is a possibility that the data has become an abnormal value due to the power being cut off during the data writing to the data 70, the data before the data writing (the old data of the EEPROM 108, which is the physical data in this example) The data of page No. H'00) is made valid (valid data page) (see FIG. 4).

《ケース3》
ケース3について説明する。
<< Case 3 >>
Case 3 will be described.

図16に示されるように、互いに等しい論理ページNo.H’00を有する二つの物理ページにおいて、それぞれ第1チェックサム(CS1,CS1’)および第2チェックサム(CS2,CS2’)が正しく、物理ページNo.H’70のタイムスタンプが物理ページNo.H’00に比べて、+1(更新)されているにもかかわらず、物理ページNo.H’70の確認フラグがH’FFのままである場合が考えられる。かかる場合には、物理ページNo.H’70が空きページと判定され、その判定結果が、論理/物理アドレス変換テーブル601に書き込まれる。   As shown in FIG. 16, logical page numbers equal to each other. In the two physical pages having H'00, the first checksum (CS1, CS1 ') and the second checksum (CS2, CS2') are correct, respectively. The time stamp of H'70 is the physical page No. Compared to H'00, although it is +1 (updated), physical page No. A case where the confirmation flag of H′70 remains H′FF is considered. In such a case, the physical page No. H′70 is determined to be an empty page, and the determination result is written in the logical / physical address conversion table 601.

本ケースは、データが正常に書き込まれたにもかかわらず、電源遮断により、ステップ406でのデータ比較に基づいてデータが正常に書き込まれたか否かの確認が済んでいないことが考えられるため、当該データ書き込み以前のデータ(EEPROM108の旧データであり、本例では物理ページNo.H’00のデータ)が有効とされる(図4参照)。   In this case, it is considered that although the data has been normally written, it has not been confirmed whether the data has been normally written or not based on the data comparison in step 406 due to the power shutdown. Data before the data writing (old data of the EEPROM 108, in this example, data of physical page No. H'00) is validated (see FIG. 4).

《ケース4》
ケース4について説明する。
<< Case 4 >>
Case 4 will be described.

図17に示されるように、互いに等しい論理ページNo.H’00を有する二つの物理ページにおいて、それぞれ第1チェックサム(CS1,CS1’)および第2チェックサム(CS2,CS2’)が正しく、物理ページNo.H’70のタイムスタンプが物理ページNo.H’00に比べて、+1されているにもかかわらず、物理ページNo.H’70の確認フラグが異常な値(ただし、「H’FF」を除く)である場合が考えられる。かかる場合、物理ページNo.H’00が空きページと判定され、その判定結果が、論理/物理アドレス変換テーブル601に書き込まれる。   As shown in FIG. 17, logical page numbers equal to each other. In the two physical pages having H'00, the first checksum (CS1, CS1 ') and the second checksum (CS2, CS2') are correct, respectively. The time stamp of H'70 is the physical page No. Despite being incremented by 1 compared to H′00, the physical page No. A case where the confirmation flag of H′70 is an abnormal value (except “H′FF”) is conceivable. In such a case, the physical page No. H′00 is determined as an empty page, and the determination result is written in the logical / physical address conversion table 601.

本ケースは、ステップ406でのデータ比較に基づいてデータが正常に書き込まれたことが確認されたものの、ステップ407での確認フラグのオーバーライトの最中に電源が遮断された可能性があり、確認フラグ以外は正常に書き込まれていると判断される。このため、本例では当該データ書き込み以後のデータ(EEPROM108の新データであり、本例では物理ページNo.H’70のデータ)が有効とされる(図4参照)。   In this case, although it was confirmed that the data was normally written based on the data comparison in step 406, the power may have been cut off during the overwriting of the confirmation flag in step 407. It is determined that data other than the confirmation flag is normally written. For this reason, in this example, the data after writing the data (new data in the EEPROM 108, data in the physical page No. H'70 in this example) is validated (see FIG. 4).

以上の空きページ判定基準によれば、電源遮断の発生タイミング、すなわち書き込みのどの段階で発生したかを考慮してデータの有効性を判断して空きページを決定するようにしているため、EEPROM108内の旧データ及び書き込みにかかる新データの何れかが必ず有効と判断され、それによって適切な空きページ判定を行うことができ、EEPROM108から読み出されるデータの信頼性の向上を図ることができる。   According to the above empty page determination standard, the empty page is determined by determining the validity of the data in consideration of the occurrence timing of power interruption, that is, at which stage of writing, the data validity. Thus, it is determined that either the old data or the new data to be written is always valid, whereby appropriate empty page determination can be performed, and the reliability of data read from the EEPROM 108 can be improved.

ここで従来技術に従えば、論理/物理アドレス変換テーブル601がEEPROM108内に設けられている場合には、EEPROM108へのデータ書き込み毎に、EEPROM108へのデータ書き込みと、当該EEPROM108内のアドレス変換テーブル更新のために、結果的にEEPROM108への書き込み動作が2度必要とされる。   Here, according to the prior art, when the logical / physical address conversion table 601 is provided in the EEPROM 108, the data writing to the EEPROM 108 and the address conversion table update in the EEPROM 108 are updated every time data is written to the EEPROM 108. As a result, the write operation to the EEPROM 108 is required twice.

これに対してこの実施の形態では、論理/物理アドレス変換テーブル601がRAM107内に設けられているため、EEPROM108内のアドレス変換テーブル更新のためのEEPROM108への書き込み動作が不要になる。RAM107内の論理/物理アドレス変換テーブル601の更新は、EEPROM108の場合に比べて高速に行うことができる。このため、EEPROM108へのデータ書き込み処理全体としてのパフォーマンスの向上を図ることができる。   On the other hand, in this embodiment, since the logical / physical address conversion table 601 is provided in the RAM 107, a write operation to the EEPROM 108 for updating the address conversion table in the EEPROM 108 becomes unnecessary. The logical / physical address conversion table 601 in the RAM 107 can be updated faster than in the case of the EEPROM 108. For this reason, it is possible to improve the performance of the entire data writing process to the EEPROM 108.

データ書き込み処理において、上記ステップ406のデータ比較の結果、両データが一致すると判断された場合、確認フラグのオーバーライトが行われる(407)。しかしこのオーバーライトでは、確認フラグ以外のデータの書き込みは不要であるため、RAM107の書き込み用エリア801における確認フラグ以外のデータは、全て「H’FF」に変更される。上記ステップ407におけるオーバーライトは、上記ステップ405のデータ書き込みと比べてデータ消去処理を実施していない分、短時間で完了することができる。従って、確認フラグのオーバーライトは、EEPROM108へのデータ書き込み処理全体としてのパフォーマンスの向上を妨げるものではない。   In the data writing process, if it is determined that the two data match as a result of the data comparison in step 406, the confirmation flag is overwritten (407). However, in this overwriting, it is not necessary to write data other than the confirmation flag. Therefore, all data other than the confirmation flag in the write area 801 of the RAM 107 is changed to “H′FF”. The overwriting in step 407 can be completed in a shorter time because the data erasing process is not performed compared to the data writing in step 405. Therefore, the overwrite of the confirmation flag does not hinder the improvement of the performance of the entire data writing process to the EEPROM 108.

また、上記ステップ407におけるオーバーライト(上書き処理)においては、通常のデータ書き込みと比べてデータ消去処理を実施していないため、データ書き込み処理においては、全体として短時間で処理を完了することが可能となる。よって、非接触通信が行われる場合においても、従来技術のような不揮発性メモリへの2度の書き込み動作を行う場合に比べて、より早く必要なデータ通信(書き込み通信等)を完了させることが可能となり、通信中に電源遮断が発生する可能性をを小さくすることが可能となる。   In addition, since the data erasure process is not performed in the overwrite (overwrite process) in step 407 as compared with the normal data write, the data write process can be completed in a short time as a whole. It becomes. Therefore, even when non-contact communication is performed, necessary data communication (write communication or the like) can be completed earlier than in the case where the write operation is performed twice in the nonvolatile memory as in the related art. This makes it possible to reduce the possibility of power interruption during communication.

次に、読み出し命令がカード用マイクロコンピュータ10において受信された場合の動作について説明する。   Next, an operation when a read command is received by the card microcomputer 10 will be described.

図5には、カード用マイクロコンピュータ10において読み出し命令が受信された場合の動作の流れが示される。   FIG. 5 shows an operation flow when the card microcomputer 10 receives a read command.

尚、読み出し命令は、リーダライタから発行され、このリーダライタから発行された書き込み命令には、データを読み出したいブロック番号などの情報が含まれるものとする。   The read command is issued from the reader / writer, and the write command issued from the reader / writer includes information such as a block number from which data is to be read.

読み出し命令が受信されると(501)、上記書き込み命令が受信された場合と同様に、当該命令がCPU101でデコードされ、そのデコード結果に基づいて、先ず、アドレス変換処理が行われる(502)。データを読み出したいブロックの論理ページNo.から物理ページNo.への変換は、RAM107内の論理/物理アドレス変換テーブル601を参照して行われる。そして、得られた物理ページNo.の記憶データがEEPROM108からRAM107の所定エリアにコピーされ(503)、コピーされたデータの中から、上記読み出し命令に対応するデータがリーダライタへ出力される(504)。   When a read command is received (501), as in the case where the write command is received, the command is decoded by the CPU 101, and address conversion processing is first performed based on the decoding result (502). The logical page number of the block from which data is to be read. To physical page No. Conversion to is performed with reference to the logical / physical address conversion table 601 in the RAM 107. The obtained physical page No. Is copied from the EEPROM 108 to a predetermined area of the RAM 107 (503), and data corresponding to the read command is output to the reader / writer from the copied data (504).

次に、EEPROM108の書き換え単位と、書き換えにかかるデータサイズとの関係について説明する。   Next, the relationship between the rewrite unit of the EEPROM 108 and the data size required for rewrite will be described.

カード用マイクロコンピュータ10は、EEPROM108の書き換え単位毎に、ページ管理情報が格納されるページ管理情報エリア201が設けられ、パワーオンリセットに起因する初期設定において、上記ページ管理情報がスキャンされ、それに基づいて論理/物理アドレス変換テーブル601が形成されるようになっている。このようなカード用マイクロコンピュータ10によれば、EEPROM108の書き換え単位と、書き換えにかかるデータサイズ(ユーザが要求するデータサイズ)との間に、以下のような関係がある。   The card microcomputer 10 is provided with a page management information area 201 in which page management information is stored for each rewriting unit of the EEPROM 108, and the page management information is scanned in the initial setting resulting from the power-on reset. Thus, a logical / physical address conversion table 601 is formed. According to such a card microcomputer 10, the following relationship exists between the rewrite unit of the EEPROM 108 and the data size (data size requested by the user) required for rewriting.

例えば図18(A)に示されるように、EEPROM108の書き換え単位が32バイトであって、データサイズ(ユーザが要求するデータサイズ)が1バイトや16バイトの場合には、上記実施の形態の場合と同様に、メモリ書き換えの回数は何れも1回となる。しかし、データサイズが32バイトの場合には、メモリ書き換えの回数は2回となる。すなわち、EEPROM108の書き換え単位が32バイトであって、データサイズが32バイトの場合には、図18(B)に示されるように、先ず、書き込みデータが16バイトに分割され、それがページ管理情報(16バイト)とともに空きページに書き込まれ、RAM内の論理/物理アドレス変換テーブル601が更新される(181)。そしてこのステップ181の処理で空きページとなった物理アドレスNo.に、残りのデータ(16バイト)とページ管理情報(16バイト)とが書き込まれ、RAM内の論理/物理アドレス変換テーブル601が更新される(182)。このようにEEPROM108の書き換え単位が32バイトであって、データサイズが32バイトの場合には、書き換え回数が2回となる。尚、EEPROM108の書き換え単位が32バイトであって、データサイズが32バイトを越える場合には、書き換え回数がさらに増える可能性がある。   For example, as shown in FIG. 18A, when the rewrite unit of the EEPROM 108 is 32 bytes and the data size (data size requested by the user) is 1 byte or 16 bytes, the case of the above embodiment Similarly, the number of memory rewrites is one. However, when the data size is 32 bytes, the number of memory rewrites is two. That is, when the rewrite unit of the EEPROM 108 is 32 bytes and the data size is 32 bytes, the write data is first divided into 16 bytes as shown in FIG. (16 bytes) is written to an empty page, and the logical / physical address conversion table 601 in the RAM is updated (181). Then, the physical address No. which has become a free page by the processing of step 181 is displayed. The remaining data (16 bytes) and page management information (16 bytes) are written, and the logical / physical address conversion table 601 in the RAM is updated (182). Thus, when the rewrite unit of the EEPROM 108 is 32 bytes and the data size is 32 bytes, the number of rewrites is two. If the EEPROM 108 has a rewrite unit of 32 bytes and the data size exceeds 32 bytes, the number of rewrites may further increase.

また、EEPROM108の書き換え単位が32バイトの場合には、図18(C)に示されるように、ページ管理情報(16バイト)の存在により、ユーザデータの書き込みに使用できる領域は、電源遮断対策対象領域202(図2参照)の半分となってしまうため、実用的ではない。   Further, when the rewrite unit of the EEPROM 108 is 32 bytes, as shown in FIG. 18C, the area that can be used for writing user data due to the presence of page management information (16 bytes) Since it becomes half of the area 202 (see FIG. 2), it is not practical.

図19(A)に示されるように、EEPROM108の書き換え単位が128バイトであって、データサイズ(ユーザが要求するデータサイズ)が1バイトや112バイト以下の場合には、上記実施の形態の場合と同様に、メモリ書き換えの回数は何れも1回となる。しかし、データサイズが113バイトを越える場合には、メモリ書き換えの回数は2回となる。尚、EEPROM108の書き換え単位が128バイトであって、データサイズが113バイトを越える場合の書き込み処理は、図18(B)に示される場合と同様となる。   As shown in FIG. 19A, when the rewrite unit of the EEPROM 108 is 128 bytes and the data size (data size requested by the user) is 1 byte or 112 bytes or less, the above embodiment is used. Similarly, the number of memory rewrites is one. However, when the data size exceeds 113 bytes, the number of memory rewrites is two. Note that the writing process when the rewrite unit of the EEPROM 108 is 128 bytes and the data size exceeds 113 bytes is the same as the case shown in FIG.

また、EEPROM108の書き換え単位が128バイトの場合には、図19(B)に示されるように、ページ管理情報(16バイト)は、EEPROM108の書き換え単位(128バイト)の1/8と少ないため、実用的と考えられる。   When the rewrite unit of the EEPROM 108 is 128 bytes, the page management information (16 bytes) is as small as 1/8 of the rewrite unit (128 bytes) of the EEPROM 108 as shown in FIG. It is considered practical.

以上を勘案すると、EEPROM108の書き換え単位と、書き換えにかかるデータサイズとの関係は、書き換えにかかるデータサイズ(ユーザが要求するデータサイズ)が、EEPROM108の書き換え単位以下となるように設定するのが望ましい。   Considering the above, it is desirable to set the relationship between the rewrite unit of the EEPROM 108 and the data size required for rewriting so that the data size required for rewriting (data size requested by the user) is equal to or smaller than the rewrite unit of the EEPROM 108. .

また、EEPROM108のメモリ使用量は、電源遮断対策対象領域202(図2参照)のうち、ページ管理情報の占める割合は、可能な限り少ないほうが良い。   Further, the memory usage of the EEPROM 108 should be as small as possible in the page management information in the power shutdown countermeasure target area 202 (see FIG. 2).

上記実施の形態では、EEPROM108の書き換え単位(ページのサイズ)を64バイト、書き換えにかかるデータサイズ(ブロックのサイズ)を16バイトとしているが、この設定は、上記の理由により適切と考えられる。   In the above embodiment, the rewrite unit (page size) of the EEPROM 108 is 64 bytes, and the data size (block size) required for rewriting is 16 bytes. This setting is considered appropriate for the above reason.

次に、上記カード用マイクロコンピュータ10が搭載された非接触式ICカードの使用例について説明する。   Next, a usage example of a non-contact type IC card on which the card microcomputer 10 is mounted will be described.

図20に示されるように、カード用マイクロコンピュータ10が搭載された非接触式ICカード212は、交通チケット、金融カード、入退出カードとして用いることができる。   As shown in FIG. 20, the non-contact IC card 212 on which the card microcomputer 10 is mounted can be used as a traffic ticket, a financial card, and an entry / exit card.

非接触式ICカード212が交通チケットとして用いられる場合、非接触式ICカード212内のEEPROM108には、カードの残高、改札通過時刻、改札を通過した駅などの各種情報が、リーダライタ211によって書き込まれる。   When the non-contact IC card 212 is used as a traffic ticket, the reader / writer 211 writes various information such as the card balance, the ticket gate passage time, and the station that has passed the ticket gate into the EEPROM 108 in the non-contact IC card 212. It is.

非接触式ICカード212が金融カードとして用いられる場合、非接触式ICカード212内のEEPROM108には、カードの残高、引き出し/預け入れ日時などの各種情報が、リーダライタ211によって書き込まれる。   When the non-contact type IC card 212 is used as a financial card, various information such as the balance of the card, withdrawal / deposit date / time, etc. are written into the EEPROM 108 in the non-contact type IC card 212 by the reader / writer 211.

非接触式ICカード212が入退出カードとして用いられる場合、非接触式ICカード212内のEEPROM108には、入室時刻や退室時刻などの各種情報が、リーダライタ211によって書き込まれる。   When the non-contact type IC card 212 is used as an entry / exit card, various information such as a room entry time and a room exit time are written into the EEPROM 108 in the non-contact type IC card 212 by the reader / writer 211.

また、リーダライタ211から伝達された各種情報を暗号化してから非接触式ICカード212内のEEPROM108に書き込み、EEPROM108からの読み出しデータを復号化してからリーダライタ211に出力することができる。この場合の暗号化処理や復号化処理は、カード用マイクロコンピュータ10内の剰余乗算コプロセッサ110、DESコプロセッサ111、AESコプロセッサ112などを用いて高速に行うことができる。   Also, various information transmitted from the reader / writer 211 can be encrypted and then written to the EEPROM 108 in the non-contact type IC card 212, and read data from the EEPROM 108 can be decrypted and output to the reader / writer 211. Encryption processing and decryption processing in this case can be performed at high speed using the remainder multiplication coprocessor 110, DES coprocessor 111, AES coprocessor 112, etc. in the card microcomputer 10.

上記のように電源遮断対策が施されたカード用マイクロコンピュータ10を搭載する非接触式ICカード212に対応するリーダライタ211に結合されるホストシステム(コンピュータシステム)においては、図21に示されるような処理が行われることで、上記カード用マイクロコンピュータ10の能力が発揮される。   FIG. 21 shows a host system (computer system) coupled to the reader / writer 211 corresponding to the non-contact type IC card 212 on which the card microcomputer 10 with the power cut-off measure taken as described above is mounted. By performing this process, the ability of the card microcomputer 10 is exhibited.

すなわち、非接触式ICカード212に対応するリーダライタ211に結合されるホストシステムでは、所定の通信プロトコルに従って、非接触式ICカード212内のカード用マイクロコンピュータ10と非接触通信接続を確立し(2101)、前回の非接触通信接続において、電源遮断に起因する処理中断が発生しているか否かの判別が行われる(2102)。この判別は、上記ホストシステムにおいて、カード用マイクロコンピュータ10におけるEEPROM108内のデータを期待値と比較することで可能となる。そして、上記ステップ2102の判別において、電源遮断に起因する処理中断は発生していない(Y)と判断された場合には、上記ホストシステムから非接触式ICカード212に対する所望のアクセスが開始される(2105)。しかし、上記ステップ2102の判別において、電源遮断に起因する処理中断が発生している(N)と判断された場合には、上記電源遮断に起因する処理中断にかかるデータが、必要に応じて、カード用マイクロコンピュータ10におけるEEPROM108に書き込まれる(2104)。   That is, the host system coupled to the reader / writer 211 corresponding to the non-contact type IC card 212 establishes a non-contact communication connection with the card microcomputer 10 in the non-contact type IC card 212 according to a predetermined communication protocol ( 2101), in the previous non-contact communication connection, it is determined whether or not the processing interruption due to the power interruption has occurred (2102). This determination can be made by comparing the data in the EEPROM 108 in the card microcomputer 10 with the expected value in the host system. If it is determined in step 2102 that processing interruption due to power interruption has not occurred (Y), desired access to the non-contact IC card 212 is started from the host system. (2105). However, if it is determined in step 2102 that the processing interruption due to the power interruption has occurred (N), the data related to the processing interruption caused by the power interruption is, if necessary, The data is written in the EEPROM 108 in the card microcomputer 10 (2104).

以上本発明者によってなされた発明を実施形態に基づいて具体的に説明したが、本発明はそれに限定されるものではなく、その要旨を逸脱しない範囲において種々変更可能であることは言うまでもない。   Although the invention made by the present inventor has been specifically described based on the embodiments, it is needless to say that the present invention is not limited thereto and can be variously modified without departing from the gist thereof.

例えば、EEPROM108における電源遮断対策対象外領域203,204(その他のデータエリア)を省略し、EEPROM108の記憶領域の全てを電源遮断対策対象領域202としても良い。   For example, the power shutdown countermeasure non-target areas 203 and 204 (other data areas) in the EEPROM 108 may be omitted, and the entire storage area of the EEPROM 108 may be used as the power shutdown countermeasure target area 202.

EEPROM108に代えて他の不揮発性メモリであるフラッシュメモリを適用することができる。   Instead of the EEPROM 108, a flash memory which is another nonvolatile memory can be applied.

10 カード用マイクロコンピュータ
101 CPU
102 I/Oポート
103 ウォッチドッグタイマ
104 システムコントロールロジック
105 セキュリティロジック
106 ROM
107 RAM
108 EEPROM
109 複数のタイマ
110 剰余乗算コプロセッサ
111 DESコプロセッサ
112 AESコプロセッサ
113 乱数生成回路
114 擬似乱数発生回路
115 接触インタフェース
116 非接触インタフェース
117 アナログ制御回路
118 アンテナ
201 ページ管理情報エリア
202 電源遮断対策対象領域
203,204 電源遮断対策対象外領域
211 リーダライタ
212 非接触式ICカード
601 論理/物理アドレス変換テーブル
801 書き込み用エリア
10 card microcomputer 101 CPU
102 I / O port 103 Watchdog timer 104 System control logic 105 Security logic 106 ROM
107 RAM
108 EEPROM
109 Multiple Timers 110 Residue Multiplication Coprocessor 111 DES Coprocessor 112 AES Coprocessor 113 Random Number Generation Circuit 114 Pseudo Random Number Generation Circuit 115 Contact Interface 116 Contactless Interface 117 Analog Control Circuit 118 Antenna 201 Page Management Information Area 202 Power Shutdown Countermeasure Target Area 203, 204 Power-off prevention target area 211 Reader / writer 212 Non-contact IC card 601 Logical / physical address conversion table 801 Write area

Claims (6)

不揮発性メモリと、
上記不揮発性メモリへのデータ書き込み及び上記不揮発性メモリからのデータ読み出しを制御可能な制御部と、
上記制御部によってランダムアクセス可能なRAMと、を含み、
上記不揮発性メモリは、書き込み単位とされるページを含み、
上記ページは、それぞれデータを記憶可能な複数のブロックと、上記複数のブロックに書き込まれたデータを上記ページ単位で管理するためのページ管理情報と、を含み、
上記制御部は、上記不揮発性メモリについての論理アドレスを物理アドレスに変換するためのアドレス変換テーブルを、電源投入時の初期設定により上記RAMの第1記憶エリアに形成するアドレス変換テーブル形成機能と、
上記RAMの第1記憶エリアに形成された上記アドレス変換テーブルを参照して、上記不揮発性メモリにおけるブロックへのデータ書き込みを制御するデータ書き込み機能と、を含み、
上記データ書き込み機能は、データ書き込みの対象となるブロックを含むページの記憶データを上記RAMの第2記憶エリアにコピーする第1機能と、
上記RAMの第2記憶エリアに対して、上記データ書き込みの対象となるブロックへのデータ書き込みを行う第2機能と、
上記第2機能によるデータ書き込みに対応して、上記RAMの第2記憶エリアのページ管理情報を更新する第3機能と、
上記ページ管理情報が更新された後に、上記RAMの第2記憶エリアの記憶データを、上記アドレス変換テーブルで空きページとされる上記不揮発性メモリの物理ページに書き込む第4機能と、を含むことを特徴とする半導体集積回路装置。
Non-volatile memory;
A control unit capable of controlling data writing to the nonvolatile memory and data reading from the nonvolatile memory;
RAM randomly accessible by the control unit,
The non-volatile memory includes a page as a writing unit,
The page includes a plurality of blocks each capable of storing data, and page management information for managing the data written in the plurality of blocks in units of pages,
An address conversion table forming function for forming an address conversion table for converting a logical address of the nonvolatile memory into a physical address in a first storage area of the RAM by an initial setting at power-up;
A data writing function for controlling data writing to a block in the nonvolatile memory with reference to the address conversion table formed in the first storage area of the RAM,
The data writing function includes a first function for copying storage data of a page including a block to which data is to be written to the second storage area of the RAM;
A second function for writing data to the block to which the data is written in the second storage area of the RAM;
A third function for updating page management information in the second storage area of the RAM in response to data writing by the second function;
A fourth function for writing data stored in the second storage area of the RAM to a physical page of the nonvolatile memory that is set as an empty page in the address conversion table after the page management information is updated. A semiconductor integrated circuit device.
上記ページ管理情報は、データが正常に書き込まれたことを示す確認フラグを含み、
上記データ書き込み機能は、上記アドレス変換テーブルで空きページとされる上記不揮発性メモリの物理ページに書き込まれたデータと、それに対応する上記RAMの第2エリアのデータとが一致するか否かを判別する第5機能と、
上記アドレス変換テーブルで空きページとされる上記不揮発性メモリの物理ページに書き込まれたデータと、それに対応する上記RAMの第2記憶エリアのデータとが一致する場合に、上記RAMの第2記憶エリアの上記確認フラグの値を変更してから、その確認フラグを、上記不揮発性メモリにおいて対応する物理ページへ上書きすることで、当該物理ページにおける確認フラグを更新する第6機能と、を含む請求項1記載の半導体集積回路装置。
The page management information includes a confirmation flag indicating that data has been successfully written,
The data write function determines whether or not the data written in the physical page of the non-volatile memory, which is an empty page in the address conversion table, matches the data in the second area of the RAM corresponding thereto. A fifth function to
The second storage area of the RAM when the data written in the physical page of the non-volatile memory, which is an empty page in the address conversion table, matches the corresponding data in the second storage area of the RAM. And a sixth function for updating the confirmation flag in the physical page by overwriting the corresponding physical page in the nonvolatile memory after changing the value of the confirmation flag. 2. The semiconductor integrated circuit device according to 1.
上記ページ管理情報は、タイムスタンプを更に含み、
上記第3機能は、上記第2機能によるデータ書き込みに対応して、上記タイムスタンプの現在の値に、1を加算することで上記タイムスタンプを更新する機能を含む請求項2記載の半導体集積回路装置。
The page management information further includes a time stamp,
3. The semiconductor integrated circuit according to claim 2, wherein the third function includes a function of updating the time stamp by adding 1 to a current value of the time stamp in response to data writing by the second function. apparatus.
上記ページ管理情報は、当該ページ管理情報を含むページの論理ページナンバーと、上記ページ管理情報についてのチェックサムと、を更に含む請求項3記載の半導体集積回路装置。   4. The semiconductor integrated circuit device according to claim 3, wherein the page management information further includes a logical page number of a page including the page management information, and a checksum for the page management information. 上記アドレス変換テーブル形成機能は、上記制御部のリセットにより起動され、同じ論理ページナンバーを持つ物理ページが複数存在する場合に、当該物理ページにおけるページ管理情報に基づいて上記空きページを判定する第7機能を含む請求項4記載の半導体集積回路装置。   The address conversion table forming function is activated by resetting the control unit, and when there are a plurality of physical pages having the same logical page number, a seventh page for determining the empty page based on page management information in the physical page. 5. The semiconductor integrated circuit device according to claim 4, comprising a function. 上記第7機能は、同じ論理ページナンバーを持つ複数の物理ページ間で、上記チェックサム及び上記確認フラグが共に正常であり、上記タイムスタンプが互いに異なる場合に、上記タイムスタンプの値が小さいほうを上記空きページと判定する機能と、
同じ論理ページナンバーを持つ複数の物理ページのうち、上記タイムスタンプ、上記論理ページナンバー、上記確認フラグ、及び上記チェックサムの少なくともひとつが異常であると判断された物理ページを上記空きページと判定する機能と、
同じ論理ページナンバーを持つ複数の物理ページのうち、データが正常に書き込まれたか否かの確認が済んでいないと判断された物理ページを上記空きページと判定する機能と、
同じ論理ページナンバーを持つ複数の物理ページのうち、確認フラグ以外のデータは正常と判断された物理ページは有効とし、それとは異なる物理ページを上記空きページと判定する機能と、を含む請求項5記載の半導体集積回路装置。
In the seventh function, when both the checksum and the confirmation flag are normal between a plurality of physical pages having the same logical page number and the time stamps are different from each other, the smaller value of the time stamp is determined. A function to determine that the page is free,
Among a plurality of physical pages having the same logical page number, a physical page in which at least one of the time stamp, the logical page number, the confirmation flag, and the checksum is determined to be abnormal is determined as the free page. Function and
A function of determining, as a free page, a physical page that has been determined that the data has not been successfully written out of a plurality of physical pages having the same logical page number;
6. A function of validating a physical page for which data other than the confirmation flag is determined to be normal among a plurality of physical pages having the same logical page number, and determining a physical page different from the physical page as the empty page. The semiconductor integrated circuit device described.
JP2010046453A 2010-03-03 2010-03-03 Semiconductor integrated circuit device Withdrawn JP2011180963A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2010046453A JP2011180963A (en) 2010-03-03 2010-03-03 Semiconductor integrated circuit device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2010046453A JP2011180963A (en) 2010-03-03 2010-03-03 Semiconductor integrated circuit device

Publications (1)

Publication Number Publication Date
JP2011180963A true JP2011180963A (en) 2011-09-15

Family

ID=44692379

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2010046453A Withdrawn JP2011180963A (en) 2010-03-03 2010-03-03 Semiconductor integrated circuit device

Country Status (1)

Country Link
JP (1) JP2011180963A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2019049876A (en) * 2017-09-11 2019-03-28 大日本印刷株式会社 Electronic information storage medium, ic card, table management method with electronic information storage medium, and table management program
CN112214162A (en) * 2019-06-25 2021-01-12 株式会社日立制作所 Storage device and control method

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2019049876A (en) * 2017-09-11 2019-03-28 大日本印刷株式会社 Electronic information storage medium, ic card, table management method with electronic information storage medium, and table management program
CN112214162A (en) * 2019-06-25 2021-01-12 株式会社日立制作所 Storage device and control method

Similar Documents

Publication Publication Date Title
US7708195B2 (en) Memory card
KR102095614B1 (en) Memory protection
JP6985011B2 (en) Equipment and methods for ensuring access protection schemes
EP1396815B1 (en) Memory card
EP2263187B1 (en) Peripheral device locking mechanism
US8838950B2 (en) Security architecture for system on chip
TWI436372B (en) Flash memory storage system, and controller and method for anti-falsifying data thereof
TWI405211B (en) Flash memory storage system, controller and data protecting method thereof
US20050259465A1 (en) Nonvolatile memory apparatus
US8417902B2 (en) One-time-programmable memory emulation
CN111226215B (en) Transparent attached flash memory security
CN108319520A (en) Mobile device alternate operating system based on secure storage
US20050209716A1 (en) Method and system for writing nv memories in a controller architecture, corresponding computer program product and computer-readable storage medium
KR20060002664A (en) Apparatus and method for controlling memory address mapping in embedded system
TW201525870A (en) Updatable integrated-circuit radio
KR20150135753A (en) Ic card, electronic device and portable electronic device
JP2011180963A (en) Semiconductor integrated circuit device
US20080034150A1 (en) Data processing circuit
JP2003022216A (en) Storage device
US20040186947A1 (en) Access control system for nonvolatile memory
JP5241065B2 (en) Apparatus and method for checking whether data stored in external memory is changed
CN113557500A (en) Multi-mode protected memory
JP6396119B2 (en) IC module, IC card, and IC card manufacturing method
JP2009129402A (en) Semiconductor device for ic card, ic card and terminal for ic card
JP2008310460A (en) Control circuit, storage medium, processor, integrated system, and area management method

Legal Events

Date Code Title Description
A300 Withdrawal of application because of no request for examination

Free format text: JAPANESE INTERMEDIATE CODE: A300

Effective date: 20130507