Improvements in or relating to mask generation

Abstract: The present invention relates to mask generation and in particular to a mask generation for selectively addressing locations in an addressable space, such as for example a memory array or devices which are bus connected or memory mapped. The mask generator including means for receiving control signals representative of a number of bytes to be masked, means for receiving a mode signal or signals representative of an addressing scheme, means responsive to said mode signal for generating mask values, and means responsive to said control signals for selectively placing said mask values at mask byte positions to generate said mask. A particular advantage of the present invention is that it provides a mechanism whereby both big and little endian masking operations can be achieved from a single mask generator and rotator without the need for any 2's complement operations.

Description: The present invention relates to mask generation and in particular to a mask generation for selectively addressing locations in an addressable space, such as for example a memory array or devices which are bus connected or memory mapped. Most microprocessors have wide databuses that allow them to access 4,8 or even 16 bytes at a time from memory. The TI 486 DLC processor for example has a 32 bit wide data bus so that four eight bit bytes (two sixteen bit words) may be accessed at a time. However, it is not always required or desirable to write to all the bytes in a given memory word and a selective addressing mechanism may be employed to ensure that only the desired bytes are written. This is typically achieved by having a separate write enable associated with each byte. In order to be able to activate the particular write enables required, two pieces of information are necessary; namely the number of bytes to be written and the byte address of the first byte. The number of bytes may be used to generate a mask containing as many contiguous 1's as there are bytes to be written. The byte address is then used to rotate this mask to align it accordingly to the position of the bytes within the portion of the word that is to be written. Techniques for generating the mask and performing the rotation exist in the prior art. There are two common addressing mechanisms, known as big endian and little endian. In the TI 486 DLC device for example the little endian format is used in which the low-order bits are in lowest (little end) address byte. The addressing mode used by a microprocessor system affects the way in which the masking and rotating functions are implemented. Consider for example a number stored in a memory word, the left-most bit of the number being numerically more significant than the right-most. In a big endian system, the byte with the lowest address in the word is numerically most significant (on the left), whereas the byte with the highest address within the word is numerically least significant (on the right). This means that bytes within a word are indexed from the left. For byte selection this system therefore requires a mask of 1's justified to the left, which is then rotated to the right (clockwise) to align it according to the byte address. In a little endian system, the byte with the lowest address in the word is the numerically least significant (on the right), whereas the byte with the highest address within the word is the numerically most significant (on the left). This means that bytes within a word are indexed from the right. For byte selection this system therefore requires a mask of 1's justified to the right, which is then rotated to the left (anti clockwise) to align it according to the byte address. There is a need for some devices to be able to deal with both addressing formats, and to this end the TI 486 DLC processor for example has an instruction BSWAP to convert data from one format to the other. Of course use of an instruction places a significant processing overhead on the use of the format not employed by the device and where both formats are to be supported a hardware solution is preferred in which both regimes of mask generator and rotation are provided. Some microprocessors for example are configurable to operate in either big or little endian modes, and in non-programmable devices only a hardware solution is possible. There are presently several ways in which dual mode addressing might be achieved, for example:- Two completely separate mask generation and rotation circuits could be used; one for each endian. A multiplexer could then be used to select the appropriate one. This is simple, but expensive in terms of the amounts of hardware required. Alternatively two mask generators could be employed but with a single rotator. A multiplexer could select the output from the left or right justified mask generators (according to the endian) as the input of the rotator. This uses less hardware however, the single rotator cannot rotate both clockwise and anti-clockwise; to perform this requires the rotate amount to be 2's complemented in one endian or the other. This is because a clockwise rotation of N places is equivalent to an anti-clockwise rotation of the (2's complement of N) places. The disadvantage here is that the 2's complement operation requires a subtraction which will increase the amount of time required to perform the operation. This may have a detrimental effect on the operating speed of the circuit. It will also offset some of the transistor savings made by the use of a single rotator. Further reductions can be achieved if the same mask generator can be used to generate both the left and right justified masks. A mask generator which produces N 1's justified to the left can be thought of as also producing the 2's complement of N 0's justified to the right. Therefore, if the input to the mask generator is 2's complemented and the output inverted in one endian or the other, both mask configurations can be obtained. Again the disadvantage is that the 2's complement requires a subtraction which will slow down the circuit and offset some of the transistor savings. According to the present invention in one aspect thereof, there is provided a mask generator as defined in independent claim 1. Further embodiments of the invention are specified in the depended claims. A particular advantage of the present invention is that it provides a mechanism whereby both big and little endian masking operations can be achieved from a single mask generator and rotator without the need for any 2's complement operations. In order that the present invention may be better appreciated an embodiment will now be described by way of example only and with reference to the accompanying diagrammatic drawings of which:- Fig 1 shows a mask generator, Fig 2 shows a rotator, Fig 3 shows a mask generator/rotator and control logic, and Fig 4 shows the mask generator/rotator of Fig 3 in a processor system arrangement. A mask generator cell 10 (fig 1) is formed in an integrated circuit, for example a micro-processor, of MOS transistors such as NMOS transistor 11 and PMOS transistor 12. The transistors are connected together as a combinational logic arrangement, the arrangement having three inputs; the left and right mask values, and a three bit value indicating the number of right mask bits, in binary. These are referred to as L R and N(2:0) respectively. The output, M, is 9 bits wide, of which the most and least significant bits are L and R respectively. In addition, all the outputs can be set to the same value by equating R and L. The truth table of the mask generator cell of Fig.1 is given below. N(2:0) M(8:0) 0 0 0 L L L L L L L L R 0 0 1 L L L L L L L R R 0 1 0 L L L L L L R R R 0 1 1 L L L L L R R R R 1 0 0 L L L L R R R R R 1 0 1 L L L R R R R R R 1 1 0 L L R R R R R R R 1 1 1 L R R R R R R R R L = R R R R R R R R R R R = L L L L L L L L L L The generator operates in response to four control signals (G0,G1,G2 and G3) logically derived from N(2:0) as follows:- G0 = N(0) OR N(1) G1 = N(1) G2 = N(0) AND N(1) G3 = N(2) It will be realised that this mask generator could be used in a dual mode system if M(8:1) were used to form the mask output and were subject to a two's complement in one endian or the other. For example, in little endian, N(2:0) = 001 will result in L L L L L L L R, however, in big endian, N(2:0) = 001 must produce the result R L L L L L L L. This can be achieved when the input to the mask generator is 111, which is the 2's complement of N(2:0); i.e. N(2:0) +1. However, the 2's complement would be relatively slow and expensive to implement since it requires a full adder. The ideal truth tables for both little and big endian mask operations are shown in Table A and Table B below respectively. In both cases, N(2:0)=000 is defined to indicate 8 bits, rather than 0. N(2:0) MASK 0 0 0 1 1 1 1 1 1 1 1 0 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 0 1 0 0 0 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 N(2:0) MASK 0 0 0 1 1 1 1 1 1 1 1 0 0 1 1 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 1 0 0 1 1 1 1 0 0 0 0 1 0 1 1 1 1 1 1 0 0 0 1 1 0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 0 The little endian mask may be generated in accordance with the present invention by taking the outputs M(8:1) of the mask generator cell and constraining the input L = N(2) & N(1) & N(0) with R = 1 (for little endian mode). The truth table for this is as follows:- N(2:0) R L M(8:0) 000 1 1 111111111 001 1 0 000000011 010 1 0 000000111 011 1 0 000001111 100 1 0 000011111 110 1 0 001111111 111 1 0 011111111 The big endian mask may be generated by taking the outputs N(7:1) of the mask generator cell in response to N(2:0) together with an output K defined such that K = 1 if the number of bytes is zero and constraining the input R = N(2) & N(1) & N(0) with L = 1 (for big endian mode). The truth table for this mode is as follows:- N(2:0) N(2 :0) L R M(7:1) K 000 111 1 1 1111111 1 001 110 1 0 1000000 0 010 101 1 0 1100000 0 011 100 1 0 1110000 0 100 011 1 0 1111000 0 101 010 1 0 1111100 0 110 001 1 0 1111110 0 111 000 1 0 1111111 0 It will be observed that K is identical to the first bit M(8) of the mask generator cell in little endian mode. Taking K then bits M (7 : 1) of the cell as the output and given an input LE = 1 (for little endian) and LE = O (for big endian) so that L may be defined as (L = LE or K) and R may be defined as (R = LE or K), the combined truth table listed below as Table C may be constructed. A logical implementation of this is shown in fig 3, wherein the mask generator 30 and the rotator 31 may be identified. Number of Bytes Little Endian (LE=1) Big Endian (LE=0) N(2:0) K M(7:1) N(2:0) K M(7:1) 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 0 1 0 0 0 0 0 0 0 1 1 1 0 0 1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 1 1 0 1 0 1 1 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0 0 1 1 1 1 0 0 0 1 1 1 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 1 1 1 0 1 1 0 1 1 1 1 0 0 0 1 0 1 1 0 1 0 0 0 1 1 1 1 1 0 1 0 0 1 1 1 1 1 0 0 1 1 0 1 1 0 0 0 1 1 1 1 1 1 0 0 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 It can be seen that the number of 1's in the mask is now correct for both big and little endian. However, the big endian mask needs to be rotated one place anti clockwise to align it correctly. In accordance with the present invention this is achieved in subsequent rotator logic which aligns the mask. The mask rotation logic will now be described. Having generated the mask above, it must be rotated according to the byte address of the 1st byte to be written. This is indicated by A(2:0), the byte alignment, in Table D below, which is the rotation logic truth table. Byte Little Endian Big Endian Adress A(2:0) 1st Stage 2nd Stage Rotate A(2:0) 1st Stage 2nd Stage Rotate 0 0 0 0 0 0 0 0 0 1 1 1 4 5 9(-7) 0 0 1 0 0 1 0 1 1 1 1 0 4 4 8(0) 0 1 0 0 1 0 2 0 2 1 0 1 2 5 7(-1) 0 1 1 0 1 1 2 1 3 1 0 0 2 4 6(-2) 1 0 0 1 0 0 0 4 4 0 1 1 4 1 5(-3) 1 0 1 1 0 1 0 5 5 0 1 0 4 0 4(-4) 1 1 0 1 1 0 2 4 6 0 0 1 2 1 3(-5) 1 1 1 1 1 1 2 5 7 0 0 0 2 0 2(-6) In little endian mode, the rotation must be anti clockwise by the alignment amount A(2:0). In big endian mode, the rotation must be clockwise, however, in the embodiment an anti-clockwise equivalent of the alignment amount, minus one to compensate for the fact that the mask is offset one place to the right. In the prior art a typical implementation for an anti clockwise rotator might use two stages; the first to rotate by 0 or 1 place, and the second to rotate by 0,2,4 or 6 places. By connecting these in series, any rotation amount between 0 and 7 can be achieved. However, it will be realised that the same results can be achieved if the first stage rotates by 0 or 2 places, and the second by 0, 1, 4 or 5 places. Furthermore, by adding a 'rotate by 4' option to the first stage, the extra 2 bit rotation required for big endian can be achieved without increasing the delay through the rotator. In little endian mode, the first stage would rotate by either 0 or 2. In big endian, the first stage would rotate by either 2 or 4. Figure 2 shows the schematic for one bit; 'bit x' of the rotator. The embodiment described above shows how a mask generation and rotation function for both big and little endian can be performed using a single piece of hardware, and furthermore that this can be achieved without the need for an adder to perform a 2's complementing operation. Instead a simple and efficient 1's complement is used together with generating a special term, K, for the most significant bit of the mask output and constructing the rotator with 0, 2 and 4 bit rotates in the 1st stage, and 0, 1, 4 and 5 bit rotates in the 2nd. This only adds one extra transistor per bit to the rotator, and allows the extra 2-bit rotate required for big endian operation to be performed without affecting the performance. As will be observed from the example of figure 3, the control logic required is minimal and much less than the full adder required by the prior art. The exemplary mask generator and rotator 43 (figure 4) thus far described may be used in a microprocessor arrangement in which a central processor 40 addresses an array of memory modules 41, in which data may be in either big endian or little endian format, via a timing control 42, other control signals being omitted for clarity of presentation. The mask generator and / or rotator may be integrated into a semi-conductor device (integrated circuit) of larger functionality.

Claims: A mask generator for generating a mask for both big endian and little endian addressing modes, comprising: input terminals for receiving: a number signal (N) indicative of the number of set bits in the mask in the form of a binary number, an alignment signal (A) indicative of the alignment of the mask in the form of a binary number, and a mode signal (LE) indicative of whether the mask is for the big endian or little endian mode, a mask generation means (30) responsive to the number signal and to the mode signal (LE) for providing, for number signals greater than or equal to one, on an output, a mask having justified to one end of the output a group of set bits of the length indicated by the number signal, the other bits of the mask being reset, wherein the end of that output to which the group of set bits is justified depends on which mode is indicated by the mode signal, extra bit means for providing an extra bit (K) to the output of the mask generation means at one end, that bit being reset for number signals greater than or equal to one, and rotation means for rotating the output of the mask generation means, including the extra bit, the number of places indicated by the alignment signal, and, for the mode where set bits are justified towards the end where the extra reset bit is added, rotating the mask an extra place towards that end, the rotated mask being the output of the mask generator. A mask generator as claimed in claim 1, comprising: number signal inverting means for inverting each of the bits of the number signal applied to the mask generation means if the mode signal indicates a particular one of the addressing modes and for leaving the number signal uninverted if the mode signal indicates the other mode from that particular mode. A mask generator as claimed in claim 1 or claim 2 comprising: extreme bit generation means for providing, for number signals greater than or equal to one, two extreme bits one being set and the other reset, responsive to the mode signal to determine which of those bits is the one that is set, wherein the mask generation means has two inputs (L,R) for the extreme bits and is arranged to propagate the extreme bits to the relevant bits of its output. A mask generator as claimed in any one of claims 1 to 3, wherein for a number signal of zero the circuit is so arranged that the bits of the output of mask generation means, including the extra bit, are all set. A mask generator as claimed in claim 4, when dependent on claim 3, wherein the extreme bit generation means is so responsive to the number signal that when the number signal is zero both the extreme bits are set. A mask generator as claimed in any preceding claim wherein the number signal has three bits, the alignment signal has three bits and the mask output by the mast generator has eight bits. A mask generator as claimed in any preceding claim comprising alignment signal inversion means for inverting each of the bits of the alignment signal if the mode signal indicates the said particular one of the addressing modes and for leaving the alignment signal uninverted if the mode signal indicates the other mode from that particular mode. A mask generator as claimed in claim 7 when dependent on claim 6, wherein the rotation means has two stages, the first being for providing a rotation of 0, 2, or 4 places and the second for providing a rotation of 0, 1, 4 or 5 places, the first stage being responsive to the mode signal for providing a rotation of 2 or 4 places in the mode requiring the extra place rotation and 0 or 2 in the other mode. A software product arranged to implement, when executed, a mask generator as claimed in any preceding claim. A memory addressing circuit including a mask generator or a software product as claimed in any preceding claim. A processor system including a memory addressing circuit as claimed in claim 10. A semiconductor device including a mask generator, an addressing circuit, a software product or a processor system, as claimed in any preceding claim. A semiconductor device as claimed in claim 12, being an integrated circuit. A method of using a mask generator, a software product, a memory addressing circuit, or a semiconductor device, as claimed in any preceding claim, to provide masks for little endian and big endian addressing modes. A method as claimed in claim 14, wherein the extra place rotation and the inversions of the number and alignment signals are provided for the big endian mode.

Inventors: JEACOCKE JONATHON, ROBERTSON IAIN, SIMPSON RICHARD, JEACOCKE, JONATHON, ROBERTSON, IAIN, SIMPSON, RICHARD, JEACOCKE, JONATHON, C/O TEXAS INSTRUMENTS LIMITED, ROBERTSON, IAIN, C/O TEXAS INSTRUMENTS LIMITED, SIMPSON, RICHARD, C/O TEXAS INSTRUMENTS LIMITED
Applicants: TEXAS INSTRUMENTS INC, TEXAS INSTRUMENTS LTD, TEXAS INSTRUMENTS INCORPORATED, TEXAS INSTRUMENTS LIMITED
Application year: 1995
Main classification: G06F7
IPC codes: G06F13, G06F7, G06F12