JP2011039964A - Endian conversion circuit, endian conversion method and microcontroller - Google Patents
Endian conversion circuit, endian conversion method and microcontroller Download PDFInfo
- Publication number
- JP2011039964A JP2011039964A JP2009189097A JP2009189097A JP2011039964A JP 2011039964 A JP2011039964 A JP 2011039964A JP 2009189097 A JP2009189097 A JP 2009189097A JP 2009189097 A JP2009189097 A JP 2009189097A JP 2011039964 A JP2011039964 A JP 2011039964A
- Authority
- JP
- Japan
- Prior art keywords
- endian conversion
- data
- endian
- holding unit
- data holding
- 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.)
- Pending
Links
Images
Abstract
Description
本発明は、エンディアン変換回路、エンディアン変換方法及びマイクロコントローラに関する。 The present invention relates to an endian conversion circuit, an endian conversion method, and a microcontroller.
複数バイトのデータをメモリ上に配置する方式として、リトルエンディアン、ビッグエンディアンなどが知られている。エンディアンとは、2バイト以上のデータ量を持つ数値データを記録したり転送するときには1バイトごとに分割するが、その際の記録/転送を行う順番のことをいう。最上位のバイトから順番に記録/送信する方式を ビッグエンディアン、最下位のバイトから順番に記録/送信する方式をリトルエンディアンという。 Little endian, big endian, and the like are known as a method of arranging data of a plurality of bytes on a memory. Endian means the order in which recording / transfer is performed at the time when numerical data having a data amount of 2 bytes or more is recorded or transferred, and divided into one byte. The method of recording / transmitting in order from the most significant byte is called big endian, and the method of recording / transmitting in order from the least significant byte is called little endian.
互いに異なるエンディアン方式が用いられているCPU(Central Processing Unit)などのプロセッサ、通信マクロまたはメモリマクロなどの間で、複数バイトのデータを転送して処理するには、エンディアン変換を行う必要がある。 In order to transfer and process a plurality of bytes of data between a processor such as a CPU (Central Processing Unit) using a different endian method, a communication macro or a memory macro, it is necessary to perform endian conversion.
エンディアン変換の手法として、プログラムで行うものがある。
たとえば、CPUが自身のエンディアン方式と異なるエンディアン方式である通信マクロからデータを受信した場合、CPUがエンディアン変換プログラムを実行してエンディアン変換を行う。通信マクロへのデータ転送時にも、CPUが、予め入出力マクロのエンディアン方式への変換を行ったのち、データを転送する。
One endian conversion method is performed by a program.
For example, when the CPU receives data from a communication macro having an endian system different from its own endian system, the CPU executes an endian conversion program to perform endian conversion. Even when data is transferred to the communication macro, the CPU transfers the data after converting the input / output macro to the endian system in advance.
しかしながら、従来の技術では、プロセッサがエンディアン変換プログラムを実行して、データ並びを変換させる必要があり、プロセッサの動作効率が悪くなる問題がある。
上記の点を鑑みて、本発明は、効率よくエンディアン変換が可能なエンディアン変換回路、エンディアン変換方法及びマイクロコントローラを提供することを目的とする。
However, in the conventional technique, it is necessary for the processor to execute the endian conversion program to convert the data sequence, and there is a problem that the operation efficiency of the processor is deteriorated.
In view of the above points, an object of the present invention is to provide an endian conversion circuit, an endian conversion method, and a microcontroller that can perform endian conversion efficiently.
上記目的を達成するために、以下のようなエンディアン変換回路が提供される。
このエンディアン変換回路は、アドレス信号の最下位ビットをドントケアビットとして番地指令が行われるデータ保持部と、前記データ保持部へアクセスする前記アドレス信号の前記最下位ビットの値に基づいて、前記データ保持部への書き込みデータ、または前記データ保持部からの読み出しデータに対してエンディアン変換を行うエンディアン変換部と、を有する。
In order to achieve the above object, the following endian conversion circuit is provided.
The endian conversion circuit includes a data holding unit for which an address command is issued using the least significant bit of the address signal as a don't care bit, and the data holding unit based on the value of the least significant bit of the address signal accessing the data holding unit. And an endian conversion unit that performs endian conversion on the data written to the unit or read data from the data holding unit.
また、上記目的を達成するために、以下のようなマイクロコントローラが提供される。
このマイクロコントローラは、アドレス信号の最下位ビットをドントケアビットとして処理するデータ保持部と、エンディアン変換を行うか否かの情報を、前記データ保持部へアクセスする前記アドレス信号の最下位ビットに書き込み、前記データ保持部にアクセスするプロセッサと、前記アドレス信号の前記最下位ビットに基づき、前記データ保持部への書き込みデータ、または前記データ保持部からの読み出しデータに対してエンディアン変換を行うエンディアン変換部と、を有する。
In order to achieve the above object, the following microcontroller is provided.
The microcontroller writes a data holding unit that processes the least significant bit of the address signal as a don't care bit and information on whether to perform endian conversion in the least significant bit of the address signal that accesses the data holding unit, A processor that accesses the data holding unit; and an endian conversion unit that performs endian conversion on write data to the data holding unit or read data from the data holding unit based on the least significant bit of the address signal; Have.
開示のエンディアン変換回路、エンディアン変換方法及びマイクロコントローラによれば、効率よくエンディアン変換が可能になる。 According to the disclosed endian conversion circuit, endian conversion method, and microcontroller, endian conversion can be performed efficiently.
以下、本発明の実施の形態を、図面を参照しつつ説明する。
(第1の実施の形態)
図1は、エンディアン変換回路の一例の構成を示す図である。
Hereinafter, embodiments of the present invention will be described with reference to the drawings.
(First embodiment)
FIG. 1 is a diagram illustrating a configuration of an example of an endian conversion circuit.
以降述べるエンディアンについて、たとえば、1234ABCDHという4バイトのデータを上位バイトから「12H 34H ABH CDH」と並べる方式をビッグエンディアンとし、下位バイトから「CDH ABH 34H 12H」と並べる方式をリトルエンディアンとする。なお、下付きのHは、その数値が16進数であることを示している。 For the endian described below, for example, a system in which 4 bytes of data 1234ABCD H are arranged as “12 H 34 H AB H CD H ” from the upper byte is set to big endian, and “CD H AB H 34 H 12 H ” is set from the lower byte. The arrangement method is a little endian. The subscript H indicates that the numerical value is a hexadecimal number.
エンディアン変換回路10は、データ保持部11とエンディアン変換部12を有している。
データ保持部11は、たとえば、FIFO(First-In First-Out)回路などのバッファやメモリである。データ保持部11は、たとえば、図示しない通信マクロ及びプロセッサ間のデータ転送の際に、一時的にデータを保持する機能を有する。
The
The
なお、図1の例では、データ保持部11に、4バイトで1ワードのデータd1がリトルエンディアンで格納されている様子が示されている。データd1の1バイト目が1000番地に格納され、2バイト目が1001番地に格納され、3バイト目が1002番地に格納され、4バイト目が1003番地に格納されている。
In the example of FIG. 1, a state in which data d1 of 4 bytes and 1 word is stored in little endian in the
データ保持部11に対して与えられるアドレス信号は、たとえば、チップ内のプロセッサから出力される。プロセッサから出力されるアドレス信号の下位ビットを丸めこまず、フルアドレスアクセスできることが本実施の形態において前提である。ただし、データ保持部11ではワードアクセスあるいはハーフワードアクセスの時はアドレスの最下位ビットは無視される。つまりデータ保持部11はフルアドレスデコードせず、アドレスの最下位ビットはドントケアビット(don't care bit)として処理される。一方、エンディアン変換回路10にはアドレスの最下位ビットが、エンディアン変換を行うか行わないかを示す情報として入力される。
The address signal given to the
エンディアン変換部12は、たとえば、セレクタを用いて実現可能である。エンディアン変換部12は、データ保持部11へアクセスするアドレス信号が、データ保持部11の偶数アドレスまたは奇数アドレスのいずれか一方を指定しているか判定する。具体的には、エンディアン変換部12は、アドレス信号の最下位ビットを検出して、アドレス信号が、偶数アドレス(最下位ビットが0)を指定しているのか、奇数アドレス(最下位ビットが1)を指定しているのか判定する。そして、エンディアン変換部12は、アドレス信号が偶数アドレスまたは奇数アドレスのいずれか一方である場合に、データ保持部11への書き込みデータまたはデータ保持部11からの読み出しデータに対してエンディアン変換を行う。
The
なお、エンディアン変換回路10は、データ保持部11に、図示しないプロセッサや通信インターフェースなどから転送されてくる1ワード(またはハーフワード)のデータごと、アドレス信号により、エンディアン変換するか否か決定できる。
The
以下、エンディアン変換回路10の動作を説明する。
なお、以下の例では、エンディアン変換部12は、アドレス信号でデータ保持部11の奇数アドレスが指定されている場合にエンディアン変換を行い、偶数アドレスが指定されている場合にはエンディアン変換を行わないとして説明する。
Hereinafter, the operation of the
In the following example, the
たとえば、エンディアン変換回路10が、リトルエンディアンでデータを扱う通信マクロと、ビッグエンディアンでデータを扱うプロセッサ間に設けられた場合、エンディアン変換回路10は、以下のような動作を行う。
For example, when the
たとえば、通信マクロにより、リトルエンディアンでデータ保持部11に保持されているデータd1をプロセッサが読み出す際、プロセッサは、アドレス信号により、データ保持部11の1001番地または1003番地を指定して読み出しアクセスする。このとき、アドレス信号は奇数アドレスであるので、最下位ビットは1となり、エンディアン変換部12は、エンディアン変換を実行する。すなわち、エンディアン変換部12は、リトルエンディアンのデータ並びのデータd1を、ビッグエンディアンのデータ並びのデータd1aに変換する。
For example, when a processor reads data d1 held in the
これにより、リトルエンディアンとは逆のデータ並びとなるビッグエンディアンのプロセッサでも、データd1と同じ内容のデータd1aとして処理可能になる。
次に、データ保持部11への書き込みアクセス時にエンディアン変換を施す場合の、エンディアン変換回路10の動作を説明する。
As a result, even a big endian processor having a data arrangement opposite to that of the little endian can be processed as data d1a having the same contents as the data d1.
Next, the operation of the
図2は、データ保持部への書き込みアクセス時のエンディアン変換の様子を示す図である。
たとえば、ビッグエンディアンのプロセッサから、データd1aを、リトルエンディアンで転送するためのバッファとして用いるデータ保持部11に書き込む場合、エンディアン変換部12は、以下のような動作を行う。
FIG. 2 is a diagram illustrating a state of endian conversion at the time of write access to the data holding unit.
For example, when data d1a is written from the big endian processor to the
書き込みアクセス時のアドレス信号が、1001番地または1003番地のような奇数アドレスを指定している場合、エンディアン変換部12は、プロセッサ側からのビッグエンディアンのデータ並びのデータd1aをリトルエンディアンに変換する。そして、データ保持部11の1000番地にデータd1aの1バイト目を、1001番地に2バイト目を、1002番地に3バイト目と、1003番地に4バイト目をそれぞれ格納する。
When the address signal at the time of write access designates an odd address such as address 1001 or address 1003, the
これにより、リトルエンディアンの通信マクロでも、データd1aと同じ内容のデータd1として処理可能になる。
なお、上記では、データ保持部11がリトルエンディアンでデータを扱い、プロセッサがビッグエンディアンでデータを扱う場合について説明したが、これが逆である場合にも同様にエンディアン変換を行うことができる。すなわち、データ保持部11がビッグエンディアンでデータを扱い、プロセッサがリトルエンディアンでデータを扱う場合にも、エンディアン変換部12は、アドレス信号が奇数アドレスを指定している場合には一方のデータをエンディアン変換して他方に転送する。
As a result, even a little endian communication macro can be processed as data d1 having the same contents as data d1a.
Although the case where the
エンディアン変換部12は、データ保持部11への読み出しアクセスまたは書き込みアクセス時のアドレス信号が偶数アドレスを指定する場合に、エンディアン変換を行わない。
The
たとえば、通信マクロとプロセッサが両方ともリトルエンディアンでデータを扱う場合、図3及び図4で示すような動作が行われる。
図3は、偶数アドレスが指定された場合の、データ保持部からのデータ読み出しの様子を示す図である。
For example, when both the communication macro and the processor handle data in little endian, the operations shown in FIGS. 3 and 4 are performed.
FIG. 3 is a diagram showing how data is read from the data holding unit when an even address is designated.
読み出しアクセスの際、アドレス信号で偶数アドレス(最下位ビットが0)が指定されている場合、エンディアン変換部12は、エンディアン変換を行わず、データ保持部11のリトルエンディアンの並びのデータd1をそのまま転送する。
At the time of read access, if an even address (the least significant bit is 0) is specified by the address signal, the
通信マクロとプロセッサが両方ともビッグエンディアンでデータを扱う場合も同様に、エンディアン変換部12は、データ保持部11に保持されたビッグエンディアンの並びのデータを、エンディアン変換せずに、そのまま読み出せばよい。
Similarly, when both the communication macro and the processor handle data in big endian, the
図4は、偶数アドレスが指定された場合の、データ保持部へのデータ書き込みの様子を示す図である。
書き込みアクセスの際、アドレス信号で偶数アドレスが指定されると、エンディアン変換部12は、エンディアン変換を行わず、プロセッサ側からのリトルエンディアンの並びのデータd1aを、データ保持部11に書き込む。
FIG. 4 is a diagram illustrating a state of data writing to the data holding unit when an even address is designated.
When an even address is specified by an address signal at the time of write access, the
通信マクロとプロセッサが両方ともビッグエンディアンでデータを扱う場合も同様に、エンディアン変換部12は、プロセッサ側からのリトルエンディアンの並びのデータを、エンディアン変換せずに、データ保持部11に書き込めばよい。
Similarly, when both the communication macro and the processor handle data in big endian, the
以上のように、本実施の形態のエンディアン変換回路10では、データ保持部11へアクセスするアドレス信号が、偶数アドレスまたは奇数アドレスを指定しているかによって、エンディアン変換を行うか否かを決定している。これにより、簡単にエンディアン変換の要否が判定可能となり、エンディアン変換の要否を設定するためのレジスタやスイッチなどのハードウェア構成などを付加することなく、効率よくエンディアン変換が可能となる。また、プログラムによるデータのスワップも不要となり、プログラム効率が向上する。
As described above, in the
なお、上記の説明では、エンディアン変換部12は、アドレス信号で奇数アドレスが指定されている場合にエンディアン変換を行い、偶数アドレスが指定されている場合にはエンディアン変換を行わないとしたが、これに限定されない。エンディアン変換部12は、アドレス信号で偶数アドレスが指定されている場合にエンディアン変換を行い、奇数アドレスが指定されている場合にはエンディアン変換を行わないようにしてもよい。
In the above description, the
また、上記の説明では、エンディアン変換部12は、アドレス信号が偶数アドレスまたは奇数アドレスかを判定して、エンディアン変換を行うか否かを決定する場合について説明したが、さらに、アクセスサイズを考慮してもよい。詳細は後述するが、バイトごとのアクセスが行われる場合には、エンディアン変換を行わなくてよいので、エンディアン変換を無効とし、複数バイト(たとえば、ハーフワードまたはワード)のアクセスの場合にエンディアン変換を有効とするようにしてもよい。
In the above description, the
次に、上記のようなエンディアン変換回路を、マイクロコントローラに適用した場合を例にして説明する。
(第2の実施の形態)
図5は、マイクロコントローラの一例の構成を示す図である。
Next, a case where the endian conversion circuit as described above is applied to a microcontroller will be described as an example.
(Second Embodiment)
FIG. 5 is a diagram illustrating a configuration of an example of a microcontroller.
以降述べるエンディアンについて、たとえば、1234ABCDHという4バイトのデータを上位バイトから「12H 34H ABH CDH」と並べる方式をビッグエンディアンとし、下位バイトから「CDH ABH 34H 12H」と並べる方式をリトルエンディアンとする。なお、下付きのHは、その数値が16進数であることを示している。 For the endian described below, for example, a system in which 4 bytes of data 1234ABCD H are arranged as “12 H 34 H AB H CD H ” from the upper byte is set to big endian, and “CD H AB H 34 H 12 H ” is set from the lower byte. The arrangement method is a little endian. The subscript H indicates that the numerical value is a hexadecimal number.
マイクロコントローラ20は、プロセッサ21、RAM(Random Access Memory)22、フラッシュメモリ23、バスコンバータ24、バスブリッジ25、周辺回路26,27、通信マクロ28,29を有している。
The
プロセッサ21は、たとえば、CPUやDSP(Digital Signal Processor)などであり、マイクロコントローラ20の各部を制御する。また、プロセッサ21は、通信マクロ28,29の、後述のデータ保持部にアクセスする際、たとえば、アドレスの下位ビットを丸めこまず、フルアドレスアクセスする。ただし、データ保持部11ではワードアクセスあるいはハーフワードアクセスの時はアドレスの最下位ビットは無視される。つまりデータ保持部11はフルアドレスデコードせず、アドレスの最下位ビットはドントケアビット(don't care bit)として処理される。一方、エンディアン変換回路10にはアドレスの最下位ビットが、エンディアン変換を行うか行わないかを示す情報として入力される。
The
RAM22は、プロセッサ21が実行途中のプログラムや、演算途中のデータを格納する。
フラッシュメモリ23は、プロセッサ21が実行するOS(Operation System)や、各種プログラム、各種データを格納する。
The
The
バスコンバータ24は、プロセッサ21、RAM22、フラッシュメモリ23及び内部バスbsとのインターフェースとして機能し、たとえば、32ビットと16ビットの変換機能なども有する。
The
バスブリッジ25は、内部バスbs1と、周辺バスbs2とを接続する。
周辺回路26,27は、割りこみコントローラや、ウォッチドッグタイマなどであり、周辺バスbs2に接続されている。
The
The
通信マクロ28,29は、マイクロコントローラ20の外部との通信を行うためのインターフェース回路である。通信マクロ28,29は、たとえば、USB(Universal Serial Bus)や、UART(Universal Asynchronous Receiver Transmitter)、I2Cバス、CAN(Controller Area Network)バス、IE(Inter Equipment)バスなどのインターフェース回路である。図1で示したような、エンディアン変換回路10は、たとえば、通信マクロ28,29内に設けられる。
The
なお、図5では、2つの通信マクロ28,29を示しているが、1つでも3つ以上であってもよい。
図6は、通信マクロ内に設けられたエンディアン変換回路の一例を示す図である。
In FIG. 5, two
FIG. 6 is a diagram illustrating an example of the endian conversion circuit provided in the communication macro.
通信マクロ28は、データ保持部281、エンディアン変換部282を有しており、これらが、図1で示したようなエンディアン変換回路として機能する。すなわち、データ保持部281は、図1のデータ保持部11に対応し、エンディアン変換部282は、図1のエンディアン変換部12に対応している。ただし、図6に示されている構成では、エンディアン変換部282は、エンディアン変換を行うエンディアン変換セレクタ282aのほかに、アクセスサイズ検出部282bを有している。
The
アクセスサイズ検出部282bは、データ保持部281へアクセスするアドレス信号と、データ保持部281へのアクセスサイズを基に、エンディアン変換セレクタ282aに、エンディアン変換を実行させるか否かを決定する。アクセスサイズ検出部282bは、バイトごとのアクセスが行われる場合には、エンディアン変換を行わなくてよいので、エンディアン変換を無効とし、複数バイトのアクセスの場合にエンディアン変換を有効とする。アクセスサイズ検出部282bは、エンディアン変換部282の外部にあってもよい。
The access
なお、以下の説明では、エンディアン変換セレクタ282aは、アドレス信号がデータ保持部281の奇数アドレス(最下位ビットが1)を指定している場合に、エンディアン変換を行う例を説明する。その場合、アクセスサイズ検出部282bは、たとえば、図6に示すように、OR回路282b1と、AND回路282b2とを用いて実現される。
In the following description, an example will be described in which the
OR回路282b1には、複数バイトのアクセスとして、ワードアクセスかハーフワードアクセスなのかを示す2つの入力信号が、プロセッサ21から入力される。ワードアクセスまたはハーフワードアクセスの場合には、OR回路282b1には、1,0の信号が入力され、OR回路282b1は、1を出力する。また、バイトアクセスの場合には、OR回路282b1の2つの入力はともに0になり、OR回路282b1は、0を出力する。
Two input signals indicating whether the access is a word access or a halfword access are input from the
AND回路282b2の一方の入力端子には、アドレス信号の最下位ビットが入力され、他方の入力端子には、OR回路282b1の出力信号が入力される。OR回路282b1の出力が1である場合、AND回路282b2の出力は、アドレス信号の最下位ビットによって決まる。すなわち、AND回路282b2は、最下位ビットが1の場合は1を出力し、最下位ビットが0の場合は0を出力する。一方、OR回路282b1の出力が0である場合、AND回路282b2の出力は、アドレスの信号の最下位ビットの値によらず0となり、エンディアン変換が無効となる。
The least significant bit of the address signal is input to one input terminal of the AND circuit 282b2, and the output signal of the OR circuit 282b1 is input to the other input terminal. When the output of the OR circuit 282b1 is 1, the output of the AND circuit 282b2 is determined by the least significant bit of the address signal. That is, the AND
なお、エンディアン変換部282は、通信マクロ28の外に設けられていてもよい。
以下、通信マクロ28がPC30とUSBで通信するインターフェース回路である場合を例にして、マイクロコントローラ20の動作を説明する。
Note that the
Hereinafter, the operation of the
まず、データ読み出し時における、マイクロコントローラ20の動作を説明する。
図7は、データ読み出し時のマイクロコントローラの処理の流れを示すフローチャートである。
First, the operation of the
FIG. 7 is a flowchart showing a flow of processing of the microcontroller at the time of data reading.
まず、通信マクロ28は、PC30からUSBデータを受信してデータ保持部281に保持する(ステップS1)。図6では、1バイト目が01H、2バイト目が23H、3バイト目が45H、4バイト目が67Hという4バイトのデータd10が、リトルエンディアンの並びで、データ保持部281の100〜103番地に保持されている様子を示している。なお、下付きのHは、その数値が16進数であることを示している。
First, the
次にプロセッサ21は、データ保持部281に対して読み出しアクセスを行う(ステップS2)。プロセッサ21は、データ保持部281に対して、たとえば、バイトごとのアクセスか、複数バイト(ワードまたはハーフワード)ごとのアクセスを行う。プロセッサ21は、ワードアクセスまたはハーフワードアクセスを行う場合には、図6で示したアクセスサイズ検出部282bのOR回路282b1の一方の入力端子に1を入力する。
Next, the
また、プロセッサ21は、ワードアクセスまたはハーフワードアクセスを行う際、自身がビッグエンディアンを採用している場合、リトルエンディアンの並びでデータを保持する通信マクロ28のデータ保持部281に対して、奇数アドレスでアクセスする。たとえば、プロセッサ21は、100〜103番地の1ワードのデータd10を読み出す場合には、アドレス信号により101番地または103番地を指定して読み出しアクセスする。
Further, when performing the word access or the half word access, the
一方、プロセッサ21は、ワードアクセスまたはハーフワードアクセスを行う際、自身がリトルエンディアンを採用している場合、リトルエンディアンの並びでデータを保持する通信マクロ28のデータ保持部281に対して、偶数アドレスでアクセスする。たとえば、プロセッサ21は、100〜103番地の1ワードのデータd10を読み出す場合には、アドレス信号により100番地または102番地を指定して読み出しアクセスする。
On the other hand, when performing the word access or the halfword access, the
次に、エンディアン変換部282は、プロセッサ21からのアクセスサイズが複数バイト(ワードまたはハーフワード)アクセスか否かを判定する(ステップS3)。そして、エンディアン変換部282は、複数バイトアクセスが発生していると判定した場合には、次に、アドレス信号の最下位ビットが1か否かを判定する(ステップS4)。
Next, the
具体的には、アクセスサイズ検出部282bは、OR回路282b1の2つの入力端子の少なくともいずれか一方に1が入力されている場合には、複数バイトアクセスと判定する。一方、アクセスサイズ検出部282bは、OR回路282b1の2つの入力端子の両方に0が入力されている場合には、バイトごとのアクセスと判定する。後者の場合、アクセスサイズ検出部282bは、アドレス信号の最下位ビットにかかわらず、エンディアン変換を無効にする。これにより、バイトアクセスの場合には、プロセッサ21で指定されたアドレスの1バイトのデータが、エンディアン変換されずに読み出される(ステップS5)。
Specifically, the access
また、ステップS4の処理において最下位ビットが0と判定された場合にも、エンディアン変換部282は、ステップS5の処理を行う。エンディアン変換部282は、プロセッサ21により、たとえば、100番地または102番地を指定したワードアクセスがなされると、100〜103番地の1ワード分のデータd10を、エンディアン変換せずに読み出し、プロセッサ21に送信する。また、プロセッサ21により、100番地を指定したハーフワードアクセスがなされた場合、エンディアン変換部282は、100番地と101番地のハーフワード分のデータを、エンディアン変換せずに読み出し、プロセッサ21に送信する。
Even when the least significant bit is determined to be 0 in the process of step S4, the
一方、ステップS4の処理において最下位ビットが1と判定された場合、エンディアン変換部282は、エンディアン変換セレクタ282aにより、データ保持部281に保持されているデータに対してエンディアン変換を行い、読み出す(ステップS6)。エンディアン変換部282は、プロセッサ21により、たとえば、101番地または103番地を指定したワードアクセスがなされると、100〜103番地の1ワード分のデータd10を、図6のようなビッグエンディアンの並びのデータd10aに変換する。そして、エンディアン変換部282は、エンディアン変換したデータd10aを読み出し、プロセッサ21に送信する。
On the other hand, if the least significant bit is determined to be 1 in the process of step S4, the
次に、プロセッサ21からのデータ書き込み時における、マイクロコントローラ20の動作を説明する。
図8は、データ書き込み時のマイクロコントローラの処理の流れを示すフローチャートである。
Next, the operation of the
FIG. 8 is a flowchart showing a flow of processing of the microcontroller at the time of data writing.
また、図9は、データ書き込み時にエンディアン変換を行う様子を示す図である。
まずプロセッサ21は、データ保持部281に対してデータの書き込みアクセスを行う(ステップS10)。このとき、プロセッサ21は、データ保持部281に対して、たとえば、バイトごとの書き込みアクセスか、複数バイト(たとえば、ワードまたはハーフワード)ごとの書き込みアクセスを行う。ワードアクセスまたはハーフワードアクセスを行う場合には、プロセッサ21は、アクセスサイズ検出部282bのOR回路282b1の一方の入力端子に1を入力する。
FIG. 9 is a diagram showing how endian conversion is performed when data is written.
First, the
また、プロセッサ21は、ワードアクセスまたはハーフワードアクセスを行う際、自身がビッグエンディアンを採用している場合、リトルエンディアンの並びでデータを保持する通信マクロ28のデータ保持部281に対して、奇数アドレスでアクセスする。たとえば、プロセッサ21は、100〜103番地に1ワードのデータを書き込む場合には、アドレス信号により101番地または103番地を指定して書き込みアクセスする。
Further, when performing the word access or the half word access, the
一方、プロセッサ21は、ワードアクセスまたはハーフワードアクセスを行う際、自身がリトルエンディアンを採用している場合、リトルエンディアンの並びでデータを保持する通信マクロ28のデータ保持部281に対して、偶数アドレスでアクセスする。たとえば、プロセッサ21は、100〜103番地に1ワードのデータを書き込む場合には、アドレス信号により100番地または102番地を指定して書き込みアクセスする。
On the other hand, when performing the word access or the halfword access, the
次に、エンディアン変換部282は、プロセッサ21からのアクセスサイズが複数バイト(ワードまたはハーフワード)アクセスか否かを判定する(ステップS11)。そして、エンディアン変換部282は、複数バイトアクセスが発生していると判定した場合には、次に、アドレス信号の最下位ビットが1か否かを判定する(ステップS12)。
Next, the
具体的には、アクセスサイズ検出部282bは、OR回路282b1の2つの入力端子の少なくともいずれか一方に1が入力されている場合には、複数バイトアクセスと判定する。一方、アクセスサイズ検出部282bは、OR回路282b1の2つの入力端子の両方に0が入力されている場合には、バイトごとのアクセスと判定する。後者の場合、アクセスサイズ検出部282bは、アドレス信号の最下位ビットにかかわらず、エンディアン変換を無効にする。これにより、バイトアクセスの場合には、プロセッサ21で指定されたデータ保持部281のアドレスに、プロセッサ21側からの1バイトのデータが、エンディアン変換されずに書き込まれる(ステップS13)。
Specifically, the access
また、ステップS12の処理において最下位ビットが0と判定された場合にも、エンディアン変換部282は、ステップS13の処理を行う。プロセッサ21により、たとえば、データ保持部281の100番地または102番地を指定したワードアクセスがなされると、エンディアン変換部282は、100〜103番地に、1ワード分のデータd10aを、エンディアン変換せずに書き込む。また、プロセッサ21により、100番地を指定したハーフワードアクセスがなされた場合、エンディアン変換部282は、100番地と101番地に、ハーフワード分のデータを、エンディアン変換せずに書き込む。
Even when the least significant bit is determined to be 0 in the process of step S12, the
一方、ステップS12の処理において最下位ビットが1と判定された場合、エンディアン変換部282は、プロセッサ21側から送信されてきたデータに対してエンディアン変換を行い、データ保持部281に書き込む(ステップS14)。エンディアン変換部282は、プロセッサ21により、たとえば、データ保持部281の101番地または103番地を指定したワードアクセスがなされると、1ワード分のデータd10aを、図9のようなリトルエンディアンの並びのデータd10に変換する。そして、エンディアン変換部282は、エンディアン変換したデータd10を、データ保持部281の100〜103番地に書き込む。そして、通信マクロ28は、書き込んだデータd10を、USBデータとしてPC30に送信する(ステップS15)。
On the other hand, when the least significant bit is determined to be 1 in the process of step S12, the
以上のように、本実施の形態のマイクロコントローラ20では、データ保持部281へアクセスするアドレス信号が、偶数アドレスまたは奇数アドレスを指定しているかによって、エンディアン変換を行うか否かを決定している。これにより、簡単にエンディアン変換の要否が判定可能となり、効率よくエンディアン変換が可能となる。
As described above, in the
たとえば、エンディアンが異なる複数の通信マクロ28,29があった場合、プロセッサ21では、偶数または奇数アドレスを指定するだけで、通信マクロ28,29ごとに、エンディアン変換をするか否か決定できる。
For example, when there are a plurality of
なお、上記では、エンディアン変換部282は、アドレス信号で奇数アドレスが指定されている場合にエンディアン変換を行い、偶数アドレスが指定されている場合にはエンディアン変換を行わないとして説明したが、これに限定されない。エンディアン変換部282は、アドレス信号で偶数アドレスが指定されている場合にエンディアン変換を行い、奇数アドレスが指定されている場合にはエンディアン変換を行わないようにしてもよい。その場合、エンディアン変換セレクタ282aは、アドレス信号の最下位ビットが0の場合に、エンディアン変換を行うようにする。また、アクセスサイズ検出部282bは、バイトアクセスの場合に、エンディアン変換セレクタ282aに入力する出力信号を1に固定するような回路構成とすればよい。
In the above description, the
また、アドレス信号により、ワードごと、またはハーフワードごとにエンディアン変換を行うか否かの設定を行うようにしてもよい。
以上、実施の形態に基づき、本発明のエンディアン変換回路、エンディアン変換方法及びマイクロコントローラの一観点について説明してきたが、これらは一例にすぎず、上記の記載に限定されるものではない。
Further, it may be set whether or not to perform endian conversion for each word or for each half word by an address signal.
As described above, the endian conversion circuit, the endian conversion method, and the microcontroller according to the present invention have been described based on the embodiments. However, these are merely examples, and the present invention is not limited to the above description.
以上説明した複数の実施の形態に関し、さらに以下の付記を開示する。
(付記1) アドレス信号の最下位ビットをドントケアビットとして番地指令が行われるデータ保持部と、
前記データ保持部へアクセスする前記アドレス信号の前記最下位ビットの値に基づいて、前記データ保持部への書き込みデータ、または前記データ保持部からの読み出しデータに対してエンディアン変換を行うエンディアン変換部と、
を有することを特徴とするエンディアン変換回路。
The following additional notes are further disclosed with respect to the plurality of embodiments described above.
(Supplementary note 1) A data holding unit in which an address command is performed with the least significant bit of the address signal as a don't care bit;
An endian conversion unit that performs endian conversion on write data to the data holding unit or read data from the data holding unit based on the value of the least significant bit of the address signal that accesses the data holding unit; ,
An endian conversion circuit comprising:
(付記2) 前記データ保持部への書き込み時または前記データ保持部からの読み出し時のアクセスサイズを検出するアクセスサイズ検出部を有し、前記アクセスサイズ検出部は、前記アクセスサイズが複数バイトの場合に、前記エンディアン変換を有効にすることを特徴とする付記1記載のエンディアン変換回路。
(Additional remark 2) It has an access size detection part which detects the access size at the time of the writing to the said data holding part or the reading from the said data holding part, and the said access size detection part is when the said access size is multiple bytes The endian conversion circuit according to
(付記3) 前記アクセスサイズ検出部は、前記アクセスサイズが、ワードまたはハーフワードの場合に前記エンディアン変換を有効にすることを特徴とする付記2記載のエンディアン変換回路。 (Additional remark 3) The said endian conversion circuit of Additional remark 2 characterized by the said access size detection part validating the said endian conversion, when the said access size is a word or a halfword.
(付記4) アドレス信号の最下位ビットをドントケアビットとして処理するデータ保持部へアクセスするアドレス信号が、前記データ保持部の偶数アドレスまたは奇数アドレスのいずれを指定しているのか判定し、
前記判定結果に基づきエンディアン変換部が、前記データ保持部への書き込みデータ、または前記データ保持部からの読み出しデータに対してエンディアン変換を行うことを特徴とするエンディアン変換方法。
(Supplementary Note 4) Determine whether an address signal for accessing the data holding unit that processes the least significant bit of the address signal as a don't care bit specifies an even address or an odd address of the data holding unit,
An endian conversion method in which an endian conversion unit performs endian conversion on write data to the data holding unit or read data from the data holding unit based on the determination result.
(付記5) 前記データ保持部への書き込み時または前記データ保持部からの読み出し時のアクセスサイズを検出し、前記アクセスサイズが複数バイトの場合に、前記エンディアン変換を有効にすることを特徴とする付記4記載のエンディアン変換方法。 (Supplementary Note 5) The access size at the time of writing to the data holding unit or at the time of reading from the data holding unit is detected, and the endian conversion is enabled when the access size is a plurality of bytes. The endian conversion method according to appendix 4.
(付記6) 前記アクセスサイズが、ワードまたはハーフワードの場合に前記エンディアン変換を有効にすることを特徴とする付記5記載のエンディアン変換方法。
(付記7) アドレス信号の最下位ビットをドントケアビットとして処理するデータ保持部と、
エンディアン変換を行うか否かの情報を、前記データ保持部へアクセスする前記アドレス信号の最下位ビットに書き込み、前記データ保持部にアクセスするプロセッサと、
前記アドレス信号の前記最下位ビットに基づき、前記データ保持部への書き込みデータ、または前記データ保持部からの読み出しデータに対してエンディアン変換を行うエンディアン変換部と、を有することを特徴とするマイクロコントローラ。
(Supplementary note 6) The endian conversion method according to supplementary note 5, wherein the endian conversion is enabled when the access size is a word or a halfword.
(Appendix 7) A data holding unit that processes the least significant bit of the address signal as a don't care bit;
Information on whether or not to perform endian conversion is written in the least significant bit of the address signal that accesses the data holding unit, and a processor that accesses the data holding unit;
A microcontroller comprising: an endian conversion unit for performing endian conversion on write data to the data holding unit or read data from the data holding unit based on the least significant bit of the address signal .
(付記8) 前記データ保持部への書き込み時または前記データ保持部からの読み出し時の、前記プロセッサからのアクセスサイズを検出するアクセスサイズ検出部を有し、前記アクセスサイズ検出部は、前記アクセスサイズが複数バイトの場合に、前記エンディアン変換を有効にすることを特徴とする付記7記載のマイクロコントローラ。 (Additional remark 8) It has the access size detection part which detects the access size from the said processor at the time of the writing to the said data holding part or the reading from the said data holding part, The said access size detection part is the said access size The microcontroller according to appendix 7, wherein the endian conversion is validated when is a plurality of bytes.
(付記9) 前記アクセスサイズ検出部は、前記アクセスサイズが、ワードまたはハーフワードの場合に前記エンディアン変換を有効にすることを特徴とする付記8記載のマイクロコントローラ。 (Additional remark 9) The said access size detection part validates the said endian conversion, when the said access size is a word or a halfword, The microcontroller of Additional remark 8 characterized by the above-mentioned.
(付記10) 前記エンディアン変換部は、通信処理を行う通信マクロ内に配置されることを特徴とする付記7乃至9に記載のマイクロコントローラ。 (Supplementary Note 10) The microcontroller according to any one of Supplementary Notes 7 to 9, wherein the endian conversion unit is arranged in a communication macro that performs communication processing.
10 エンディアン変換回路
11 データ保持部
12 エンディアン変換部
d1,d1a データ
10
Claims (6)
前記データ保持部へアクセスする前記アドレス信号の前記最下位ビットの値に基づいて、前記データ保持部への書き込みデータ、または前記データ保持部からの読み出しデータに対してエンディアン変換を行うエンディアン変換部と、
を有することを特徴とするエンディアン変換回路。 A data holding unit in which an address command is performed using the least significant bit of the address signal as a don't care bit;
An endian conversion unit that performs endian conversion on write data to the data holding unit or read data from the data holding unit based on the value of the least significant bit of the address signal that accesses the data holding unit; ,
An endian conversion circuit comprising:
前記判定結果に基づきエンディアン変換部が、前記データ保持部への書き込みデータ、または前記データ保持部からの読み出しデータに対してエンディアン変換を行うことを特徴とするエンディアン変換方法。 Determine whether the address signal that accesses the data holding unit that processes the least significant bit of the address signal as a don't care bit specifies an even address or an odd address of the data holding unit,
An endian conversion method in which an endian conversion unit performs endian conversion on write data to the data holding unit or read data from the data holding unit based on the determination result.
エンディアン変換を行うか否かの情報を、前記データ保持部へアクセスする前記アドレス信号の最下位ビットに書き込み、前記データ保持部にアクセスするプロセッサと、
前記アドレス信号の前記最下位ビットに基づき、前記データ保持部への書き込みデータ、または前記データ保持部からの読み出しデータに対してエンディアン変換を行うエンディアン変換部と、
を有することを特徴とするマイクロコントローラ。 A data holding unit that processes the least significant bit of the address signal as a don't care bit;
Information on whether or not to perform endian conversion is written in the least significant bit of the address signal that accesses the data holding unit, and a processor that accesses the data holding unit;
Based on the least significant bit of the address signal, an endian conversion unit that performs endian conversion on write data to the data holding unit or read data from the data holding unit;
A microcontroller comprising:
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2009189097A JP2011039964A (en) | 2009-08-18 | 2009-08-18 | Endian conversion circuit, endian conversion method and microcontroller |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2009189097A JP2011039964A (en) | 2009-08-18 | 2009-08-18 | Endian conversion circuit, endian conversion method and microcontroller |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2011039964A true JP2011039964A (en) | 2011-02-24 |
Family
ID=43767637
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2009189097A Pending JP2011039964A (en) | 2009-08-18 | 2009-08-18 | Endian conversion circuit, endian conversion method and microcontroller |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2011039964A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2012127590A1 (en) * | 2011-03-18 | 2012-09-27 | 富士通株式会社 | Endian conversion method and system |
CN112835842A (en) * | 2021-03-05 | 2021-05-25 | 深圳市汇顶科技股份有限公司 | Terminal sequence processing method, circuit, chip and electronic terminal |
-
2009
- 2009-08-18 JP JP2009189097A patent/JP2011039964A/en active Pending
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2012127590A1 (en) * | 2011-03-18 | 2012-09-27 | 富士通株式会社 | Endian conversion method and system |
JP5733385B2 (en) * | 2011-03-18 | 2015-06-10 | 富士通株式会社 | Endian conversion method and system |
US9448931B2 (en) | 2011-03-18 | 2016-09-20 | Fujitsu Limited | Endian conversion method and system |
CN112835842A (en) * | 2021-03-05 | 2021-05-25 | 深圳市汇顶科技股份有限公司 | Terminal sequence processing method, circuit, chip and electronic terminal |
CN112835842B (en) * | 2021-03-05 | 2024-04-30 | 深圳市汇顶科技股份有限公司 | Terminal sequence processing method, circuit, chip and electronic terminal |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP5217929B2 (en) | Interrupt detection device and information processing system | |
JP2008090375A (en) | Interrupt control system and storage control system using the same | |
KR101913968B1 (en) | Micro computer | |
JP5128093B2 (en) | Device that invalidates multiple address cache entries | |
JP2013092852A (en) | Bus connection circuit, semiconductor device, and operation method for bus connection circuit | |
JP5664187B2 (en) | Interconnect apparatus and control method thereof | |
JP2011039964A (en) | Endian conversion circuit, endian conversion method and microcontroller | |
JP2000322259A (en) | Data processor | |
WO2009098737A1 (en) | External device access apparatus, its controlling method and system lsi | |
CN104750634B (en) | Read method and system, InterWorking Equipment controller | |
JP2006243811A (en) | Dma transfer system and dma transfer method | |
JP2004355432A (en) | Endian conversion circuit | |
US20020188771A1 (en) | Direct memory access controller for carrying out data transfer by determining whether or not burst access can be utilized in an external bus and access control method thereof | |
JP3611049B2 (en) | Internal register circuit | |
TWI427481B (en) | A bridge system, a device and a method of the isa bus | |
JP5364641B2 (en) | Information processing device | |
JP2005148904A (en) | Ring buffer controller and ring buffer control method | |
JP6570046B2 (en) | DMA controller, realization method and computer storage medium | |
JP3269435B2 (en) | Bus interface unit | |
JP4860811B2 (en) | Microcomputer | |
JPH09305530A (en) | Dma controller | |
JP2004118235A (en) | Data processor | |
JPH02287625A (en) | Single chip microcomputer | |
JP2004280664A (en) | Bit arithmetic unit | |
KR20050037695A (en) | Flash memory controller |