FIND FIRST FUNCTION

A method for finding the first one bit in a vector groups the bits of the vector into pairs of adjacent bits. Within each pair of two the presence or absence of a one bit is identified and the position determined. There may be multiple levels so a second level groups has inputs based on the determinations from the two pairs. Based on the inputs the presence of absence of a one bit is determined and, if present, the position within the respective bits of the vector. This can be repeated over multiple levels.

BACKGROUND

Find first function is a common function in which the first 1 bit in a vector is found. This can be starting from the least significant bit, working towards the more significant bits. Alternatively, an arbitrary starting point can be used and the first 1 bit in a vector (moving towards more significant bits) found. If an arbitrary starting point is used and no 1 bit is found in the more significant bits the function can be set up to wrap to the least significant bit and continue searching from the least significant bit.

Find first functions are commonly used in sequencing of transactions. For example, it is commonly used to find the oldest instruction that is ready for processing in a queue. Find first functions are also used in caches and circular buffers to find the oldest data or in look up tables.

There are currently different solutions for finding the first 1 bit. However, they involve iterating over the whole string of bits and, for a large vector, iterating over the whole vector can be very time consuming.

It is therefore desirable to find a faster way of searching for the first one bit in a vector.

SUMMARY

A method for finding the first one bit in a vector is disclosed. The bits of the vector are grouped into pairs of adjacent bits. Within each pair of two the presence or absence of a one bit is identified and the position determined. There may be multiple levels so a second level groups has inputs based on the determinations from the two pairs. Based on the inputs the presence of absence of a one bit is determined and, if present, the position within the respective bits of the vector. This can be repeated over multiple levels.

According to one aspect, there is provided a machine-implemented method of processing a vector, the method comprising: receiving the vector, grouping the bits of the vector into mutually exclusive pairs of two adjacent bits, identifying, in each pair of two, the presence or absence of a one bit and outputting a first level indicator output indicating whether a one bit is present in the respective bits of the vector and a first level position output indicating the position of the first one bit in the respective bits of the vector, grouping the first level indicator output and the first level position outputs into mutually exclusive groups of two adjacent first level indicator outputs and first level position outputs, and determining, based on a group of two adjacent first level indicator outputs, the presence of absence of a one bit in the respective bits of the vector and outputting a second level indicator output indicating whether a one bit is present in the respective bits of the vector and, based on a group of two adjacent first level position outputs, the position of the first one bit in the respective bits of the vector and outputting a second level position output indicating the position of the first one bit in the respective bits of the vector.

Due to the tree structure the time taken to search the vector does not scale linearly with the length of the vector but rather scales as the number of levels of the tree structure increases.

The method may further comprise: grouping the second level indicator output and the second level position outputs into mutually exclusive groups of two adjacent second level indicator outputs and second level position outputs, and determining, based on a group of two adjacent second level indicator outputs, the presence or absence of a one bit in the respective bits of the vector and outputting a third level indicator output indicating whether a one bit is present in the respective bits of the vector and, based on a group of two adjacent second level position outputs, the position of the first one bit in the respective bits of the vector and outputting a third level position output indicating the position of the first one bit in the respective bits of the vector.

Grouping an (n−1)th level indicator output and a (n−1)th level position output and determining the presence or absence of a one bit in the respective bits of the vector to output an n level indicator output and a n level position output may be repeated until a grouping and determining step is determining the presence or absence of a one bit, and the position of the first one bit in the whole vector.

In some examples the position of the first one bit is searched starting from the least significant bit in each group or pair. In other examples the position of the first one bit is searched starting from the most significant bit in each group or pair.

The most significant bit in the second level position output may be based on the first one bit in the first level indicator outputs in the group of two adjacent first level indicator outputs, a zero most significant bit indicating a first one bit in a first group of two and a one most significant bit indicating a first one bit in a second group of two. The least significant bits in the second level position output may be the position input from the group of two on which the most significant bit is based.

In some examples a position output is only valid if the corresponding indicator output indicates that a zero is present in the respective bits of the vector.

In some examples a starting position other than the least or most significant bit may be used. The method may further comprise receiving an index position indicating the starting search position, switching each pair of two and each group of two into one of three states on the basis of the relative location of the index position and the position of the bits in the vector, the three states comprising on, off and indexed, wherein the outputting an indicator output based on each pair of two and each group of two comprises, if the pair or group of two is in an off state outputting an indicator output indicating that no one bit is present, and if the pair or group of two is in an on state outputting an indicator output based on the presence or absence of a one bit, and if the pair or group of two is in an indexed state outputting an indicator output based on the presence or absence of a one bit only for positions to be searched.

Each pair of two and each group of two at a lower bit position than the index position is switched into an off state, each pair of two and each group of two at a higher bit position than the index position is switched into an on state, and each pair of two and each group of two including the index position is switched into an indexed state.

The method may search for the first one bit from a starting position, moving towards more significant bits. In some examples, a second function of finding the first one bit may be carried out without a starting position i.e. searching from the least significant bit. This may be achieved by performing two search functions: one with a starting, or index, position and the second without an index position i.e. starting from the least significant bit. If a one bit is identified from the processing using an index position, the position of the first one bit from the processing using an index is output as a result and if a one bit is not identified from the processing using an index position the position of the first one bit from the processing with no index is output as a result.

The method has been described in conjunction with finding the first one bit. However, it can equally be used to find the first zero bit. An alternative way of achieving this is to switch the one bits and zero bits and search for the zero bits as described above.

The present invention has been described in conjunction with pairs, or groups of two. However, the vector could instead be grouped into groups of a different number: for example, three, four or five. Binary notation could still be used or alternatively base x notation could be used for groupings of size x.

Also provided is a data processing system configured to perform a method as summarised above. The data processing system may be embodied in hardware on an integrated circuit.

Also provided is a method of manufacturing, using an integrated circuit manufacturing system, a data processing system as summarised above.

Also provided is a method of manufacturing, using an integrated circuit manufacturing system, a data processing system as summarised above, the method comprising: processing, using a layout processing system, a computer readable description of the data processing system so as to generate a circuit layout description of an integrated circuit embodying the data processing system; and manufacturing, using an integrated circuit generation system, the data processing system according to the circuit layout description.

Also provided is computer readable code configured to cause a method as summarised above to be performed when the code is run. Also provided is a computer readable storage medium (optionally non-transitory) having encoded thereon the computer readable code.

Further provided is an integrated circuit definition dataset that, when processed in an integrated circuit manufacturing system, configures the integrated circuit manufacturing system to manufacture a data processing system as summarised above.

Also provided is a computer readable storage medium having stored thereon a computer readable description of a data processing system as summarised above that, when processed in an integrated circuit manufacturing system, causes the integrated circuit manufacturing system to manufacture an integrated circuit embodying the data processing system.

Also provided is a computer readable storage medium having stored thereon a computer readable description of a data processing system as summarised above which, when processed in an integrated circuit manufacturing system, causes the integrated circuit manufacturing system to: process, using a layout processing system, the computer readable description of the data processing system so as to generate a circuit layout description of an integrated circuit embodying the data processing system; and manufacture, using an integrated circuit generation system, the data processing system according to the circuit layout description.

Also provided is an integrated circuit manufacturing system configured to manufacture a data processing system as summarised above.

Further provided is an integrated circuit manufacturing system comprising: computer readable storage medium having stored thereon a computer readable description of a data processing system as summarised above; layout processing system configured to process the computer readable description so as to generate a circuit layout description of an integrated circuit embodying the data processing system; and an integrated circuit generation system configured to manufacture the data processing system according to the circuit layout description. The layout processing system may be configured to determine positional information for logical components of a circuit derived from the integrated circuit description so as to generate a circuit layout description of an integrated circuit embodying the data processing system.

DETAILED DESCRIPTION

Embodiments will now be described by way of example only.

Faced with a desire to find the first one bit in a lengthy vector current methods involve iterating over the whole vector. In a lengthy vector this can take a long time. It is therefore desirable to provide a faster method of finding the first one bit digit in a vector.

The present approach groups bits of a vector into mutually exclusive pairs. The pairs are generally paired from the least significant bit first. Each pair is then examined by a leaf node.

FIG.1depicts a leaf node according to this approach for finding the first one bit in a two bit vector. The two bits, data[0] and data[1] are input and there are two outputs, each of a single bit (or digit): an indicator output and a position output. The leaf node identifies whether or not a one bit is present in the two bits input. If a one bit is present it outputs a first output as an indicator output and if a one bit is not present it outputs a second output as an indicator output. For example, if a one bit is found among the two bits a one might be output as a first indicator output. If no one bit is found among the two bits a zero might be output as a first indicator output.

The second output from the leaf node is a position output. This is only valid if the indicator output indicates that a one bit is present. If valid, the position output indicates the position of the first one bit, starting from the least significant bit. So, searching for the first one bit starting from the least significant bit generates the following outputs:

So, a leaf node can be summarised as:“Indicator output” indicates if a one bit was found based on the two input bits, in this example data [0] or data [1]“Position output” indicates the position of the first one bit and is only valid if “indicator output”=1. It can be NOT data[0] (as this will give the correct position output whenever the position output is valid)

In this example a leaf node only searches two digits. In order to search vectors with more than two digits multiple leaf nodes are required. The outputs from each leaf node are then grouped into mutually exclusive groups of two and each mutually exclusive group of two is examined by a branch node.FIG.2depicts an arrangement for searching for the first one bit in an eight digit vector. As can be seen, there are three levels: a first level comprising leaf nodes; a second level comprising branch nodes and a third level comprising another branch node. The outputs from one level are the inputs into the next level. So, a first level output forms an input to a second level node.

The leaf nodes operate as described above in conjunction withFIG.1.

A branch node is depicted inFIG.3. InFIG.3, which shows a single branch node in isolation, the signals depicted at the bottom of the figure are the inputs to the respective node, and are labelled as such, whilst the signals depicted above the node are the outputs from the node (and, again, are labelled as such). However, in figures that contain multiple levels of branch nodes, an output signal from a node in one (lower) level can be an input to a node at the next (higher) level and, for simplicity, those signals are simply labelled as outputs from the lower level node.

A branch node identifies if there are any one bits identified in the nodes (either leaf nodes or branch nodes) directly below (i.e. which provide inputs to it). A branch node has four inputs: indicator outputs and position outputs from each of the nodes below. A branch node has two outputs: a single digit indicator output and a multibit position output.

If a one bit is present in either of the indicator inputs the branch node outputs a first output as an indicator output and if a one bit is not present it outputs a second output as an indicator output. For example, if a one bit is found among either of the two indicator inputs (indicating that a one bit is present among the respective bits of the vector) a one might be output as a first indicator output. If no one bit is found among the two indicator inputs a zero might be output as a first indicator output.

The second output from a branch node is a multibit position output. Similar to the leaf node, the second output is only valid if the indicator output indicates that a one bit is present. If valid, the position output indicates the position of the first one bit, starting from the least significant bit.

The multibit position output can be divided into the most significant bit (MSB) and the least significant bits (LSBs), which comprise all the bits except the most significant bit.

The most significant bit indicates the nodal position, starting from the least significant bit, of the first indicator input that indicates a one bit is present.

The least significant bits for the position output of the branch node are copied from position output of either node0or node1depending on whether the MSB is based on the indicator from node0or node1. So, in the example above, if the MSB is based on the indicator from node0(because the indicator input from0is one) then the LSBs are taken from the position input from node1. If the MSB is based on the indicator from node1(because the indicator from node0, which takes precedence, is zero and the indicator from node1is one) then the LSBs are taken from the position input from node1.

The position output has a number of bits equal to the number of the level at which the node is located. So, a branch node on the second level has a two bit position output. A branch node on the fourth level has a four bit position output and a branch node on the nth level has an n bit position output.

The operation of a branch node at level n can be summarised:“Indicator output” is set to one if either of the received indicator signals, indicator input0or indicator input1(i.e. the indicator signals received from level n−1, which are indicator outputs of nodes in level n−1), are zero“Position output” MSB is the position of the first received indicator signal, indicator input0or indicator input1, that is set to one (indicator input0takes priority). It can be NOT indicator input0.“Position output” LSBs are copied from received signal position input0or position input1(i.e. from one of the position signals received from level n−1, which are also position output signals from nodes in level n−1), depending on which indicator input0or indicator input1input is used in position output MSB (indicator input0takes priority)

FIG.4adepicts a vector input into the three level system depicted inFIG.2. This depicts how the bits of the vector are processed. At the first level, each leaf node searches, and identifies, whether a one bit is present in the two bit inputs.

At the second level, the branch nodes identify whether a one bit is present in either of the indicator inputs (which indicate whether a one bit is present in the respective bits of the vector) and the position of any one bit in the respective bits of the vector. So, in both the right hand and left hand second level branch nodes inFIG.4athe indicator output is set to one because (at least) one of the indicator inputs is one.

Starting from the least significant bit the position of the first one bit indicator input is identified and set as the most significant bit in the position output. In the right hand second level branch node the indicator input from the right hand (i.e. least significant bit) leaf node is zero. The indicator input from the left hand leaf node is one and so the most significant bit is set to one, the position of the first one among the indicator inputs. In the left hand second level branch node the indicator input from the right hand (least significant bit) leaf node is one so the most significant bit of the position output is set to zero, the position of the first one among the indicator inputs.

The third level branch node has inputs from the two second level branch nodes. A one is found in at least one of the indicator inputs to the third level branch node so the indicator output is set to one. The position of the first one in the indicator outputs is zero (the right hand/least significant bit node) so the most significant bit of the position output is set to zero. As the most significant bit of the position output is based on the indicator output from the right hand/least significant bit node the two digit least significant bits are the same as the position input from the right hand/least significant bit node.

The indicator output from the third level indicates that a one bit has been found and the position output gives the position of the first one bit. In this case the position is given as bit number three.

FIG.4bdepicts the same three level system processing a different vector. Here, the first one bit is at bit number four.

As can be seen, each level in the multi-level structure provides a single bit of the final result. Each tree level takes approximately the same processing time so doubling the length of the vector increases the processing time by approximately the same amount. A vector of 256 bits has eight tree levels. The present approach considerably speeds up processing compared to conventional methods of finding the first one bit in which the time taken scales linearly with the length of the vector. For example, the present approach can search vectors of up to 2048 bits in one clock cycle at 900 MHz.

The examples described above start searching from the least significant bit. However, on occasions, for example, in circular buffers or instruction queues, it is desirable to search from a particular starting position.

Searching from a starting position can be achieved in the present approach using an index indicating the starting search position. Nodes (or pairs or groups of two) are switched into an on, off, or indexed state based on the relative location of the node and the index. Nodes (or pairs or groups of two) positioned at a lower bit position than the index position are switched into an off state. In an off state the indicator output is set to zero.

Nodes (or pairs or groups of two) positioned at a higher bit position than the index position are switched into an on state and the inputs are examined as described above.

Nodes (or pairs or groups of two) which straddle the index, or start, position are switched into an indexed state. In an indexed state the inputs only from positions higher than the index position are searched to find a one bit.

The states are assigned to the nodes (or pairs or groups of two) as follows:Nodes whose inputs are wholly below the start position are given state OFFNodes whose inputs are wholly above the start position are given the state ONNodes whose inputs straddle the start position are given the state INDEX

The functions are as follows:OFF—do not examine either input and set the indicator output to zeroON—examine input0followed by input1but ignore the start inputINDEX—examine input0followed by input1if start=0, otherwise only examine input1

FIG.5depicts a three level system with a starting search position at data[5], or index of [101]. The bits of the index [101] are used in the determination of node states (as further explained herein), with each bit relating to a level within the system as illustrated on the right ofFIG.5. Node states are assigned in a top down manner with the top, or root node, having an INDEX state. The state of child nodes is then assigned based on the state of the node. If a node is in an ON or OFF state then both child nodes are assigned, or switched, to the same state. If the node is in an INDEX state, and the index input for this level is [1] then the right child node (input0) is switched to an OFF state, otherwise the right child node is assigned an INDEX state. If the node is in an INDEX state and the index input for this level is [0] then the left child node (input1) is assigned an ON state, otherwise the left child node is assigned an INDEX state.

The assignation of states for a right hand child node can be summarised as follows:If the (parent) node is in an OFF or ON state then the right child node is assigned the same stateIf the index input for the parent node is [1] then the right child is assigned an OFF stateOtherwise the right child node is assigned an INDEX state

The assignation of states for a left hand child node can be summarised as follows:If the (parent) node is in an OFF or ON state then the left child node is assigned the same stateIf the index input for the parent node is [0] then the left child is assigned an ON stateOtherwise the left child node is assigned an INDEX state

InFIG.5the top, or level three, node is switched to an index state. As can be seen the index for the level three, or top node, is [1] (the MSB of the index [101]) and therefore the right hand child node is switched to an OFF state. As the index for the level three node the left hand child node is assigned an INDEX state.

Looking at the right hand level two node in an OFF state, all child nodes are assigned an OFF state.

Looking at the left hand level two node in an INDEX state, the index for this level node is [0]. The right hand child node (i.e. at the first level) is therefore assigned an INDEX state. The left hand node is therefore assigned an ON state.

Looking at the first level node in an INDEX state, only the left hand (data[5]) input is examined because the index for the first level is a [1] (the LSB of the index [101]), indicating that only input1should be examined.

With the nodes switched as described above data[6] is output as the first one bit starting from position [5].

A wrap function can be implemented in conjunction with the starting position. This is achieved by running two parallel find first functions: a first find first function which begins at the search starting position and a second find first function which has no starting position (i.e. begins at the least significant bit). If a one bit is found by the first find first function the position of that one bit is output as the first one bit. If no one bit is found by the first find first function the position of a one bit found by the second find first function is output as the first one bit. Thus, a wrapping function can easily be implemented.

FIGS.6aand6bdepict the use of a starting position in conjunction with a wrap function. For this, there are two find first functions: one (depicted inFIG.6a) which begins at the search starting position and a second (depicted inFIG.6b) find first function which begins at the least significant bit.

FIG.6adepicts a find first function using a starting position [5]. As described above in relation toFIG.5the nodes, or groups and pairs of two, are switched into an on, off or indexed state. Looking at the first level node in an INDEX state, only the left hand (data[5]) is examined. However, none of data[5], data[6] or data[7] have a one bit and therefore the indicator output from the level three node is0.

FIG.6bdepicts a starting function, operating on the same inputs as the find first function inFIG.6a, but starting searching from the least significant bit. As can be seen, the first one bit is at data[1] and thus the output from the top level node indicates that a one bit has been found and also that the position is data[1] (shown by001as the position output).

As no one bit was found by the find first function searching from a starting position the result, or output from the find first function searching from the least significant bit (depicted inFIG.6b) is used. Thus the first one bit found is at position001. The two find first functions depicted inFIGS.6aand6bcan operate simultaneously or consecutively.

The examples above describe a three level system but this can easily be increased and for each level increase the maximum size of the vector to be searched doubles. Thus, lengthy vectors can quickly and easily be searched. A seven level system could be used to search a 128 bit vector and a 9 level system used to search up to a 512 bit vector.

The system can also be used to search vectors which are not 2nbits long. For vectors which aren't 2nbits long zeros are added to the most significant bit end until a vector is 2nbits long. So, the vector 011001 would have two zeros added to the most significant bit end to become 00011001 and it could then be searched by a three level system.

The examples above describe searching for the first one bit. However, this method can also be used to search for the first zero bit. Either a zero bit can be searched for in the way that a one bit is searched for above. Alternatively the zero bits can be converted to one bits and the one bits converted to zero bits (so 00011001 becomes 11100110) and the method of searching for a one bit described above used.

The methods and systems described above can be embodied in fixed function or fixed logic hardware. For example, a plurality of fixed logic devices can be used for each node to process each pair or group of two.

FIG.7shows a computer system in which the data processing systems described herein may be implemented. The computer system comprises a CPU902, an NNA904, a memory906and other devices914, such as a display916, speakers918and a camera919. A processing block910(corresponding to mapping unit12, MMM40, and hardware accelerator200) is implemented on the NNA904. The components of the computer system can communicate with each other via a communications bus905. A store912(corresponding to memory25) is implemented as part of the memory906.

WhileFIG.7illustrates one implementation of a graphics processing system, it will be understood that a similar block diagram could be drawn for an artificial intelligence accelerator system—for example, by replacing either the CPU902or the GPU904with a Neural Network Accelerator (NNA), or by adding the NNA as an additional unit. In such cases, the processing block910can be implemented in the NNA.

The data processing system ofFIGS.1to6are shown as comprising a number of functional blocks. This is schematic only and is not intended to define a strict division between different logic elements of such entities. Each functional block may be provided in any suitable manner. It is to be understood that intermediate values described herein as being formed by a data processing system need not be physically generated by the data processing system at any point and may merely represent logical values which conveniently describe the processing performed by the data processing system between its input and output.

Therefore, there may be provided a method of manufacturing, at an integrated circuit manufacturing system, a data processing system as described herein. Furthermore, there may be provided an integrated circuit definition dataset that, when processed in an integrated circuit manufacturing system, causes the method of manufacturing a data processing system to be performed.

An integrated circuit definition dataset may be in the form of computer code, for example as a netlist, code for configuring a programmable chip, as a hardware description language defining hardware suitable for manufacture in an integrated circuit at any level, including as register transfer level (RTL) code, as high-level circuit representations such as Verilog or VHDL, and as low-level circuit representations such as OASIS® and GDSII. Higher level representations which logically define hardware suitable for manufacture in an integrated circuit (such as RTL) may be processed at a computer system configured for generating a manufacturing definition of an integrated circuit in the context of a software environment comprising definitions of circuit elements and rules for combining those elements in order to generate the manufacturing definition of an integrated circuit so defined by the representation. As is typically the case with software executing at a computer system so as to define a machine, one or more intermediate user steps (e.g. providing commands, variables etc.) may be required in order for a computer system configured for generating a manufacturing definition of an integrated circuit to execute code defining an integrated circuit so as to generate the manufacturing definition of that integrated circuit.

An example of processing an integrated circuit definition dataset at an integrated circuit manufacturing system so as to configure the system to manufacture a data processing system will now be described with respect toFIG.8.

FIG.8shows an example of an integrated circuit (IC) manufacturing system1002which is configured to manufacture a data processing system as described in any of the examples herein. In particular, the IC manufacturing system1002comprises a layout processing system1004and an integrated circuit generation system1006. The IC manufacturing system1002is configured to receive an IC definition dataset (e.g. defining a data processing system as described in any of the examples herein), process the IC definition dataset, and generate an IC according to the IC definition dataset (e.g. which embodies a data processing system as described in any of the examples herein). The processing of the IC definition dataset configures the IC manufacturing system1002to manufacture an integrated circuit embodying a data processing system as described in any of the examples herein.

In some embodiments, processing of the integrated circuit definition dataset at an integrated circuit manufacturing system may configure the system to manufacture a system as described herein. For instance, an integrated circuit definition dataset may define the configuration of a reconfigurable processor, such as an FPGA, and the processing of that dataset may configure an IC manufacturing system to generate a reconfigurable processor having that defined configuration (e.g. by loading configuration data to the FPGA).