[go: up one dir, main page]

CN100561421C - Circuit and method for realizing data sorting - Google Patents

Circuit and method for realizing data sorting Download PDF

Info

Publication number
CN100561421C
CN100561421C CNB2006100995388A CN200610099538A CN100561421C CN 100561421 C CN100561421 C CN 100561421C CN B2006100995388 A CNB2006100995388 A CN B2006100995388A CN 200610099538 A CN200610099538 A CN 200610099538A CN 100561421 C CN100561421 C CN 100561421C
Authority
CN
China
Prior art keywords
group
mux
circuit
extreme value
selects
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.)
Active
Application number
CNB2006100995388A
Other languages
Chinese (zh)
Other versions
CN101114215A (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.)
Sanechips Technology Co Ltd
Original Assignee
ZTE 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 ZTE Corp filed Critical ZTE Corp
Priority to CNB2006100995388A priority Critical patent/CN100561421C/en
Publication of CN101114215A publication Critical patent/CN101114215A/en
Application granted granted Critical
Publication of CN100561421C publication Critical patent/CN100561421C/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Complex Calculations (AREA)

Abstract

本发明公开一种实现数据排序的电路和方法,为解决现有软件排序时间长,不满足实时性要求问题而发明。本发明的电路和方法:根据要查找的极值个数n,确定寄存器组、比较器组、n选1的多路选择器组、第一组2选1的多路选择器和第二组多路选择器、极值指针寄存器的深度,及第一组2选1多路选择器和第二组多路选择器、极值指针寄存器组的宽度;根据数据源的个数m,确定电路的运行时间为m个时钟;根据查找数值类型,选择比较器的输出类型;复位寄存器组、极值指针寄存器组;每个时钟周期向电路输入一个采样数据;经过m个时钟后停止本电路,此时寄存器组中保存的即为n个极值。本发明电路和方法,电路实时处理性强,排序时间成倍减少。

Figure 200610099538

The invention discloses a circuit and method for realizing data sorting, which is invented to solve the problem that existing software sorting takes a long time and does not meet real-time requirements. The circuit and method of the present invention: according to the number n of extreme values to be searched, determine the register group, the comparator group, the multiplexer group where n selects 1, the first group of 2 selectors 1 multiplexer, and the second group The depth of the multiplexer and the extremum pointer register, and the width of the first group of 2-to-1 multiplexers and the second group of multiplexers and the extremum pointer register group; according to the number m of data sources, determine the circuit The running time is m clocks; according to the search value type, select the output type of the comparator; reset the register group, the extreme value pointer register group; input a sampling data to the circuit every clock cycle; stop the circuit after m clocks, At this time, n extreme values are stored in the register group. The circuit and the method of the present invention have strong real-time processing capability, and the sorting time is doubled.

Figure 200610099538

Description

实现数据排序的电路和方法 Circuit and method for realizing data sorting

技术领域 technical field

本发明涉及数字信号处理领域,具体涉及一种实现数据排序的硬件电路及方法。The invention relates to the field of digital signal processing, in particular to a hardware circuit and method for realizing data sorting.

背景技术 Background technique

在数字信号处理中,经常需要对一系列数据进行排序,比如要对m个数据的大小顺序进行排序,或者从m个数据中找出n个最大(或最小)的数据,m≥n,以确定这些数据的优先级别。In digital signal processing, it is often necessary to sort a series of data, such as sorting the size order of m data, or finding the n largest (or smallest) data from m data, m≥n, to Prioritize this data.

现有的技术主要为软件排序。虽然软件排序的算法很多,但由于软件的运算速度较慢,无法满足实时性要求比较高的环境。比如通信系统的基站在进行小区搜索时,需要从大量的数据中找到真正的信号,并迅速向移动终端反馈信息,这个时间间隔要求很短,通常在1ms左右,在小区半径比较大或搜索的小区比较多时,需要处理的数据量非常庞大,经常达到十万的数量级,软件无法在如此短时间内实现如此多数据的查找排序。Existing technologies are mainly software sorting. Although there are many algorithms for software sorting, due to the slow computing speed of the software, it cannot meet the environment with high real-time requirements. For example, when the base station of the communication system searches for a cell, it needs to find the real signal from a large amount of data and quickly feed back the information to the mobile terminal. When there are many communities, the amount of data to be processed is very large, often reaching the order of 100,000. The software cannot search and sort so much data in such a short period of time.

发明内容 Contents of the invention

为了克服上述缺陷,本发明的目的在于提供一种满足实时性比较高的场合的实现数据排序的硬件电路和方法。In order to overcome the above-mentioned defects, the object of the present invention is to provide a hardware circuit and method for realizing data sorting that meet the requirements of relatively high real-time performance.

为达到上述目的,本发明一种实现数据排序的电路,包括:In order to achieve the above object, a circuit for realizing data sorting of the present invention includes:

一寄存器组(A),一比较器组(B),一n选1的多路选择器组(C),一第一2选1的多路选择器组(D),一第二2选1的多路选择器组(E),一极值指针寄存器组(F),一地址译码器(G),一与门阵列(H);所述寄存器组(A),比较器组(B),n选1的多路选择器组(C)和极值指针寄存器组(F)的个数为n,所述第一2选1的多路选择器组(D)和第二2选1的多路选择器组(E)的个数为n-1;A register group (A), a comparator group (B), a multiplexer group (C) where n selects 1, a multiplexer group (D) where the first 2 selects 1, and a second 2 selector group 1 multiplexer group (E), an extreme value pointer register group (F), an address decoder (G), an AND gate array (H); said register group (A), comparator group ( B), the number of the multiplexer group (C) and the extreme value pointer register group (F) that n selects 1 is n, and the multiplexer group (D) that the first 2 selects 1 and the second 2 The number of multiplexer groups (E) that select 1 is n-1;

其中,n为大于1的整数,定义i=0,1,……,n-1,Wherein, n is the integer greater than 1, defines i=0,1,...,n-1,

所述寄存器组(A)用于存储排序过程中当前的极值,寄存器组(A)的输出和本电路的数据输入作为比较器组(B)的输入;The register group (A) is used to store the current extreme value in the sorting process, and the output of the register group (A) and the data input of this circuit are used as the input of the comparator group (B);

所述比较器组(B)中的比较器(B0,B-1,……,B-n-1)输出的比较结果作为各n选1的多路选择器(C-i)的输入;The comparison results output by the comparators (B0, B-1, ..., B-n-1) in the comparator group (B) are used as the input of the multiplexer (C-i) where each n selects 1;

所述极值指针寄存器组(F)用于记录当前极值所在寄存器组(A)的存储位置及当前极值顺序,并作为n选1的多路选择器组(C)的控制端;The extremum pointer register group (F) is used to record the storage location and current extremum sequence of the register group (A) where the current extremum is located, and serves as the control terminal of the multiplexer group (C) where n selects 1;

所述第i+1个n选1的多路选择器(C-i)输出本电路输入的数据与当前极值比较的结果,作为第i+1个第一2选1多路选择器(D-i)的选择控制端,The i+1th n-choice multiplexer (C-i) outputs the result of comparing the data input by this circuit with the current extreme value, as the i+1th first 2-choice 1 multiplexer (D-i) The selection control terminal,

所述第i+1个极值指针寄存器(F-i)和所述第n个极值指针寄存器(F-n-1)作为第i+1个第一2选1多路选择器(D-i)的输入端;The i+1th extreme value pointer register (F-i) and the nth extreme value pointer register (F-n-1) are used as the input end of the i+1th first 2-to-1 multiplexer (D-i) ;

所述第i个n选1的多路选择器(C-i-1)的输出作为第i+1个第二2选1多路选择器(E-i)的选择控制端;The output of the ith n-selecting 1 multiplexer (C-i-1) is used as the selection control terminal of the i+1 second 2-selecting 1 multiplexer (E-i);

所述第i+1个第一2选1多路选择器(D-i)的输出和第i个极值指针寄存器(F-i-1)作为第i+1个第二2选1多路选择器(E-i)的输入;The output of the i+1 first 2-choice 1 multiplexer (D-i) and the i-th extreme value pointer register (F-i-1) are used as the i+1 second 2-choice 1 multiplexer ( E-i) input;

所述第i+1个第二2选1多路选择器(E-i)的输出作为第i+1个极值指针寄存器(F-i)的输入;The output of the i+1 second 2-to-1 multiplexer (E-i) is used as the input of the i+1 extreme value pointer register (F-i);

所述第n-1个极值指针寄存器(F-n-1)作为地址译码器(G)的输入端;The n-1th extreme value pointer register (F-n-1) is used as the input end of the address decoder (G);

所述第n-1个n选1的多路选择器(C-n-1)和地址译码器(G)的输出作为与门阵列(H)的输入;The output of the n-1 multiplexer (C-n-1) and the address decoder (G) for n selecting 1 is used as the input of the AND gate array (H);

所述与门阵列(H)的输出连接到寄存器(A)的输入使能端。The output of the AND gate array (H) is connected to the input enable terminal of the register (A).

其中,本电路的数据输入连接到寄存器组(A)和比较器组(B),将寄存器组(A)和极值指针寄存器组(F)连接到输出。Wherein, the data input of the circuit is connected to the register group (A) and the comparator group (B), and the register group (A) and the extremum pointer register group (F) are connected to the output.

其中,所述地址译码器(G)和与门阵列(H)组合为一个带使能端的地址译码器。Wherein, the address decoder (G) and the AND gate array (H) are combined into an address decoder with an enable terminal.

为达到上述目的,本发明一种基于权利要求1所述电路实现数据排序的方法,包括:In order to achieve the above object, the present invention provides a method for realizing data sorting based on the circuit described in claim 1, comprising:

(1)根据要查找的极值个数n,确定深度为n的寄存器组(A)、比较器组(B)、n选1的多路选择器组(C)和极值指针寄存器组(F);以及深度为n-1的第一组2选1的多路选择器(D)和第二组多路选择器组(E);其中,所述n选1的多路选择器组(C)的每一选择器的输出位宽为1、所述第一组2选1的多路选择器(D)、第二组多路选择器(E)和极值指针寄存器组(F)中各单元的输出位宽为大于或者等于或等于log 2(n)的最小整数;(1) According to the number n of extremum values to be searched, determine the register group (A) with a depth of n, the comparator group (B), the multiplexer group (C) where n selects 1, and the extremum pointer register group ( F); and the first group of 2-choice multiplexers (D) and the second group of multiplexer groups (E) with a depth of n-1; wherein, the n-choice 1 multiplexer group The output bit width of each selector of (C) is 1, the multiplexer (D) of described first group of 2 selecting 1, the second group of multiplexer (E) and the extremum pointer register group (F ) The output bit width of each unit is greater than or equal to or equal to the minimum integer of log 2(n);

(2)根据数据源的个数m,确定电路的运行时间为m个时钟;(2) According to the number m of data sources, determine the running time of the circuit as m clocks;

(3)根据查找数值类型,选择比较器组(B)的输出类型;(3) Select the output type of the comparator group (B) according to the search value type;

(4)复位寄存器组(A)、极值指针寄存器组(F);(4) reset register group (A), extreme value pointer register group (F);

所述极值指针寄存器组(F)中的各寄存器要分别复位为不同的值;查找最大值时,所述寄存器组(A)全部复位为其最小值,否则寄存器组(A)全部复位为其最大值;Each register in the described extremum pointer register group (F) will be reset to different values respectively; its maximum value;

(5)每个时钟向向电路输入采样数据;(5) Each clock inputs sampling data to the circuit;

(6)经过m个时钟后停止本电路。(6) Stop the circuit after m clocks.

采用本发明所述的方法和装置,克服了软件排序花费时间长,不能用于实时性要求高的场合的缺点。本发明使用硬件电路来实现数据的排序,此电路每个时钟可以处理一个数据,目前的集成电路一般可以工作在100MHz以上,对10万个数据进行排序的时间小于1ms,如果使用多套排序电路并行工作,排序时间还可以成倍减少,所以本电路的实时处理性强,可以满足对处理时间要求比较高的场合。The method and device of the invention overcome the disadvantages that software sorting takes a long time and cannot be used in occasions with high real-time requirements. The present invention uses a hardware circuit to realize the sorting of data. Each clock of this circuit can process one data. The current integrated circuit can generally work above 100MHz, and the time for sorting 100,000 data is less than 1ms. If multiple sets of sorting circuits are used Working in parallel, the sorting time can also be reduced exponentially, so this circuit has strong real-time processing performance and can meet the occasions that require relatively high processing time.

附图说明 Description of drawings

图1为一个单链表的示意图;Fig. 1 is a schematic diagram of a singly linked list;

图2为对图1进行重新排列并去掉空指针后得到的单链表;Fig. 2 rearranges Fig. 1 and removes the singly linked list obtained after the null pointer;

图3为一个2选1的多路选择器;Fig. 3 is a multiplexer that selects 1 from 2;

图4为一个16选1的多路选择器;Fig. 4 is a multiplexer of 16 selections;

图5为本发明实现数据排序的电路结构框图;Fig. 5 is the circuit structure block diagram that the present invention realizes data sorting;

图6为本发明实现数据排序的一个具体实施例;Fig. 6 is a specific embodiment of realizing data sorting in the present invention;

图7为本发明实现数据排序方法的流程图。FIG. 7 is a flow chart of the method for implementing data sorting in the present invention.

具体实施方式 Detailed ways

下面结合附图和实施例对本发明作进一步的详细说明。The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments.

本方法的主要思想来源于软件数据结构中的单链表,单链表是存储数据的一种结构,访问存储在链表中的数据时,需要查询一组指针,这组指针的内容为这些数据的存储位置。The main idea of this method comes from the single-linked list in the software data structure. The single-linked list is a structure for storing data. When accessing the data stored in the linked list, it is necessary to query a set of pointers. The content of this set of pointers is the storage of these data. Location.

图1为一个单链表的示意图,头指针为d0的存储位置,指针1为d1的存储位置,……,指针n为dn的存储位置,最后是一个空指针,如果n为一个固定的数,可以不使用最后的空指针。Figure 1 is a schematic diagram of a singly linked list, the head pointer is the storage location of d0, the pointer 1 is the storage location of d1, ..., the pointer n is the storage location of dn, and the last is a null pointer, if n is a fixed number, The final null pointer may not be used.

图2为对图1进行重新排列并去掉空指针后得到的单链表。Figure 2 is the singly linked list obtained after rearranging Figure 1 and removing the null pointer.

为了更好的解释本发明,下面对本发明中用到的一些元件进行说明。In order to better explain the present invention, some elements used in the present invention are described below.

图3为一个2选1的多路选择器,i0,i1为数据输入端口,s为选择控制端口,z为输出端口,当s为0时,z的输出为i0,当s为1时,z的输出为i1。Figure 3 is a 2-to-1 multiplexer, i0, i1 are data input ports, s is a selection control port, z is an output port, when s is 0, the output of z is i0, when s is 1, The output of z is i1.

图4为一个16选1的多路选择器,i为数据输入端口,s为选择控制端口,z为输出端口。i的位宽为16,i由i15,i14,i13,……,i1,i0组成;s的位宽为4,取值范围为0~15。当s的值为j时,z的输出为j,这里j的取值范围为0~15。如果一个多路选择器的输入位宽是其他值,其工作原理与16选1的多路选择器是相似的。可以用2选1的多路选择器搭建16选1的多路选择器或其他类型的多路选择器,一般的数字电路教材中都有论述,此处不再赘述。Figure 4 is a 16-to-1 multiplexer, i is the data input port, s is the selection control port, and z is the output port. The bit width of i is 16, and i is composed of i15, i14, i13,..., i1, i0; the bit width of s is 4, and the value range is 0~15. When the value of s is j, the output of z is j, where the value of j ranges from 0 to 15. If the input bit width of a multiplexer is other values, its working principle is similar to that of a 16-to-1 multiplexer. A 2-to-1 multiplexer can be used to build a 16-to-1 multiplexer or other types of multiplexers, which are discussed in general digital circuit textbooks and will not be repeated here.

通用的比较器一般有两个输入a和b,三个输出,一个输出判断a是否大于b,一个判断a是否等于b,另一个判断a是否小于b。A general-purpose comparator generally has two inputs a and b, and three outputs. One output judges whether a is greater than b, one judges whether a is equal to b, and the other judges whether a is smaller than b.

本发明中用到的比较器只需要一个输出,根据需要可以是判断a是否大于b的,也可以是判断a是否小于b的。The comparator used in the present invention only needs one output, and it can judge whether a is greater than b or whether a is smaller than b as required.

本发明所述的排序电路主要用于从m个数据中找出n个最大(或最小)的数据,m≥n,并且同时实现对这n个最大(或最小)的值进行大小排序。The sorting circuit of the present invention is mainly used to find out the n largest (or smallest) data from m data, m≥n, and at the same time realize the size sorting of the n largest (or smallest) values.

如图5所示,此电路主要由以下几个部分组成:一组寄存器A,一组比较器B,一组n选1的多路选择器C,一组2选1的多路选择器D,一组2选1的多路选择器E,一组极值指针寄存器F,一个地址译码器G,一个与门阵列H。As shown in Figure 5, this circuit is mainly composed of the following parts: a set of registers A, a set of comparators B, a set of n to 1 multiplexer C, a set of 2 to 1 multiplexer D , a group of 2-to-1 multiplexers E, a group of extremum pointer registers F, an address decoder G, and an AND gate array H.

本电路的输入连接到寄存器组A和比较器组B,本电路的输出为寄存器组A和极值指针寄存器组F。The input of this circuit is connected to register group A and comparator group B, and the output of this circuit is register group A and extremum pointer register group F.

与门阵列H的输出连接到寄存器组A的输入使能端;寄存器组A的输出和本电路的数据输入作为比较器组B的输入;比较器组B的输出作为多路选择器组C的输入,极值指针寄存器组F作为多路选择器组C的控制端;多路选择器组C的输出作为多路选择器组D的控制端,极值指针寄存器组F作为多路选择器组D的输入端;多路选择器组C的输出作为多路选择器组E的控制端,多路选择器组D的输出和极值指针寄存器组F作为多路选择器组E的输入端;多路选择器组E的输出作为极值指针寄存器组F的输入端;极值指针寄存器组F作为地址译码器G的输入端;多路选择器组C和地址译码器G的输出作为与门阵列H的输入。The output of the AND gate array H is connected to the input enable terminal of the register group A; the output of the register group A and the data input of this circuit are used as the input of the comparator group B; the output of the comparator group B is used as the input of the multiplexer group C Input, the extreme value pointer register group F is used as the control terminal of the multiplexer group C; the output of the multiplexer group C is used as the control terminal of the multiplexer group D, and the extreme value pointer register group F is used as the multiplexer group The input terminal of D; the output of the multiplexer group C is used as the control terminal of the multiplexer group E, and the output of the multiplexer group D and the extreme value pointer register group F are used as the input terminal of the multiplexer group E; The output of the multiplexer group E is used as the input terminal of the extreme value pointer register group F; the extreme value pointer register group F is used as the input terminal of the address decoder G; the output of the multiplexer group C and the address decoder G is used as Input to AND gate array H.

所述电路适用于从m个数据中找到n个最大或最小的数据,实现对最大或最小的数据进行大小排序。The circuit is suitable for finding n largest or smallest data from m data, and realizing size sorting of the largest or smallest data.

所述地址译码器和与门阵列可以组合为一个带使能端的地址译码器。The address decoder and the AND gate array can be combined into an address decoder with an enable terminal.

利用上述电路进行数据排序的方法,包括下列步骤:The method for sorting data by utilizing the above circuit comprises the following steps:

步骤1、根据要查找最大值(或最小值)的个数n,确定本发明电路中寄存器A、比较器B、n选1的多路选择器C、2选1的多路选择器D、2选1的多路选择器E、极值指针寄存器F的深度和2选1的多路选择器D、2选1的多路选择器E、极值指针寄存器F的宽度;Step 1, according to the number n of maximum value (or minimum value) to be searched, determine register A, comparator B, n in the circuit of the present invention select 1 multiplexer C, 2 select 1 multiplexer D, The depth of the 2-to-1 multiplexer E, the extremum value pointer register F, and the width of the 2-to-1 multiplexer D, the 2-to-1 multiplexer E, and the extremum pointer register F;

A、B、C、F的深度为n,D、E的深度为n-1,C的宽度为1,D、E、F的宽度为大于或等于log2(n)的最小整数。The depth of A, B, C, F is n, the depth of D, E is n-1, the width of C is 1, and the width of D, E, F is the smallest integer greater than or equal to log2(n).

步骤2、选择待查找的数据源的个数m,以确定电路的运行时间为m个时钟。Step 2. Select the number m of data sources to be searched to determine the running time of the circuit as m clocks.

步骤3、根据查找数值类型,即要查找最大值还是最小值选择比较器的输出类型。Step 3. Select the output type of the comparator according to the search value type, that is, to find the maximum value or the minimum value.

步骤4、复位寄存器组A、极值指针寄存器组F;Step 4, reset register group A, extreme value pointer register group F;

F要分别复位为0,1,2,……,n-1,要保证他们复位后的值各不相同;查找最大值时,寄存器组A全部复位为其最小值,否则寄存器组A全部复位为其最大值。F should be reset to 0, 1, 2, ..., n-1 respectively, and the values after reset should be guaranteed to be different; when searching for the maximum value, all register group A is reset to its minimum value, otherwise all register group A is reset to its maximum value.

步骤5、每个时钟周期向本电路输入一个数据(采样);Step 5, each clock cycle inputs a data (sampling) to this circuit;

步骤6、经过m个时钟后停止本电路,此时寄存器组A中保存的即为n个极值,极值指针寄存器组F内保存的是这些极值的大小顺序。Step 6. Stop the circuit after m clocks. At this time, n extreme values are stored in the register group A, and the magnitude order of these extreme values is stored in the extreme value pointer register group F.

使用寄存器组A保存当前的n个极值,极值指针寄存器组F用于记录A中各个极值的大小顺序。Register group A is used to save the current n extremum values, and extremum pointer register group F is used to record the magnitude order of each extremum value in A.

新的采样同时与A中所有的值进行比较,根据极值指针寄存器组F和比较器组B的比较结果来判断新的采样是否是一个新的极值,并同时判断出新的大小顺序。The new sample is compared with all values in A at the same time, and whether the new sample is a new extremum is judged according to the comparison result of the extremum pointer register group F and the comparator group B, and the new order of magnitude is judged at the same time.

如果当前采样不是新的极值,原先的大小顺序不变,否则原先的极值当中有一个将不再是极值,此极值在A中的存储位置将变为当前采样在A中的写入位置。If the current sample is not a new extremum, the order of the original size remains unchanged, otherwise one of the original extremum will no longer be an extremum, and the storage position of this extremum in A will become the write of the current sample in A into position.

上述极值大小顺序的调整和当前采样写入位置判断的操作通过n选1的多路选择器组C、2选1的多路选择器组D、2选1的多路选择器组E、极值指针寄存器组F、地址译码器G和与门阵列H共同来实现。The above-mentioned adjustment of the extreme value order and the operation of judging the writing position of the current sample are performed through the multiplexer group C of n to 1, the multiplexer group D of 2 to 1, the multiplexer group E of 2 to 1, The extremum pointer register group F, the address decoder G and the AND gate array H are realized together.

下面以从1000个无符号数据中选择16个最大值为例,详细讲解本发明的电路。Taking the selection of 16 maximum values from 1000 unsigned data as an example, the circuit of the present invention will be explained in detail below.

查找最小值的原理与查找最大值的原理类同。The principle of finding the minimum value is similar to the principle of finding the maximum value.

此电路的详细结构如附图6所示,16个极值指针寄存器记录了当前16个最大值在寄存器组A中的存储位置,指针寄存器F-0记录当前最大值的位置,指针寄存器F-1记录当前次大值的位置,……,指针寄存器F-14记录当前次小值的位置,指针寄存器F-15记录当前最小值的位置。存储器A中虽然存储了16个最大值,但并不是一定按大小顺序存储,其大小顺序靠这里的16个极值指针寄存器来记录。The detailed structure of this circuit is shown in accompanying drawing 6, 16 extremum pointer registers record the storage position of current 16 maximum values in register group A, pointer register F-0 records the position of current maximum value, pointer register F- 1 records the position of the current second largest value, ..., the pointer register F-14 records the position of the current second smallest value, and the pointer register F-15 records the position of the current minimum value. Although 16 maximum values are stored in memory A, they are not necessarily stored in order of size, and the order of their size is recorded by the 16 extreme value pointer registers here.

当前采样进来后同时与寄存器组A中的16个值进行比较,以判断其是否是一个新的极值。如果当前采样没有当前16个最大值中的最小值大,则A和F不需要更新;如果当前采样比前16个最大值中的任何一个大,则将当前采样的数据写入原先16个最大值中最小值的位置,并同时调整16个极值指针的内容,即同时调整寄存器组A中各个数据的大小顺序。After the current sample comes in, it is compared with the 16 values in register group A at the same time to determine whether it is a new extreme value. If the current sample is not as large as the minimum of the current 16 maximum values, A and F do not need to be updated; if the current sample is larger than any of the previous 16 maximum values, the current sampled data will be written into the original 16 maximum values value, and adjust the contents of 16 extreme value pointers at the same time, that is, adjust the order of the size of each data in register group A at the same time.

在系统复位后,将寄存器组A全部复位为0,并且将16个指针寄存器F复位,这里将指针寄存器F-0复位为15,指针寄存器F-1复位为14,指针寄存器F-2复位为13,……,指针寄存器F-14复位为1,指针寄存器F-15复位为0(如图6中最右边所示)。After the system is reset, all the register group A is reset to 0, and the 16 pointer registers F are reset, where the pointer register F-0 is reset to 15, the pointer register F-1 is reset to 14, and the pointer register F-2 is reset to 13, ..., the pointer register F-14 is reset to 1, and the pointer register F-15 is reset to 0 (as shown on the far right in FIG. 6 ).

寄存器组A中的16个值A-0,A-1,…,A-15同时与当前采样进行比较,比较时使用16个比较器B-0,B-1,…,B-15,如果当前采样比A-s大,B-s输出为1,否则B-s的输出为0,s=0,…15。极值指针寄存器F-i记录了第i号最大值的存储位置,i=0,…15,因此可以通过极值指针寄存器F-i获得第i号最大值与当前采样的比较结果。多路选择器组C中有16个16选1的多路选择器,以极值指针寄存器F-i作为C-i的选择控制端,以B-0,B-1,…,B-15作为C-i的输入,C-i的输出为极值指针寄存器F-i对应的极值与当前采样的大小比较结果(如附图6中所示)。The 16 values A-0, A-1, ..., A-15 in register group A are compared with the current sample at the same time, and 16 comparators B-0, B-1, ..., B-15 are used for comparison, if The current sampling is larger than A-s, and the output of B-s is 1, otherwise, the output of B-s is 0, s=0,...15. The extreme value pointer register F-i records the storage location of the i-th maximum value, i=0, ... 15, so the comparison result of the i-th maximum value and the current sampling can be obtained through the extreme value pointer register F-i. There are 16 16-to-1 multiplexers in the multiplexer group C, the extreme value pointer register F-i is used as the selection control terminal of C-i, and B-0, B-1, ..., B-15 are used as the input of C-i , the output of C-i is the comparison result between the extreme value corresponding to the extreme value pointer register F-i and the size of the current sample (as shown in Figure 6).

16个最大值的指针寄存器中,极值指针寄存器F-i记录的是当前第i个最大值的存储位置,i=0,…,15,即极值指针0对应当前最大值,极值指针1对应当前次大值,……,极值指针15对应当前16个最大值中的最小值。Among the 16 maximum value pointer registers, the extreme value pointer register F-i records the storage location of the current i-th maximum value, i=0,...,15, that is, the extreme value pointer 0 corresponds to the current maximum value, and the extreme value pointer 1 corresponds to The current next largest value, ..., the extreme value pointer 15 corresponds to the minimum value among the current 16 maximum values.

如果当前采样没有寄存器组A中当前16个最大值中的最小值大,则寄存器组A和极值指针寄存器组F保持不变;如果当前采样比寄存器组A中当前16个最大值中的任何一个大,则将当前采样写入原先16个最大值中最小值的位置,即极值指针寄存器F-15的值。If the current sample is not greater than the minimum of the current 16 maximum values in register bank A, then register bank A and the extremum pointer register bank F remain unchanged; if the current sample is greater than any of the current 16 maximum values in register bank A If one is large, the current sample is written to the position of the minimum value among the original 16 maximum values, that is, the value of the extreme value pointer register F-15.

对于16个极值指针寄存器中的任何一个指针寄存器F-i来说,如果当前采样没有自己对应的值大,则指针寄存器F-i的内容不需要更改;如果当前采样刚好替代了原先第i个最大值的大小位置,则指针寄存器F-i替换为指针寄存器F-15的内容;如果当前采样比指针寄存器F-i-1对应的值还大,则指针寄存器F-i的内容要替换为指针寄存器F-i-1的内容;这里,当前采样与第i-1个最大值的比较结果优先级高于当前采样与第i个最大值的比较结果。For any pointer register F-i in the 16 extreme value pointer registers, if the current sample is not as large as its corresponding value, the content of the pointer register F-i does not need to be changed; if the current sample just replaces the value of the original i-th maximum value size position, the pointer register F-i is replaced by the content of the pointer register F-15; if the current sample is larger than the corresponding value of the pointer register F-i-1, the content of the pointer register F-i is replaced by the content of the pointer register F-i-1; here , the priority of the comparison result between the current sample and the i-1th maximum value is higher than the comparison result between the current sample and the i-th maximum value.

在本发明中,其电路实现为:将第i个最大值与当前采样的比较结果C-i作为多路选择器D-i的选择控制端,F-15和F-i做为D-i的输入,C-i为1时D-i的输出为F-15,否则输出为F-i;将第i-1个最大值与当前采样的比较结果C-i-1作为多路选择器E-i的选择控制端,D-i和F-i-1做为E-i的输入,C-i-1为1时E-i的输出为F-i-1,否则输出为D-i;E-i的输出作为指针F-i的输入,如附图6中所示。In the present invention, its circuit is realized as: using the comparison result C-i of the ith maximum value and the current sampling as the selection control terminal of the multiplexer D-i, F-15 and F-i as the input of D-i, when C-i is 1, D-i The output is F-15, otherwise the output is F-i; the comparison result C-i-1 of the i-1th maximum value and the current sampling is used as the selection control terminal of the multiplexer E-i, and D-i and F-i-1 are used as the input of E-i , when C-i-1 is 1, the output of E-i is F-i-1, otherwise the output is D-i; the output of E-i is used as the input of pointer F-i, as shown in Figure 6.

对于指针0来讲,由于指针0对应的为15个最大值中的最大值,因此不需要E-0,直接将D-0的输出作为F-0的输入,如附图6中所示。For pointer 0, since pointer 0 corresponds to the maximum value among the 15 maximum values, E-0 is not needed, and the output of D-0 is directly used as the input of F-0, as shown in FIG. 6 .

对于E-15来讲,由于D-15的两个输入端都为F-15,所以可以不使用D-15,直接将F-15和F-14作为E-15的输入,如附图6中所示。For E-15, since the two input terminals of D-15 are both F-15, it is not necessary to use D-15, and directly use F-15 and F-14 as the input of E-15, as shown in Figure 6 shown in .

当前采样的写入位置为极值指针寄存器F-15的输出,当前采样连接到寄存器组A中所有寄存器的输入端口,寄存器组A中的各个寄存器都有使能端口。将极值指针寄存器F-15的输出送入4-16译码器G,由G和与门阵列H生成寄存器组A中各个寄存器的使能。地址译码器G的输出位宽为16,其输出信号分别为G15,G14,…,G1,G0。当4-16译码器的输入取值为s时,其输出Gs为有效,其他输出为无效,s=0,1,…15。当前采样是否要写入寄存器组A中,还需要根据C-15来判断。与门阵列H将G的输出G15,G14,…,G1,G0分别与C-15进行相与,得到H15,H14,…,H1,H0,Hs连接到A-s的使能端口。这样可以根据当前采样是否为新的极值来控制当前采样是否可以写入到寄存器组A中。The write position of the current sample is the output of the extremum pointer register F-15, and the current sample is connected to the input port of all registers in register group A, and each register in register group A has an enable port. The output of the extremum pointer register F-15 is sent to the 4-16 decoder G, and the enable of each register in the register group A is generated by G and the AND gate array H. The output bit width of the address decoder G is 16, and its output signals are respectively G15, G14, . . . , G1, G0. When the input value of the 4-16 decoder is s, its output Gs is valid, and other outputs are invalid, s=0,1,...15. Whether the current sampling should be written into register group A still needs to be judged according to C-15. The AND gate array H ANDs the outputs G15, G14, ..., G1, G0 of G with C-15 respectively, and H15, H14, ..., H1, H0, Hs are connected to the enable ports of A-s. In this way, whether the current sample can be written into register group A can be controlled according to whether the current sample is a new extreme value.

通过上面的操作,经过1000个时钟以后,就可以将16个最大值挑选出来,这些值保存于寄存器组A中,他们在寄存器组A中的存储位置保存于15个极值指针寄存器中,极值指针寄存器F-0对应最大值,指针存器F-1对应次大值,……,指针存器F-15对应16个最大值中的最小值。Through the above operation, after 1000 clocks, 16 maximum values can be selected, and these values are stored in register group A, and their storage locations in register group A are stored in 15 extreme value pointer registers, which are extremely The value pointer register F-0 corresponds to the maximum value, the pointer register F-1 corresponds to the next largest value, ..., and the pointer register F-15 corresponds to the minimum value among the 16 maximum values.

利用图6中的装置查找最大值的过程,包括下列步骤:Utilize the process that the device among Fig. 6 finds maximum value, comprise the following steps:

步骤1、根据要查找最大值的个数16,可确定A、B、C、F的深度为16,D、E的深度为15,C的宽度为1,D、E、F的宽度为4;Step 1. According to the number 16 of the maximum value to be found, it can be determined that the depth of A, B, C, and F is 16, the depth of D, E is 15, the width of C is 1, and the width of D, E, and F is 4 ;

步骤2、根据待查找的数据源的个数1000,确定电路的运行时间为1000个时钟,Step 2. According to the number of 1000 data sources to be searched, determine that the running time of the circuit is 1000 clocks,

步骤3、根据查找类型,即,要查找最大值选择比较器的输出类型;Step 3, according to the search type, that is, to find the maximum value and select the output type of the comparator;

步骤4、将寄存器组A全部复位为0,将极值指针寄存器组F分别复位为0,1,2,……,15;Step 4, reset all the register group A to 0, and reset the extremum pointer register group F to 0, 1, 2, ..., 15 respectively;

步骤5、每个时钟向本发明的电路输入一个数据(采样);Step 5, each clock inputs a data (sampling) to the circuit of the present invention;

步骤6、经过1000个时钟后停止本电路,此时16个最大值保存于寄存器组A中,极值指针寄存器组F内保存的是这些极值的大小顺序。Step 6. Stop the circuit after 1000 clocks. At this time, the 16 maximum values are stored in the register group A, and the extreme value pointer register group F stores the order of the magnitudes of these extreme values.

采用本发明所述的方法和装置,与现有技术相比,本发明克服了软件排序花费时间长,不能用于实时性要求高的场合的缺点。本发明使用硬件电路来实现数据的排序,此电路每个时钟可以处理一个数据,目前的集成电路一般可以工作在100MHz以上,对10万个数据进行排序的时间小于1ms,如果使用多套排序电路并行工作,排序时间还可以成倍减少,所以本电路的实时处理性强,可以满足对处理时间要求比较高的场合。By adopting the method and device of the present invention, compared with the prior art, the present invention overcomes the disadvantages that software sorting takes a long time and cannot be used in occasions with high real-time requirements. The present invention uses a hardware circuit to realize the sorting of data. Each clock of this circuit can process one data. The current integrated circuit can generally work above 100MHz, and the time for sorting 100,000 data is less than 1ms. If multiple sets of sorting circuits are used Working in parallel, the sorting time can also be reduced exponentially, so this circuit has strong real-time processing performance and can meet the occasions that require relatively high processing time.

Claims (4)

1, a kind of circuit of realizing data sorting comprises:
One registers group (A), a comparator bank (B), a n selects 1 MUX group (C), one the 1 selects 1 MUX group (D), and one the 22 selects 1 MUX group (E), an extreme value pointer register set (F), one address decoder (G), one with gate array (H); Described registers group (A), comparator bank (B), it is n that n selects 1 the MUX group (C) and the number of extreme value pointer register set (F), the described the 1 to select 1 MUX group (D) and the 22 to select the number of 1 MUX group (E) be n-1;
Wherein, n is the integer greater than 1, definition i=0, and 1 ..., n-1;
Described registers group (A) is used for the current extreme value of memory sequencing process, and the output of registers group (A) and the data of this circuit are imported the input of device group (B) as a comparison;
Each comparer in the described comparator bank (B) (B-0, B-1 ..., B-n-1) Shu Chu comparative result selects the input of 1 MUX (C-i) as each n;
Described extreme value pointer register set (F) is used to write down the memory location and the current extreme value order of current extreme value place registers group (A), and selects the control end of 1 MUX group (C) as n;
Described i+1 n selects 1 MUX (C-i) to export data and the current ratio of extreme values result of the input of this circuit, selects the selection control end of 1 MUX (D-i) as i+1 the individual the 1,
Described i+1 extreme value pointer register (F-i) and described n extreme value pointer register (F-n-1) select the input end of 1 MUX (D-i) as i+1 the individual the 1;
The selection control end of 1 MUX (E-i) is selected in the output that described i n selects 1 MUX (C-i-1) as i+1 the 22;
Described i+1 the individual the 1 selects the output of 1 MUX (D-i) and i extreme value pointer register (F-i-1) selects 1 MUX (E-i) as i+1 the individual the 22 input;
Described i+1 the individual the 22 selects the input of the output of 1 MUX (E-i) as i+1 extreme value pointer register (F-i);
Described n extreme value pointer register (F-n-1) is as the input end of address decoder (G);
The output that described n n selects 1 MUX (C-n-1) and address decoder (G) as with the input of gate array (H);
Described and output gate array (H) is connected to the input Enable Pin of register (A).
2, the circuit of realization data sorting according to claim 1 is characterized in that, the data input of this circuit is connected to registers group (A) and comparator bank (B), and registers group (A) and extreme value pointer register set (F) are connected to output.
3, the circuit of realization data sorting according to claim 1 is characterized in that, described address decoder (G) and with gate array (H) be combined as one the band Enable Pin address decoder.
4, a kind of method based on the described circuit realization of claim 1 data sorting comprises:
(1), determines that the degree of depth is that registers group (A), comparator bank (B), the n of n selects 1 MUX group (C) and extreme value pointer register set (F) according to the extreme value number n that will search; And the degree of depth is that the 1 of n-1 selects 1 the MUX group (D) and the second MUX group (E); Wherein, it is the 1, the described the 1 to select the output bit wide of each unit in 1 MUX group (D), the second MUX group (E) and the extreme value pointer register set (F) for being greater than or equal to log that described n selects the output bit wide of each selector switch of 1 MUX group (C) 2(n) smallest positive integral;
(2) according to the number m of data source, be m clock the working time of determining circuit;
(3) according to searching value type, select the output type of comparator bank (B);
(4) reseting register group (A), extreme value pointer register set (F);
Each register in the described extreme value pointer register set (F) will be reset to different values respectively; When searching maximal value, described registers group (A) all is reset to its minimum value, otherwise registers group (A) all is reset to its maximal value;
(5) each the time clockwise to the circuit input sampling data;
(6) stop this circuit through behind m clock.
CNB2006100995388A 2006-07-28 2006-07-28 Circuit and method for realizing data sorting Active CN100561421C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2006100995388A CN100561421C (en) 2006-07-28 2006-07-28 Circuit and method for realizing data sorting

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2006100995388A CN100561421C (en) 2006-07-28 2006-07-28 Circuit and method for realizing data sorting

Publications (2)

Publication Number Publication Date
CN101114215A CN101114215A (en) 2008-01-30
CN100561421C true CN100561421C (en) 2009-11-18

Family

ID=39022580

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2006100995388A Active CN100561421C (en) 2006-07-28 2006-07-28 Circuit and method for realizing data sorting

Country Status (1)

Country Link
CN (1) CN100561421C (en)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102207846A (en) * 2010-03-31 2011-10-05 国际商业机器公司 Circuit and method for realizing data sorting
CN102291107A (en) * 2010-06-18 2011-12-21 中兴通讯股份有限公司 Method and device for realizing multi-path comparison by using digital circuit
CN104317549A (en) * 2014-10-15 2015-01-28 中国航天科技集团公司第九研究院第七七一研究所 Cascade structure circuit and method for realizing data sorting
CN105159597A (en) * 2015-06-17 2015-12-16 北京空间机电研究所 High-speed real-time ordering method for large quantity data in uncertain number
CN111651204B (en) * 2016-04-26 2024-04-05 中科寒武纪科技股份有限公司 Apparatus and method for performing vector maximum-minimum operation
CN109460210B (en) * 2018-10-22 2020-11-03 重庆中科云从科技有限公司 Sorting system and data processing method
CN111260042B (en) * 2018-11-30 2022-12-02 上海寒武纪信息科技有限公司 Data selector, data processing method, chip and electronic equipment
CN111340229B (en) * 2018-11-30 2022-12-09 上海寒武纪信息科技有限公司 Data selector, data processing method, chip and electronic equipment
CN111260043B (en) * 2018-11-30 2022-12-02 上海寒武纪信息科技有限公司 Data selector, data processing method, chip and electronic equipment
CN109766074B (en) * 2018-12-05 2021-04-13 西安电子科技大学 Data sorting circuit and sorting method

Also Published As

Publication number Publication date
CN101114215A (en) 2008-01-30

Similar Documents

Publication Publication Date Title
CN100561421C (en) Circuit and method for realizing data sorting
Kim et al. In-storage processing of database scans and joins
US6845024B1 (en) Result compare circuit and method for content addressable memory (CAM) device
US20180247682A1 (en) Methods for reading data from a storage buffer including delaying activation of a column select
US10489159B2 (en) Pipelined decompression of sliding window compressed data
WO2018148918A1 (en) Storage apparatus, chip, and control method for storage apparatus
US10803974B1 (en) Memory device providing bad column repair and method of operating same
CN1987771A (en) Hardware circuit for realizing data sequencing and method
Lenart et al. A 2048 complex point FFT processor using a novel data scaling approach
CN1653345A (en) Tester system having multiple instruction memories
CN101162919A (en) Data caching circuit
US9135984B2 (en) Apparatuses and methods for writing masked data to a buffer
CN105426314A (en) Process mapping method for FPGA memory
CN1653346A (en) Tester system having a multi-purpose memory
US7694068B1 (en) Re-entrant processing in a content addressable memory
US7774583B1 (en) Processing bypass register file system and method
US9570125B1 (en) Apparatuses and methods for shifting data during a masked write to a buffer
CN1851824A (en) High speed streamline long-time-delay multi-port SRAM quick access method
US8214305B1 (en) Pattern matching system and method for data streams, including deep packet inspection
CN100356345C (en) Method and system for access of high speed buffer memory line
KR102769706B1 (en) Systems, methods, and devices for shuffle acceleration
US7996649B1 (en) Translation look-aside buffer with look-up optimized for programmable logic resource utilization
CN115185584A (en) Configurable storage interface system based on DSP
US6925014B1 (en) Integrated circuit and method of reading data from a memory device
CN102736996A (en) Method for reducing occupation of storage controller interface, and high-speed storage

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
C41 Transfer of patent application or patent right or utility model
TR01 Transfer of patent right

Effective date of registration: 20151113

Address after: Dameisha Yantian District of Shenzhen City, Guangdong province 518085 Building No. 1

Patentee after: SHENZHEN ZTE MICROELECTRONICS TECHNOLOGY CO., LTD.

Address before: 518057, Guangdong Shenzhen hi tech Industrial Park Nanshan District science and technology south road ZTE building 6 floor of the Ministry of law

Patentee before: ZTE Corporation

EE01 Entry into force of recordation of patent licensing contract
EE01 Entry into force of recordation of patent licensing contract

Application publication date: 20080130

Assignee: Xi'an Chris Semiconductor Technology Co. Ltd.

Assignor: SHENZHEN ZTE MICROELECTRONICS TECHNOLOGY CO., LTD.

Contract record no.: 2019440020036

Denomination of invention: Circuit for realizing data ordering and method thereof

Granted publication date: 20091118

License type: Common License

Record date: 20190619