JP4507888B2 - Microcomputer - Google Patents
Microcomputer Download PDFInfo
- Publication number
- JP4507888B2 JP4507888B2 JP2005009413A JP2005009413A JP4507888B2 JP 4507888 B2 JP4507888 B2 JP 4507888B2 JP 2005009413 A JP2005009413 A JP 2005009413A JP 2005009413 A JP2005009413 A JP 2005009413A JP 4507888 B2 JP4507888 B2 JP 4507888B2
- Authority
- JP
- Japan
- Prior art keywords
- instruction
- general
- compare
- purpose register
- value
- 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.)
- Expired - Fee Related
Links
- 230000006870 function Effects 0.000 claims description 100
- 238000005070 sampling Methods 0.000 claims description 83
- 230000002093 peripheral effect Effects 0.000 claims description 40
- 238000012545 processing Methods 0.000 claims description 33
- 206010048669 Terminal state Diseases 0.000 claims description 11
- 238000000034 method Methods 0.000 description 17
- 238000004891 communication Methods 0.000 description 15
- 238000010586 diagram Methods 0.000 description 13
- 230000005540 biological transmission Effects 0.000 description 10
- 230000000630 rising effect Effects 0.000 description 9
- 238000001514 detection method Methods 0.000 description 8
- 230000001360 synchronised effect Effects 0.000 description 7
- 101100172132 Mus musculus Eif3a gene Proteins 0.000 description 5
- 238000003708 edge detection Methods 0.000 description 3
- 238000012544 monitoring process Methods 0.000 description 2
- 238000004458 analytical method Methods 0.000 description 1
- 238000001914 filtration Methods 0.000 description 1
- 238000009432 framing Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/30—Arrangements for executing machine instructions, e.g. instruction decode
- G06F9/30181—Instruction operation extension or modification
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/30—Arrangements for executing machine instructions, e.g. instruction decode
- G06F9/38—Concurrent instruction execution, e.g. pipeline or look ahead
- G06F9/3836—Instruction issuing, e.g. dynamic instruction scheduling or out of order instruction execution
- G06F9/3851—Instruction issuing, e.g. dynamic instruction scheduling or out of order instruction execution from multiple instruction streams, e.g. multistreaming
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Multimedia (AREA)
- Executing Machine-Instructions (AREA)
- Microcomputers (AREA)
Description
本発明は、複数のタスクを時分割並行処理可能であると共に、それらの内少なくとも1つのタスクは、命令アドレスを指し示すプログラムカウンタの増分が一定となるよう、分岐命令が禁止され固定ループ化されたプログラムが記述された特定タスクとなっているマイクロコンピュータに関する。 In the present invention, a plurality of tasks can be processed in a time-sharing parallel manner , and at least one of these tasks has a branch loop prohibited and a fixed loop so that the increment of the program counter indicating the instruction address is constant . The present invention relates to a microcomputer that is a specific task in which a program is described.
CPUにROM,RAMやその他の周辺機能などを加えて構成されるマイクロコンピュータを様々なユーザアプリケーションに適用する場合は、一般に、夫々のアプリケーションで要求される機能に応じてハードウエアを変更する必要があり、製品のバリエーションが多くなってしまうという問題がある。
そこで、周辺機能としての動作をソフトウエアによって実現する構成が考えられている。例えば、特許文献1には、1つのCPUにおいて2つのタスク(A,L)を時分割並行的に処理し、Lタスクでは分岐命令の実行を禁止して固定ループ化することで、プログラムカウンタの値をタイマとして使用したり、Aタスクの暴走監視処理を行なわせるようにしたマイクロコンピュータが開示されている。
When a microcomputer configured by adding ROM, RAM, and other peripheral functions to a CPU is applied to various user applications, it is generally necessary to change the hardware according to the functions required for each application. There is a problem that the variation of the product increases.
Therefore, a configuration has been considered in which operations as peripheral functions are realized by software. For example, in
しかしながら、特許文献1のマイコンにおいて、例えば、特定の入力端子のレベル変化に応じてタイマ値を取得する、所謂「インプットキャプチャ」機能や、シリアル通信といったようなより複雑な周辺機能を実現しようとすると、プログラムサイズが非常に大きくなってしまうという問題がある。
また、特許文献2には、マイクロコンピュータが実行する命令機能を拡張するため、プログラムに記述されているターゲット命令の直前にプリフィックス命令を配置するようにして、そのプリフィックス命令にセットするフラグの状態に応じて前記ターゲット命令の機能を拡張するようにした構成が開示されている。
Further, in
しかしながら、特許文献2の技術では、命令機能を拡張するためには必ずプリフィックス命令を挿入する必要があるため、やはりプログラムサイズが増加してしまう。
本発明は上記事情に鑑みてなされたものであり、その目的は、プログラムサイズの増加を極力抑制した上で、多様な周辺機能をソフトウエアによって実現することができるマイクロコンピュータを提供することにある。
However, in the technique of
The present invention has been made in view of the above circumstances, and an object thereof is to provide a microcomputer capable of realizing various peripheral functions by software while suppressing an increase in program size as much as possible. .
請求項1記載のマイクロコンピュータによれば、CPUは、特定タスクに記述されている周辺機能命令を1命令として実行処理可能に構成されている。そして、オペランドで指定されている汎用レジスタより周辺機能命令の実行に要する情報を取得する共に、当該命令の実行結果に関する情報を汎用レジスタに格納する。具体的には、周辺機能命令は、プログラムカウンタのカウンタ値を、タイマカウンタのカウンタ値として汎用レジスタに格納するか、又は汎用レジスタに格納されている値と比較するか、又は汎用レジスタに格納されている値に加算する何れかの命令である。従って、周辺機能をソフトウエアによって実現するためのプログラムの記述が極めて簡単になり、プログラムサイズを小さくすることができる。また、汎用レジスタのビットは、CPUに通常用意されている命令によって操作可能であるから、周辺機能命令を実行させるために、プリフィックス命令のような特殊な命令を別途用意する必要がない。尚、ここで言う「周辺機能をソフトウエアによって実現する」とは、本発明のマイクロコンピュータにおけるCPUの内部構成であるハードウエアと、当該CPUが実行するプログラムとの協働によって周辺機能を実現することを示す。
According to the microcomputer of the first aspect, the CPU is configured to be capable of executing the peripheral function instruction described in the specific task as one instruction. Then, information necessary for executing the peripheral function instruction is acquired from the general-purpose register specified by the operand, and information related to the execution result of the instruction is stored in the general-purpose register. Specifically, the peripheral function instruction stores the counter value of the program counter in the general-purpose register as the counter value of the timer counter, compares it with the value stored in the general-purpose register, or stores it in the general-purpose register. Any instruction that adds to the value being Therefore, the description of the program for realizing the peripheral function by software becomes extremely simple, and the program size can be reduced. Further, since the bits of the general-purpose register can be manipulated by instructions normally prepared in the CPU, it is not necessary to separately prepare special instructions such as prefix instructions in order to execute peripheral function instructions. Here, “peripheral function is realized by software” means that the peripheral function is realized by the cooperation of the hardware of the CPU in the microcomputer of the present invention and the program executed by the CPU. It shows that.
請求項2記載のマイクロコンピュータによれば、CPUは、インプットキャプチャ命令を実行する場合、タイマ値を取得する条件となる入力端子のエッジ指定情報を汎用レジスタより取得する。そして、汎用レジスタに格納される、前回サンプリングした入力端子のレベルと、当該入力端子の現在のレベルとを比較すれば取得条件(エッジの立上がり,立下りなど)の成立を判定することができ、条件成立時に取得したタイマカウンタの値をキャプチャ値として格納すると共に、インプットキャプチャが成立したことを示すフラグを格納する。従って、予め通常命令によって汎用レジスタにエッジ指定情報をセットした後、インプットキャプチャ命令を実行することで、ソフトウエアによってインプットキャプチャ機能を実現することができる。 According to the microcomputer of the second aspect, when executing the input capture instruction, the CPU acquires edge designation information of the input terminal which is a condition for acquiring the timer value from the general-purpose register. Then, by comparing the level of the input terminal sampled last time stored in the general-purpose register with the current level of the input terminal, it is possible to determine whether the acquisition condition (rising edge, falling edge, etc.) is satisfied, The value of the timer counter acquired when the condition is satisfied is stored as a capture value, and a flag indicating that input capture is satisfied is stored. Therefore, the input capture function can be realized by software by executing the input capture instruction after setting the edge designation information in the general-purpose register in advance by the normal instruction.
請求項3記載のマイクロコンピュータによれば、CPUは、サンプリングコンペア命令を実行する場合、汎用レジスタにセットされるコンペア周期値を取得する。また、汎用レジスタには、サンプリングタイミング毎にコンペア周期値を累積加算したデータをコンペア値として格納し、そのコンペア値とタイマカウンタ値とが一致した場合に、サンプリング結果及び成立フラグを汎用レジスタに格納する。従って、予め通常命令によって汎用レジスタにコンペア周期値をセットした後サンプリングコンペア命令を実行することで、ソフトウエアによってサンプリングコンペア機能を実現できる。 According to the microcomputer of the third aspect, when executing the sampling compare instruction, the CPU acquires a compare cycle value set in the general-purpose register. In the general-purpose register, data obtained by cumulatively adding the compare cycle values at each sampling timing is stored as a compare value. When the compare value matches the timer counter value, the sampling result and establishment flag are stored in the general-purpose register. To do. Therefore, a sampling compare function can be realized by software by executing a sampling compare instruction after setting a compare cycle value in a general-purpose register in advance by a normal instruction.
請求項4記載のマイクロコンピュータによれば、CPUは、インプットコンペアセット命令を実行する場合、汎用レジスタにセットされるコンペア周期値及びコンペアセット条件となる入力端子のエッジ指定情報を取得する。そして、コンペアセット条件が成立すると、その時点のタイマカウンタの値にコンペア周期値を加算した値をコンペア値として汎用レジスタに格納すると共に成立フラグを格納する。従って、予め通常命令によって汎用レジスタにコンペア周期値及びエッジ指定情報をセットした後インプットコンペアセット命令を実行することで、ソフトウエアによってインプットコンペアセット機能を実現できる。 According to the microcomputer of the fourth aspect, when executing the input compare set instruction, the CPU acquires the compare period value set in the general-purpose register and the edge designation information of the input terminal which becomes the compare set condition. When the compare set condition is satisfied, a value obtained by adding the compare cycle value to the value of the timer counter at that time is stored as a compare value in the general-purpose register and the satisfied flag is stored. Therefore, the input compare set function can be realized by software by executing the input compare set instruction after setting the compare cycle value and edge designation information in the general-purpose register in advance by a normal instruction.
請求項5記載のマイクロコンピュータによれば、CPUは、条件付サンプリング命令を実行する場合、汎用レジスタに条件フラグがセットされたか否か判断する。そして、条件フラグのセットを認識すると、汎用レジスタにサンプリング結果及び成立フラグを格納する。従って、特定タスクを実行している間に所定の条件が成立した場合に、通常命令によって汎用レジスタに条件フラグをセットすることで、ソフトウエアによって条件付サンプリング機能を実現できる。 According to the microcomputer of the fifth aspect, when executing the conditional sampling instruction, the CPU determines whether or not the condition flag is set in the general-purpose register. When the condition flag set is recognized, the sampling result and the establishment flag are stored in the general-purpose register. Therefore, when a predetermined condition is satisfied while executing a specific task, a conditional sampling function can be realized by software by setting a condition flag in a general-purpose register by a normal instruction.
請求項6記載のマイクロコンピュータによれば、CPUは、入力処理系の命令を実行する場合、汎用レジスタに前回の入力端子の状態と今回の入力端子の状態とを格納して、両者の値が一致した場合に、前記入力処理系命令の実行を許可する2度一致フィルタ機能を備える。ここで言う「入力処理系の命令」とは、請求項2乃至5における「インプットキャプチャ命令」,「サンプリングコンペア命令」,「インプットコンペアセット命令」,「条件付サンプリング命令」を示す。従って、入力信号又はデータの状態が安定したことを確認した段階で、入力処理系命令を実行することができる。
請求項7記載のマイクロコンピュータによれば、CPUは、汎用レジスタにおけるビットの設定に応じて2度一致フィルタ機能の実行可否を選択可能に構成されるので、当該フィル多機能の要否を、ユーザのアプリケーションに応じて選択することができる。
According to the microcomputer of the sixth aspect, when the CPU executes the instruction of the input processing system, the CPU stores the state of the previous input terminal and the state of the current input terminal in the general-purpose register, and the values of both are stored. In case of a match, it has a double match filter function that permits execution of the input processing system instruction. The “input processing instructions” referred to here are “input capture instructions”, “sampling compare instructions”, “input compare set instructions”, and “conditional sampling instructions” in
According to the microcomputer of the seventh aspect, the CPU is configured to be able to select whether or not to execute the coincidence filter function according to the bit setting in the general-purpose register. Can be selected according to the application.
請求項8記載のマイクロコンピュータによれば、CPUは、アウトプットコンペア命令を実行する場合、汎用レジスタにセットされるコンペア周期値及び出力レベル指定条件を取得する。また、汎用レジスタには、サンプリングコンペア命令の場合と同様に、コンペア周期値が累積加算されたデータをコンペア値として格納し、そのコンペア値とタイマカウンタ値とが一致すれば、指定されたレベルを出力端子より出力すると共に成立フラグを汎用レジスタに格納する。従って、予め通常命令によって汎用レジスタにコンペア周期値をセットした後アウトプットコンペア命令を実行することで、ソフトウエアによってアウトプットコンペア機能を実現できる。 According to the microcomputer of the eighth aspect, when executing the output compare instruction, the CPU acquires the compare cycle value and the output level designation condition set in the general-purpose register. Similarly to the sampling compare instruction, the general-purpose register stores the data obtained by cumulatively adding the compare cycle values as a compare value. If the compare value matches the timer counter value, the specified level is stored. Output from the output terminal and store the establishment flag in the general-purpose register. Therefore, the output compare function can be realized by software by executing the output compare instruction after setting the compare cycle value in the general-purpose register in advance by the normal instruction.
請求項9記載のマイクロコンピュータによれば、CPUは、条件付アウトプット命令を実行する場合、汎用レジスタにセットされる出力レベル指定条件を取得する。また、汎用レジスタに条件フラグがセットされたか否かを判断する。そして、条件フラグのセットを認識すると、前記指定条件に応じたレベルを出力端子に出力させると共に汎用レジスタに成立フラグを格納する。従って、予め通常命令によって汎用レジスタに出力レベル指定条件をセットした後、特定タスクを実行している間に所定の条件が成立した場合、通常命令によって汎用レジスタに条件フラグをセットすれば、ソフトウエアによって条件付アウトプット機能を実現できる。 According to the microcomputer of the ninth aspect, when the conditional output instruction is executed, the CPU acquires the output level designation condition set in the general-purpose register. Also, it is determined whether a condition flag is set in the general-purpose register. When the condition flag set is recognized, a level corresponding to the specified condition is output to the output terminal and the establishment flag is stored in the general-purpose register. Therefore, after setting the output level specification condition in the general-purpose register in advance by a normal instruction, if a predetermined condition is satisfied while executing a specific task, the software can be set by setting a condition flag in the general-purpose register by a normal instruction. A conditional output function can be realized.
以下、本発明の一実施例について図面を参照して説明する。図1は、マイクロコンピュータ10の構成を示す機能ブロック図である。マイクロコンピュータ10は、CPU11と、ROMにより構成されたプログラムメモリ12と、RAMにより構成されたデータメモリ13と、I/Oブロック14(入出力ピン)と、後述するCPU切替信号(クロック信号)を発生するタイミングジェネレータ(図示せず)と、データを送受信するデータバス15と、アドレス信号を送受信するアドレスバス16と、リード信号とライト信号をそれぞれ送受信するコントロールバス17,18とを備えている。
上記CPU11は、例えば、2種類のタスク(Lタスク,Aタスク)を時分割で並行にパイプライン処理するため2つのアドレスレジスタ19,20と2つの演算レジスタ21,22を備え、これらアドレスレジスタ19,20と演算レジスタ21,22をCPU切替信号により交互に切り替えることで、見掛上、2つのCPUを交互に切り替えて動作させるように機能する。
An embodiment of the present invention will be described below with reference to the drawings. FIG. 1 is a functional block diagram showing the configuration of the
The
この場合、一方のアドレスレジスタ19と演算レジスタ21がCPU0用(Lタスク用)のレジスタとなり、他方のアドレスレジスタ20と演算レジスタ22がCPU1用(Aタスク用)のレジスタとなる。これらアドレスレジスタ19,20の切替えに応じてプログラムカウンタ23の値(次にフェッチする命令のアドレス)が更新され、このプログラムカウンタ23からCPU0用(Lタスク用)とCPU1用(Aタスク用)のアドレス信号が交互にプログラムメモリ12に出力される。
In this case, one
また、CPU11内には、プログラムメモリ12から読み込まれた命令の属するタスクの種類を判別してそのエラーを検出するエラー検出手段たるエラー検出回路24と、このエラー検出回路24を通過した命令をデコード(解読)する命令デコーダ・命令シーケンサ25が設けられ、この命令デコーダ・命令シーケンサ(以下、単に命令デコーダと称す)25によりデコードした命令の内容に応じて、演算器26(ALU)で演算レジスタ21,22を用いて演算したり、リード信号又はライト信号をコントロールバス17,18に出力するようになっている。
Further, in the
一方、プログラムメモリ12内には、CPU0用(Lタスク用)のプログラム領域27と、CPU1用(Aタスク用)のプログラム領域28と、テーブル即値データ領域29とが設けられている。この場合、CPU0用のプログラム領域27に格納されたLタスクは、プログラム暴走に至る危険性のある分岐命令が禁止された固定ループ化されたプログラムで構成されている。これにより、Lタスクのプログラムの実行時には0番地から2バイト命令アクセスで実行を開始し、2番地,4番地,6番地,…と順々に命令を実行していき、その後、所定番地まで行くと、プログラムカウンタ23がオーバーフローして0番地に戻り、以後、上述した番地順の命令実行を繰り返すようになる。また、このLタスクは、命令が全て1ワード(2バイト)命令に固定されている。
On the other hand, in the
Lタスク(特定タスク)は、シーケンス制御の処理を行うのに適し、そのプログラム中に、Aタスクの暴走監視用のルーチンと、システムのフェイルセーフを成立させるためのバックアップシーケンス用のルーチンが含まれている。更に、このLタスクは、固定ループ動作によるタイマとしての機能も備え、例えばインクリメント命令又はデクリメント命令を実行させてそのカウント値が所定の設定値に達したときに、Aタスクの処理に割込みを発生させることでタイマ割込みと等価な定時間処理が可能となっている。
一方、Aタスクは、Lタスクで禁止されている分岐命令も許容されており、例えば複雑な解析処理・数値処理に適している。このAタスクについても、Lタスクと同じく、命令が全て1ワード命令に固定されている。このAタスクとLタスクは、1ワード内にオペコードとオペランド(アドレス)の両方が割り付けられている。
The L task (specific task) is suitable for performing sequence control processing, and the program includes a routine for monitoring runaway of the A task and a routine for backup sequence for establishing system fail-safety. ing. Furthermore, this L task also has a function as a timer by a fixed loop operation. For example, when an increment instruction or a decrement instruction is executed and the count value reaches a predetermined set value, an interrupt is generated in the processing of the A task. This makes it possible to perform fixed-time processing equivalent to timer interrupts.
On the other hand, for the A task, branch instructions prohibited by the L task are also permitted, and are suitable for, for example, complex analysis processing and numerical processing. As for the A task, as in the L task, all instructions are fixed to a one-word instruction. In the A task and the L task, both an operation code and an operand (address) are allocated in one word.
次に、上記構成のマイクロコンピュータ採用しているパイプライン制御方式について図2に基づいて説明する。このパイプラインは、例えば、命令フェッチ,命令デコード,命令実行の各ステージからなる3段のパイプラインとして構成され、全命令がこの3段のパイプラインで遅滞なく処理できるように設計されている。各ステージはそれぞれ1サイクルで実行され、3サイクルで1命令を実行するようになっているが、3段のパイプラインにより3つの命令を並行処理することで、見掛上、1命令を1サイクルで実行するのと等価となっている。 Next, a pipeline control system adopting the microcomputer having the above configuration will be described with reference to FIG. This pipeline is configured as, for example, a three-stage pipeline including instruction fetch, instruction decode, and instruction execution stages, and is designed so that all instructions can be processed without delay in the three-stage pipeline. Each stage is executed in one cycle, and one instruction is executed in three cycles, but apparently one instruction is processed in one cycle by processing three instructions in parallel by a three-stage pipeline. Is equivalent to running
1サイクル(各ステージ)の時間は、CPU切替信号(クロック信号)により規定されている。このCPU切替信号は、ローレベルの時間TLoとハイレベルの時間THiとが同一であり、ローレベル期間でCPU0(Lタスク)の命令フェッチを行い、ハイレベル期間でCPU1(Aタスク)の命令フェッチを行うことにより、CPU0(Lタスク)とCPU1(Aタスク)の両プログラムを1:1の時分割比で並行にパイプライン処理するようになっている。
更に、CPU1がAタスクのプログラムに含まれる分岐命令をフェッチしたときには、当該分岐命令が含まれるAタスクの次の命令フェッチステージで分岐先アドレスの命令をフェッチするために、命令デコードステージで分岐先アドレスをセットするように構成されている。また、図2では、パイプライン処理中に、CPU1のY+1番地の命令が分岐命令(JMP)である場合の処理タイミングが示されている。
The time for one cycle (each stage) is defined by a CPU switching signal (clock signal). This CPU switching signal has the same low-level time TLo and high-level time THi, and CPU0 (L task) instruction fetch is performed during the low level period, and CPU1 (A task) instruction fetch is performed during the high level period. By doing this, both the CPU0 (L task) and CPU1 (A task) programs are pipelined in parallel at a time division ratio of 1: 1.
Further, when the
CPU11は、プログラムカウンタ23に異なる命令アドレスを順次セットするための複数のアドレスレジスタと19,20と、命令デコーダ25によってデコードされた命令を、演算器26に順次セットするための複数の演算レジスタ(命令レジスタ)21,22とを備え、前記複数のアドレスレジスタ19,20及び複数の演算レジスタ21,22を順次切替えることで、プログラムメモリ12に記憶されている複数のプログラム27,28をパイプライン処理可能に構成されている。
The
また、CPU11の命令セットとして、後述する「周辺機能命令」が用意されている。この「周辺機能命令」とは、従来はCPU11の外部に構成されたハードウエアを利用して実現していた処理を、CPU11がLタスクにおいてソフトウエア的に処理するために用意された命令である。そして、命令デコーダ25及び演算器26は、周辺機能命令を、パイプライン処理の実行ステージにおいて1サイクルで実行するように構成されている。
Further, as a command set of the
汎用レジスタ30は、通常は例えばCPU11の周辺回路に対してロード命令が実行された場合に、データバス15を介して読み出されたデータが格納されるものである。本実施例の汎用レジスタ30は、命令デコーダ25が命令のデコード動作を行なった結果、当該命令が「周辺機能命令」であった場合、一部のビットに入力端子31の入力信号レベルが格納されたり、或いは、一部のビットに設定されたデータに応じた信号を、出力端子32を介して出力することが可能となるように構成されている。また、汎用レジスタ30とプログラムカウンタ23との間で、データの転送も可能となっている。尚、実際には、汎用レジスタ30,入力端子31,出力端子32は夫々複数存在するが、図示の都合上図1では夫々1つだけ示している。
The general-
次に、本実施例の作用について図3乃至図15も参照して説明する。以降に示す図3乃至図8は、何れもCPU11が周辺機能命令を実行した場合における(a)汎用レジスタ30における各ビットの設定状態、(b)命令デコーダ25又は演算器26において、パイプライン処理の実行ステージにおいて1サイクルで(ハードウエアにより)実行される処理の内容をC言語で表現したもの、(c)実行形態の一例を示すタイミングチャート、である。
Next, the operation of the present embodiment will be described with reference to FIGS. FIGS. 3 to 8 shown below are the case where (a) the setting state of each bit in the general-
<インプットキャプチャ命令>
図3はインプットキャプチャ命令に関する内容を示す。インプットキャプチャ機能は、特定のトリガ信号が与えられたタイミングでフリーランカウンタのカウント値を読み込むものである。例えば、入力端子の信号エッジ間の時間を計測する際や、単なるエッジ検出にも使用される。本実施例では、CPU11がLタスクにおいて記述されたインプットキャプチャ命令を実行する場合は、プログラムカウンタ23のカウント値をタイマカウンタとして使用することで、CPU11の内部でソフトウエア的に処理する。
尚、ここで「ソフトウエア的に処理する」とは、CPU11の外部に設けられたハードウエアを利用して行う処理に対して、CPU11の内部において完結する処理を意味する。即ち、CPU11の内部ロジックなどが動作する部分も含めて「ソフトウエア的」と称している。
<Input capture instruction>
FIG. 3 shows the contents related to the input capture instruction. The input capture function reads the count value of the free-run counter at a timing when a specific trigger signal is given. For example, it is used when measuring the time between signal edges of the input terminal or for simple edge detection. In the present embodiment, when the
Here, “processing in software” means processing completed inside the
図3(a)に示すように、インプットキャプチャ命令が実行される場合、汎用レジスタ30の1つであるレジスタRmの各ビットは、以下のように割り当てが行なわれる。
ビット
15 :現在の入力端子の状態(レベル)
14 :前回の入力端子の状態(レベル)
13 :入力端子のサンプリング値(レベル)
11 :2度一致フィルタ許可/禁止
10,9:入力端子の信号エッジ指定
8 :インプットキャプチャ成立フラグ
7〜0:キャプチャ値
尚、これらのうち、ビット11における2度一致フィルタの許可/禁止や、ビット10,9における入力端子の信号エッジ指定は、Aタスク側に記述されているロード命令によって予めレジスタRmにセットされ、インプットキャプチャ命令では、オペランドでレジスタRmを指定する。
As shown in FIG. 3A, when the input capture instruction is executed, each bit of the register Rm, which is one of the general purpose registers 30, is assigned as follows.
Bit 15: Current input terminal state (level)
14: Previous input terminal state (level)
13: Sampling value (level) of input terminal
11: Double match filter enable / disable 10, 9: Signal edge specification of input terminal 8: Input capture establishment flag 7-0: Capture value Of these, the double match filter in
そして、インプットキャプチャ命令は、実行ステージにおいて図3(b)に示すような処理内容が実行される。尚、図3(b)に示す手順がプログラム的に1ステップずつ実行されるわけではなく、インプットキャプチャ命令が実行される場合に、これらの処理が命令デコーダ25または演算器26のロジックにより1サイクルで実行される。
即ち、ビット13で2度一致フィルタ許可が設定されている場合、ビット15,14の排他的論理和が成立し両者が不一致であれば、ビット15の内容がビット14に転送される。両者が一致した場合も、同様にその時点のビット15の内容がビット14に転送される。また、フィルタ禁止が設定されている場合は、最初の不一致判定を行うことなくビット15の内容がビット14に転送される。それから、入力端子31のエッジ判定を行う。
The input capture instruction is executed in the execution stage as shown in FIG. 3B. Note that the procedure shown in FIG. 3B is not executed programmatically step by step, but when an input capture instruction is executed, these processes are performed in one cycle by the logic of the
That is, when the coincidence filter permission is set in
エッジ判定は、現時点の入力端子31のレベルであるビット15と、前回同じ命令が実行された場合の入力端子31のレベルがサンプリング値として格納されているビット13とが比較され、両者が一致していれば入力レベルの変化がなくエッジは検出されず、ビット15の内容をビット13に転送して終了する。
一方、ビット15,13が不一致であれば入力端子31のレベルが変化してエッジが検出されたことになる。この場合、ビット10,9で指定されたエッジの条件(立上がり,立下り,何れかのエッジ)が成立しているかどうかを判断し、当該条件が成立していればプログラムカウンタ23の値をレジスタRmのビット7:0に格納すると共に、ビット8に成立フラグを立てて処理を終了する。尚、各入力端子31の指定は、デフォルトで固定であっても、例えば、他の汎用命令を使用して指定可能としても良い。
In the edge determination, the
On the other hand, if the
ここで、上記のインプットキャプチャ機能を、CPU11の外部に回路を設けて実現することを想定すると、一般に、以下のような回路が必要となる。
(1)フリーランタイマ
(2)フリーランタイマのカウント値を格納するキャプチャレジスタ
(3)トリガとするエッジの指定や、2度一致フィルタの有無を選択するため
のコントロールレジスタ
これに対して、本実施例では、(1)はプログラムカウンタ23が対応し、(2)及び(3)はレジスタRmが対応することで、ハードウエアとしてはCPU11単体でインプットキャプチャ機能を実現している。
Here, assuming that the above-described input capture function is realized by providing a circuit outside the
(1) Free-run timer (2) Capture register that stores the count value of the free-run timer (3) Control register for specifying the trigger edge and the presence / absence of the double match filter In the embodiment, (1) corresponds to the
<サンプリングコンペア命令>
図4はサンプリングコンペア命令に関する内容を示す。サンプリングコンペア機能は、指定されたサンプリング周期が経過する毎に入力端子31のレベルをサンプリングするものである。この場合も、プログラムカウンタ23のカウント値をタイマカウンタとして使用する。
<Sampling compare instruction>
FIG. 4 shows the contents relating to the sampling compare instruction. The sampling compare function samples the level of the
図4(a)に示すように、サンプリングコンペア命令が実行される場合、汎用レジスタ30におけるレジスタRm,Rnの各ビットは、以下のように割り当てが行なわれる。
レジスタRm ビット
15 :現在の入力端子の状態(レベル)
14 :前回の入力端子の状態(レベル)
13 :入力端子のサンプリング値(レベル)
12 :サンプリング結果(1ビットの場合)
11 :2度一致フィルタ許可/禁止
10,9:サンプリングの指定
8 :サンプリングコンペア成立フラグ
7〜0:コンペア値
レジスタRn ビット
15〜8 :サンプリング結果(1バイトの場合)
7〜0 :コンペア周期
As shown in FIG. 4A, when the sampling compare instruction is executed, the bits of the registers Rm and Rn in the general-
Register Rm bit
15: Current input terminal state (level)
14: Previous input terminal state (level)
13: Sampling value (level) of input terminal
12: Sampling result (1 bit)
11: Double match filter enable / disable
10, 9: Specifying sampling
8: Sampling compare establishment flag
7 to 0: Compare value register Rn bit
15 to 8: Sampling result (in the case of 1 byte)
7 to 0: Compare cycle
そして、サンプリングコンペア命令は、図4(b)に示すような処理内容が実行される。2度一致フィルタに関する処理は、ビット15,14が不一致であれば、ビット15の内容をビット14に転送する。両者が一致した場合、若しくはフィルタ禁止が設定されている場合は、ビット15の内容がビット14,13に夫々転送される。それから、プログラムカウンタ23のカウント値がレジスタRmのビット7:0以上となった場合、即ちコンペア周期Δtが経過すると、レジスタRnのビット7:0がレジスタRmのビット7:0に加算されて次回のコンペア値がセットされる。そして、ビット8に成立フラグを立てると、レジスタRmのビット10,9で指定された態様に応じてサンプリングを行う。サンプリング指定は、例えば以下のように設定される。
ビット10,9 サンプリング態様
00 1ビット
01 不履行
10 1バイト(左シフト)
11 1バイト(右シフト)
尚、左シフトはMSBファーストに対応し、レジスタRnを1ビットずつ左シフトさせながら、レジスタRmのビット13をレジスタRnのビット8側から格納する。また、右シフトはLSBファーストに対応しており、レジスタRnを1ビットずつ右シフトさせながら、レジスタRmのビット13をレジスタRnのビット15側から格納する。
The sampling compare instruction executes the processing contents as shown in FIG. In the process related to the twice match filter, if the
00 1 bit
01 default
10 1 byte (left shift)
11 1 byte (right shift)
Note that the left shift corresponds to MSB first, and the
<アウトプットコンペア命令>
図5はアウトプットコンペア命令に関する内容を示す。アウトプットコンペア機能は、指定されたコンペア周期が経過する毎に出力端子より出力を行うものである。例えば、PWM信号の出力や、マイクロコンピュータ10がスリープモードに移行した場合に、その移行している時間を計測するためのスリープタイマに連動して信号の出力を行う場合などに使用される。この場合も、プログラムカウンタ23のカウント値をタイマカウンタとして使用する。
<Output compare instruction>
FIG. 5 shows the contents relating to the output compare instruction. The output compare function performs output from the output terminal every time a designated compare cycle elapses. For example, it is used when outputting a PWM signal or outputting a signal in conjunction with a sleep timer for measuring the time when the
図5(a)に示すように、アウトプットコンペア命令が実行される場合、汎用レジスタ30におけるレジスタRm,Rnの各ビットは、以下のように割り当てが行なわれる。
レジスタRm ビット
15 :出力端子のレベル設定
11〜9:出力レベルの指定
8 :アウトプットコンペア成立フラグ
7〜0:コンペア値
レジスタRn ビット
15〜8 :出力データ(1バイトの場合)
7〜0 :コンペア周期
As shown in FIG. 5A, when the output compare instruction is executed, each bit of the registers Rm and Rn in the general-
Register Rm bit
15: Output terminal level setting
11-9: Designation of output level
8: Output compare establishment flag
7 to 0: Compare value register Rn bit
15 to 8: Output data (1 byte)
7 to 0: Compare cycle
尚、出力指定及びコンペア周期は、アウトプットコンペア命令の実行前に他の命令によりセットされる。そして、アウトプットコンペア命令は、以下のように実行される。まず、プログラムカウンタ23のカウント値がレジスタRmのビット7:0以上となった場合、即ちコンペア周期Δtが経過すると、レジスタRnのビット7:0がレジスタRmのビット7:0に加算されて次回のコンペア値がセットされる。それから、ビット8に成立フラグを立てると、レジスタRmのビット11〜9で指定された態様に応じて出力を行う。出力レベル指定は、例えば以下のように設定される。
ビット11〜9 サンプリング態様
000 出力なし
001 「L」出力
010 「H」出力
011 現在のレベルの反転
100 出力なし
101 出力なし
110 1バイト出力(右シフト)
111 1バイト出力(左シフト)
尚、1バイト出力の右シフトはLSBファーストに対応し、レジスタRnのビット8をレジスタRmのビット15に格納すると、レジスタRnのビット15〜8を1ビット右シフトさせる。また、1バイト出力の左シフトはMSBファーストに対応しており、レジスタRnのビット15をレジスタRmのビット15に格納すると、レジスタRnのビット15〜8を1ビット左シフトさせる。
Note that the output designation and the compare cycle are set by another instruction before the output compare instruction is executed. The output compare instruction is executed as follows. First, when the count value of the
Bits 11-9 Sampling mode
000 No output
001 “L” output
010 “H” output
011 Invert current level
100 No output
101 No output
110 1 byte output (right shift)
111 1 byte output (left shift)
The right shift of 1-byte output corresponds to LSB first. When
<インプットコンペアセット命令>
図6はインプットコンペアセット命令に関する内容を示す。インプットコンペアセット機能は、入力端子31の指定されたエッジを検出した場合に、コンペア値をセットするものである。この場合も、プログラムカウンタ23のカウント値をタイマカウンタとして使用する。尚、2度一致フィルタに関する処理は、インプットキャプチャ命令の場合と同様である。
<Input compare set instruction>
FIG. 6 shows the contents relating to the input compare set instruction. The input compare set function sets a compare value when a specified edge of the
図6(a)に示すように、インプットコンペアセット命令が実行される場合、汎用レジスタ30におけるレジスタRm,Rnの各ビットは以下のように割り当てが行なわれる。
レジスタRm ビット
15 :現在の入力端子の状態(レベル)
14 :前回の入力端子の状態(レベル)
13 :入力端子のサンプリング値(レベル)
11 :2度一致フィルタ許可/禁止
10,9:エッジの指定
8 :インプットコンペアセット成立フラグ
7〜0:コンペアセット値
レジスタRn ビット
7〜0:コンペア値
尚、エッジの指定及びコンペアセット値は、インプットコンペアセット命令の実行前に他の通常命令によりセットされる。そして、インプットコンペアセット命令は、以下のように実行される。尚、2度一致フィルタに関する処理はインプットキャプチャ命令等と同様であるから省略する。まず、ビット15の内容がビット14に夫々転送される。それから、インプットキャプチャ命令の場合と同様に入力端子31についてエッジ判定が行われ、エッジが検出され且つエッジ条件が成立すると、プログラムカウンタ23のカウント値にレジスタRmのビット7:0を加算した値をレジスタRnのビット7:0にセットする。そして、ビット8に成立フラグを立てる。このインプットコンペアセット命令は、図6(c)に示すように、例えば信号の立下りエッジを検出した時点にコンペアセット値Δtをセットする場合などに使用する。
As shown in FIG. 6A, when the input compare set instruction is executed, each bit of the registers Rm and Rn in the general-
Register Rm bit
15: Current input terminal state (level)
14: Previous input terminal state (level)
13: Sampling value (level) of input terminal
11: Double match filter enable / disable
10, 9: Edge specification
8: Input compare set establishment flag
7 to 0: Compare set value register Rn bit
7 to 0: Compare value The edge designation and compare set value are set by another normal instruction before the execution of the input compare set instruction. The input compare set instruction is executed as follows. Note that the process related to the twice match filter is the same as that for the input capture command and the like, and is therefore omitted. First, the contents of
<条件付サンプリング命令>
図7は条件付サンプリング命令に関する内容を示す。条件付サンプリング機能は、何らかの処理の結果により条件フラグがセットされた場合に入力端子31のレベルをサンプリングするものである。図7(a)に示すように、条件付サンプリング命令が実行される場合、レジスタRmの各ビットには、以下のように割り当てが行なわれる。
ビット
15 :現在の入力端子の状態(レベル)
14 :前回の入力端子の状態
13 :入力端子のサンプリング値(レベル)
12 :サンプリング結果(1ビット)
11 :2度一致フィルタ許可/禁止
10,9:サンプリング指定
8 :条件付サンプリング成立フラグ
7〜0:サンプリング結果(1ビット)
また、レジスタRnのビット8には条件フラグが格納される。そして、図7(b)に示すように、条件フラグがセットされると2度一致フィルタ処理と共にサンプリング処理を行ない、条件フラグがセットされていなければ2度一致フィルタ処理だけを実行する。尚、何れの場合も、フィルタ処理はフィルタ許可フラグがセットされている場合に行われることは上述と同様である。
<Conditional sampling instruction>
FIG. 7 shows the contents related to the conditional sampling instruction. The conditional sampling function samples the level of the
Bit 15: Current input terminal state (level)
14: Previous input terminal state 13: Input terminal sampling value (level)
12: Sampling result (1 bit)
11: Double-match filter enable / disable 10, 9: Sampling designation 8: Conditional sampling establishment flag 7-0: Sampling result (1 bit)
A condition flag is stored in
サンプリング処理については、レジスタRmのビット8に成立フラグを立てると、サンプリングコンペア命令と同様のサンプリング指定に応じてサンプリングを行う。但し、1バイトサンプリングの場合、サンプリング結果はレジスタRmのビット7〜0に格納される。図7(c)は、例えばある入力端子31の立下がりエッジが検出されたことを条件としてサンプリングを行なう場合を示している。
As for the sampling process, when the establishment flag is set in
<条件付アウトプット命令>
図8は条件付アウトプット命令に関する内容を示す。条件付アウトプット機能は、何らかの処理の結果により条件フラグがセットされた場合に、指定されたレベルを出力端子より出力するものである。図8(a)に示すように、条件付アウトプット命令が実行される場合、レジスタRmの各ビットには、以下のように割り当てが行なわれる。
レジスタRm ビット
15 :出力端子のレベル設定
11〜9:出力レベルの指定
8 :アウトプットコンペア成立フラグ
7〜0:出力値(1バイト)
また、レジスタRnのビット8には条件フラグが格納される。そして、条件付アウトプット命令は、レジスタRnのビット8に条件フラグがセットされると、図8(b)に示すような処理内容として実行される。まず、レジスタRmのビット8に成立フラグを立てると、アウトプットコンペア命令と同様のアウトプット指定に応じて出力端子32より出力を行う。但し、1バイト出力の場合、レジスタRmのビット15にはビット7〜0にセットされたデータが1ビットずつシフトされながら与えられる。図8(c)は、例えばある入力端子31の立上がりエッジが検出されたことを条件として反転出力,出力無し,反転出力を行なう場合を示している。
<Conditional output instruction>
FIG. 8 shows the contents related to the conditional output instruction. The conditional output function outputs a specified level from an output terminal when a condition flag is set as a result of some processing. As shown in FIG. 8A, when a conditional output instruction is executed, each bit of the register Rm is assigned as follows.
Register Rm bit
15: Output terminal level setting
11-9: Designation of output level
8: Output compare establishment flag
7 to 0: Output value (1 byte)
A condition flag is stored in
[ケーススタディ:CSMA/CD,受信]
次に、図9乃至図15は、以上に説明した周辺機能命令(ペリフェラル命令)を使用してより具体的な機能の実現を図る例を示す。図9はLANにおいて利用される通信方式の1つであるCSMA/CD方式について、受信側の機能を実現する場合を示す。実現する機能は、以下のようになる。
(1)受信データRxの立下りを検出すると、
その時点からΔt2後に受信データRxをサンプリング
(2)(1)のサンプリング結果においてエッジが検出されなければ、更にΔt1(1ビット周期)後に受信データRxをサンプリングし、エッジが検出されれば(衝突検出)更にΔt2後に受信データRxをサンプリング(ビット同期)
ビット同期は、以下のように行なう。
前回の受信データ :0 → 立下りエッジで同期
前回の受信データ :1 → 立上りエッジで同期
ドミナント「0」送信中 → 立下りエッジで同期
ドミナント「1」送信中 → 立上りエッジで同期
上記機能は、
<インプットコンペアセット命令>
(1)受信データRxのエッジが検出されるとサンプリングタイミングをΔt2に変更
<サンプリングコンペア命令>
(2)Δt1毎に受信データRxをサンプリング
によって実現することができる。
[Case study: CSMA / CD, reception]
Next, FIG. 9 to FIG. 15 show an example in which a more specific function is realized by using the peripheral function instruction (peripheral instruction) described above. FIG. 9 shows a case where the function on the receiving side is realized for the CSMA / CD system which is one of the communication systems used in the LAN. The functions to be realized are as follows.
(1) When the falling edge of the received data Rx is detected,
Sampling of received data Rx after Δt2 from that point (2) If no edge is detected in the sampling result of (1), the received data Rx is further sampled after Δt1 (one bit period) and if an edge is detected (collision) Detection) Further sampling of received data Rx after Δt2 (bit synchronization)
Bit synchronization is performed as follows.
Previous received data: 0 → Synchronized on falling edge Previous received data: 1 → Synchronized on rising edge Dominant “0” transmitting → Synchronized on falling edge Dominant “1” transmitting → Synchronized on rising edge
<Input compare set instruction>
(1) When the edge of the received data Rx is detected, the sampling timing is changed to Δt2. <Sampling compare instruction>
(2) The reception data Rx can be realized by sampling every Δt1.
[ケーススタディ:CSMA/CD,送信]
図10はCSMA/CD方式における送信側の機能を実現するものである。機能の内容は、以下のようになる。
(1)一定周期(Δt1)毎に送信データを出力
(2)受信データレベルが変化してエッジを検出すると送信データを出力
これらの機能は、
<アウトプットコンペア命令>
(1)一定周期(Δt1)毎に送信データを出力端子より出力。
<インプットコンペアセット命令>
(2a)受信データRxのエッジを検出
この場合、当該命令の実行結果によりレジスタRmのビット8に成立フラグがセットされると、そのビット8の内容をレジスタRnのビット8に転送する。
<条件付アウトプット命令>
(2b)上記エッジの検出により、送信データを出力端子より出力
これらの周辺機能命令によって実現することができる。
[Case study: CSMA / CD, transmission]
FIG. 10 realizes the function on the transmission side in the CSMA / CD system. The contents of the function are as follows.
(1) Transmission data is output at regular intervals (Δt1) (2) Transmission data is output when the received data level changes and an edge is detected.
<Output compare instruction>
(1) Transmission data is output from the output terminal at regular intervals (Δt1).
<Input compare set instruction>
(2a) Detecting edge of received data Rx In this case, when the establishment flag is set in
<Conditional output instruction>
(2b) By detecting the edge, transmission data can be output from the output terminal and realized by these peripheral function instructions.
[ケーススタディ:イベントタイマ]
図11は、イベントタイマ機能を実現するものである。この機能は、
(1)入力端子31において信号エッジを検出
(2)エッジ検出からΔt後に入力端子31のレベルをサンプリング
であり、周辺機能命令によっては、
<インプットコンペアセット命令>
(1)入力端子31の信号エッジを検出してコンペア周期Δtを設定
<サンプリングコンペア命令>
(2)コンペア周期Δt経過時に入力端子31のレベルをサンプリング
で実現できる。
[Case study: Event timer]
FIG. 11 implements the event timer function. This feature
(1) A signal edge is detected at the
<Input compare set instruction>
(1) Detect signal edge of
(2) The level of the
[ケーススタディ:ポートサンプリング]
図12は、ポートサンプリング機能である。この機能は、
(1)任意のタイミングで、出力端子より信号を出力
(2)上記出力端子の信号エッジを検出すると、Δt後に入力端子31をサンプリング
である。また、サンプリングポートは、例えば「32」の内から選択可能である。これらの機能は、
<アウトプットコンペア命令>
(1)所定のカウント値にプログラムカウンタ23が一致すると、出力端子32(PSMOUT)より信号出力
<インプットコンペアセット命令>
(2a)上記出力端子32のエッジ検出により、コンペア周期を設定
(2b)上記コンペア周期にプログラムカウンタ23が一致すると、入力端子31をサンプリング
で実現することができる。
[Case study: Port sampling]
FIG. 12 shows the port sampling function. This feature
(1) A signal is output from the output terminal at an arbitrary timing. (2) When the signal edge of the output terminal is detected, the
<Output compare instruction>
(1) When the
(2a) The compare cycle is set by detecting the edge of the
[ケーススタディ:クロック同期シリアル]
図13は、クロック同期シリアル通信機能を実現する場合を示す。この通信機能は、以下のようになる。
(1)シリアルクロックSCLKの立下りエッジ検出で出力端子32(SOUT)より信号出力(送信)
(2)SCLKの立上りエッジ検出で入力端子31(SIN)をサンプリング(受信)
また、その他の機能として、外部クロック/内部クロック,LSB/MSBファースト,クロック極性の選択や、オーバーランエラーの検出などがある。
[Case study: Clock synchronous serial]
FIG. 13 shows a case where the clock synchronous serial communication function is realized. This communication function is as follows.
(1) Signal output (transmission) from output terminal 32 (SOUT) upon detection of falling edge of serial clock SCLK
(2) Sampling (receiving) the input terminal 31 (SIN) by detecting the rising edge of SCLK
Other functions include external clock / internal clock, LSB / MSB first, clock polarity selection, and overrun error detection.
上記(1),(2)の機能は、周辺機能命令によって以下のように実現される。
<インプットキャプチャ命令>
(1a)SCLKのエッジ(立下り,立上がり)を検出
<条件付アウトプット命令>
(1b)上記エッジ(立下り)の検出により、送信データを出力端子32より出力
<条件付サンプリング命令>
(2)上記エッジ(立上がり)の検出により、入力端子31をサンプリング
The functions (1) and (2) are realized as follows by peripheral function instructions.
<Input capture instruction>
(1a) SCLK edge (falling, rising) is detected <Conditional output instruction>
(1b) Transmission data is output from the
(2) The
[ケーススタディ:UART]
図14は、UART通信機能を実現する場合である。この通信機能は
(1)エッジ検出(立下り,スタートビット検出)からΔt後に入力端子31をサンプリング
(2)その後、(Δt×2)毎に入力端子31をサンプリング(受信)
(3)または(Δt×2)毎に出力端子32よりデータ出力(送信)
その他、オーバーランエラー、フレーミングエラー、パリティエラーの検出などを行なう。
[Case study: UART]
FIG. 14 shows a case where the UART communication function is realized. This communication function is: (1)
Data output (transmission) from the
In addition, overrun errors, framing errors, and parity errors are detected.
上記(1)〜(3)の機能は、周辺機能命令によって以下のように実現される。
<インプットコンペアセット命令>
(1)端子の信号エッジ(立上がり)を検出し、コンペア周期Δtを設定
<サンプリングコンペア命令>
(2)プログラムカウンタが一致した場合に、入力端子31をサンプリング
<アウトプットコンペア命令>
(3)プログラムカウンタが一致した場合に(周期:Δt×2)、出力端子32よりデータ出力
The functions (1) to (3) are realized as follows by peripheral function instructions.
<Input compare set instruction>
(1) Detect signal edge (rising edge) of terminal and set compare cycle Δt <Sampling compare command>
(2) Sampling the
(3) When the program counters match (period: Δt × 2), data is output from the
[ケーススタディ:LIN]
図15は、車内LANの一種であるLINにおいて、通信開始時に行うビット同期機能を実現する場合を示す。この機能は、以下のようになる。
(1)SYNCH BREAKのロウレベル期間がΔt1に達したことを計測すると、通信開始を認識
(2)SYNCH FIELDにおいて、送信されるクロック周期(立下りエッジ間)Δt2を計測し、ビットレートを調整(4周期分計測し、「8」で除す)
上記(1),(2)の機能は、周辺機能命令によって以下のように実現される。
<インプットキャプチャ命令>
入力端子31のエッジを検出してプログラムカウンタ23のカウント値を取得する。その他の処理は、通常命令で実現可能である。
[Case study: LIN]
FIG. 15 shows a case where a bit synchronization function performed at the start of communication is realized in LIN which is a kind of in-vehicle LAN. This function is as follows.
(1) When the fact that the SYNCH BRAKE low level period reaches Δt1 is measured, the communication start is recognized. (2) In SYNCH FIELD, the transmitted clock period (between falling edges) Δt2 is measured and the bit rate is adjusted ( (Measure for 4 cycles and divide by “8”)
The functions (1) and (2) are realized as follows by peripheral function instructions.
<Input capture instruction>
The edge of the
即ち、以上のように、複数の方式が異なる通信機能をソフトウエアによって実現することができるので、マイクロコンピュータ10は、夫々の通信機能を実現する場合に対応して通信インターフェイス用のLSIを搭載する必要がなくなる。従って、マイクロコンピュータ10の汎用性を高めることが可能となる。
That is, as described above, communication functions different in a plurality of methods can be realized by software. Therefore, the
以上のように本実施例によれば、マイクロコンピュータ10のCPU11を、Lタスクに記述されている周辺機能命令を1命令として実行処理可能に構成する。そして、CPU11は、オペランドで指定されている汎用レジスタ30より周辺機能命令の実行に要する情報を取得する共に、当該命令の実行結果に関する情報を汎用レジスタ30に格納するようにした。従って、周辺機能をソフトウエアによって実現するためのプログラムの記述が極めて簡単になり、プログラムサイズを小さくすることができる。また、汎用レジスタ30のビットはCPU11に通常用意されている命令によって操作可能であるから、周辺機能命令を実行させるために、プリフィックス命令のような特殊な命令を別途用意する必要がない。
As described above, according to the present embodiment, the
また、CPU11は、インプットキャプチャ命令を実行する場合、タイマ値の取得条件となる入力端子31のエッジ指定情報を汎用レジスタ30より取得し、汎用レジスタ30に格納される入力端子31の状態から取得条件の成立を判定し、その条件成立時に取得したプログラムカウンタ23の値をキャプチャ値として格納すると共に成立フラグを格納する。従って、予め通常命令によって汎用レジスタ30にエッジ指定情報をセットした後、インプットキャプチャ命令を実行することで、ソフトウエアによってインプットキャプチャ機能を実現することができる。
Further, when executing the input capture instruction, the
また、CPU11は、サンプリングコンペア命令を実行する場合、汎用レジスタ30にセットされるコンペア周期値を取得し、また、汎用レジスタ30に、サンプリングタイミング毎にコンペア周期値を累積加算したデータをコンペア値として格納する。そして、コンペア値とプログラムカウンタ23の値とが一致した場合に、サンプリング結果及び成立フラグを汎用レジスタ30に格納する。従って、予め通常命令によって汎用レジスタ30にコンペア周期値をセットした後サンプリングコンペア命令を実行することで、ソフトウエアによってサンプリングコンペア機能を実現できる。
Further, when executing the sampling compare instruction, the
また、CPU11は、インプットコンペアセット命令を実行する場合、汎用レジスタ30にセットされるコンペア周期値及びコンペアセット条件となる入力端子31のエッジ指定情報を取得し、その条件が成立すると、その時点のプログラムカウンタ23の値にコンペア周期値を加算した値をコンペア値として汎用レジスタ30に格納すると共に成立フラグを格納する。従って、予め通常命令によって汎用レジスタ30にコンペア周期値及びエッジ指定情報をセットした後インプットコンペアセット命令を実行することで、ソフトウエアによってインプットコンペアセット機能を実現できる。
Further, when executing the input compare set instruction, the
また、CPU11は、条件付サンプリング命令を実行する場合、汎用レジスタ30に条件フラグがセットされたか否か判断し、条件フラグのセットを認識すると、汎用レジスタ30にサンプリング結果及び成立フラグを格納する。従って、Lタスクを実行している間に所定の条件が成立した場合に、通常命令によって汎用レジスタ30に条件フラグをセットすることで、ソフトウエアによって条件付サンプリング機能を実現できる。
Further, when executing the conditional sampling instruction, the
また、CPU11は、入力処理系の命令であるインプットキャプチャ命令,サンプリングコンペア命令,インプットコンペアセット命令,条件付サンプリング命令を実行する場合、汎用レジスタ30に前回と今回の入力端子31の状態を格納して、両者の値が一致した場合に入力処理系命令の実行を許可する2度一致フィルタ機能を備えるので、入力信号又はデータの状態が安定したことを確認した段階で、入力処理系命令を実行することができる。そして、CPU11は、汎用レジスタ30におけるビットの設定に応じて2度一致フィルタ機能の実行可否を選択可能に構成されるので、当該フィル多機能の要否を、ユーザのアプリケーションに応じて選択することができる。
Further, the
また、CPU11は、アウトプットコンペア命令を実行する場合、汎用レジスタ30にセットされるコンペア周期値及び出力レベル指定条件を取得し、また、汎用レジスタ30には、サンプリングコンペア命令の場合と同様のコンペア値を格納し、そのコンペア値とプログラムカウンタ23値とが一致すれば指定されたレベルを出力端子より出力すると共に成立フラグを汎用レジスタ30に格納するようにした。従って、予め通常命令によって汎用レジスタ30にコンペア周期値をセットした後アウトプットコンペア命令を実行することで、ソフトウエアによってアウトプットコンペア機能を実現できる。
Further, when executing the output compare instruction, the
また、CPU11は、条件付アウトプット命令を実行する場合、汎用レジスタ30にセットされる出力レベル指定条件を取得し、汎用レジスタ30に条件フラグがセットされたか否かを判断する。そして、条件フラグのセットを認識すると、前記指定条件に応じたレベルを出力端子に出力させると共に汎用レジスタ30に成立フラグを格納する。従って、予め通常命令によって汎用レジスタ30に出力レベル指定条件をセットした後、特定タスクを実行している間に所定の条件が成立した場合に、通常命令によって汎用レジスタ30に条件フラグをセットすれば、ソフトウエアによって条件付アウトプット機能を実現できる。
Further, when executing the conditional output instruction, the
本発明は上記し又は図面に記載した実施例にのみ限定されるものではなく、以下のような変形が可能である。
2度一致フィルタの実行可否を設定する機能は必要に応じて設ければ良く、また、2度一致フィルタ自体の機能も必要に応じて設ければ良い。
CPUが時分割並行的に処理するタスクの数は、3つ以上あっても良い。
周辺機能命令は、マイクロコンピュータの仕様に応じて必要なものを適宜選択して実現すれば良い。
The present invention is not limited to the embodiments described above or shown in the drawings, and the following modifications are possible.
A function for setting whether or not to execute the double match filter may be provided as necessary, and a function of the double match filter itself may be provided as necessary.
The number of tasks that the CPU processes in a time-sharing manner may be three or more.
Peripheral function instructions may be realized by appropriately selecting necessary functions according to the specifications of the microcomputer.
図面中、10はマイクロコンピュータ、11はCPU、23はプログラムカウンタ、30は汎用レジスタ、31は入力端子、32は出力端子を示す。
In the drawing, 10 is a microcomputer, 11 is a CPU, 23 is a program counter, 30 is a general-purpose register, 31 is an input terminal, and 32 is an output terminal.
Claims (9)
前記特定タスクは、前記プログラムカウンタがオーバーフローすると、当該プログラムカウンタがリセットされて前記プログラムの冒頭から実行が開始され、前記プログラムカウンタをタイマカウンタとして利用可能であり、
前記特定タスクには、周辺機能を1命令で実行するための周辺機能命令が記述されており、
前記周辺機能命令は、オペランドとして汎用レジスタを1つ以上指定するように設定され、前記プログラムカウンタのカウンタ値を、タイマカウンタのカウンタ値として前記汎用レジスタに格納するか、又は前記汎用レジスタに格納されている値と比較するか、又は前記汎用レジスタに格納されている値に加算する何れかの命令であり、
前記CPUは、前記周辺機能命令を1命令として実行処理可能に構成され、汎用レジスタより当該命令の実行に要する情報を取得する共に、当該命令の実行結果に関する情報を汎用レジスタに格納することを特徴とするマイクロコンピュータ。 A plurality of tasks can be processed in parallel in a time-sharing manner , and at least one of these tasks is described as a fixed loop program in which branch instructions are prohibited so that the increment of the program counter indicating the instruction address is constant. In a microcomputer that is a specific task,
The specific task, when the program counter overflows, the program counter is reset and execution is started from the beginning of the program , the program counter can be used as a timer counter,
In the specific task, peripheral function instructions for executing peripheral functions with one instruction are described.
The peripheral function instruction is set to designate one or more general-purpose registers as operands, and the counter value of the program counter is stored in the general-purpose register as the counter value of a timer counter or stored in the general-purpose register. Any instruction that compares to or adds to the value stored in the general register,
The CPU is configured to be able to execute the peripheral function instruction as one instruction, acquires information necessary for execution of the instruction from the general-purpose register, and stores information on the execution result of the instruction in the general-purpose register. A microcomputer.
汎用レジスタに、前回にサンプリングした前記入力端子のレベルと、前記入力端子の現在のレベルとを格納し、
前回と現在の入力端子の状態に基づいて前記取得条件が成立したと判断するとタイマカウンタの値を取得し、キャプチャ値として汎用レジスタに格納することを特徴とする請求項1記載のマイクロコンピュータ。 When executing an input capture instruction as the peripheral function instruction, the CPU acquires edge designation information of an input terminal that is a condition for acquiring a timer value from a general-purpose register,
The general-purpose register stores the level of the input terminal sampled last time and the current level of the input terminal,
2. The microcomputer according to claim 1, wherein when it is determined that the acquisition condition is satisfied based on the previous and current input terminal states, a value of a timer counter is acquired and stored in a general-purpose register as a capture value.
汎用レジスタに、サンプリングタイミング毎に前記コンペア周期値を累算したコンペア値をセットし、
前記コンペア値と前記タイマカウンタの値とを比較して一致判断を行い、両者の一致時に入力端子の状態をサンプリングして、成立フラグと共に汎用レジスタに格納することを特徴とする請求項1又は2記載のマイクロコンピュータ。 When the CPU executes a sampling compare instruction as the peripheral function instruction, the CPU obtains a compare cycle value set in a general-purpose register,
Set the compare value obtained by accumulating the compare cycle value at each sampling timing in the general-purpose register,
3. The comparison value and the timer counter value are compared to determine a match, and when the two match, the state of the input terminal is sampled and stored together with the establishment flag in a general purpose register. The microcomputer as described.
前記コンペアセット条件が成立すると、汎用レジスタに、前記コンペアセット値にその時点のタイマカウンタの値を加えたコンペア値と共に、成立フラグを格納することを特徴とする請求項1乃至3の何れかに記載のマイクロコンピュータ。 The CPU, when executing an input compare set instruction as the peripheral function instruction, obtains a compare set value set in a general-purpose register and edge designation information of an input terminal serving as a compare set condition,
4. The establishment flag is stored together with a compare value obtained by adding a timer counter value at that time to the compare set value when the compare set condition is established. The microcomputer as described.
汎用レジスタに、前記サンプリング結果及び成立フラグを格納することを特徴とする請求項1乃至4の何れかに記載のマイクロコンピュータ。 When the CPU executes a conditional sampling instruction as the peripheral function instruction, it recognizes that the condition flag is set in the general-purpose register, and performs sampling of the input terminal.
5. The microcomputer according to claim 1, wherein the sampling result and the establishment flag are stored in a general-purpose register.
両者の値が一致した場合に、前記入力処理系命令の実行を許可する2度一致フィルタ機能を備えていることを特徴とする請求項2乃至5の何れかに記載のマイクロコンピュータ。 When the CPU executes an input processing instruction as the peripheral function instruction, the general-purpose register stores the previous input terminal state and the current input terminal state;
6. The microcomputer according to claim 2, further comprising a twice-match filter function that permits execution of the input processing system instruction when both values match.
汎用レジスタに、アウトプット条件の成立毎に前記コンペア周期値を累算したコンペア値をセットし、
前記コンペア値と前記タイマカウンタの値とを比較して一致判断を行い、両者が一致すると(アウトプット条件成立)、前記指定条件に応じたレベルを出力端子より出力させると共に、成立フラグを汎用レジスタに格納することを特徴とする請求項1乃至7の何れかに記載のマイクロコンピュータ。 When the CPU executes an output compare instruction as the peripheral function instruction, the CPU obtains a compare cycle value set in a general-purpose register and an output level designation condition,
In the general-purpose register, set the compare value obtained by accumulating the compare cycle value every time the output condition is satisfied,
The compare value and the timer counter value are compared to determine whether they match, and if both match (output condition is established), the level corresponding to the specified condition is output from the output terminal, and the establishment flag is set to a general-purpose register. The microcomputer according to claim 1, wherein the microcomputer is stored in the microcomputer.
前記条件フラグがセットされたことを認識すると、前記指定条件に応じたレベルを出力端子より出力させると共に、成立フラグを汎用レジスタに格納することを特徴とする請求項1乃至8の何れかに記載のマイクロコンピュータ。
When executing a conditional output instruction as the peripheral function instruction, the CPU acquires an output level designation condition and a condition flag set in a general-purpose register,
9. When recognizing that the condition flag is set, a level corresponding to the specified condition is output from an output terminal, and the establishment flag is stored in a general-purpose register. Microcomputer.
Priority Applications (3)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2005009413A JP4507888B2 (en) | 2005-01-17 | 2005-01-17 | Microcomputer |
US11/330,237 US7664933B2 (en) | 2005-01-17 | 2006-01-12 | Microcomputer and encoding system for instruction code and CPU |
US12/585,781 US7991982B2 (en) | 2005-01-17 | 2009-09-24 | Microcomputer and encoding system for executing peripheral function instructions |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2005009413A JP4507888B2 (en) | 2005-01-17 | 2005-01-17 | Microcomputer |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2006195910A JP2006195910A (en) | 2006-07-27 |
JP4507888B2 true JP4507888B2 (en) | 2010-07-21 |
Family
ID=36801936
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2005009413A Expired - Fee Related JP4507888B2 (en) | 2005-01-17 | 2005-01-17 | Microcomputer |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP4507888B2 (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP5862442B2 (en) * | 2012-05-09 | 2016-02-16 | 株式会社デンソー | Solenoid valve drive control device |
Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPS54114687A (en) * | 1978-02-27 | 1979-09-06 | Toyoda Mach Works Ltd | Sequence controller |
JPS54138354A (en) * | 1978-04-20 | 1979-10-26 | Oki Electric Ind Co Ltd | Microprocessor unit |
JPS5617441A (en) * | 1979-07-23 | 1981-02-19 | Fujitsu Ltd | Program interruption system |
JPS61237150A (en) * | 1985-04-15 | 1986-10-22 | Hitachi Ltd | Arithmetic system for input/output processing |
JPS6275733A (en) * | 1985-09-30 | 1987-04-07 | Nippon Denso Co Ltd | Microcomputer |
JPH06250857A (en) * | 1993-02-26 | 1994-09-09 | Nippondenso Co Ltd | Microcomputer |
JPH07271408A (en) * | 1994-03-30 | 1995-10-20 | Hitachi Ltd | Processor for control |
JP2003296292A (en) * | 2002-03-29 | 2003-10-17 | Denso Corp | Port sampling circuit device and microcomputer |
JP2003308307A (en) * | 2002-02-15 | 2003-10-31 | Denso Corp | Micro-computer, and ecu for vehicle |
-
2005
- 2005-01-17 JP JP2005009413A patent/JP4507888B2/en not_active Expired - Fee Related
Patent Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPS54114687A (en) * | 1978-02-27 | 1979-09-06 | Toyoda Mach Works Ltd | Sequence controller |
JPS54138354A (en) * | 1978-04-20 | 1979-10-26 | Oki Electric Ind Co Ltd | Microprocessor unit |
JPS5617441A (en) * | 1979-07-23 | 1981-02-19 | Fujitsu Ltd | Program interruption system |
JPS61237150A (en) * | 1985-04-15 | 1986-10-22 | Hitachi Ltd | Arithmetic system for input/output processing |
JPS6275733A (en) * | 1985-09-30 | 1987-04-07 | Nippon Denso Co Ltd | Microcomputer |
JPH06250857A (en) * | 1993-02-26 | 1994-09-09 | Nippondenso Co Ltd | Microcomputer |
JPH07271408A (en) * | 1994-03-30 | 1995-10-20 | Hitachi Ltd | Processor for control |
JP2003308307A (en) * | 2002-02-15 | 2003-10-31 | Denso Corp | Micro-computer, and ecu for vehicle |
JP2003296292A (en) * | 2002-03-29 | 2003-10-17 | Denso Corp | Port sampling circuit device and microcomputer |
Also Published As
Publication number | Publication date |
---|---|
JP2006195910A (en) | 2006-07-27 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
KR100588790B1 (en) | Method and apparatus for acting on subsequent command processing in data processor | |
US6434690B1 (en) | Microprocessor having a DSP and a CPU and a decoder discriminating between DSP-type instructions and CUP-type instructions | |
US5091853A (en) | Chained addressing mode pipelined processor which merges separately decoded parts of a multiple operation instruction | |
JP3745039B2 (en) | Microprocessor with delayed instructions | |
US5313644A (en) | System having status update controller for determining which one of parallel operation results of execution units is allowed to set conditions of shared processor status word | |
US7991982B2 (en) | Microcomputer and encoding system for executing peripheral function instructions | |
EP0287115B1 (en) | Coprocessor and method of controlling the same | |
JP4507888B2 (en) | Microcomputer | |
US7010677B2 (en) | Data processor speeding up repeat processing by inhibiting remaining instructions after a break in a repeat block | |
US20010023481A1 (en) | Processor that executes control signals included in operand section of control instruction | |
US5463747A (en) | Microprogram data processor processing operand address calculation and instruction execution with common hardware | |
JP5251353B2 (en) | Information processing device | |
JP2007004475A (en) | Processor and method for executing program | |
JP5012562B2 (en) | Microcomputer | |
US20050216704A1 (en) | Device and method for managing a microprocessor instruction set | |
TWI389027B (en) | Central processing unit and microcontroller | |
JP4702004B2 (en) | Microcomputer | |
US8516225B2 (en) | Central processing unit and microcontroller | |
JP2721610B2 (en) | Programmable controller | |
JP2559924B2 (en) | Programmable controller | |
JP3060917B2 (en) | Processor | |
JPH10207704A (en) | Device for changing program of microcomputer | |
JPS5880743A (en) | Fetch forecaster for microprocessor | |
JPH0991167A (en) | Instruction detector | |
JPH0340013A (en) | Central arithmetic processing unit |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20070905 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20091215 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20100209 |
|
A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20100323 |
|
TRDD | Decision of grant or rejection written | ||
A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 Effective date: 20100413 |
|
A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20100426 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20130514 Year of fee payment: 3 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20130514 Year of fee payment: 3 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20140514 Year of fee payment: 4 |
|
R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
LAPS | Cancellation because of no payment of annual fees |