JPH0833812B2 - Sorting device - Google Patents

Sorting device

Info

Publication number
JPH0833812B2
JPH0833812B2 JP63224304A JP22430488A JPH0833812B2 JP H0833812 B2 JPH0833812 B2 JP H0833812B2 JP 63224304 A JP63224304 A JP 63224304A JP 22430488 A JP22430488 A JP 22430488A JP H0833812 B2 JPH0833812 B2 JP H0833812B2
Authority
JP
Japan
Prior art keywords
data
sorted
sort
register
buffer
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 - Lifetime
Application number
JP63224304A
Other languages
Japanese (ja)
Other versions
JPH0271327A (en
Inventor
一 福澤
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.)
NEC Corp
Original Assignee
NEC 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 NEC Corp filed Critical NEC Corp
Priority to JP63224304A priority Critical patent/JPH0833812B2/en
Publication of JPH0271327A publication Critical patent/JPH0271327A/en
Publication of JPH0833812B2 publication Critical patent/JPH0833812B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Landscapes

  • Memory System Of A Hierarchy Structure (AREA)
  • Executing Machine-Instructions (AREA)

Description

【発明の詳細な説明】 〔産業上の利用分野〕 本発明はソート処理装置に関し、特にソート処理をパ
イプライン処理で高速に実行可能なソート処理装置に関
する。
The present invention relates to a sort processing device, and more particularly to a sort processing device capable of executing sort processing at high speed by pipeline processing.

〔従来の技術〕[Conventional technology]

従来、ソート処理はソフトウェアで行なわれ、その処
理には多数の命令の実行が必要であった。ソート処理は
与えられたデータを一定の順序、即ち昇順あるいは降順
に並べ替える処理であり、例えば数字のみから成るデー
タや英文字から成るデータの場合等では、大小順やアル
ファベット順に並べる操作がある。
Conventionally, the sorting process is performed by software, which requires the execution of many instructions. The sort process is a process of rearranging given data in a fixed order, that is, in ascending or descending order. For example, in the case of data consisting only of numbers or data consisting of English characters, there is an operation of arranging in order of magnitude.

計算機内ではアルファベットもASCIIコードやEBCDIC
コードのように、大小の順序関係が保たれた数字として
処理されるため、結局、数字の大小関係に帰着した昇順
および降順の並べ替え処理となる。
In the computer, the alphabet is ASCII code or EBCDIC
Like the code, since the numbers are processed as numbers that maintain the order relation of magnitude, the ascending and descending sorting processes result in the magnitude relation of numbers.

ソフトウェアによりソート処理の手法の一つにバブル
ソートによるものがある。バブルソートは、与えられた
データ列に対して先頭のデータから順に次のデータと比
較し、必要に応じて入れ替えを行なう一連の操作を何回
か繰り返すことによってソートを行う。
Bubble sorting is one of the sorting methods by software. In bubble sort, a given data string is compared with the next data in order from the first data, and a series of operations for performing replacement as needed is repeated several times to perform sorting.

表1は、ソートされるデータ列の一例であり、データ
D0〜データD3の4つのデータ列が示されている。一つの
データの形式は、前半部にソートを行なう比較値をもつ
キー部と後半部に実際のレコードの格納場所を示すポイ
ンタ部とからなっている。データ列はキー部のキー値に
従ってソートされ、ソート結果の順番にポインタ部で示
されたレコードを順番に取出すことによってソート済の
レコードを取出すことができる。
Table 1 is an example of a sorted data string
Four data strings from D0 to data D3 are shown. One data format consists of a key part having comparison values for sorting in the first half and a pointer part showing the actual record storage location in the second half. The data strings are sorted according to the key value of the key part, and the sorted records can be taken out by sequentially taking out the records indicated by the pointer part in the order of the sorting result.

一般に用いられるレコード長は数バイトから数百バイ
ト以上にもおよぶことがあり、このようにポインタ部で
格納場所を保持しておくことにより、実際のレコードそ
のものの移動を伴わずにソートを行うことができる。
The record length that is generally used can range from several bytes to several hundred bytes or more. By holding the storage location in the pointer part in this way, sorting can be performed without moving the actual record itself. You can

今、表1のデータ列をキー値に従ってバブルソートに
よって昇順にソートする場合を考える。キーK0〜キーK3
の値は順に4,2,3,1であり、これを昇順に1,2,3,4の順番
に並べ替える。その処理の様子を第6図に従って順に追
って説明する。
Now, consider a case where the data strings in Table 1 are sorted in ascending order by bubble sorting according to the key value. Key K0 to Key K3
The value of is 4,2,3,1 in order, and it is sorted in ascending order of 1,2,3,4. The state of the processing will be sequentially described with reference to FIG.

(1)まず、先頭と2番目のキー値、即ちキーK0とキー
K1の内容を読出して比較を行なう。昇順に並んでいる場
合はそのままとし、昇順に並んでいない場合は両者を入
れ替える。
(1) First, the first and second key values, that is, key K0 and key
Read the contents of K1 and compare. If they are in ascending order, leave them as they are, and if they are not in ascending order, replace both.

(2)次に、(1)の並べ替え後のデータ列の2番目と
3番目のキー値、即ちキーK0とキーK2の内容を読出し、
(1)と同様の処理を行なう。
(2) Next, read the second and third key values of the rearranged data string of (1), that is, the contents of the keys K0 and K2,
The same process as (1) is performed.

(3)同様にキーK0とキーK3に対して(1)と同様の処
理を行なう。以上最終データまでの比較、並べ替え動作
が終了し、最大のキー値を有するキーK0が列の最後尾に
移される。
(3) Similarly, the same processing as (1) is performed on the keys K0 and K3. The comparison and rearrangement operations up to the final data are completed, and the key K0 having the largest key value is moved to the end of the column.

(4)次に、先頭より残った3つのキー、即ちキーK1、
キーK2、キーK3に対して、再び同様の比較、並べ替えの
処理が行なわれる。まず、先頭と2番目のキーK1とキー
K2の処理が行なわれる。この場合、キーK1とキーK2はす
でに昇順に並んでいるので並べ替えは行なわれずそのま
まとなる。
(4) Next, the three keys remaining from the beginning, namely key K1,
Similar comparison and rearrangement processing is performed again on the keys K2 and K3. First, the first and second keys K1 and key
K2 processing is performed. In this case, the keys K1 and K2 have already been arranged in ascending order, so that the keys are not rearranged and remain as they are.

(5)次に、2番目と3番目のキーK2とキーK3について
処理する。以上により、2回目の比較、並べ替え動作が
終了し、2番目に大きいキー値を有するキーK2が比較動
作が行なわれた3キーの内の最後尾に移される。
(5) Next, the second and third keys K2 and K3 are processed. As described above, the second comparison and rearrangement operation is completed, and the key K2 having the second largest key value is moved to the end of the three keys for which the comparison operation is performed.

(6)再び先頭より残った2つのキー、即ちキーK1、キ
ーK3に対して同様の比較、並べ替えの処理が行なわれ
る。
(6) Similar comparison and rearrangement processing is performed on the two keys remaining from the beginning, that is, the keys K1 and K3.

以上、(1)〜(6)の一連の操作によってキー値に
従った昇順ソートが完了し、この順番にポインタによっ
て示されたレコードを取出すことにより、昇順ソート後
のレコード配列が得られる。
As described above, the ascending sort according to the key value is completed by the series of operations (1) to (6), and the records indicated by the pointers are taken out in this order to obtain the record array after the ascending sort.

上記(1)〜(6)の操作での比較動作の回数は、3
+2+1=6回であり、一般に、n個のデータ配列の比
較動作の回数の最大は、(n−1)+(n−2)+…+
1=n(n−1)/2回となる。さらに、従来のソフトウ
ェアの処理では、1回の比較動作を、 (1)キーアドレスの生成命令 (2)キーのロード命令 (3)キー同士の比較命令 (4)比較結果による処理ルーチンへの分岐命令 (5)データ交換のためのストア命令 (6)残データ数の更新命令 (7)繰り返しのための分岐命令 のように多数の命令により実行していた。
The number of comparison operations in the operations (1) to (6) is 3
+ 2 + 1 = 6 times, and in general, the maximum number of comparison operations of n data arrays is (n-1) + (n-2) + ... +
1 = n (n-1) / 2 times. Furthermore, in the conventional software processing, one comparison operation is performed by (1) a key address generation instruction, (2) a key load instruction, (3) a key comparison instruction, and (4) a branch to a processing routine depending on the comparison result. Instruction (5) Store instruction for data exchange (6) Update instruction for remaining data number (7) Branch instruction for repetition It was executed by a large number of instructions.

〔発明が解決しようとする課題〕[Problems to be Solved by the Invention]

上述した従来のソフトウェアによるソート処理は、多
数の命令の実行を必要とし、かつその処理のほとんどが
前の命令の結果に依存して逐次的に実行されるため、処
理時間が非常に長くかかるという欠点がある。
The conventional software sort process described above requires the execution of a large number of instructions, and most of the processes are executed sequentially depending on the result of the previous instruction, so that the processing time is extremely long. There are drawbacks.

〔課題を解決するための手段〕[Means for solving the problem]

本発明の第1のソート処理装置は、 第1および第2のデータバッファと、 これら第1および第2のデータバッファのうち、いず
れか一方をソートすべきデータの読出し用バッファに、
他方をソートすべきデータの退避用バッファとして選択
する手段と、 最初にソートすべきデータの読出し用として選択され
たデータバッファに外部から与えられるソートすべきデ
ータを入力する手段と、 ソートすべきデータの読出し用バッファの出力を保持
する第1および第2のレジストと、 これら第1および第2のレジスタにソートすべきデー
タを順次格納する手段と、 前記第1および第2のレジスタにソートすべきデータ
が格納される度に、第1および第2のレジスタの予め定
められた部分の内容同士を比較し、比較結果を出力する
比較手段と、 この比較手段が第1のレジスタの値を退避すべき旨を
出力した場合は、第1のレジスタに保持されているデー
タを前記退避用バッファに退避し、第2のレジスタに保
持されているデータはそのまま保持し、新たなデータを
第1のレジスタに格納して次の比較動作を実行させ、一
方前記比較手段が第2のレジスタの値を退避すべき旨を
出力した場合は、同様に第2のレジスタに保持されてい
るデータを前記退避用バッファに退避し、第1のレジス
タに保持されているデータはそのまま保持し、新たなデ
ータを第2のレジスタに格納して次の動作を実行させる
手段と、 予め指定された全データの前記比較手段と前記退避手
段が終了すると、前記退避用バッファに退避されずに前
記第1および第2のレジスタのいずれか一方にそのまま
保持されているデータを予め指定された格納場所に出力
する手段と、 前記退避用バッファとして用いられたデータバッファ
をソートすべきデータの読出し用バッファとし、他方を
ソートすべきデータの退避用バッファとして再選択し、
この再選択された読出し用バッファから順次ソートすべ
きデータを読み出し、上記一連の比較動作と退避用バッ
ファへの退避動作および結果データの出力動作を繰り返
させる手段とを有している。
A first sort processing device according to the present invention comprises: a first and a second data buffer; and one of the first and second data buffers as a read buffer for data to be sorted,
A means for selecting the other as the save buffer for the data to be sorted, a means for inputting the data to be sorted given from the outside to the data buffer selected for reading the data to be sorted first, and the data for the sort First and second resists for holding the output of the reading buffer of, the means for sequentially storing the data to be sorted in the first and second registers, and the first and second registers for sorting. Each time data is stored, the contents of the predetermined parts of the first and second registers are compared with each other, and the comparing means outputs the comparison result; and the comparing means saves the value of the first register. If it is output that the data should be saved, the data held in the first register is saved in the save buffer, and the data held in the second register is If the comparison means outputs the fact that the value of the second register should be saved, the new data is stored in the first register and the next comparison operation is executed. The data held in the second register is saved in the save buffer, the data held in the first register is held as it is, the new data is stored in the second register, and the next operation is executed. When the comparing means and the saving means for all the data designated in advance are completed, the data held in one of the first and second registers without being saved in the save buffer. To a storage location designated in advance, and the data buffer used as the save buffer as a read buffer for the data to be sorted, and the other for the data to be sorted. Re-selected as the 避用 buffer,
It has means for reading data to be sequentially sorted from the reselected read buffer, and repeating the series of comparison operations, save operation to the save buffer, and output operation of result data.

また、本発明の第2のソート処理装置は、 第1および第2のレジスタと、 これら第1および第2のレジスタにソートすべきデー
タが格納される度に、前記第1および第2のレジスタの
予め定められた部分の内容同士を比較し、比較結果を出
力する比較手段と、 この比較手段の比較結果に従って、前記第1および第
2のレジスタのいずれに新たなソートすべきデータを格
納すべきかを指定するレジスタ指定手段と、 このレジスタ指定手段の指定に従って、前記第1およ
び第2のレジスタの一方に新たなソートすべきデータを
格納する手段と、 前記レジスタ指定手段がソートすべき全データに対し
て前記第1および第2のレジスタを交互に指定したかを
検出する検出手段と、 この検出手段の検出出力があった場合は、前記ソート
すべき全データがすでにソート済みデータであることを
検出し、前記ソートすべき全データを予め定められた順
序に従って出力してソート処理を終了させる手段とを有
している。
The second sort processing device of the present invention includes a first register and a second register, and the first register and the second register each time data to be sorted is stored in the first register and the second register. Comparing the contents of the predetermined parts of each other and outputting the comparison result, and according to the comparison result of this comparing means, store the new data to be sorted in either the first register or the second register. Register specifying means for specifying a key, means for storing new data to be sorted in one of the first and second registers according to the specification of the register specifying means, and all data to be sorted by the register specifying means And a detection means for detecting whether the first and second registers are alternately designated, and if there is a detection output of this detection means, all the data to be sorted is There has been and means output to terminate the sorting process in accordance with the detection, defined all data to be the sort previously sequence that is already sorted data.

〔作用〕[Action]

第1、第2のソート処理装置とも、ソート処理をハー
ドウェアによるパイプライン処理により行なうので、処
理時間が短かくなり、処理が高速化される。
Since both the first and second sort processing devices perform the sort processing by pipeline processing by hardware, the processing time becomes short and the processing speed is increased.

なお、第1のソート処理装置では、バブルソートを実
行している途中でソート処理が完了した場合も後続の無
駄な処理を実行してしまうという欠点がある。第2のソ
ート処理装置は、バブルソートの実行中にソート処理が
すでに終了したか否かを検出することにより、無駄なソ
ート処理の実行を削減し、ソート処理の一層の高速化を
図ったものである。
It should be noted that the first sort processing device has a drawback that the subsequent wasteful process is executed even when the sort process is completed while the bubble sort is being executed. The second sort processing device reduces unnecessary execution of sort processing by detecting whether or not the sort processing has already been completed during execution of bubble sort, thereby further speeding up sort processing. Is.

〔実施例〕〔Example〕

次に、本発明の実施例について図面を参照して説明す
る。
Next, embodiments of the present invention will be described with reference to the drawings.

第5図は本発明のソート処理装置を含む、システム構
成の一実施例を示すブロック図である。
FIG. 5 is a block diagram showing an embodiment of the system configuration including the sorting apparatus of the present invention.

主記憶装置1は命令語およびオペランドを格納する記
憶装置、バッファ記憶制御装置2は要求元の指示に従っ
て、主記憶装置1より命令語およびオペランドを読出し
て要求元へ送出したり、主記憶装置1の所定の場所へ演
算結果を格納する記憶制御装置、演算制御装置3は命令
制御装置4の指示に従って所定の演算を行なう演算制御
装置、命令制御装置4は主記憶装置1から命令語を読出
して解読し、演算制御装置3またはソート処理装置5に
演算の実行を指示する命令制御装置、ソート処理装置5
は本発明のソート処理装置である。
The main storage device 1 is a storage device for storing instruction words and operands, and the buffer storage control device 2 reads the instruction words and operands from the main storage device 1 and sends them to the request source according to the instruction of the request source. , A storage controller for storing the calculation result in a predetermined location, a calculation controller 3 for executing a predetermined calculation in accordance with an instruction from the instruction controller 4, and a command controller 4 for reading a command word from the main memory 1. An instruction control device for decoding and instructing the operation control device 3 or the sort processing device 5 to execute an operation, a sort processing device 5
Is a sort processing device of the present invention.

本実施例のシステム構成は、主記憶装置1、バッファ
記憶制御装置2、演算制御装置3、命令制御装置4から
成る公知のシステム構成に本発明のソート処理装置5が
付加される構成となっている。なお、ソート処理装置5
は演算制御装置3内に内蔵される構成であってもよい。
The system configuration of this embodiment is such that the sort processing device 5 of the present invention is added to a known system configuration including a main storage device 1, a buffer storage control device 2, an operation control device 3, and an instruction control device 4. There is. The sorting device 5
May be built in the arithmetic and control unit 3.

バッファ記憶制御装置2によって主記憶装置1から読
出された命令語が命令制御装置4で解読され、ソート命
令である場合には、ソート処理装置5に通知される。
The instruction word read from the main storage device 1 by the buffer storage control device 2 is decoded by the instruction control device 4, and when it is a sort instruction, it is notified to the sort processing device 5.

ソート命令は、ソートすべきデータの格納場所とソー
ト済データの格納場所を示す情報を有しており、さらに
ソートすべきデータの個数および昇順にソートすべきか
降順にソートすべきかを指示するフィールドを有してい
る。ソートすべきデータの格納場所とソート済データの
格納場所はいずれも主記憶装置1内のメモリ上にとられ
る。本実施例のソートデータは表1のようにキー部とポ
インタ部よりなり、キー部4バイト、ポインタ部4バイ
トの8バイト固定長データで、メモリ上に連続に配置さ
れる。ソート処理の実行にあたっては、ソートすべきデ
ータの読出しおよびソート済データの格納のリクエスト
の制御は、命令制御装置4が司ってもよいし、ソート処
理装置5自身が司ってもよい。本実施例では命令制御装
置4が制御を司どり、メモリ上に連続に配置されている
ソートすべきデータを順次読出してソート処理装置5に
送出する。命令制御装置4はまた、ソートすべきデータ
の個数と、昇順にソートすべきか、降順にソートすべき
かの指示をソート処理装置5に通知する。
The sort command has information indicating the storage location of the data to be sorted and the storage location of the sorted data, and further has a field indicating the number of data to be sorted and whether to sort in ascending order or descending order. Have Both the storage location of the data to be sorted and the storage location of the sorted data are stored in the memory in the main storage device 1. As shown in Table 1, the sort data of this embodiment is composed of a key portion and a pointer portion, and is 8-byte fixed length data of 4 bytes for the key portion and 4 bytes for the pointer portion, which are continuously arranged on the memory. When executing the sort processing, the instruction control device 4 may control the request for reading the data to be sorted and the request for storing the sorted data, or the sort processing device 5 itself may control the request. In this embodiment, the instruction control unit 4 controls the control, sequentially reads out the data to be sorted which are continuously arranged in the memory, and sends the data to the sort processing unit 5. The instruction control device 4 also notifies the sort processing device 5 of the number of pieces of data to be sorted and an instruction as to whether to sort in ascending order or descending order.

第1図は本発明のソート処理装置5の第1の実施例の
ブロック構成図である。
FIG. 1 is a block configuration diagram of a first embodiment of a sort processing device 5 of the present invention.

SL10は命令制御装置4から送られてくるソートすべき
データの個数もしくはカウンタ50の出力を保持するレジ
スタ、カウンタ50はSL10の内容を−1する減算器、セレ
クタ30は命令制御装置4から送られてくるソートすべき
データの個数およびカウンタ50の出力の一方を選択して
出力する選択器、SDB20およびSDB21はソートすべきデー
タを保持するバッファ、WAR11およびWAR13はSDB20およ
びSDB21の書込みアドレスを保持するライトアドレスレ
ジスタ、RAR12およびRAR14はSDB20およびSDB21の読出し
アドレスを保持するリードアドレスレジスタ、カウンタ
51〜54はWAR11、RAR12、WAR13、RAR14の内容をそれぞれ
+1する加算器、セレクタ31〜34はリセット値0とカウ
ンタ51〜54の出力をそれぞれ選択する選択器、SDR16お
よびSDR17はSDB20またはSDB21から読出されたソートす
べきデータを保持するレジスタ、セレクタ36および37は
SDB20またはSDB21から読出されたソートすべきデータを
選択する選択器、SDR18はSDR16またはSDR17から出力さ
れた結果データを受け取り、結果データを主記憶装置1
に格納するために、バッファ記憶制御装置2に結果デー
タを送出するインタフェースレジスタ、セレクタ38はSD
R16およびSDR17の出力データを選択する選択器、セレク
タ40は主記憶装置1から読出されてソート処理装置5に
送出されてくるソートすべきデータまたはSDR16およびS
DR17からの出力データのいずれかを選択する選択器、セ
レクタ41はSDR16およびSDR17からの出力データを選択す
る選択器、FGR15はSDB20およびSDB21のいずれか一方を
ソートすべきデータの読出し用バッファとして指定し、
他方をソートすべきデータの退避用バッファとして指定
するフラグレジスタ、セレクタ35は初期値0とFGR15の
内容が反転を受けた値とを選択する選択器、比較器23
は、SDR16およびSDR17に保持されるソートすべきデータ
の予め定められた部分、即ち本実施例ではソートすべき
データのキー部の内容同士を比較し、比較結果を出力す
る比較器、比較器22はSL10の内容と、RAR12またはRAR14
のいずれかの内容とを比較し、一致を検出して出力する
比較器、セレクタ39はRAR12およびRAR14の内容を選択す
る選択器、制御回路24はソート処理装置5全体の制御を
司る制御回路である。
SL10 is a register for holding the number of data to be sorted or the output of the counter 50 sent from the instruction control unit 4, the counter 50 is a subtractor for subtracting the content of SL10 by -1, and the selector 30 is sent from the instruction control unit 4. A selector that selects and outputs one of the number of data to be sorted and the output of the counter 50, SDB20 and SDB21 are buffers that store the data to be sorted, and WAR11 and WAR13 are the write addresses of SDB20 and SDB21. Write address registers, RAR12 and RAR14 are read address registers and counters that hold the read addresses of SDB20 and SDB21.
51 to 54 are adders that add +1 to the contents of WAR11, RAR12, WAR13, and RAR14, selectors 31 to 34 are selectors that select the reset value 0 and the outputs of counters 51 to 54, and SDR16 and SDR17 are from SDB20 or SDB21. The registers that hold the read data to be sorted, selectors 36 and 37,
A selector for selecting the data to be sorted read from SDB20 or SDB21, SDR18 receives the result data output from SDR16 or SDR17, and stores the result data in the main storage device 1.
The interface register that sends the result data to the buffer storage controller 2 for storing in the
The selector 40, which selects the output data of R16 and SDR17, is the data to be sorted which is read from the main memory 1 and sent to the sort processing device 5, or SDR16 and SDR.
Selector to select one of the output data from DR17, selector 41 to select the output data from SDR16 and SDR17, FGR15 to specify one of SDB20 and SDB21 as a read buffer for data to be sorted Then
A flag register that designates the other as a buffer for saving the data to be sorted, a selector 35 that selects an initial value 0 and a value obtained by inverting the contents of the FGR 15, and a comparator 23
Is a predetermined part of the data to be sorted held in SDR16 and SDR17, that is, in this embodiment, the contents of the key part of the data to be sorted are compared with each other, and a comparator and comparator 22 for outputting the comparison result Is the contents of SL10 and RAR12 or RAR14
Of the RAR12 and RAR14, a selector 39 for selecting the contents of RAR12 and RAR14, and a control circuit 24 for controlling the entire sort processing device 5. is there.

次に、本実施例のソート処理装置5によって、表1の
データ列がソートされる動作について説明する。
Next, the operation of sorting the data strings in Table 1 by the sort processing device 5 of this embodiment will be described.

今、表1のデータ列、即ちデータD0〜データD3までの
4データがメモリ上に連続に配置されており、このデー
タ列を昇順にソートする場合を考える。表1のデータD0
〜データD3は、バッファ記憶制御装置2によって主記憶
装置1から順次読出され、ソート処理装置5へ送出され
る。また、ソート命令によって示されるソートすべきデ
ータの個数「4」が命令制御装置4によって解読されソ
ート処理装置5へ送出される。
Now, consider a case where the data sequence of Table 1, that is, four data of data D0 to data D3 are continuously arranged in the memory, and this data sequence is sorted in ascending order. Data D0 in Table 1
The data D3 are sequentially read from the main storage device 1 by the buffer storage control device 2 and sent to the sort processing device 5. Further, the number “4” of data to be sorted indicated by the sort command is decoded by the command control device 4 and sent to the sort processing device 5.

第2図は表1のデータ列、データD0〜データD3がソー
ト処理装置5によってソートされる動作を示すタイミン
グ図である。
FIG. 2 is a timing chart showing an operation of sorting the data strings, data D0 to data D3, in Table 1 by the sort processing device 5.

サイクルT0ではSL10、WAR11、RAR12、WAR13、RAR14は
初期値0にリセットされた状態を保っている。また、命
令制御装置4からソートレングス、即ちソートすべきデ
ータの個数「4」がソート処理装置5に送られてきて、
サイクルT1でSL10にセットされる。FGR15には、同時に
初期値「0」がセットされる。FGR15が値「0」を保持
している場合は、SDB20をソートすべきデータの読出し
用バッファとし、SDB21のソートすべきデータの退避用
バッファとして使用することを指示する。一方、FGR15
が値「1」にセットされると、SDB20がソートすべきデ
ータの退避用バッファとし、SDB21がソートすべきデー
タの読出し用バッファとして使用することが指示され
る。
In the cycle T0, SL10, WAR11, RAR12, WAR13, and RAR14 maintain the initial value 0. Further, the sort length, that is, the number “4” of data to be sorted is sent from the instruction control device 4 to the sort processing device 5,
Set to SL10 in cycle T1. At the same time, the initial value "0" is set in FGR15. When the FGR15 holds the value "0", it is instructed to use the SDB20 as a read buffer for the data to be sorted and the SDB21 as a save buffer for the data to be sorted. On the other hand, FGR15
Is set to the value "1", it is instructed to use SDB20 as a buffer for saving data to be sorted and SDB21 as a buffer for reading data to be sorted.

また、サイクルT1〜T4では、主記憶装置1から読出さ
れたソートすべきデータD0〜D3が順次ソート処理装置5
へ転送され、SDB20のライトアドレスレジスタWAR11が順
次カウントアップして、サイクルT2〜T5にかけて、SDB2
0に取り込まれる。ソートデータD0〜D3がSDB20に取り込
まれると、順次SDR16、SDR17にデータが読出されて、比
較器23でデータのキー部の比較が行なわれる。まず、サ
イクルT3でSDB20のワード0より読出されたソートデー
タD0がSDR16にセットされ、サイクルT4でSDB20のワード
1より読出されたソートデータD1がSDR17にセットされ
る。SDR16とSDR17にデータがそろうと比較器23でキー部
の比較が行なわれ、比較結果が制御回路24に通知され
る。比較器23はSDR16とSDR17の大小を検出する機能と一
致を検出する機能から構成されており、SDR16<SDR17の
時論理「1」を、SDR16>SDR17の時論理「0」を出力
し、SDR16=SDR17が検出された時には上記信号とは別に
一致信号が制御回路24に通知される。
In the cycles T1 to T4, the data D0 to D3 read from the main storage device 1 to be sorted are sequentially sorted by the sort processing device 5.
Are transferred to SDB20, the write address register WAR11 of SDB20 is sequentially incremented, and SDB2 is incremented during cycles T2 to T5.
Captured at 0. When the sort data D0 to D3 are taken into the SDB20, the data are sequentially read out to the SDR16 and SDR17, and the comparator 23 compares the key parts of the data. First, in cycle T3, sort data D0 read from word 0 of SDB20 is set in SDR16, and in cycle T4 sort data D1 read from word 1 of SDB20 is set in SDR17. When the data is stored in SDR16 and SDR17, the comparator 23 compares the keys, and the control circuit 24 is notified of the comparison result. Comparator 23 is composed of a function to detect the magnitude of SDR16 and SDR17 and a function to detect a match. When SDR16 <SDR17, a logic “1” is output, and when SDR16> SDR17, a logic “0” is output, and SDR16 When = SDR17 is detected, a coincidence signal is notified to the control circuit 24 in addition to the above signal.

サイクルT4でSDR16内のソートデータD0とSDR17内のソ
ートデータD1のキー部が比較され、比較器23は論理
「0」を出力し、制御回路24に通知する。
In cycle T4, the key parts of the sort data D0 in SDR16 and the sort data D1 in SDR17 are compared, the comparator 23 outputs a logic "0", and notifies the control circuit 24.

本実施例では、バブルソートによる昇順ソートを行な
っているので、より大きいキー値を有するソートデータ
は次のソートデータとの比較のために用いられ、小なる
キー値を有するソートデータは退避用バッファに退避さ
れる。この退避用バッファへの退避動作によって、バブ
ルソートにおけるソートデータの入れ替え処理が実行さ
れる。
In this embodiment, since the ascending sort is performed by the bubble sort, the sort data having a larger key value is used for comparison with the next sort data, and the sort data having a smaller key value is stored in the save buffer. Are evacuated to. By the save operation to the save buffer, the sort data replacement process in the bubble sort is executed.

比較器23からの論理「0」の出力結果を受けた制御回
路24の制御によってサイクルT5ではSDR17内のソートデ
ータD1がソートすべきデータの退避用バッファとして指
定されているSDB21のワード0に退避され、同時にSDB20
のワード2から次の比較動作のために読出されたソート
データD2がSDR17にセットされる。比較器23で比較動作
が再び行なわれ、小なるキー値を有するソートデータD2
がサイクルT6でSDB21のワード1に退避される。サイク
ルT6ではSDB20のワード3から読出された最後尾のソー
トデータD3がSDR17にセットされる。サイクルT6での比
較器23の比較動作により、小なるキー値を有するソート
データD3がサイクルT7でSDB21のワード2に退避され
る。
In cycle T5, the sort data D1 in SDR17 is saved in word 0 of SDB21 designated as a save buffer for the data to be sorted by the control of the control circuit 24 which receives the output result of the logic "0" from the comparator 23. And at the same time SDB20
Sort data D2 read for the next comparison operation from word 2 of is set in SDR17. The comparison operation is performed again by the comparator 23, and the sort data D2 having a smaller key value is displayed.
Are saved to word 1 of SDB21 in cycle T6. In cycle T6, the last sort data D3 read from word 3 of SDB20 is set in SDR17. By the comparison operation of the comparator 23 in the cycle T6, the sort data D3 having a smaller key value is saved in the word 2 of the SDB21 in the cycle T7.

SDB20、SDB21のライトアドレスレジスタWAR11、WAR13
およびリードアドレスレジスタRAR12、RAR14は、それぞ
れ書込みおよび読出し動作を実行する度毎に、次のアド
レスを示すように+1カウントアップが行なわれる。し
たがって、サイクルT5でSDB20のワード3より最後尾の
ソートデータD3が読出され、サイクルT6でSDR17にセッ
トされると同時にRAR12はSDB20のワード4を示すように
カウントアップされる。セレクタ39は、ソートすべきデ
ータの読出し用バッファとして用いられている側のリー
ドアドレスレジスタの内容を選択して比較器22に出力し
ており、比較器22でSL10の内容と比較される。サイクル
T6ではRAR12の内容は「4」でありSL10の内容「4」と
一致する。比較器22は一致信号を出力し、制御回路24に
通知する。この一致信号は、ソートすべきデータの読出
し用バッファ内のソートデータの比較動作が全て終了し
たことを示す。この比較動作終了信号を受けた制御回路
24の制御によってサイクルT7では以下の動作が行なわれ
る。
SDB20, SDB21 write address registers WAR11, WAR13
The read address registers RAR12 and RAR14 are incremented by +1 each time a write or read operation is performed to indicate the next address. Therefore, the last sort data D3 from word 3 of SDB20 is read in cycle T5, set in SDR17 in cycle T6, and at the same time RAR12 is counted up to indicate word 4 of SDB20. The selector 39 selects the content of the read address register on the side used as a read buffer for the data to be sorted and outputs it to the comparator 22, which compares it with the content of SL10. cycle
At T6, the content of RAR12 is "4", which matches the content of SL10 "4". The comparator 22 outputs a coincidence signal and notifies the control circuit 24. This coincidence signal indicates that all sort data comparison operations in the read buffer for the data to be sorted have been completed. Control circuit receiving this comparison operation end signal
By the control of 24, the following operation is performed in cycle T7.

まず、比較器23の比較動作の結果により、小なるキー
値を有するSDR17内のソートデータD3が退避用バッファS
DB21のワード3に退避され、SDR16内に残った最大のキ
ー値を有するソートデータD0がSDR18にセットされて、
メモリの所定の場所へ格納するためにバッファ記憶制御
装置2に送出される。
First, according to the result of the comparison operation of the comparator 23, the sort data D3 in the SDR 17 having a small key value is stored in the save buffer S.
Sort data D0 having the maximum key value remaining in SDR16 and saved in word 3 of DB21 is set in SDR18,
Sent to the buffer storage controller 2 for storage in a predetermined location in memory.

SL10は、減算器50で−1された値「3」に更新され
る。この値は、ソート処理装置5内に保持されているソ
ートすべきデータの残数を示している。
SL10 is updated to the value "3" subtracted by the subtractor 50. This value indicates the remaining number of data to be sorted which is held in the sort processing device 5.

WAR11、RAR12、WAR13、RAR14の各アドレスレジスタの
値は初期値「0」にリセットされる。
The value of each address register of WAR11, RAR12, WAR13, and RAR14 is reset to the initial value "0".

また、FGR15は、自身の内容が反転された値、即ち値
「1」に更新される。これはサイクルT7以降、SDB20が
ソートすべきデータの退避用バッファに、SDB21がソー
トすべきデータの読出し用バッファとして使用されるこ
とを示しており、この指示に従って上述した一連の処理
動作が繰り返される。
Further, the FGR 15 is updated to a value in which its contents are inverted, that is, the value “1”. This indicates that after the cycle T7, the SDB20 is used as a save buffer for data to be sorted and the SDB21 is used as a read buffer for data to be sorted, and the series of processing operations described above are repeated according to this instruction. .

即ち、サイクルT8〜T10まではSDB21のワード0〜ワー
ド2に保持されているソートデータがSDR16もしくはSDR
17に順次読出されて、比較器23で比較動作が行なわれて
小なるキー値を有するソートデータがFGR15の指示によ
りSDB20のワード0より順に退避させられる。
That is, in cycles T8 to T10, the sort data held in word 0 to word 2 of SDB21 is SDR16 or SDR.
The data is sequentially read by 17, and the comparison operation is performed by the comparator 23, and the sort data having a small key value is sequentially saved from the word 0 of the SDB 20 according to the instruction of the FGR 15.

サイクルT10ではRAR14の値とSL10の値の一致が検出さ
れて、比較動作の終了が制御回路24に通知される。そし
てサイクルT11で、SDR16に保持されている小なるキー値
を有するソートデータD3がSDB20のワード1に退避さ
れ、同時に残ソートデータの中で最大のキー値を有する
ソートデータD2がSDR17からSDR18にセットされてバッフ
ァ記憶制御装置2に送出される。また、サイクルT11で
はSL10の値が「3」→「2」に、FGR15の値が「1」→
「0」に更新され、WAR11、RAR12、WAR13、RAR14の各ア
ドレスレジスタの値が初期値「0」にリセットされて新
たな比較動作と退避動作が実行される。
In cycle T10, the match between the value of RAR14 and the value of SL10 is detected, and the control circuit 24 is notified of the end of the comparison operation. Then, in cycle T11, the sort data D3 having the small key value held in SDR16 is saved in word 1 of SDB20, and at the same time, the sort data D2 having the largest key value in the remaining sort data is changed from SDR17 to SDR18. It is set and sent to the buffer storage controller 2. Also, in cycle T11, the value of SL10 changes from “3” to “2” and the value of FGR15 changes from “1” to →
It is updated to "0", the value of each address register of WAR11, RAR12, WAR13, RAR14 is reset to the initial value "0", and a new comparison operation and save operation are executed.

サイクルT13では、残った2つのソートデータD1とD3
の比較動作が実行され、サイクルT14で、小なるキー値
を有するソートデータD3がSDB21のワード0に退避さ
れ、大なるキー値を有するソートデータD1がSDR18にセ
ットされてバッファ記憶制御装置2に送出される。
In cycle T13, the remaining two sort data D1 and D3
Is performed, the sort data D3 having a small key value is saved in the word 0 of the SDB21 in the cycle T14, the sort data D1 having a large key value is set in the SDR18, and is stored in the buffer storage controller 2. Sent out.

サイクルT15でSDB21のワード0から読出された最後の
ソートデータD3がSDR16にセットされる。この時、SDB21
のリードアドレスレジスタRARは値「1」にカウントア
ップされており、セレクタ39で選択されて比較器22でSL
10の値「1」と比較され一致信号が制御回路24に通知さ
れる。SDR17には有効なデータがセットされていないこ
とにより、制御回路24はサイクルT16でSDR16に保持され
ている最後のソートデータD3をSDR18にセットしバッフ
ァ記憶制御装置2に送出する。また、サイクルT16ではS
L10の残ソートデータを示す値「0」となり、全ソート
処理動作が終了したことが比較器22を通して制御回路24
に通知され、一連のソート処理動作が終了する。
In cycle T15, the last sort data D3 read from word 0 of SDB21 is set in SDR16. At this time, SDB21
The read address register RAR of has been counted up to the value "1", selected by the selector 39 and SL by the comparator 22.
It is compared with the value “1” of 10 and the coincidence signal is notified to the control circuit 24. Since valid data is not set in SDR17, the control circuit 24 sets the last sort data D3 held in SDR16 in cycle T16 in SDR18 and sends it to the buffer storage controller 2. In cycle T16, S
The value indicating the remaining sort data of L10 becomes “0”, and the completion of all sort processing operations causes the control circuit 24 through the comparator 22.
Is notified, and a series of sort processing operations ends.

昇順ソートの結果はソートデータがストアされたメモ
リの所定の場所より、ストア順の逆にソートデータのポ
インタ部を取り出すことにより得られる。
The result of the ascending sort is obtained by retrieving the pointer portion of the sort data in a reverse order of the store order from a predetermined location in the memory where the sort data is stored.

降順ソートの場合も、昇順ソートの場合と同様に行な
うことができる。
The descending sort can be performed in the same manner as the ascending sort.

次に、表2のデータ列を本ソート処理装置がキー値に
従ってバブルソートにより昇順にソートする場合の処理
手順について、第7図に従って簡単に説明する。
Next, a processing procedure when the data string of Table 2 is sorted in ascending order by bubble sorting by the sorting apparatus according to the key value will be briefly described with reference to FIG.

キーK0〜キーK3の値は順に4,1,2,3であり、これを昇順
に1,2,3,4の順番に並べ替える。
The values of keys K0 to K3 are 4,1,2,3 in order, and they are rearranged in ascending order of 1,2,3,4.

(1)まず、先頭と2番目のキー値、即ちキーK0とキー
K1の内容を読出して比較を行なう。昇順に並んでいる場
合はそのままとし、昇順に並んでいない場合は両者を入
れ替える。
(1) First, the first and second key values, that is, key K0 and key
Read the contents of K1 and compare. If they are in ascending order, leave them as they are, and if they are not in ascending order, replace both.

(2)次に、(1)の並べ替え後のデータ列の2番目と
3番目のキー値、即ちキーK0とキーK2の内容を読出し、
(1)と同様の処理を行なう。
(2) Next, read the second and third key values of the rearranged data string of (1), that is, the contents of the keys K0 and K2,
The same process as (1) is performed.

(3)同様にキーK0とキーK3に対して(1)と同様の処
理を行なう。以上最終データまでの比較、並べ替え動作
が終了し、最大のキー値を有するキーK0が列の最後尾に
移される。
(3) Similarly, the same processing as (1) is performed on the keys K0 and K3. The comparison and rearrangement operations up to the final data are completed, and the key K0 having the largest key value is moved to the end of the column.

(4)次に、再び先頭より残った3つのキー、即ちキー
K1、キーK2、キーK3に対して、同様の比較、並べ替えの
処理が行なわれる。まず、先頭と2番目のキーK1とキー
K2の処理が行なわれる。この場合、キーK1とキーK2はす
でに昇順に並んでいるので並べ替えは行なわれずそのま
まとなる。
(4) Next, the three keys remaining from the beginning again, that is, the keys
Similar comparison and rearrangement processing is performed on K1, key K2, and key K3. First, the first and second keys K1 and key
K2 processing is performed. In this case, the keys K1 and K2 have already been arranged in ascending order, so that the keys are not rearranged and remain as they are.

(5)次に、2番目と3番目のキーK2とキーK3について
処理する。以上により、2回目の比較、並べ替え動作が
終了し、2番目に大きいキー値を有するキーK3が比較動
作が行なわれた3キーの内の最後尾に移される。
(5) Next, the second and third keys K2 and K3 are processed. As described above, the second comparison and rearrangement operation is completed, and the key K3 having the second largest key value is moved to the end of the three keys for which the comparison operation is performed.

(6)再び先頭より残った2つのキー、即ちキーK1、キ
ーK2に対して同様の比較、並べ替えの処理が行なわれ
る。
(6) The same comparison and rearrangement processing is performed on the two keys remaining from the beginning, that is, the keys K1 and K2.

以上、(1)〜(6)の一連の操作によってキー値に
従った昇順ソートが完了し、この順番にポインタによっ
て示されたレコードを取出すことにより、昇順ソート後
のレコード配列が得られる。
As described above, the ascending sort according to the key value is completed by the series of operations (1) to (6), and the records indicated by the pointers are taken out in this order to obtain the record array after the ascending sort.

上記(1)〜(6)の操作での比較動作の回数は、3
+2+1=6回である。
The number of comparison operations in the operations (1) to (6) is 3
+ 2 + 1 = 6 times.

このように、上述した第1図のソート処理装置は、バ
ブルソートのアルゴリズムをそのままハードウェア化し
ているために、例えば表2のデータ列を昇順にソートす
る場合のように、実際は第7図の処理手順の(1)〜
(3)までの処理でソート処理が完了するような場合で
も、後続の(4)〜(6)の処理を自動的に実行してし
まう、つまり、バブルソートを実行している途中でソー
ト処理が完了した場合も後続の無駄な処理を実行してし
まい、高速化の妨げとなる欠点がある。
As described above, since the sorting apparatus of FIG. 1 described above uses the bubble sorting algorithm as it is in hardware, as in the case of sorting the data strings of Table 2 in ascending order, the sorting apparatus of FIG. Processing procedure (1)-
Even when the sort process is completed by the process up to (3), the subsequent processes (4) to (6) are automatically executed, that is, the sort process is performed during the bubble sort. Even when is completed, the subsequent useless processing is executed, and there is a drawback that speeding up is hindered.

次に、第1の実施例の欠点を解消する本発明の第2の
実施例について図面を参照して説明する。
Next, a second embodiment of the present invention which solves the drawbacks of the first embodiment will be described with reference to the drawings.

第5図は本発明のソート処理装置を含むシステム構成
の一実施例を示すブロック図である。
FIG. 5 is a block diagram showing an embodiment of a system configuration including the sort processing device of the present invention.

主記憶装置1は命令語およびオペランドを格納する記
憶装置、バッファ記憶制御装置2は要求元の指示に従っ
て、主記憶装置1より命令語およびオペランドを読出し
て要求元へ送出したり、主記憶装置1の所定の場所へ演
算結果を格納する記憶制御装置、演算制御装置3は命令
制御装置4の指示に従って所定の演算を行なう演算制御
装置、命令制御装置4は主記憶装置1から命令語を読出
して解読し、演算制御装置3またはソート処理装置5に
演算の実行を指示する命令制御装置、ソート処理装置5
は本発明のソート処理装置である。
The main storage device 1 is a storage device for storing instruction words and operands, and the buffer storage control device 2 reads the instruction words and operands from the main storage device 1 and sends them to the request source according to the instruction of the request source. , A storage controller for storing the calculation result in a predetermined location, a calculation controller 3 for executing a predetermined calculation in accordance with an instruction from the instruction controller 4, and a command controller 4 for reading a command word from the main memory 1. An instruction control device for decoding and instructing the operation control device 3 or the sort processing device 5 to execute an operation, a sort processing device 5
Is a sort processing device of the present invention.

本実施例のシステム構成は、主記憶装置1、バッファ
記憶制御装置2、演算制御装置3、命令制御装置4から
なる公知のシステム構成に本発明のソート処理装置5が
付加される構成となっている。また、ソート処理装置5
は演算制御装置3内に内蔵される構成であってもよい。
The system configuration of the present embodiment is a configuration in which the sort processing device 5 of the present invention is added to a known system configuration including a main storage device 1, a buffer storage control device 2, an arithmetic control device 3, and an instruction control device 4. There is. Also, the sort processing device 5
May be built in the arithmetic and control unit 3.

バッファ記憶制御装置2によって主記憶装置1から読
出された命令語が命令制御装置4で解読され、ソート命
令である場合には、ソート処理装置5に通知される。
The instruction word read from the main storage device 1 by the buffer storage control device 2 is decoded by the instruction control device 4, and when it is a sort instruction, it is notified to the sort processing device 5.

ソート命令は、ソートすべきデータの格納場所とソー
ト済データの格納場所を示す情報を有しており、さらに
ソートすべきデータの個数および昇順にソートすべきか
降順にソートすべきかを指示するフィールドを有してい
る。ソートすべきデータの格納場所とソート済データの
格納場所はいずれも主記憶装置1内のメモリ上にとられ
る。本実施例におけるソートデータは表2のようにキー
部とポインタ部よりなり、キー部4バイト、ポインタ部
4バイトの8バイト固定長データでメモリ上に連続に配
置される。ソート処理の実行にあたっては、ソートすべ
きデータの読出しおよびソート済データの格納のリクエ
ストの制御は、命令制御装置4が司ってもよいし、ソー
ト処理装置5自身が司ってもよい。本実施例では命令制
御装置4が制御を司どり、メモリ上に連続に配置されて
いるソートすべきデータを順次読出してソート処理装置
5に送出する。命令制御装置4はまた、ソートすべきデ
ータの個数と、昇順にソートすべきか、降順にソートす
べきかの指示をソート処理装置5に通知する。
The sort command has information indicating the storage location of the data to be sorted and the storage location of the sorted data, and further has a field indicating the number of data to be sorted and whether to sort in ascending order or descending order. Have Both the storage location of the data to be sorted and the storage location of the sorted data are stored in the memory in the main storage device 1. As shown in Table 2, the sort data in the present embodiment is composed of a key portion and a pointer portion, and is 8 bytes fixed length data of 4 bytes for the key portion and 4 bytes for the pointer portion, which are continuously arranged in the memory. When executing the sort processing, the instruction control device 4 may control the request for reading the data to be sorted and the request for storing the sorted data, or the sort processing device 5 itself may control the request. In this embodiment, the instruction control unit 4 controls the control, sequentially reads out the data to be sorted which are continuously arranged in the memory, and sends the data to the sort processing unit 5. The instruction control device 4 also notifies the sort processing device 5 of the number of pieces of data to be sorted and an instruction as to whether to sort in ascending order or descending order.

第3図は本発明のソート処理装置5の第2の実施例の
ブロック構成図である。
FIG. 3 is a block diagram of the second embodiment of the sort processing device 5 of the present invention.

SL10は命令制御装置4から送られてくるソートすべき
データの個数を保持し、ソート処理装置5内に保持され
ているソートすべきデータの個数を示すレジスタ、カウ
ンタ50はSL10の内容を−1する減算器、セレクタ30は命
令制御装置4から送られてくるソートすべきデータの個
数またはカウンタ50の出力および初期値「0」のいずれ
かを選択して出力する選択器、SDB20およびSDB21はソー
トすべきデータを保持するバッファ、WAR11およびWAR13
は、SDB20およびSDB21の書込みアドレスを保持するライ
トアドレスレジスタ、RAR12およびRAR14は、SDB20およ
びSDB21の読出しアドレスを保持するリードアドレスレ
ジスタ、カウンタ51〜54はWAR11、RAR12、WAR13、RAR14
の内容をそれぞれ+1する加算器、カウンタ55,56はRAR
12、RAR14の内容をそれぞれ−1する減算器、セレクタ3
1,33はリセット値0とカウンタ51,53の出力をそれぞれ
選択する選択器、セレクタ32,33はリセット値0とカウ
ンタ52と55、54と56、およびWAR11、WAR13の内容をそれ
ぞれ選択する選択器、SDR16およびSDR17は、SDB20また
はSDB21から読出されたソートすべきデータを保持する
レジスタ、セレクタ36および37は、SDB20またはSDB21か
ら読出されたソートすべきデータを選択する選択器、SD
R18はSDR16もしくはSDR17から出力された結果データを
受け取り、結果データを主記憶装置1に格納するため
に、バッファ記憶制御装置2に結果データを送出するイ
ンタフェースレジスタ、セレクタ38はSDR16およびSDR17
の出力データを選択する選択器、セレクタ40は主記憶装
置1から読出されてソート処理装置5に送出されてくる
ソートすべきデータまたは、SDR16およびSDR17からの出
力データのいずれかを選択する選択器、セレクタ41はSD
R16およびSDR17からの出力データを選択する選択器、FG
R15は、SDB20およびSDB21のいずれか一方をソートすべ
きデータの読出し用バッファとして指定し、他方をソー
トすべきデータの退避用バッファとして指定するフラグ
レジスタ、セレクタ35は初期値0のFGR15の内容が反転
を受けた値とを選択する選択器、比較器23は、SDR16お
よびSDR17に保持されるソートすべきデータの予め定め
られた部分、即ち本実施例ではソートすべきデータのキ
ー部の内容同士を比較し、比較結果を出力する比較器、
比較器22はSL10の内容と、RAR12またはRAR14のいずれか
の内容とを比較し、一致を検出して出力する比較器、セ
レクタ39は、RAR12とRAR14の内容を選択する選択器、ケ
ート回路25は比較器23の内容を反転させる反転器、レジ
スタ19は初期値「0」または「1」または比較器23の出
力を保持するレジスタ、セレクタ42は初期値「0」また
は「1」と比較器23の出力を選択する選択器、比較器26
はゲート回路25の出力とレジスタ19の出力を比較し、一
致を検出する比較器、制御回路24はソート処理装置5全
体の制御を司る制御回路である。
SL10 holds the number of pieces of data to be sorted sent from the instruction control unit 4, and the register showing the number of pieces of data to be sorted held in the sort processing unit 5, the counter 50 sets the content of SL10 to -1. The selector 30, selector 30 is a selector for selecting and outputting either the number of data to be sorted sent from the instruction control unit 4 or the output of the counter 50 and the initial value "0", and SDB20 and SDB21 are sorts. Buffers, WAR11 and WAR13, that hold the data that should be
Is a write address register that holds the write address of SDB20 and SDB21, RAR12 and RAR14 is a read address register that holds the read address of SDB20 and SDB21, and counters 51 to 54 are WAR11, RAR12, WAR13, RAR14
The counters 55 and 56 are RAR
Subtractor and selector 3 for subtracting -1 from the contents of 12 and RAR14 respectively
Selectors 1 and 33 select the reset value 0 and the outputs of the counters 51 and 53 respectively. Selectors 32 and 33 select the reset value 0 and the contents of the counters 52 and 55, 54 and 56 and WAR 11 and WAR 13, respectively. SDR16 and SDR17 are registers for holding the data to be sorted read from SDB20 or SDB21, selectors 36 and 37 are selectors for selecting the data to be sorted read from SDB20 or SDB21, SD
R18 is an interface register that receives the result data output from SDR16 or SDR17 and sends the result data to the buffer storage control device 2 in order to store the result data in the main storage device 1. The selector 38 is the SDR16 and SDR17.
Selector 40 for selecting the output data from the main memory device 1 and the selector 40 for selecting either the data to be sorted which is read out from the main storage device 1 and sent to the sort processing device 5 or the output data from the SDR16 and SDR17. , Selector 41 is SD
Selector to select output data from R16 and SDR17, FG
R15 is a flag register that designates one of SDB20 and SDB21 as a read buffer for data to be sorted and the other as a save buffer for data to be sorted, and the selector 35 has the contents of FGR15 with an initial value of 0. The selector, which selects the value subjected to the inversion, the comparator 23 is a predetermined part of the data to be sorted held in the SDR16 and SDR17, that is, the contents of the key part of the data to be sorted in this embodiment. Comparator for comparing and outputting the comparison result,
The comparator 22 compares the content of SL10 with the content of either RAR12 or RAR14, detects a match and outputs the comparator, the selector 39 selects the content of RAR12 and RAR14, and the gate circuit 25. Is an inverter that inverts the contents of the comparator 23, the register 19 is an initial value "0" or "1" or a register that holds the output of the comparator 23, and the selector 42 is an initial value "0" or "1" and a comparator Selector for selecting 23 outputs, comparator 26
Is a comparator that compares the output of the gate circuit 25 with the output of the register 19 to detect a match, and the control circuit 24 is a control circuit that controls the entire sort processing device 5.

次に、本実施例のソート処理装置5によって、表2の
データ列がソートされる動作について説明する。
Next, the operation of sorting the data strings in Table 2 by the sort processing device 5 of this embodiment will be described.

今、表2のデータ列、即ちデータD0〜データD3までの
4データがメモリ上に連続に配置されており、このデー
タ列を昇順にソートする場合を考える。表2のデータD0
〜データD3は、バッファ記憶制御装置2によって主記憶
装置1から順次読出され、ソート処理装置5へ送出され
る。また、ソート命令によって示されるソートすべきデ
ータの個数「4」が命令制御装置4によって解読され、
ソート処理装置5へ送出される。
Now, consider a case where the data string in Table 2, that is, the four data D0 to D3 are continuously arranged in the memory, and this data string is sorted in ascending order. Data D0 in Table 2
The data D3 are sequentially read from the main storage device 1 by the buffer storage control device 2 and sent to the sort processing device 5. Further, the number of data to be sorted “4” indicated by the sort instruction is decoded by the instruction control device 4,
It is sent to the sort processing device 5.

第4図は表2のデータ列、データD0〜データD3がソー
ト処理装置5によってソートされる動作を示すタイミン
グ図である。
FIG. 4 is a timing chart showing the operation of sorting the data strings, data D0 to data D3 in Table 2, by the sort processing device 5.

サイクルT0では、SL10、WAR11、RAR12、WAR13、RAR14
は初期値0にリセットされた状態を保っている。また、
命令制御装置4からソートレングス、即ちソートすべき
データの個数「4」がソート処理装置5に送られてき
て、サイクルT1でSL10にセットされる。FGR15には、同
時に初期値「0」がセットされる。FGR15が値「0」を
保持している場合は、SDB20をソートすべきデータの読
出し用バッファとし、SDB21をソートすべきデータの退
避用バッファとして使用することを指示する。一方、FG
R15が値「1」にセットされると、SDB20がソートすべき
データの退避用バッファとし、SDB21がソートすべきデ
ータの読出し用バッファとして使用することが指示され
る。
SL10, WAR11, RAR12, WAR13, RAR14 in cycle T0
Keeps the initial value 0 reset. Also,
The sort length, that is, the number "4" of data to be sorted is sent from the instruction control unit 4 to the sort processing unit 5 and set in SL10 in cycle T1. At the same time, the initial value "0" is set in FGR15. When FGR15 holds the value "0", it instructs to use SDB20 as a read buffer for data to be sorted and SDB21 as a save buffer for data to be sorted. On the other hand, FG
When R15 is set to the value "1", it is instructed that SDB20 be used as a save buffer for data to be sorted and SDB21 be used as a read buffer for data to be sorted.

また、サイクルT1〜T4では、メモリから読出されたソ
ートすべきデータD0〜D3が順次ソート処理装置5へ転送
され、SDB20のライトアドレスレジスタWAR11が順次カウ
ントアップして、サイクルT2〜T5にかけて、SDB20に取
り込まれる。ソートデータD0〜D3がSDB20に取り込まれ
ると、順次SDR16、SDR17にデータが読出されて、比較器
23でデータのキー部の比較が行なわれる。レジスタ19
は、昇順ソートを行なう時には初期値「0」に、降順ソ
ートを行なう時には初期値「1」にリセットされ、今の
場合は「0」にリセットされる。まず、サイクルT3でSD
B20のワード0より読出されたソートデータD0がSDR16に
セットされ、サイクルT4でSDB20のワード1より読出さ
れたソートデータD1がSDR17にセットされる。SDR16とSD
R17にデータがそろうと比較器23でキー部の比較が行な
われ、比較結果が制御回路24に通知される。比較器23は
SDR16とSDR17の大小を検出する機能と一致を検出する機
能から構成されており、SDR16<SDR17の時論理「1」
を、SDR16>SDR17の時論理「0」を出力し、SDR16=SDR
17が検出された時には上記信号とは別に一致信号が制御
回路24に通知される。
In the cycles T1 to T4, the data D0 to D3 to be sorted read out from the memory are sequentially transferred to the sort processing device 5, the write address register WAR11 of the SDB20 is sequentially counted up, and the cycles S2 to T5 are repeated. Is taken into. When the sort data D0 to D3 are taken into the SDB20, the data are sequentially read out to SDR16 and SDR17, and the comparator
At 23, a comparison of the key parts of the data is made. Register 19
Is reset to an initial value "0" when performing ascending sort, to an initial value "1" when performing descending sort, and to "0" in this case. First, SD in cycle T3
Sort data D0 read from word 0 of B20 is set in SDR16, and sort data D1 read from word 1 of SDB20 is set in SDR17 in cycle T4. SDR16 and SD
When the data is stored in R17, the comparator 23 compares the key parts, and the comparison result is notified to the control circuit 24. The comparator 23
It is composed of the function to detect the size of SDR16 and SDR17 and the function to detect the match. When SDR16 <SDR17, the logic is "1".
When SDR16> SDR17, a logic "0" is output, and SDR16 = SDR
When 17 is detected, a coincidence signal is notified to the control circuit 24 in addition to the above signals.

サイクルT4でSDR16内のソートデータD0とSDR17内のソ
ートデータD1のキー部が比較され、比較器23は論理
「0」を出力し、制御回路24に通知する。この時、比較
器26では比較器23の内容がゲート回路25で反転をうけた
値「1」とレジスタ19に保持されている値「0」が比較
され、不一致を示す論理「0」が同時に制御回路24に通
知される。このことはSDR16に保持されているソートデ
ータD0とSDR17に保持されているソートデータD1が昇順
に並んでおらずソートデータの入れ替え処理が必要であ
ることを示している。つまり、先頭のソートデータはSD
R16に格納され、2番目のソートデータはSDR17に格納さ
れて比較動作が実行される。この先頭のデータD0と2番
目のデータD1がすでに昇順にソートされているならば、
比較器23は2番目のデータがより大なるキー値を保持し
ていることにより論理「1」を出力し、ゲート回路25で
反転を受けた値「0」がレジスタ19の初期値「0」と比
較され一致が検出されるはずである。バブルソートによ
る昇順ソートではより大きいキー値を有するソートデー
タが次のソートデータとの比較のために用いられ、小な
るキー値を有するソートデータが次の新たなソートデー
タと入れ替えられる。したがって、全ソートデータがす
でに昇順ソートされている場合には、ソートデータは、
必ずSDR16→SDR17→SDR16のようにSDR16とSDR17に交互
に入力されるはずである。即ち比較器23の出力も「1」
→「0」→「1」と交互に繰り返されるはずである。つ
まり、レジスタ19の値は比較器23出力値により毎回更新
され、一つ前の比較結果を保持し、今回の比較結果と比
較され、ソートデータが昇順に配列されているか否かが
検出される。
In cycle T4, the key parts of the sort data D0 in SDR16 and the sort data D1 in SDR17 are compared, the comparator 23 outputs a logic "0", and notifies the control circuit 24. At this time, the comparator 26 compares the value "1" of the contents of the comparator 23, which has been inverted by the gate circuit 25, with the value "0" held in the register 19, and simultaneously the logic "0" indicating the disagreement is obtained. The control circuit 24 is notified. This means that the sort data D0 held in the SDR16 and the sort data D1 held in the SDR17 are not arranged in ascending order, and a sort data replacement process is necessary. In other words, the top sort data is SD
The data is stored in R16, the second sort data is stored in SDR17, and the comparison operation is executed. If the first data D0 and the second data D1 are already sorted in ascending order,
The comparator 23 outputs the logic "1" because the second data holds the larger key value, and the value "0" inverted by the gate circuit 25 is the initial value "0" of the register 19. Should be compared to find a match. In ascending sort by bubble sort, sort data having a larger key value is used for comparison with the next sort data, and sort data having a smaller key value is replaced with the next new sort data. Therefore, if all sort data are already sorted in ascending order, the sort data will be
It should be input to SDR16 and SDR17 alternately like SDR16 → SDR17 → SDR16. That is, the output of the comparator 23 is also "1".
→ "0" → "1" should be repeated alternately. That is, the value of the register 19 is updated each time by the output value of the comparator 23, holds the previous comparison result, is compared with the current comparison result, and detects whether or not the sort data is arranged in ascending order. .

また、新たな比較動作のために供給されたソートデー
タのキー値が、前回、次の比較動作のために残されたソ
ートデータのキー値と等しい場合には、前回のソートデ
ータを保持するレジスタおよびレジスタ19の内容は更新
されずにそのまま保持され、新たなソートデータを保持
する側のレジスタに異なるキー値を有する新たなソート
データが供給されるまで新たなソートデータを保持する
側のレジスタの内容が更新される。
If the key value of the sort data supplied for the new comparison operation is equal to the key value of the sort data left for the previous comparison operation, the register holding the previous sort data is used. And the contents of the register 19 are held as they are without being updated, and until the new sort data having a different key value is supplied to the register holding the new sort data, the register holding the new sort data is Contents are updated.

なお、降順ソートを行なう場合はレジスタ19の初期値
が「1」にリセットされるだけの相異で後は同様であ
る。
It should be noted that when the descending sort is performed, the initial value of the register 19 is reset to "1", and the same applies thereafter.

再び、第3図および第4図にもどって本実施例の動作
の続きを説明する。
Again, returning to FIGS. 3 and 4, the continuation of the operation of this embodiment will be described.

本実施例ではより大なるキー値を有するソートデータ
は次のソートデータとの比較に用いられるためにそのま
まレジスタに保持され、小なるキー値を有するソートデ
ータは退避用バッファに退避される。この退避用バッフ
ァへの退避動作によって、バブルソートにおけるソート
の入れ替え処理が実行される。
In the present embodiment, the sort data having a larger key value is used for comparison with the next sort data, and is therefore held in the register as it is, and the sort data having a smaller key value is saved in the save buffer. By this save operation to the save buffer, the sort replacement processing in the bubble sort is executed.

比較器23からの論理「0」の出力結果を受けた制御回
路24の制御によってサイクルT5ではSDR17内のソートデ
ータD1がソートすべきデータの退避用バッファとして指
定されているSDB21のワード0に退避され、同時にSDB20
のワード2から次の比較動作のために読出されたソート
データD2がSDR17にセットされる。再び比較器23で比較
動作が行なわれ、小なるキー値を有するソートデータD2
がサイクルT6でSDB21のワード1に退避される。サイク
ルT6では、SDB20のワード3から読出された最後尾のソ
ートデータD3がSDR17にセットされる。サイクルT6での
比較器23の比較動作により、小なるキー値を有するソー
トデータD3がサイクルT7でSDB21のワード2に退避され
る。
In cycle T5, the sort data D1 in SDR17 is saved in word 0 of SDB21 designated as a save buffer for the data to be sorted by the control of the control circuit 24 which receives the output result of the logic "0" from the comparator 23. And at the same time SDB20
Sort data D2 read for the next comparison operation from word 2 of is set in SDR17. The comparison operation is performed again by the comparator 23, and the sort data D2 having a smaller key value is displayed.
Are saved to word 1 of SDB21 in cycle T6. In cycle T6, the last sort data D3 read from word 3 of SDB20 is set in SDR17. By the comparison operation of the comparator 23 in the cycle T6, the sort data D3 having a smaller key value is saved in the word 2 of the SDB21 in the cycle T7.

SDB20、SDB21のライトアドレスレジスタWAR11、WAR13
およびリードアドレスレジスタRAR12、RAR14は、それぞ
れ書込みおよび読出し動作を実行する度毎に、次のアド
レスを示すように+1カウントアップが行なわれる。し
たがって、サイクルT5でSDB20のワード3より最後尾の
ソートデータD3が読出され、サイクルT6でSDR17にセッ
トされると同時にRAR12はSDB20のワード4を示すように
カウントアップされる。セレクタ39は、ソートすべきデ
ータの読出し用バッファとして用いられている側のリー
ドアドレスレジスタの内容を選択して比較器22に出力し
ており、比較器22でSL10の内容と比較される。サイクル
T6ではRAR12の内容は「4」でありSL10の内容「4」と
一致する。比較器22は一致信号を出力し、制御回路24に
通知する。この一致信号は、ソートすべきデータの読出
し用バッファ内のソートデータの比較動作が全て終了し
たことを示す。また、一連のソートデータは、すでに昇
順にソートされたデータではなかったためにこの比較動
作終了信号を受けた制御回路24の制御によってサイクル
T7では以下の動作が行なわれる。
SDB20, SDB21 write address registers WAR11, WAR13
The read address registers RAR12 and RAR14 are incremented by +1 each time a write or read operation is performed to indicate the next address. Therefore, the last sort data D3 from word 3 of SDB20 is read in cycle T5, set in SDR17 in cycle T6, and at the same time RAR12 is counted up to indicate word 4 of SDB20. The selector 39 selects the content of the read address register on the side used as a read buffer for the data to be sorted and outputs it to the comparator 22, which compares it with the content of SL10. cycle
At T6, the content of RAR12 is "4", which matches the content of SL10 "4". The comparator 22 outputs a coincidence signal and notifies the control circuit 24. This coincidence signal indicates that all sort data comparison operations in the read buffer for the data to be sorted have been completed. In addition, since the series of sort data is not already sorted in ascending order, the cycle is controlled by the control circuit 24 which receives this comparison operation end signal.
The following operations are performed at T7.

まず、比較器23の比較動作の結果により、小なるキー
値を有するSDR17内のソートデータD3が退避用バッファS
DB21のワード3に退避され、SDR16内に残った最大のキ
ー値を有するソートデータD0がSDR18にセットされて、
メモリの所定の場所へ格納するためにバッファ記憶制御
装置2に送出される。
First, according to the result of the comparison operation of the comparator 23, the sort data D3 in the SDR 17 having a small key value is stored in the save buffer S.
Sort data D0 having the maximum key value remaining in SDR16 and saved in word 3 of DB21 is set in SDR18,
Sent to the buffer storage controller 2 for storage in a predetermined location in memory.

SL10は、減算器50で−1された値「3」に更新され
る。この値は、ソート処理装置5内に保持されているソ
ートすべきデータの残数を示している。
SL10 is updated to the value "3" subtracted by the subtractor 50. This value indicates the remaining number of data to be sorted which is held in the sort processing device 5.

WAR11、RAR12、WAR13、RAR14の各アドレスレジスタの
値は初期値「0」にリセットされ、レジスタ19も初期値
「0」にリセットされる。また、FGR15は、自身の内容
が反転された値、即ち値「1」に更新される。これはサ
イクルT7以降、SDB20がソートすべきデータの退避用バ
ッファに、SDB21がソートすべきデータの読出し用バッ
ファとして使用されることを示している。ここまでは第
1図のソート処理装置と同様の動作であり、この指示に
従って上述した一連の処理動作が繰り返される。
The value of each address register of WAR11, RAR12, WAR13, and RAR14 is reset to the initial value "0", and the register 19 is also reset to the initial value "0". Further, the FGR 15 is updated to a value in which its contents are inverted, that is, the value “1”. This indicates that after the cycle T7, the SDB20 is used as a save buffer for data to be sorted and the SDB21 is used as a read buffer for data to be sorted. The operation up to this point is the same as that of the sort processing apparatus in FIG. 1, and the series of processing operations described above are repeated in accordance with this instruction.

即ち、サイクルT8〜T10までSDB21のワード0〜ワード
2に保持されているソートデータがSDR16またはSDR17に
順次読出されて比較器23で比較動作が行なわれて小なる
キー値を有するソートデータがFGR15の指示によりSDB20
のワード0より順に退避させられる。ところで今回の一
連の比較動作では比較器26はいずれもソートデータが昇
順にソートされている論理「1」を出力し、全ソートデ
ータがすでに昇順にソートされていることを検出し、制
御回路24に通知する。同時にサイクルT10ではRAR14の値
とSL10の値の一致が検出されて、比較動作の終了が制御
回路24に通知され、以降では、全ソートデータがすでに
昇順にソートされていることにより、ソート処理の終了
処理が実行される。
That is, in cycles T8 to T10, the sort data held in the word 0 to the word 2 of the SDB21 are sequentially read by the SDR16 or SDR17, and the comparison operation is performed by the comparator 23, so that the sort data having a small key value is FGR15. SDB20
Are sequentially saved from the word 0. By the way, in the series of comparison operations this time, the comparator 26 outputs a logic "1" in which all sort data are sorted in ascending order, and it is detected that all sort data are already sorted in ascending order, and the control circuit 24 To notify. At the same time, in cycle T10, a match between the value of RAR14 and the value of SL10 is detected, and the control circuit 24 is notified of the end of the comparison operation.After that, since all sort data have already been sorted in ascending order, Termination processing is executed.

まず、サイクルT11でSDR17に保持されている小なるキ
ー値を有するソートデータD2がSDB20のワード1に退避
され、同時に残ソートデータの中で最大のキー値を有す
るソートデータD3がSDR16からSDR18にセットされてバッ
ファ記憶制御装置2に送出される。また、サイクルT11
ではSL10の値は残ソートデータの個数を示す値「0」に
リセットされ、またSDB20に退避されている昇順ソート
済のソートデータを掃き出すためにサイクルT10で保持
されているWAR11のポインタ値がサイクルT11でRAR12に
移される。そして、RAR12のポインタ値が−1ずつ減算
されて、SDB20のワード1,0よりソートデータD2およびD1
が読出され、サイクルT12,T13でSDR16にセットされ引き
続いてサイクルT13,T14でSDR18にセットされて、バッフ
ァ記憶制御装置2に送出されることで全ソート処理動作
が終了する。
First, in cycle T11, sort data D2 having a small key value held in SDR17 is saved to word 1 of SDB20, and at the same time sort data D3 having the largest key value among the remaining sort data is changed from SDR16 to SDR18. It is set and sent to the buffer storage controller 2. Also, cycle T11
Then, the value of SL10 is reset to the value "0" which indicates the number of remaining sort data, and the pointer value of WAR11 held in cycle T10 to sweep out the sorted data sorted in ascending order saved in SDB20 is cycled. Moved to RAR12 at T11. Then, the pointer value of RAR12 is decremented by -1, and sort data D2 and D1 are obtained from words 1 and 0 of SDB20.
Is read out, set in SDR16 in cycles T12, T13, subsequently set in SDR18 in cycles T13, T14, and sent to the buffer storage control device 2 to complete the entire sort processing operation.

昇順ソートの結果はソートデータがストアされたメモ
リの所定の場所より、ストア順の逆にソートデータのポ
インタ部を取り出すことにより得られる。
The result of the ascending sort is obtained by retrieving the pointer portion of the sort data in a reverse order of the store order from a predetermined location in the memory where the sort data is stored.

降順ソートの場合も、昇順ソートの場合と同様に行な
うことができる。
The descending sort can be performed in the same manner as the ascending sort.

〔発明の効果〕〔The invention's effect〕

以上説明したように本発明は、従来多数のソフトウェ
ア命令により逐次的に実行していたソート処理をハード
ウェアによるパイプライン処理により行なうことによ
り、高速に実行できる効果があり、また、バブルソート
の実行中にソート処理がすでに終了したか否かを検出す
ることにより、無駄なソート処理の実行を削減し、ソー
ト処理の一層の高速化が可能となる効果がある。
As described above, the present invention has the effect that it can be executed at high speed by performing the sorting process, which has been conventionally executed sequentially by a large number of software instructions, by the pipeline process by hardware, and the execution of bubble sort By detecting whether or not the sorting process has already been completed, there is an effect that unnecessary execution of the sorting process is reduced and the sorting process can be further speeded up.

【図面の簡単な説明】[Brief description of drawings]

第1図は本発明のソート処理装置の第1の実施例のブロ
ック図、第2図は第1図のソート処理装置によって実行
されるソート処理の動作を表わすタイミング図、第3図
は本発明のソート処理装置の第2の実施例のブロック
図、第4図は本実施例のソート処理装置によって実行さ
れるソート処理の動作を表わしたタイミング図、第5図
はソート処理装置を含むシステム全体の一実施例の構成
図、第6図、第7図はバブルソートによるソート処理の
動作を示す図である。 1……主記憶装置、2……バッファ記憶制御装置、3…
…演算制御装置、4……命令制御装置、5……ソート制
御装置、10……ソートレングスレジスタ(SL)、11,13
……ライトアドレスレジスタ(WAR)、12,14……リード
アドレスレジスタ(RAR)、15……フラグレジスタ(FG
R)、16,17,18……ソートデータレジスタ(SDR)、19…
…レジスタ、20,21……ソートデータバッファ(SDB)、
22,23,26……比較器、24……制御回路、25……ゲート回
路、30〜42……セレクタ、50,55,56……−1減算器、51
〜54……+1加算器。
FIG. 1 is a block diagram of a first embodiment of a sort processing apparatus of the present invention, FIG. 2 is a timing chart showing an operation of sort processing executed by the sort processing apparatus of FIG. 1, and FIG. 2 is a block diagram of a second embodiment of the sort processing apparatus, FIG. 4 is a timing chart showing the operation of the sort processing executed by the sort processing apparatus of the present embodiment, and FIG. 5 is the entire system including the sort processing apparatus. FIG. 6 and FIG. 7 are diagrams showing the operation of a sort process by bubble sort according to an embodiment of the present invention. 1 ... Main storage device, 2 ... Buffer storage control device, 3 ...
... arithmetic control device, 4 ... command control device, 5 ... sort control device, 10 ... sort length register (SL), 11, 13
...... Write address register (WAR), 12,14 ...... Read address register (RAR), 15 …… Flag register (FG
R), 16, 17, 18 ... Sort data register (SDR), 19 ...
… Register, 20,21 …… Sort data buffer (SDB),
22,23,26 …… Comparator, 24 …… Control circuit, 25 …… Gate circuit, 30 to 42 …… Selector, 50,55,56 …… -1 Subtractor, 51
~ 54 …… + 1 adder.

Claims (2)

【特許請求の範囲】[Claims] 【請求項1】第1および第2のデータバッファと、 これら第1および第2のデータバッファのうち、いずれ
か一方をソートすべきデータの読出し用バッファに、他
方をソートすべきデータの退避用バッファとして選択す
る手段と、 最初にソートすべきデータの読出し用として選択された
データバッファに外部から与えられるソートすべきデー
タを入力する手段と、 ソートすべきデータの読出し用バッファの出力を保持す
る第1および第2のレジスタと、 これら第1および第2のレジスタにソートすべきデータ
を順次格納する手段と、 前記第1および第2のレジスタにソートすべきデータが
格納される度に、第1および第2のレジスタの予め定め
られた部分の内容同士を比較し、比較結果を出力する比
較手段と、 この比較手段が第1のレジスタの値を退避すべき旨を出
力した場合は、第1のレジスタに保持されているデータ
を前記退避用バッファに退避し、第2のレジスタに保持
されているデータはそのまま保持し、新たなデータを第
1のレジスタに格納して次の比較動作を実行させ、一方
前記比較手段が第2のレジスタの値を退避すべき旨を出
力した場合は、同様に第2のレジスタに保持されている
データを前記退避用バッファに退避し、第1のレジスタ
に保持されているデータはそのまま保持し、新たなデー
タを第2のレジスタに格納して次の動作を実行させる手
段と、 予め指定された全データの前記比較手段と前記退避手段
が終了すると、前記退避用バッファに退避されずに前記
第1および第2のレジスタのいずれか一方にそのまま保
持されているデータを予め指定された格納場所に出力す
る手段と、 前記退避用バッファとして用いられたデータバッファを
ソートすべきデータの読出し用バッファとし、他方をソ
ートすべきデータの退避用バッファとして再選択し、こ
の再選択された読出し用バッファから順次ソートすべき
データを読み出し、上記一連の比較動作と退避用バッフ
ァへの退避動作および結果データの出力動作を繰り返さ
せる手段とを含むことを特徴とするソート処理装置。
1. A first and second data buffer, and one of these first and second data buffers is a read buffer for data to be sorted, and the other is a save buffer for data to be sorted. A means for selecting as a buffer, a means for inputting data to be sorted externally given to the data buffer selected for reading the data to be sorted first, and holding the output of the buffer for reading the data to be sorted First and second registers, means for sequentially storing the data to be sorted in the first and second registers, and each time the data to be sorted is stored in the first and second registers A comparing means for comparing the contents of predetermined portions of the first and second registers with each other and outputting a comparison result, and this comparing means is a first register. When it is output that the value of the data should be saved, the data held in the first register is saved in the save buffer, the data held in the second register is held as is, and a new When the data is stored in the first register and the next comparison operation is executed, while the comparison means outputs that the value of the second register should be saved, it is similarly held in the second register. Existing data is saved in the save buffer, the data held in the first register is held as it is, the new data is stored in the second register, and the next operation is executed. When the comparing means and the saving means for all the data are completed, the data held in one of the first and second registers without being saved in the save buffer is designated in advance. A means for outputting to the storage location, and the data buffer used as the save buffer as a read buffer for the data to be sorted, and the other is reselected as a save buffer for the data to be sorted, and the reselected read is performed. A sorting processing device comprising: means for reading data to be sequentially sorted from the data buffer, and repeating the series of comparison operations, saving operation to the saving buffer, and outputting result data.
【請求項2】第1および第2のレジスタと、 これら第1および第2のレジスタにソートすべきデータ
が格納される度に、前記第1および第2のレジスタの予
め定められた部分の内容同士を比較し、比較結果を出力
する比較手段と、 この比較手段の比較結果に従って、前記第1および第2
のレジスタのいずれに新たなソートすべきデータを格納
すべきかを指定するレジスタ指定手段と、 このレジスタ指定手段の指定に従って、前記第1および
第2のレジスタの一方に新たなソートすべきデータを格
納する手段と、 前記レジスタ指定手段がソートすべき全データに対して
前記第1および第2のレジスタを交互に指定したかを検
出する検出手段と、 この検出手段の検出出力があった場合は、前記ソートす
べき全データがすでにソート済みデータであることを検
出し、前記ソートすべき全データを予め定められた順序
に従って出力してソート処理を終了させる手段とを含む
ことを特徴とするソート処理装置。
2. A first and a second register and the contents of a predetermined portion of the first and the second register each time data to be sorted is stored in the first and the second register. Comparing means for comparing each other and outputting a comparison result, and the first and second comparing means according to the comparison result of the comparing means
Register designating means for designating in which of the registers the new data to be sorted is stored, and according to the designation of the register designating means, the new data to be sorted is stored in one of the first and second registers. Means for detecting whether or not the register designating means alternately designates the first and second registers for all the data to be sorted, and when there is a detection output of the detecting means, Sorting processing for detecting that all the data to be sorted are already sorted data, outputting all the data to be sorted according to a predetermined order, and terminating the sorting processing. apparatus.
JP63224304A 1988-09-06 1988-09-06 Sorting device Expired - Lifetime JPH0833812B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP63224304A JPH0833812B2 (en) 1988-09-06 1988-09-06 Sorting device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP63224304A JPH0833812B2 (en) 1988-09-06 1988-09-06 Sorting device

Publications (2)

Publication Number Publication Date
JPH0271327A JPH0271327A (en) 1990-03-09
JPH0833812B2 true JPH0833812B2 (en) 1996-03-29

Family

ID=16811670

Family Applications (1)

Application Number Title Priority Date Filing Date
JP63224304A Expired - Lifetime JPH0833812B2 (en) 1988-09-06 1988-09-06 Sorting device

Country Status (1)

Country Link
JP (1) JPH0833812B2 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP6318515B2 (en) 2013-09-24 2018-05-09 横浜ゴム株式会社 Pneumatic tire and manufacturing method thereof
JP6255840B2 (en) 2013-09-24 2018-01-10 横浜ゴム株式会社 Pneumatic tire

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS6054043A (en) * 1983-09-01 1985-03-28 Fujitsu Ltd Sort processor

Also Published As

Publication number Publication date
JPH0271327A (en) 1990-03-09

Similar Documents

Publication Publication Date Title
US4053871A (en) Method and system for the iterative and simultaneous comparison of data with a group of reference data items
US5742805A (en) Method and apparatus for a single history register based branch predictor in a superscalar microprocessor
JPH0814801B2 (en) Programmable access memory
KR0152979B1 (en) Variable length data processing apparatus
US5081608A (en) Apparatus for processing record-structured data by inserting replacement data of arbitrary length into selected data fields
JPS6235949A (en) Memory device
US4028670A (en) Fetch instruction for operand address calculation
JPH0833812B2 (en) Sorting device
JPS6142031A (en) Sorting processor
JPH01273132A (en) Microprocessor
JPS6327746B2 (en)
JP2772125B2 (en) Dictionary search method
JP2671325B2 (en) Data processing device
JPS61278933A (en) Data sorting out system
KR0141906B1 (en) Hardware driving device for searching data
JP3693873B2 (en) Mask bit number arithmetic unit, vector processing unit, information processing unit
JPH048815B2 (en)
JPH0926872A (en) Pipeline merge sorter
JPH0370826B2 (en)
JPS6234231A (en) File data processor
JPH0477349B2 (en)
JPS61110233A (en) Data processor
JPH01184577A (en) Information processor
JPH0470987A (en) Parallel data processing system
JPH11305992A (en) Data match detector