TWI898521B - A method of adding binary strings and a circuit therefor - Google Patents
A method of adding binary strings and a circuit thereforInfo
- Publication number
- TWI898521B TWI898521B TW113112601A TW113112601A TWI898521B TW I898521 B TWI898521 B TW I898521B TW 113112601 A TW113112601 A TW 113112601A TW 113112601 A TW113112601 A TW 113112601A TW I898521 B TWI898521 B TW I898521B
- Authority
- TW
- Taiwan
- Prior art keywords
- binary
- sub
- characters
- character
- pair
- Prior art date
Links
Landscapes
- Compression, Expansion, Code Conversion, And Decoders (AREA)
- Logic Circuits (AREA)
Abstract
Description
本發明是有關於將二進制字符格式的數字相加的邏輯電路。 The present invention relates to a logic circuit for adding numbers in binary character format.
處理器一般包含用來對二進制字符格式的數字進行數學運算(亦即,加減乘除)的邏輯電路,這類電路最基本的一種就是數位加法器。 A processor typically contains logic circuits used to perform mathematical operations (i.e., addition, subtraction, multiplication, and division) on numbers in binary format. The most basic type of such circuit is the digital adder.
第1圖是包含及閘(AND gate)與互斥或閘(Exclusive OR gate)的通用型半加法器電路。 Figure 1 shows a general-purpose half-adder circuit consisting of an AND gate and an exclusive OR gate.
半加法器可納入兩個單一位元輸入並產生兩個單一位元的輸出,其中一個稱為總和位元,另一個稱為進位輸出(COUT)位元。如果兩個輸入位元都是1,因為結果等於10就會產生一個進位。 A half adder takes two single-bit inputs and produces two single-bit outputs, one of which is called the sum bit and the other is called the carry-out (C OUT ) bit. If both input bits are 1, a carry is generated because the result is equal to 10.
第2圖是由兩個彼此相連的半加法器組成的全加法器的簡圖,第一個半加法器將進位傳送到第二個半加法器。全加法器的真值表包括一個額外的輸入,用來納入前一較低有效位位元總和的任一進位位元。 Figure 2 is a simplified diagram of a full adder consisting of two half adders connected to each other. The first half adder passes the carry bit to the second half adder. The truth table of the full adder includes an additional input to include any carry bit from the sum of the previous less significant bits.
輸出是前一較高有效位的總和以及預備連接到全加法器之進位輸入的進位。如此一來,可讓級聯的全加法器將二進制字符的數字相加,並將進位傳送到下一更有效位,此稱為「漣漪效應」。 The output is the sum of the previous more significant bit and the carry, which is then connected to the carry input of the full adder. This allows cascaded full adders to add binary digits and pass the carry to the next more significant bit, a process known as the "ripple effect."
可將一系列四個全加法器組合成為一個4-位元的加法器,如第3圖所示。來自所有進位的漣漪效應會造成延遲。在加法器取得能產生一個輸出所需要的全部輸入之前,每一個加法器都必須等待進位訊號。在一系列加法器中,每一種這樣的等待時間會造成所謂「傳輸延遲」的整體效能延遲。傳輸延遲會使依序排列的較大數字的全加法器,將較長的二進制字符相加。 A series of four full adders can be combined to form a single 4-bit adder, as shown in Figure 3. The ripple effect from all the carries creates a delay. Each adder must wait for the carry signal before it receives all the inputs it needs to produce an output. In a chain of adders, each of these wait times creates an overall performance delay known as "propagation delay." Propagation delay causes full adders with larger numbers to add longer binary characters.
為了減輕傳輸延遲,有人提出一種將全加法器依序排列的改良電路,稱為「超前進位加法器」,如第4圖所示。基本上,藉由組合全加法器的某些輸入來預測進位值,並將全加法器的輸出提供給另一個稱為「超前進位」的邏輯元件,以便在上游加法器仍在計算時,將進位訊號傳送給下游加法器。有兩種情況會使下游加法器收到進位位元,即,當上游加法器產生一個進位或將收到的進位傳送出去,這些會讓下游加法器知道出現「進位生成」與「進位傳輸」的邏輯組合,以及如果有能被分成多個位元組之較長的二進制字符存在時,還可能出現「組生成」與「組傳輸」的邏輯組合。 To reduce transmission delay, an improved circuit called a "carry lookahead adder" has been proposed, which places full adders in sequence, as shown in Figure 4. Essentially, a carry value is predicted by combining certain inputs of the full adder, and the full adder's output is fed into another logic element called a "carry lookahead" to propagate the carry signal to the downstream adder while the upstream adder is still calculating. There are two situations in which the downstream adder receives a carry bit: when the upstream adder generates a carry or propagates a received carry. These situations inform the downstream adder of the "carry generate" and "carry propagate" logic combinations. Furthermore, if a longer binary character that can be split into multiple bytes is present, the "group generate" and "group propagate" logic combinations may also occur.
在較長的二進制字符的加法器中,使用超前進位加法器所節省時間的程度可達指數層級,但也伴隨有費用高及邏輯電路複雜的缺點,這也進一步引發費用及複雜度關係中惡名昭彰的摩爾定律。經濟及複雜度的負擔也使業界喪失開發大容量加法器的動力。 In adders for longer binary characters, the use of a carry-lookahead adder can save exponential amounts of time, but this comes with the disadvantages of high cost and complex logic circuitry, further invoking the infamous Moore's Law of the relationship between cost and complexity. These economic and complexity constraints have also discouraged the industry from developing large-capacity adders.
儘管超前進位邏輯已有突破,但先前技術沒有可逃脫漣漪效應的方法,因此使得從最小有效位到最大有效位的加法運算都變成了必要的運算。 Despite breakthroughs in lookahead carry logic, previous technologies had no way to escape the ripple effect, making addition operations from the least significant digit to the most significant digit necessary.
因此,本領域需要一種能移除或減輕任一或多個前述缺陷的新穎方法及邏輯電路設計。 Therefore, there is a need in the art for a novel method and logic circuit design that can remove or mitigate any one or more of the aforementioned defects.
本發明第一態樣係有關一種將以二進制字符形式存在的數字格式化為適合與另一同樣格式之數字相加之格式及傳輸任一源於該相加總合之進位值的方法。所述方法包含:提供該數字;提供代表該數字之絕對值的二進制字符;將該二進制字符的值分裂為一對二進制子字符,其中,該對二進制子字符x及y的總和等於該二進制字符的值;重新安排該對二進制子字符x及y的多個零以及非零使:(a)產生一對格式化的二進制子字符及,其中該對格式化的二進制子字符及的總和等於該二進制字符的值;(b)在每一格式化的二進制子字符及中,每一非零的位元與任一其他非零的位元之間被至少一個零的位元隔開;及(c)在該對格式化的二進制子字符及中任一相同位元位置i,其值不能同時為非零 A first aspect of the present invention relates to a method for formatting a number in the form of a binary character into a format suitable for addition to another number in the same format and transmitting any carry value resulting from the sum of the addition. The method comprises: providing the number; providing a binary character representing the absolute value of the number; splitting the value of the binary character into a pair of binary sub-characters, wherein the sum of the pair of binary sub-characters x and y is equal to the value of the binary character; rearranging the plurality of zeros and non-zeros in the pair of binary sub-characters x and y so as to: (a) generate a pair of formatted binary sub-characters and , where the pair of binary subcharacters formatted and The sum of the binary subcharacters is equal to the value of the binary character; (b) in each formatted binary subcharacter and Each non-zero bit is separated from any other non-zero bit by at least one zero bit; and (c) in the pair of formatted binary subcharacters and The values of any bit position i in the
本發明提供立即產生總和的可能性,此也可彌補在數字相加之前或之後因運算所需要的時間,例如將二進制數字格式化為適合相加格式的時間,以及將總和格式化為傳統二補數二進制格式所需的時間。 The present invention provides the possibility of generating a sum immediately, which can also compensate for the time required for operations before or after the addition of numbers, such as the time required to format binary numbers into a format suitable for addition and the time required to format the sum into the traditional two's complement binary format.
較佳是,該對二進制子字符之一是減數,另一者則是被減數,使得該對二進制子字符的總和等於減數與被減數之間的差。 Preferably, one of the pair of binary subcharacters is the subtrahend and the other is the minuend, such that the sum of the pair of binary subcharacters is equal to the difference between the subtrahend and the minuend.
或是,重新安排該對二進制子字符x及y的多個零以及非零的步驟包含依以下順序排列的步驟(1)、(2)及(3): Alternatively, the step of rearranging the plurality of zeros and non-zeros of the pair of binary sub-characters x and y comprises steps (1), (2) and (3) arranged in the following order:
(1)應用下列方程式來移除該二進制子字符y中任何中間鄰近非零的位元:
及
(2)應用下列方程式來移除下列特定順序之任一對鄰近非零的位元,將該對二進制子字符x及y中的x=1,y=1接著是x=0,y=1變成x=0,y=0接著x=1,y=0:
(3)應用下列方程式來移除該二進制子字符x任何中緊鄰非零的位元:
其中,及代表在該對格式化的二進制子字符及位置i之位元的值。 in, and Represents the binary sub-characters formatted in this pair and The value of the bit at position i.
或是,重新安排該對二進制子字符x及y的多個零以及非零的步驟包含在執行以下步驟(b)之前,先執行以下步驟(a):(a)應用下列方程式到該對二進制子字符x及y上:
其中n w 代表該對二進制子字符x及y;(b)應用下列方程式到以獲得,
其中,及;及代表不同對之二進制子字符及在位置i之位元的值。 in, and ; and Binary subcharacters representing different pairs and The value of the bit at position i.
或是,重新安排該對二進制子字符x及y的多個零以及非零的步驟包含在執行以下步驟(ii)之前,先執行以下步驟(i): Alternatively, the step of rearranging the plurality of zeros and non-zeros of the pair of binary sub-characters x and y comprises performing the following step (i) before performing the following step (ii):
(i)依據下列方程式分別將二進制子字符及轉變成及:
(ii)將下列方程式應用到x'及y'上:
典型的,在執行重新安排該對二進制子字符x及y的多個零以及非零的步驟之前,先將子字符爭相同位置非零的位元轉變成零的位元。 Typically, before performing the step of rearranging the plurality of zeros and non-zeros in the pair of binary sub-characters x and y, the non-zero bits in the same position of the sub-characters are first converted to zero bits.
上述技術特徵可解決移除冗餘位元的問題,只有在輸出後續重複相加運算時所需的總和時才需要此步驟。此種從子字符中移除冗餘位元的步驟,只應用在需要輸出前一相加運算總和的實施方式中,因此輸出的總和還可再次被最佳化處理。若不移除冗餘位元,最佳化處理將因需要處理冗餘位元而變得更為複雜。 The above technical features solve the problem of removing redundant bits, requiring this step only when outputting the sum required for subsequent repeated addition operations. This step of removing redundant bits from sub-characters is only applied in implementations that need to output the sum of the previous addition operation, so that the output sum can be optimized again. If redundant bits are not removed, the optimization process becomes more complicated due to the need to handle redundant bits.
或是,本發明方法更包含換該對二進制子字符及的內容。此一技術特徵可反轉一數字子字符的內容,使得數字變成負數並讓所述方法由加法運算變為剪除被交換內容數字的減法運算。 Alternatively, the method of the present invention further comprises converting the pair of binary sub-characters and This technical feature can invert the content of a numeric sub-character, making the number negative and changing the method from an addition operation to a subtraction operation that removes the swapped content.
本發明第二態樣是提供一種可應用所述方法步驟(1)的邏輯電路,其包含以下組態:
此外,本發明也提出可應用所述方法步驟(2)的邏輯電路,其包含以下組態:
此外,本發明也提出可應用所述方法步驟(3)的邏輯電路,其包含以下組態:
此外,本發明也提出可應用所述方法步驟(a)及步驟(b)的邏輯電路,其包含以下組態:
此外,本發明也提出可應用所述方法步驟(i)的邏輯電路,其包含以下組態:
此外,本發明也提出可應用所述方法步驟(ii)的邏輯電路,其包含以下組態:
此外,本發明還提出一種可將子字符x及y中相同位置之非零的位元轉變成零的位元的邏輯電路,其包含以下組態:
本發明更進一步的態樣是提供一種二進制字符用的加法器,包含複數個加法器電路;該些加法器電路排列成可達成以下:每一加法器電路可與該些加法器電路之其他加法器同時在兩個二進制字符個別相同位置執行位元相加;該加法器電路具有以下組態:
較佳是,藉由將所有xi=1,yi=1都變成xi=0,yi=0而進一步簡化所獲得的位元。 Preferably, the obtained bits are further simplified by changing all x i = 1, y i = 1 to x i = 0, y i = 0.
典型是,所述加法器更包含一輸入端,可輸入該兩對二進制子字符之每一對二進制子字符的每一二進制子字符,其中該輸入端是由一上游電路供應,該上游電路是用來產生該兩對二進制子字符;且每一對二進制子字符具有以下特性:‧沒有非零的位元緊接在相同二進制子字符中另一相同值的位元之後;且‧在另一二進制子字符相同位置沒有非零的位元。 Typically, the adder further includes an input terminal for inputting each binary sub-word of each pair of the two pairs of binary sub-words, wherein the input terminal is supplied by an upstream circuit for generating the two pairs of binary sub-words; and each pair of binary sub-words has the following characteristics: ‧ No non-zero bit immediately follows another bit of the same value in the same binary sub-word; and ‧ No non-zero bit is in the same position in the other binary sub-word.
典型是,所述加法器更包含一輸出端,可輸出一對二進制子字符的每一個二進制子字符,其中,該輸出端是與一下游電路相連,用以將該對二進制子字符轉變成一可代表該二進制字符之加法器總和的二進制字符。 Typically, the adder further includes an output terminal configured to output each binary sub-word of a pair of binary sub-words, wherein the output terminal is connected to a downstream circuit for converting the pair of binary sub-words into a binary word representing the sum of the binary words.
或者,在執行位元相加之前,先將一對二進制子字符的該兩個二進制子字符彼此的內容交換。此一技術特徵可反轉一數字子字符的內容,使得數字變成負數並讓所述方法由加法運算變為剪除被交換內容數字的減法運算。 Alternatively, before performing the bit addition, the contents of the two binary sub-characters in a pair of binary sub-characters are swapped. This technical feature can invert the contents of a numeric sub-character, making the number negative and transforming the method from an addition operation to a subtraction operation that removes the swapped numeric contents.
501、503、505、507、508、509、511、513、515、517:步驟 501, 503, 505, 507, 508, 509, 511, 513, 515, 517: Steps
為讓本發明的上述與其他目的、特徵、優點與實施例能更明顯易懂,所附圖式之說明如下:第1圖繪示出先前技術用的一種半加法器;第2圖繪示出先前技術用的一種全加法器; 第3圖繪示出先前技術用的一種4-位元脈動進位加法器;第4圖繪示出先前技術用的一種超前進位加法器;第5圖是本發明兩種實施方式的流程圖;第6圖繪示出用來將二補數二進制字符轉化成可用於第5圖實施方式之泛化格式的子電路;第7a圖是第6圖子電路內部的電路圖;第7b圖繪示出第7a圖之電路如何將二進制字符加以泛化的過程;第8圖繪示出將第6圖用來進行半最佳化之子電路所輸出的二進制字符重排、相加或移除其中的零及非零位元,以便用於第5圖實施方式的高階子電路;第9圖繪示出第8圖子電路所代表的三種子電路及其排列方式;第10圖為第9圖三種子電路中的一種子電路圖;第11圖為第10圖中9種子電路中每一種子電路的邏輯電路圖;第12圖為第11圖邏輯電路的真值表;第13圖為第9圖三種子電路中另一子電路的電路圖;第14圖為第13圖電路中每一種子電路的邏輯電路圖;第15圖為第13圖邏輯電路的真值表;第16圖為第9圖三種子電路中另一子電路的電路圖;第17圖是第16圖電路中每一種子電路的邏輯電路圖; 第18圖為第16圖邏輯電路的真值表;第19圖為可提供第5圖流程圖中一步驟所需加數的高階子電路;第20圖為第19圖子電路的電路圖;第21圖繪示出第20圖子電路之每一子電路單元內的加法器子電路;第22圖繪示出用來建構第21圖加法器子電路之子加法器的電路邏輯;第23圖為第22圖邏輯電路的真值表;第24a-24g圖一系列圖示顯示如何對加法器輸出的子字符(例如第19圖子電路所示的輸出)的每一個位置同時進行計算;第25圖為用來將以第19圖加法器計算之總和從泛化格式去轉化成為二補數二進制字符格式的子電路圖;第26圖為第25圖子電路的邏輯電路圖;第27圖為第26圖邏輯電路的真值表;第28圖為第26圖的真值表;第29a圖繪示出如何將4-位元泛化二進制數字去轉化成為5-位元二補數二進制數字;第29b圖為類似超前進位電路用來生成、傳送及加總的去轉化電路;第30a圖為第5圖流程圖的另一種變化; 第30b圖為用來移除泛化二進制數字子字符中冗餘位元的子電路;第30c圖為第30b圖邏輯電路的真值表;第31圖繪示出將第6圖用來進行完全最佳化之電路所輸出的二進制字符重排或改變其中的零及非零位元,以便用於第5圖中另一實施方式的高階子電路;第32圖繪示出第31圖區塊電路圖內的子電路;第33圖為第32圖子電路中每一電路單元的子電路圖;第34圖為第33圖子電路的邏輯電路;第35圖為第33圖子電路的真值表(表6a);第36圖繪示出將第6圖用來進行半最佳化之電路所輸出的二進制字符重排、相加或移除其中的零及非零位元,以便用於第5圖中一實施方式的另一種子電路;第37a圖為第36圖子電路的邏輯電路;第37b圖為第36圖程序之第一種變形,其步驟(a)的真值表(表6b);第37c圖為接續在第37b圖步驟(a)真值表6b之後的步驟(b)之真值表(表6c),;第38圖為第36圖子電路的真值表;第39圖繪示出將第6圖用來進行半最佳化之電路所輸出的二進制字符重排、相加或移除其中的零及非零位元,以便用於第5圖中一實施方式的另一種子電路; 第40圖為第39圖子電路的邏輯電路;第41圖為第39圖子電路的真值表;第42圖為用來處理第39圖子電路之輸出的子電路圖;第43圖為第42圖電路圖的邏輯電路;及第44圖為第42圖子電路的真值表。 To make the above and other objects, features, advantages, and embodiments of the present invention more readily apparent, the accompanying drawings are described as follows: FIG. 1 illustrates a prior art half adder; FIG. 2 illustrates a prior art full adder; FIG. 3 illustrates a prior art 4-bit pulse carry adder; FIG. 4 illustrates a prior art carry lookahead adder; FIG. 5 is a flow chart of two embodiments of the present invention; FIG. 6 illustrates a subroutine for converting two's complement binary characters into a generalized format usable in the embodiment of FIG. 5. FIG7a is a circuit diagram of the subcircuit in FIG6; FIG7b illustrates how the circuit in FIG7a generalizes binary characters; FIG8 illustrates a high-level subcircuit for the implementation of FIG5 by rearranging, adding, or removing zero and non-zero bits from the binary characters output by the semi-optimized subcircuit in FIG6; FIG9 illustrates the three subcircuits represented by the subcircuit in FIG8 and their arrangements; FIG10 is a diagram of one of the three subcircuits in FIG9; and FIG11 is a diagram of the nine subcircuits in FIG10. Figure 12 is the logic circuit diagram for each sub-circuit in Figure 11; Figure 13 is the circuit diagram for another of the three sub-circuits in Figure 9; Figure 14 is the logic circuit diagram for each of the sub-circuits in Figure 13; Figure 15 is the truth table for the logic circuit in Figure 13; Figure 16 is the circuit diagram for another of the three sub-circuits in Figure 9; Figure 17 is the logic circuit diagram for each of the sub-circuits in Figure 16; Figure 18 is the truth table for the logic circuit in Figure 16; Figure 19 provides the logic circuit diagram for the flow chart in Figure 5. Figure 20 is a circuit diagram of the subcircuit in Figure 19; Figure 21 illustrates the adder subcircuit within each subcircuit unit of the subcircuit in Figure 20; Figure 22 illustrates the circuit logic used to construct the subadder of the adder subcircuit in Figure 21; Figure 23 is a truth table for the logic circuit in Figure 22; Figures 24a-24g are a series of diagrams showing how to perform calculations simultaneously for each position of the adder output subword (such as the output shown in the subcircuit in Figure 19); Figure 25 is a circuit diagram used to add the subword in Figure 19. Figure 26 is the logic diagram of the subcircuit in Figure 25; Figure 27 is the truth table for the logic circuit in Figure 26; Figure 28 is the truth table for Figure 26; Figure 29a illustrates how to convert a 4-bit generalized binary number into a 5-bit two's complement binary number; Figure 29b is a deconversion circuit similar to the carry lookahead circuit for generation, transfer, and summation; Figure 30a is another variation of the flowchart in Figure 5; Figure 30b uses FIG30c is a truth table of the logic circuit of FIG30b; FIG31 shows a binary character output by the circuit used for full optimization in FIG6, in which the zero and non-zero bits are rearranged or changed for use in a high-level subcircuit of another embodiment in FIG5; FIG32 shows a subcircuit within the block circuit diagram of FIG31; FIG33 is a subcircuit diagram of each circuit unit in the subcircuit of FIG32; FIG34 is a logic circuit of the subcircuit of FIG33; FIG35 is a high-level subcircuit of FIG36. 3 (Table 6a); FIG. 36 illustrates the binary character output by the semi-optimized circuit of FIG. 6 after rearranging, adding, or removing zero and non-zero bits for use in another sub-circuit of an embodiment of FIG. 5; FIG. 37a is the logic circuit of the sub-circuit of FIG. 36; FIG. 37b is the truth table for step (a) of the first variation of the process of FIG. 36 (Table 6b); FIG. 37c is the truth table for step (b) following the truth table 6b for step (a) of FIG. 37b (Table 6c); Figure 38 is a truth table for the subcircuit in Figure 36; Figure 39 illustrates another subcircuit in one embodiment of Figure 5 by rearranging, adding, or removing zero and non-zero bits from the binary character output by the semi-optimized circuit in Figure 6; Figure 40 is a logic circuit for the subcircuit in Figure 39; Figure 41 is a truth table for the subcircuit in Figure 39; Figure 42 is a subcircuit diagram for processing the output of the subcircuit in Figure 39; Figure 43 is a logic circuit for the circuit in Figure 42; and Figure 44 is a truth table for the subcircuit in Figure 42.
本發明實施方式之一是有關於用來將二進制字符(亦即,被加數與加數)相加的多位元加法器,其中在同時發生的多個平性運算中,同樣有效位中的兩個位元或是兩個二進制字符相同位置的個別字符被同時相加。本實施方式主要是處理加法,但也可被改良來處理減法。 One embodiment of the present invention relates to a multi-bit adder for adding binary characters (i.e., a summand and an addend), wherein two bits in the same significant position, or individual characters in the same position of two binary characters, are added simultaneously during multiple simultaneous operations. This embodiment primarily handles addition, but can also be modified to handle subtraction.
本實施方式也是關於可對被加數與加數進行前處理的邏輯電路,將被加數與加數的格式轉變成適合被平行運算直接相加的格式。轉變包含兩個步驟:泛化步驟及最佳化步驟。轉變被加數與加數之任一者可產生在本文稱為「泛化的」及「最佳化的」一對二進制字符,其特徵將詳述於下面。此二進制字符的格式是沒有進位值需要被連續傳送給更有效位的位元,或是進位值不會一直存在,而是在下游幾個位元後就終止了。實際操作時,可將此二進制字符的格式視為消滅或終止進位位元的格式,因此可減輕需要連續傳送進位位元的需求。 This embodiment also relates to logic circuitry that can perform pre-processing on a summand and addend, converting the formats of the summand and addend into a format suitable for direct addition via parallel operations. This conversion comprises two steps: a generalization step and an optimization step. Converting either the summand or addend produces a pair of binary characters referred to herein as "generalized" and "optimized," the characteristics of which are described in detail below. These binary characters are in a format where no carry bit needs to be continuously propagated to a more significant bit, or where the carry bit does not persist but terminates after several bits downstream. In practical operations, these binary characters can be considered to eliminate or terminate the carry bit, thereby alleviating the need to continuously propagate the carry bit.
一般來說,最佳化演算法可將鄰近被加數與加數之所有非零的位元移除,使得每兩個非零的位元之間至少有一個零的位元存在。任何從被加數與加數相加後產生的進位可被下一有效位的非零的位元捕獲,因此 不會被傳遞。但是,最佳化演算法還需應用所謂「等效原則」來保留被加數與加數的原始值,方能在相加後仍可獲得正確的總和。 Generally speaking, the optimization algorithm removes all nonzero bits adjacent to the augend and addend, ensuring that there is at least one zero bit between every two nonzero bits. Any carry resulting from the addition of the augend and addend is captured by the next nonzero bit in the next significant digit and is therefore not propagated. However, the optimization algorithm also needs to apply the so-called "equivalence principle" to preserve the original values of the augend and addend so that the correct sum is still obtained after addition.
第5圖是本實施方式例式處理之5-步驟的流程圖。每一步驟都是由一個不同的邏輯電路來執行。用於每一步驟的邏輯電路圖已在流程旁的內文框中指明。也可設計出與這些邏輯電路功能等效的其他電路在數位處理器中執行本實施方式。 Figure 5 is a flowchart of the five-step process of this embodiment. Each step is performed by a different logic circuit. The logic circuit diagram for each step is indicated in the text box next to the flow chart. Other circuits with equivalent functions to these logic circuits can also be designed to implement this embodiment in a digital processor.
在第一步驟501中,提供了二補數格式的被加數與加數。須知被加數與加數在此亦可總稱為「加數」。 In the first step 501, the augend and addend in two's complement format are provided. Note that the augend and addend may also be collectively referred to as "addends" herein.
在第二步驟503中,將以二進制字符格式存在的加數轉變成在本文中所謂的「泛化二進制字符格式」。此轉變的二進制字符稱為「泛化二進制字符」。 In the second step 503, the addend in binary character format is converted into what is referred to herein as a "generalized binary character format." This converted binary character is referred to as a "generalized binary character."
在第三步驟505中,以稱為「最佳化」的處理來處理前述泛化二進制字符,移除其周圍所有非零的位元,防止進位位元的傳遞。將泛化二進制字符最佳化後,會產生「最佳化及泛化的二進制字符」。 In the third step 505, the generalized binary character is processed using a process called "optimization" to remove all surrounding non-zero bits to prevent carry bits from being propagated. After the generalized binary character is optimized, an "optimized and generalized binary character" is generated.
可利用依據下列段落描述的觀念所設計出來的任何演算法及邏輯電路來實施上述最佳化處理。但是,有兩種態樣,其一是所謂的「全最佳化」,另一稱為「半最佳化」。 The above optimization process can be implemented using any algorithm and logic circuit designed based on the concepts described in the following paragraphs. However, there are two approaches: one is called "full optimization" and the other is called "semi-optimization."
在第四步驟507中,將已被格式為最佳化及泛化的二進制字符之加數及被加數輸入至加法器中。輸出的總和是泛化二進制字符且可包含相鄰的非零的位元,因此,已經不是最佳化字符。 In the fourth step 507, the addend and augend formatted as optimized and generalized binary characters are input into the adder. The output sum is a generalized binary character and may include adjacent non-zero bits, and therefore is no longer an optimized character.
在第五步驟509中,將上述總和從泛化二進制字符去轉化成為二補數二進制字符。 In the fifth step 509, the sum is converted from a generalized binary character to a two's complement binary character.
將被邏輯電路處理的數字,永遠都是以位元字符形式(亦即,二進制字符)存在,且每一個位元的值不是1(非零)就是0。一般來說,二進制字符可以是正數值或是負數值。代表正數值的二進制字符沒有特別的名稱,但是,如果二進制字符代表負數值,該二進制必須是二補數二進制格式。這是因為它不會取可代表正數值的二進制字符,且為了更好說明,只使用二進制位元中的一個位元作為負號。 Numbers processed by logic circuits always exist in the form of bit characters (i.e., binary characters), with each bit value being either 1 (non-zero) or 0. Generally speaking, binary characters can represent positive or negative values. Binary characters representing positive values don't have special names, but if a binary character represents a negative value, it must be in two's complement binary format. This is because it doesn't take a binary character that can represent a positive value, and for better explanation, only one bit of the binary digits is used as the negative sign.
舉例來說,數字1在16-位元二進制格式中為0000 0000 0000 0001。但是,數字-1在有負號的二補數二進制格式為1111 1111 1111 1111。此外,數字27在16-位元二進制格式中為0000 0000 0001 1011,但數字-27在有負號的二補數二進制格式為1111 1111 1110 0101。 For example, the number 1 is 0000 0000 0000 0001 in 16-bit binary format. However, the number -1 is 1111 1111 1111 1111 in two's complement binary format with a negative sign. Furthermore, the number 27 is 0000 0000 0001 1011 in 16-bit binary format, but the number -27 is 1111 1111 1110 0101 in two's complement binary format with a negative sign.
為了精準起見,所有傳統的二進制字符都是二補數二進制格式,因此,為了方便稱呼,所有代表正數值的二進制字符都不稱為二補數二進制字符。 For the sake of accuracy, all traditional binary characters are in two's complement binary format. Therefore, for convenience, all binary characters representing positive values are not called two's complement binary characters.
泛化二進制字符Generalized binary characters
利用第6圖所示的子電路來對二進制字符實施泛化處理。第7a圖則是其邏輯電路部件圖。 The subcircuit shown in Figure 6 is used to perform generalized processing on binary characters. Figure 7a is a diagram of its logic circuit components.
將兩個加法器的每一者饋入第7a圖的電路部件內。若最大有效位的位元是非零,加數是以二補數二進制格式存在的一個負數。在這種情況下,如第7b圖所示,在最大有效位的非零數值的位元是1,其係以子字符y被傳送到最大有效位元。加數其他位元的數值則被轉移成為子字符x。因此,將加數1000 0011分裂成第一二進制字符0000 0011以及第二二進制字符1000 0000。為區隔起見,將這些分裂出來的二進制字符稱為子字符。第一子字符0000 0011以x代表,第二子字符1000 0000以y代表。每一子字符數值的讀取方式與任一二進制字符相同。因此,兩個二進制子字符代表由加數之數值分裂出來的兩個數值,且x-y等於該加數的值。典型的是,子字符的字符長度與其原來加數的字符長度相同。 Feed each of the two adders into the circuit components of Figure 7a. If the most significant bit is non-zero, the addend is a negative number in two's complement binary format. In this case, as shown in Figure 7b, the non-zero bit in the most significant bit is 1, which is transferred to the most significant bit as sub-character y . The values of the other bits of the addend are shifted to sub-character x . Therefore, the addend 1000 0011 is split into the first binary character 0000 0011 and the second binary character 1000 0000. To distinguish them, these split binary characters are called sub-characters. The first sub-character 0000 0011 is represented by x , and the second sub-character 1000 0000 is represented by y . The value of each sub-character is read in the same way as any binary character. Thus, the two binary subcharacters represent the two values derived from the value of the addend, with xy being equal to the value of the addend. Typically, the subcharacters have the same character length as their original addend.
在諸多對x及y子字符中,某些對子字符的兩個子字符都包含非零的位元,且都被至少一個零的位元隔開。找出這類子字符的程序稱為「最佳化」。被最佳化的加數子字符可依據其位元位置直接相加,且兩個非零的位元相加後產生的進位可被相鄰更有效的零的位元捕獲,使得該位元不會出現漣漪效應。 Among many pairs of x and y subcharacters, some pairs contain both subcharacters containing non-zero bits, separated by at least one zero bit. The process of identifying such subcharacters is called "optimization." Optimized addend subcharacters can be added directly based on their bit positions, and any carry from the addition of two non-zero bits is captured by an adjacent, more significant zero bit, preventing ripple effects on the bits.
較佳是,x代表一個正數,y代表將自x中減除的另一個正數。在此情況下,更精準的說法是x為一個減數,而y是一個被減數。自x中減除y會產生原來加數的值。換言之,透過運用等效原則,以原來加數的數值來確認將x及y中的零及非零的位元重新排列後是可接受的且不會改變總和。 Preferably, x represents a positive number, and y represents another positive number to be subtracted from x . In this case, it's more accurate to say that x is the subtrahend, and y is the minuend. Subtracting y from x yields the value of the original addend. In other words, by applying the equivalence principle, the values of the original addends confirm that rearranging the zero and non-zero bits in x and y is acceptable and does not change the sum.
更明確的說,等效原則是指任何一個m(1)1的子字符可以用一個非零的位元1(在更有效位)以及一個被m-1個零隔開的(較不有效位)來取代。類似的,任何一個m(1)的子字符可以用一個位元(在更有效位)以及一個被m-1個零隔開的1(較不有效位)來取代。在此,1代表x子字符中的”1”,而代表y子字符中的”1”,而y即將從x子字符中被減除。 More specifically, the equivalence principle states that any m( 1) A subcharacter of 1 can be represented by a non-zero bit 1 (in the most significant position) and a subcharacter separated by m-1 zeros. (less significant bits) to replace. Similarly, any m( 1) The sub-characters can be represented by a bit (in the more significant position) and a 1 separated by m-1 zeros (in the less significant position). Here, 1 represents the "1" in the x sub-character, and Represents the "1" in the y subcharacter, which is about to be subtracted from the x subcharacter.
避免不要將y稱為負數。這是因為真實的負數必須以二補數二進制格式表示,其包含諸多相鄰的非零的位元,最佳化程序會避開這些位元。加數被視為「泛化」,因為加數的值不再以一個特定、單一的二進制字符來表示。換言之,對同樣長度的字符,可改變或重新排列在該對子字符中零及非零 的位元的排列方式,只要兩個子字符的總和保持等於加數值即可。此為等效原則在泛化處理中每一變異下的作用。但是,子字符x及y的字符長度,會比加數原始數值非零字符的長度多出一個位元。如此可讓x的數值大了一個位元級別,使得x可以成為一個減數。從x中減除一個適當的y值會得到原來的加數值。 Avoid calling y a negative number. This is because true negative numbers must be represented in two's complement binary format, which contains multiple adjacent non-zero bits, and the optimizer avoids these bits. The addend is considered "generalized" because the value of the addend is no longer represented by a specific, single binary character. In other words, for characters of the same length, the arrangement of zero and non-zero bits in the pair of sub-characters can be changed or rearranged as long as the sum of the two sub-characters remains equal to the addend value. This is the effect of the equivalence principle under each variation of the generalization process. However, the character length of the sub-characters x and y will be one bit longer than the length of the original non-zero value of the addend. This makes the value of x one bit larger, allowing x to be a subtraction. Subtracting an appropriate value of y from x returns the original value of the addend.
可以改良本發明用來將兩個泛化二進制數字相加的觀念及電路,來執行從其他泛化二進制數字(即,減數)中減除一個泛化二進制數字(即,被減數)。在二進制數字被泛化後,只有x及y的被減數內容需要被交換,使得加法器的操作變成減法,即,從減數中減除被減數的操作成為將減數與已改良的被減數(x及y的內容被交換)兩者相加的操作。 The concepts and circuits used in the present invention for adding two generalized binary numbers can be modified to perform subtraction of a generalized binary number (i.e., the minuend) from another generalized binary number (i.e., the subtraction). After the binary numbers are generalized, only the contents of the minuend (x ) and y need to be swapped, so that the adder operation becomes a subtraction. That is, the operation of subtracting the minuend from the subtraction becomes the operation of adding the subtraction to the modified minuend (with the contents of x and y swapped).
以下段落僅限於x是一個具有減數角色的子字符,而y是具有被減數角色的子字符。方便起見,當描述y中一個非零的位元時,使用下列的縮寫:(1的數字上面有一橫線)代表在y子字符中任何一個非零的位元,或是-1因y是被減數(本說明書真實表內使用了第二種縮寫,請勿與目前縮寫混淆)。 The following paragraphs are restricted to the case where x is a subcharacter with the decrementing role, and y is a subcharacter with the decremented role. For convenience, the following abbreviations are used when describing a non-zero bit in y : (1 has a dash through it) represents any non-zero bit in the y subcharacter, or -1 because y is being decremented (this second abbreviation is used in the actual tables in this manual; please do not confuse it with the current abbreviation).
因此,x=0001 0000且y=0000 0001可以寫成如後之單行形式:。在此,在最右方字符位置的代表在y子字符中具有非零數值的特定位元。類似的,在x子字符中具有1的位元代表在該特定位元有一個非零的數值。 Therefore, x = 0001 0000 and y = 0000 0001 can be written in a single line as follows: Here, at the rightmost character position Indicates that a specific bit in the y subcharacter has a non-zero value. Similarly, a bit in the x subcharacter that has a 1 indicates that there is a non-zero value at that specific bit.
在此提供一個如何將數字31泛化的實例。數字81在8-位元二進制格式中的二補數二進制格式是0001 1111。泛化時,以兩個子字符來重新表示0001 1111,即x=0001 1111,而y=0000 0000。應用等效原則後,x=0010 0000,y=0000 0001。在建議的簡寫中,可將兩個子字符寫成,其 中是y子字符中的1且位於最右邊的位元,且0010 0000是在x子字符中且1是位於第6位元位置。因0010 0000是32(十進位系統)且0000 0001是1(十進位系統),故在十進位系統中x-y=32-1=31。 Here's an example of how to generalize the number 31. The two's complement binary format of the number 81 in 8-bit binary format is 0001 1111. When generalizing, 0001 1111 is re-expressed as two sub-characters, i.e., x = 0001 1111 and y = 0000 0000. Applying the equivalence principle, x = 0010 0000 and y = 0000 0001. In the recommended abbreviation, the two sub-characters can be written as ,in The y subcharacter has a 1 at the rightmost bit, and 0010 0000 is in the x subcharacter with a 1 at the 6th bit position. Since 0010 0000 is 32 (decimal) and 0000 0001 is 1 (decimal), xy = 32 - 1 = 31 in decimal.
在此提供一個如何將數字23泛化的實例。數字23在8-位元二進制格式中的二補數二進制格式是0001 0111。泛化時,以兩個子字符來重新表示0001 0111,即x=0001 0111,而y=0000 0000。應用等效原則後,x=0010 1000,而y=0001 0001。在建議的簡寫中,可將兩個子字符寫成。因0010 1000是23(十進位系統)且0001 0001是17(十進位系統),故在十進位系統中x-y=40-17=23。 Here is an example of how to generalize the number 23. The two's complement binary format of the number 23 in 8-bit binary format is 0001 0111. When generalizing, 0001 0111 is re-expressed as two sub-characters, that is, x = 0001 0111 and y = 0000 0000. After applying the equivalence principle, x = 0010 1000 and y = 0001 0001. In the recommended abbreviation, the two sub-characters can be written as Since 0010 1000 is 23 (decimal system) and 0001 0001 is 17 (decimal system), xy = 40 - 17 = 23 in the decimal system.
在此提供一個如何將數字-23泛化的實例。數字-23在8-位元二進制格式中的二補數二進制格式是1110 1001(須知,在最有效數字中”1”代表其為一個負數)。泛化時,依據第6及7圖,以兩個子字符來重新表示1110 1001,即x=0110 1001,而y=1000 0000。應用等效原則後,x=0010 1000,而y=0001 0001。在建議的簡寫中,可將兩個子字符寫成。因0110 1001=105且1000 0000=128(十進位系統),故在十進位系統中x-y=105-128=-23。 Here is an example of how to generalize the number -23. The two's complement binary format of the number -23 in 8-bit binary format is 1110 1001 (note that the "1" in the most significant digit represents a negative number). When generalizing, according to Figures 6 and 7, 1110 1001 is re-expressed as two sub-characters, that is, x = 0110 1001 and y = 1000 0000. After applying the equivalence principle, x = 0010 1000 and y = 0001 0001. In the recommended abbreviation, the two sub-characters can be written as Since 0110 1001 = 105 and 1000 0000 = 128 (decimal system), xy = 105 - 128 = -23 in the decimal system.
一個子字符是減數而另一個子字符是被減數的觀念可以用下面方式來表示:在兩個預備相加的數字被轉變成為泛化二進制字符格式後,將出現4個子字符,x 1 、y 1 、x 2 及y 2 。若以數學來表示,一個n-位元二進制字符可以寫成如下:
其中,且,i=0,1,...,n-1。<,>代表該變數之一組可能的數值,須知,如前述,是負數子字符中一個非零的位元的縮寫。該二進制子字符每一位元的權重是一樣的,或是2的正整數次方。因此,可以將n w 寫成
n w 的域(domain)涵蓋從-(2 n -1)到2 n -1的範圍。 The domain of nw covers the range from -( 2n -1) to 2n -1.
半最佳泛化二進制字符Semi-optimal generalized binary characters nn ww
將任何加數泛化後所產生的子字符,只涉及將加數的數值分裂成為兩個以二進制子字符表示的數值。最佳化則是移除子字符周圍所有非零的位元,利用改變子字符中零及非零的位置和數字,同時使用等效原則,使得子字符的總和等於加數的值。 Generalizing any addend to generate subcharacters simply involves splitting the addend's value into two binary subcharacters. Optimization involves removing all non-zero bits surrounding the subcharacters, changing the position and number of zeros and non-zeros within the subcharacters, and applying the equivalence principle so that the sum of the subcharacters equals the addend's value.
較佳的最佳化策略是稱為「半最佳化」的處理,其係相對於「全最佳化」處理而言。 A better optimization strategy is called "semi-optimization" processing, as opposed to "full optimization" processing.
將一個泛化加數之兩個子字符施以「半最佳化」處理,會產生兩個具有下列特徵的子字符:1.在每一子字符中的每兩個非零的位元會被至少一個零的位元隔開;2.一個非零的位元是緊接在另一非零的位元之後,如果一個非零的位元是位在一個子字符中且另一個非零的位元是位在另一個子字符中;3.零位元的數目沒有限制。 Applying a "semi-optimization" to two sub-characters of a generalized addend produces two sub-characters with the following characteristics: 1. Every two non-zero bits in each sub-character are separated by at least one zero bit; 2. A non-zero bit is immediately followed by another non-zero bit if a non-zero bit is in one sub-character and another non-zero bit is in another sub-character; 3. There is no limit on the number of zero bits.
半最佳泛化二進制字符的實例及負數實例:兩個子字符的半最佳化格式:
‧在同樣的子字符中,沒有非零的位元緊接在另一相同數值的位元後 ‧In the same sub-character, no non-zero bit immediately follows another bit of the same value
‧另一子字符相同位置處沒有非零的位元 ‧There is no non-zero bit at the same position in another sub-character
兩個子字符的半最佳化格式:
‧在同樣的子字符中,沒有非零的位元緊接在另一相同數值的位元後 ‧In the same sub-character, no non-zero bit immediately follows another bit of the same value
‧另一子字符相同位置處沒有非零的位元 ‧Another sub-character has no non-zero bit at the same position
‧在另一子字符中,可能有一個非零的位元緊接在相鄰的位置 ‧In another sub-character, there may be a non-zero bit immediately adjacent to the next position
兩個子字符的半最佳化格式:
‧在同樣的子字符中,沒有非零的位元緊接在另一相同數值的位元後 ‧In the same sub-character, no non-zero bit immediately follows another bit of the same value
‧另一子字符相同位置處沒有非零的位元 ‧There is no non-zero bit at the same position in another sub-character
‧在另一子字符中,可能有一個非零的位元緊接在相鄰的位置 ‧In another sub-character, there may be a non-zero bit immediately adjacent to the next position
換言之,一對半最佳化二進制子字符乃是在每一個所獲得的半最佳化的正的x子字符及負的y子字符中,以至少一個零將所有非零的數字隔開。或是,不存在兩個連續的1(在全部的x子字符中)或是兩個連續的(在全部的y子字符中),但是在1之前或之後,可以有一個,反之亦然。 In other words, a pair of semi-optimal binary subcharacters is such that in each obtained semi-optimal positive x subcharacter and negative y subcharacter, all non-zero digits are separated by at least one zero. Alternatively, there are no two consecutive 1s (in all x subcharacters) or two consecutive (in all y subcharacters), but before or after the 1, there can be a ,vice versa.
以下是一個半最佳化處理的實例,因為有兩個非零在最小第一及第二位元位置,因此子字符並未被最佳化。 The following is an example of semi-optimization, where the sub-character is not optimized because there are two non-zeros in the first and second smallest bit positions.
上述x及y子字符是由數字3得來的,數字3在二補數二進制格式下為0000 0011。在等效原則下,以半最佳化處理將子字符轉變成下列:每一個加數的x及y子字符分別被最佳化,且無須參照另一加數。 The x and y sub-characters above are derived from the number 3, which is 0000 0011 in two's complement binary format. Under the principle of equivalence, the sub-characters are converted to the following using a semi-optimization process: the x and y sub-characters of each addend are optimized separately without reference to the other addend.
上述的簡寫為。 The above abbreviation is .
或者,以下列方式重新表達兩個子字符,使x-y=5-2=3。 Alternatively, re-express the two sub-characters in the following way so that x-y = 5-2 = 3.
上述的簡寫為。 The above abbreviation is .
可在其他實施方式中,選擇將011最佳化為。 In other implementations, it may be possible to optimize 011 to .
以下是半最佳化處理的第二個實例:
第一種可能的半最佳化是下列子字符8-1=7。 The first possible semi-optimization is the following sub-character 8-1=7.
上述的簡寫為。 The above abbreviation is .
第二種可能的半最佳化是下列子字符9-2=7。 The second possible semi-optimization is the following sub-character 9-2=7.
上述的簡寫為。 The above abbreviation is .
以下是半最佳化處理的第三個實例:
最佳的半最佳化處理實例如下:
上述的簡寫為。 The above abbreviation is .
上述三個半最佳化處理實例顯示對任一給定的輸入可產生多種可能的半最佳化子字符。 The three semi-optimization processing examples above show that for any given input, multiple possible semi-optimal sub-characters can be generated.
有許多方式可將一對代表一個數值的泛化的字符半最佳化。最直接的方式是以演算法來操控每一對子字符的位元。在這種實施方式中,操控位元的演算法以類似習知藉由移動位元來產生二進制被乘數及二進制乘數之乘積值的布斯乘法算法(Booth's multiplication algorithm)來操控位元。布斯乘法算法是用來在一個單一二進制字符上執行乘法。相反的,本實施方式所使用的操控位元並不會產生乘積或是總和,而是移除每一子字符周圍的非零位元。 There are many ways to semi-optimize a pair of generalized characters representing a single numeric value. The most straightforward approach is to algorithmically manipulate the bits of each sub-character pair. In this implementation, the bit manipulation algorithm operates in a manner similar to Booth's multiplication algorithm, which shifts bits to produce the product of a binary multiplicand and a binary multiplier. Booth's multiplication algorithm is used to perform multiplication on a single binary character. In contrast, the bit manipulation used in this implementation does not produce a product or sum, but rather removes the non-zero bits surrounding each sub-character.
但是,本實施方式操控位元的演算法必須依循等效原則,使得代表一個數值的一對子字符只能被轉變成另一對子字符(擁有不同的數字以及不同的零與非零位元的排列方式),但仍保有相同數值。所希望獲得之已轉變的一對子字符,在x子字符及y子字符周圍都沒有非零的位元,同時還具有一對半最佳化子字符的特性。 However, the bit manipulation algorithm used in this embodiment must adhere to the equivalence principle, so that a pair of sub-characters representing a numerical value can only be transformed into another pair of sub-characters (with different numerical values and a different arrangement of zero and non-zero bits) while still retaining the same numerical value. The desired transformed pair of sub-characters has no non-zero bits surrounding the x and y sub-characters and also exhibits the properties of a pair of semi-optimized sub-characters.
第8圖是將8-位元泛化二進制字符半最佳化成為9-位元半最佳泛化二進制字符的子電路圖。第9圖示出第8圖電路塊包含3塊子電路,分別標示為Vin8o08-31、Vin8o08-32及Vin8o08-33。 Figure 8 shows a subcircuit diagram for semi-optimizing an 8-bit generalized binary character into a 9-bit semi-optimized generalized binary character. Figure 9 shows that the circuit block in Figure 8 consists of three subcircuits, labeled Vin8o08-31, Vin8o08-32, and Vin8o08-33.
第10圖示出Vin8o08-31的細節,其是由多個如第11圖所繪示之基本子電路組成。 Figure 10 shows the details of Vin8o08-31, which is composed of multiple basic sub-circuits as shown in Figure 11.
第13圖示出Vin8o08-32的細節,其是由多個如第14圖所繪示之基本子電路組成。 Figure 13 shows the details of Vin8o08-32, which is composed of multiple basic sub-circuits as shown in Figure 14.
第16圖示出Vin8o08-33的細節,其是由多個如第17圖所繪示之基本子電路組成。 Figure 16 shows the details of Vin8o08-33, which is composed of multiple basic sub-circuits as shown in Figure 17.
優選的,可以第8圖的數位化區塊電路同時對子字符中每一個位元位置實施半最佳化,其包含以下步驟:半最佳化步驟1:與子電路Vin8o08-31相關,此步驟可利用符合下列方程式的相等原則,及第12圖之真值表1的邏輯與第11圖的邏輯電路,將任一字符移除:
換言之,對該對x及y子字符施用方程式,可移除y子字符周圍的非零數值。如前一段落所述,本說明書的真值表使用另一簡化符號Z來代表該對x及y子字符。詳言之,可將泛化二進制字符寫成二進制數字,其中一個字符以一個正的二進制數字表示,另一個字符以一個負的二進制數字表示,兩個字符之間則是0或1的數字。一般來說,n-位元之泛化二進制數字n w 可以寫成:
其中,x i =〈0,1〉且y i =〈0,1〉,其中i=0,1,...,n-1。在此,
每一位元的權重相同或是2的正冪。因此,z w 也可表示成以下:
z w 域涵蓋從-(2 n -1)至2 n -1的範圍。此另一種泛化二進制數字系統也可用在二補數二進制數字上。 The domain of zw covers the range from -( 2n -1) to 2n -1. This generalized binary number system can also be used for two's complement binary numbers.
半最佳化步驟2:與子電路Vin8o08-32相關,此步驟可利用符合下列方程式的相等原則,及第15圖之真值表2的邏輯與第14圖的邏輯電路,將任一叢集轉變成1:
半最佳化步驟3:與子電路Vin8o08-33相關,此步驟可利用符合下列方程式的相等原則,及第18圖之真值表3的邏輯與第17圖的邏輯電路,將任一字符1移除:
其中,及代表加數之半最佳化且泛化的二進制字符。 in, and An optimized and generalized binary character representing half of an addend.
換言之,對該對x及y子字符施用方程式,可移除x子字符周圍的非零數值。 In other words, applying the equation to the pair of x and y subcharacters removes the non-zero values surrounding the x subcharacter.
步驟1、2、及3的執行順序非常重要且必須嚴格遵循。 The order in which steps 1, 2, and 3 are performed is very important and must be followed strictly.
每一個欲被相加之加數的泛化二進制字符都經過上述半最佳化步驟1、2、及3的處理,以產生兩對半最佳化之泛化二進制子字符。 Each generalized binary character of the addend to be added is processed through the semi-optimization steps 1, 2, and 3 above to generate two pairs of semi-optimized generalized binary sub-characters.
將最佳化及泛化二進制子字符相加Add optimized and generalized binary substrings
接著,將兩對9-位元之半最佳化的泛化二進制子字符x 1,y 1,x 2,y 2餵入第19圖所示之加法器中相加。 Next, two pairs of 9-bit half-optimized generalized binary subwords x 1 , y 1 , x 2 , y 2 are fed into the adder shown in FIG. 19 and added together.
第21圖為第20圖中多個子電路中一個子電路的詳細圖示。此加法器的輸入為該兩對半最佳化且泛化之加數的4個子字符,輸出則是一個具有x輸出子字符及y輸出子字符的10-位元之泛化二進制字符。 FIG21 is a detailed diagram of one of the sub-circuits in FIG20. The input of this adder is the four sub-words of the two pairs of half-optimized and generalized addends, and the output is a 10-bit generalized binary word having an x- output sub-word and a y -output sub-word.
第22圖繪示出該加法器的邏輯電路,必須使用兩個這樣的加法器(如第21圖所示)才能產生包含兩個子字符之泛化總和。 Figure 22 shows the logic circuit of the adder. Two such adders (as shown in Figure 21) are required to produce a generalized sum that includes two sub-characters.
但是,第22圖邏輯電路的4-位元輸入只會產生一個輸出位元。類似的,第21圖子電路繪示出一個8-位元的輸入。 However, the 4-bit input of the logic circuit in Figure 22 will only produce one output bit. Similarly, the circuit in Figure 21 shows an 8-bit input.
事實上,只需要加數的兩個相應的位元(分別來自子字符x 1及x 2)就可進行相加,並產生一個輸出位元X。類似的,將兩個分別來自子字符y 1及y 2)就可進行相加,並產生一個輸出位元Y。輸出位元X及Y形成泛化二進制字符之總和。加法器係取位置i及i-1之兩個相鄰的位元,因為半最佳化程序可確保其中一個位元是零。這些插入的零位元可終止進位值使其不再繼續傳送。 In fact, only two corresponding bits of the addends (one from each sub-word, x 1 and x 2 ) are added together to produce an output bit, X. Similarly, two corresponding bits from each sub-word, y 1 and y 2 , are added together to produce an output bit, Y. Output bits X and Y form the sum of the generalized binary word. The adder takes two adjacent bits at positions i and i-1, because the semi-optimization process ensures that one of these bits is zero. These inserted zero bits terminate the carry value so that it is not propagated further.
此外,因為半最佳化程序可確保緊鄰非零位元的位元永遠是零,因此在加法過程中納入一個相鄰的額外的位元,並不會影響輸出值。 Furthermore, because the semi-optimization ensures that bits immediately adjacent to non-zero bits are always zero, including an extra bit adjacent to the addition does not affect the output value.
在第20圖中有10個子電路,每一個都如第21圖所示。第20圖的子電路係同時運作,因為所有電路中的邏輯閘都會對施加在輸入導線的高電位有反應。 There are 10 subcircuits in Figure 20, each of which is shown in Figure 21. The subcircuits in Figure 20 operate simultaneously because the logic gates in all circuits respond to a high voltage applied to the input wire.
從一加法器到另一加法器之間不涉及進位值的傳遞或是剝除,每一加法器僅是藉由納入相關位置的輸入值來計算相應位元的輸出而已,與電路中其他加法器無關。 There is no carry value propagation or stripping from one adder to another. Each adder simply calculates the output of the corresponding bit by taking in the input value of the relevant position, which is independent of other adders in the circuit.
因為整個完整長度的二進制輸入字符中,並沒有任何可供傳遞或剝除的進位值,讓電路圖升級只是在現存組態中加入更多加法器子電路而已。 Because there are no carry values to propagate or strip in a full-length binary input character, upgrading the schematic simply involves adding more adder subcircuits to the existing configuration.
第24a圖至第24g圖繪示出如何將兩個加數的四個最佳化、泛化二進制字符相加。截至本階段,所有的處理都屬於直覺式的。第20圖中每一加法器子電路僅會納入相關輸入位元並產生輸入字符特定位置的輸出位元而已。同樣的,第24a圖至第24g圖所繪示的處理乃示同步進行的。 Figures 24a through 24g illustrate how to add the four optimized, generalized binary characters of two addends. Up to this point, all the processing is intuitive. Each adder subcircuit in Figure 20 simply takes in the associated input bits and produces the output bit at the specific position of the input character. Similarly, the processing illustrated in Figures 24a through 24g is performed synchronously.
在第24a至24g圖中被相加的子字符長度為6-位元,並產生一個7-位元的輸出。7-位元字符長度與8-位元字符長度的實施方式都一樣。本文只是任意選選用6-位元做為解說例而已。 In Figures 24a through 24g, the sub-characters being added are 6 bits long, resulting in a 7-bit output. The implementation is the same for 7-bit and 8-bit character lengths. This article arbitrarily uses 6 bits for illustration purposes.
每一個第20圖的加法器都可將x 1 子字符預定位置的位元與x 2 子字符預定位置的位元相加,並產生X子字符相同位置的輸出位元值。依照相同方式,產生Y子字符相同位置的輸出位元值。 Each adder in FIG. 20 adds the bit at a predetermined position in the x1 sub-character to the bit at a predetermined position in the x2 sub-character and generates the output bit value for the same position in the X sub-character. Similarly, the output bit value for the same position in the Y sub-character is generated.
第24a圖是關於位置i,從i=0開始算。將x 1 子字符的x 10 位元及x 2 子字符的x 20 位元相加。同樣的,將y 1 子字符的y 10 位元及y 2 子字符的y 20 位元相加。但是,在位置i=0之x 0 子字符及y 0 子字符的輸出為零。 Figure 24a is for position i, starting at i=0. Add the x10 bits of the x1 subcharacter and the x20 bits of the x2 subcharacter. Similarly, add the y10 bits of the y1 subcharacter and the y20 bits of the y2 subcharacter. However, at position i=0, the output for the x0 subcharacter and the y0 subcharacter is zero.
這是因為第22圖的邏輯電路需要兩個來自x 1 子字符的位元,兩個來自x 2 子字符的位元,兩個來自y 1 子字符的位元以及兩個來自y 2 子字符的位元。 This is because the logic circuit in Figure 22 requires two bits from the x1 sub -character, two bits from the x2 sub -character, two bits from the y1 sub -character, and two bits from the y2 sub -character.
第24b圖是關於i=1。以x 1 子字符的x 10 及x 11 位元,x 2 子字符的x 20 及x 21 位元,y 1 子字符的y 10 及y 11 位元,y 2 子字符的y 20 及y 21 位元來提供第23圖真值表中的輸出。 Figure 24b is for i = 1. The outputs of the truth table in Figure 23 are provided using bits x10 and x11 of the x1 sub - character, bits x20 and x21 of the x2 sub-character, bits y10 and y11 of the y1 sub -character, and bits y20 and y21 of the y2 sub-character.
第24c圖是關於i=2。將x 1 子字符的x 11 及x 12 位元,x 2 子字符的x 21 及x 22 位元相加,並產生輸出子字符的X2值。將相同操作運用在y 1及y 2子字符上,並產生輸出子字符的Y2值。 Figure 24c is for i = 2. Add bits x11 and x12 of the x1 subcharacter and bits x21 and x22 of the x2 subcharacter to produce the output subcharacter's value x2 . Apply the same operation to the y1 and y2 subcharacters to produce the output subcharacter's value y2 .
第24d圖是關於i=3。將x 1 子字符的x 12 及x 13 位元,x 2 子字符的x 22 及x 23 位元相加,並產生輸出子字符的X3值。將相同操作運用在y 1及y 2子字符上,並產生輸出子字符的Y3值。 Figure 24d is for i = 3. Add bits x12 and x13 of the x1 subcharacter and bits x22 and x23 of the x2 subcharacter to produce the output subcharacter's value x3 . Apply the same operation to the y1 and y2 subcharacters to produce the output subcharacter's value y3 .
第24e圖是關於i=4。將x 1 子字符的x 13 及x 14 位元,x 2 子字符的x 23 及x 24 位元相加,並產生輸出子字符的X4值。將相同操作運用在y 1及y 2子字符上,並產生輸出子字符的Y4值。 Figure 24e is for i = 4. Add bits x13 and x14 of the x1 subcharacter and bits x23 and x24 of the x2 subcharacter to produce the output subcharacter's value x4 . Apply the same operation to the y1 and y2 subcharacters to produce the output subcharacter's value y4 .
第24f圖是關於i=5。將x 1 子字符的x 14 及x 15 位元,x 2 子字符的x 24 及x 25 位元相加,並產生輸出子字符的X5值。將相同操作運用在y 1及y 2子字符上,並產生輸出子字符的Y5值。 Figure 24f is for i = 5. Add bits x14 and x15 of the x1 subcharacter and bits x24 and x25 of the x2 subcharacter to produce the output subcharacter value x5 . Apply the same operation to the y1 and y2 subcharacters to produce the output subcharacter value y5 .
第24g圖是關於i=6。將x 1 子字符的x 15 位元,x 2 子字符的x 25 位元相加,並產生輸出子字符的X6值。將相同操作運用在y 1及y 2子字符上,並產生輸出子字符的Y6值。 Figure 24g is for i = 6. Add the x15 bits of the x1 subcharacter and the x25 bits of the x2 subcharacter to produce the output subcharacter's value of x6 . Apply the same operation to the y1 and y2 subcharacters to produce the output subcharacter's value of y6 .
由於來自兩個泛化二進制數字子字符的4個位元的輸入,其總和為一個位元(同樣為泛化格式)。所得為兩個輸出位元,形成一個輸出總和的兩個子字符(同樣為泛化格式)。 Since the 4-bit input from the two generalized binary digit sub-characters sums to one bit (also in the generalized format), the result is two output bits, forming an output sum of two sub-characters (also in the generalized format).
在此段中呈現半最佳化泛化二進制字符的加法演算法。總和以N w 表示,半最佳化之被加數及加數分別以及表示。 In this section, a semi-optimized generalized binary character addition algorithm is presented. The sum is denoted by N w , and the semi-optimized summand and addend are denoted by and express.
以下面步驟來呈現相加的方法:(a)以下列方程式將正成分及負成分相加:
其中邏輯真值表及邏輯電路分別提供在第23圖的表12及第22圖。 The logic truth table and logic circuit are provided in Table 12 of Figure 23 and Figure 22, respectively.
將兩個子字符去轉化成為二補數格式的單一二進制字符Convert two sub-characters into a single binary character in two's complement format
必須將代表加數與被加數(以x及y子字符表示,為下一階電路的輸出)總和的X及Y兩個子字符,去轉化成傳統二進制格式(即,二補數格式的單一二進制字符),方能被其他調控程序讀取並使用。 The two sub-characters (X and Y), representing the sum of the addend and augend (represented by the x and y sub-characters, which are the output of the next-level circuit), must be converted into traditional binary format (i.e., a single binary character in two's complement format) before they can be read and used by other control programs.
一般去轉化邏輯電路與傳統超前進位加法器類似,但細部結構並不完全相同。以第25圖的子電路來取代傳統超前進位加法器中的傳遞位元、生成位元及最終總和位元。第26圖為子電路內部的對應邏輯電路,第27圖及第28圖則分別為真值表4及真值表5a。 The general deconversion logic is similar to that of a traditional carry-lookahead adder, but the detailed structure is not identical. The subcircuit in Figure 25 replaces the propagation bit, generator bit, and final sum bit in a traditional carry-lookahead adder. Figure 26 shows the corresponding logic within the subcircuit, while Figures 27 and 28 show Truth Table 4 and Truth Table 5a, respectively.
一對8-位元長度的子字符需要8個子電路。此係因為每一個子電路只能服務兩個子字符中相同位置的兩個位元,亦即,x子字符中的一個位元以及y子字符中的另一個位元,兩位元位於相同的位置。 A pair of 8-bit subwords requires 8 subcircuits. This is because each subcircuit can only service two bits in the same position in two subwords, that is, one bit in the x subword and another bit in the y subword, both bits in the same position.
如果加法器的輸出讀值如下:
x-y=84-17=67 x - y = 84 - 17 = 67
去轉化的第一個步驟是以零來取代兩個子字符中相同位置的所有非零位元。這些非零的數值會彼此抵消。參閱上方兩個子字符的第4位元均為1,而下方字子符則移除了兩個位元。 The first step in deconversion is to replace all non-zero bits in the same position in both sub-characters with zeros. These non-zero values cancel each other out. See how bit 4 of both sub-characters above is 1, while the sub-character below has two bits removed.
x-y=68-1=67 x - y = 68-1=67
可使用以下去轉化電路,將此兩個子字符合併成為一個單一二進制字符:
在數學上,將(n-1)-位元Zw的子字符去轉化成為n-位元二補數二進制字符的方法,包括使用初始位元減化來取代x i =y i =0,如果x i =y i =1。 Mathematically, convert the (n-1)-bit sub-character of Z w into an n-bit two's complement binary character The method involves using initial bit reduction to replace x i = y i = 0 if x i = y i = 1.
接著,使用常規加法器電路,將經過上述處理的兩個子字符相加。將眾所周知的超前進位加法器的預測進位邏輯改良成適合本文去轉化要求的邏輯,亦即,以下列邏輯來取代傳統的生成(g i )及傳送(p i ):
g i =y i (8b) g i = y i (8b)
上述用來去轉化為二補數數值之與生成及傳送輸出相關的真值邏輯繪示於第27圖的真值表4中。亦即,真值表4是關於可預測即將生成之進位值的輸入位元組合以及將被傳送之進位值的條件。但是,須知這種生成和傳送以及群之生成與群之傳送的程序,與超前進位加法器電路從X子字符 及Y子字符輸出類似,都是一系列操作。隨著位元數目增加,操作也變得更複雜。因此,用來產生二補數數值的去轉化程序並不是一種平行操作。 The truth logic associated with the conversion to two's complement values and the generation and propagation of outputs is shown in Truth Table 4 in Figure 27. Specifically, Truth Table 4 describes the conditions under which a carry value is predicted for the input bit combination that will generate a carry value and the carry value that will be propagated. However, it should be noted that this generation and propagation, as well as the group generation and propagation processes, are similar to the lookahead adder circuit's outputs from the X and Y sub-characters, and are a series of operations. As the number of bits increases, the operations become more complex. Therefore, the conversion process used to generate two's complement values is not a parallel operation.
可以下列方程式來表示「最後階段總和電路」:
Y n =c n (9b) Y n = c n (9b)
當每一位元的「進位」已被超前進位時,其中是改良的「超前進位電路」所產生的進位。 When the "carry" of each bit is carried forward, the carry is generated by the improved "carry-lookahead circuit".
第28a圖之真值表5a的真值邏輯,與用來將該總和之子字符對去轉化為正常二補數二進制格式之i=0,1,2,…,(n-1)的「最後階段總和」邏輯相關,其邏輯電路繪示於第26圖中。 The truth logic of truth table 5a in Figure 28a is related to the "final stage sum" logic used to convert the sub-character pairs of the sum into the normal two's complement binary format for i = 0, 1, 2, ..., ( n -1), whose logic circuit is shown in Figure 26.
第29a圖繪示出如何將4-位元泛化二進制數字去轉化為傳統5-位元二補數二進制數字的過程。如第29b圖所示,提供4-位元泛化二進制字符的兩個子字符來產生改良的生成及傳送位元,將兩個子字符的每一位元作為輸入之一送到第26圖邏輯電路陣列中一相應位置。 Figure 29a illustrates the process of converting a 4-bit generalized binary number into a traditional 5-bit two's complement binary number. As shown in Figure 29b, two sub-characters of the 4-bit generalized binary character are provided to generate the improved generation and transmission bits. Each bit of the two sub-characters is sent as one of the inputs to a corresponding position in the logic circuit array of Figure 26.
第29b圖陣列的輸出將是5-位元單一字符的傳統二補數數字,其中最左邊的數字代表二進制數字的符號。如果總和是正值,最左邊的位元是「0」,否則其將為「1」,如果總和是負值的話。這是傳統二補數數字的概念。須知將泛化二進制數字去轉化將會產生一個傳統二補數數字,其將會多出一個位元,且此多出來的位元代表二進制數字的符號。 The output of the array in Figure 29b will be a 5-bit single-digit traditional two's complement number, where the leftmost digit represents the sign of the binary number. If the sum is positive, the leftmost bit is "0", otherwise it is "1" if the sum is negative. This is the concept of a traditional two's complement number. Note that converting a generalized binary number will produce a traditional two's complement number with one extra bit, and this extra bit represents the sign of the binary number.
因此,如果總和是負值時,第29b圖的邏輯電路也能透過將二進制輸出字符轉變成二進制補數格式而恢復總和數值的符號。 Therefore, if the sum is negative, the logic circuit in Figure 29b can also restore the sign of the sum value by converting the binary output characters to two's complement format.
在所有需要加法的操作結束前僅在必要時對兩個子字符進行去轉化Deconvert the two sub-characters only if necessary before any operations requiring addition are completed.
如上述,本實施方式最後一個步驟是去轉化,其包含以典型全加法演算法將x子字符及y子字符相加,上述改良的超前進位僅是可使用的多種方式之一。但是,如第30a圖所示,可先暫停步驟509,直到步驟511、513及515中所有需要輸出加數總和以進行更多加法及減法的運算都完成為止(如步驟508中所決定的)。在此階段,分配給泛化二進制字符(亦即,最終子字符對)使用的記憶體是專用記憶體。 As mentioned above, the final step in this embodiment is deconversion, which involves adding the x sub-character and the y sub-character using a typical full addition algorithm. The modified carry-lookahead algorithm described above is only one of many possible approaches. However, as shown in FIG. 30a , step 509 may be paused until all operations in steps 511 , 513 , and 515 that require outputting the sum of the addends for further addition and subtraction operations are completed (as determined in step 508 ). At this stage, the memory allocated for the generalized binary character (i.e., the final sub-character pair) is dedicated memory.
但是,對每一個後續的加法處理,在上一輪加法所產生的輸出結果(泛化二進制格式)加上一個新的數字(同樣是泛化二進制格式)時,必須將這兩個數字最佳化。特別是,輸出一加數將使其喪失最佳化格式,即便該輸出仍是泛化格式。為了將上一輪加法的輸出值最佳化,需先處理該對二進制字符,移除其中冗餘的位元。 However, for each subsequent addition, when adding a new number (also in generalized binary format) to the output of the previous addition (in generalized binary format), both numbers must be optimized. In particular, outputting a single addend will cause it to lose its optimized format, even if the output remains in generalized format. To optimize the output value of the previous addition, the pair of binary characters must first be processed to remove redundant bits.
從泛化二進制子字符中移除冗餘位元可以下列方程式表示:
“冗餘位元”都是成對出現,且定義為x子字符一位元位置上的非零,以及y子字符相同位元位置的非零。這些非零位元除了位於x及y子字符上相同位置可以互相抵銷外,沒有其他意義。 "Redundant bits" appear in pairs and are defined as a non-zero bit position in the x subcharacter and a non-zero bit position in the y subcharacter. These non-zero bits have no other meaning except that they cancel each other out when they are in the same position in the x and y subcharacters.
在以下x子字符及y子字符的例子中,每一子字符的第一位元為一非零的值。這些是冗餘位元,因為其屬於兩個子字符相同位置上的非零。 In the following example of the x subcharacter and the y subcharacter, the first bit of each subcharacter has a non-zero value. These are redundant bits because they are non-zero bits in the same position in both subcharacters.
因此,在最佳化之前,必須將非零的值轉變成零的值而將這些冗餘位元,並獲得以下:
因此,可簡單地將位元轉變成零來移除冗餘位元,且不會影響所代表的值同時仍然遵循等效原則。 Therefore, redundant bits can be removed simply by converting them to zero without affecting the represented value and still following the equivalence principle.
因此,在第30a圖的流程圖中,如果有許多數字需要相加,在進行最佳化(即,步驟515)之前,需先對上一輪加法產生的總和進行處理,移除其中的冗餘位元(步驟517)。將被加入上一輪加法總和的新的加數,同樣要在步驟515中先被最佳化。不需要先移除新的加數中的冗餘位元,因為將加數轉變成泛化二進制數字格式時,已經避免了產生冗餘位元。 Therefore, in the flowchart of Figure 30a, if there are many numbers to be added, the sum generated by the previous round of additions must first be processed to remove redundant bits (step 517) before optimization (i.e., step 515). The new addend to be added to the previous round of additions must also be optimized in step 515. There is no need to remove redundant bits from the new addends because the generation of redundant bits is already avoided when the addends are converted to the generalized binary format.
移除冗餘位元的真值邏輯繪示於第30c圖真值表5b以及第30b圖的邏輯電路。 The truth logic for removing redundant bits is shown in truth table 5b in Figure 30c and the logic circuit in Figure 30b.
使用完全最佳化之泛化二進制子字符的第二種實施方式Second Implementation Using Fully Optimized Generalized Binary Subcharacters
如第5圖流程圖所示,用來移除非零周圍緊鄰的非零之半最佳化處理的另一種方式稱為「完全最佳化」處理,參閱第31、32、33及34圖。 As shown in the flowchart of Figure 5, an alternative to the semi-optimization process for removing non-zero neighbors is called "full optimization" processing, see Figures 31, 32, 33, and 34.
符合完全最佳化條件的子字符,必定也符合半最佳化條件。 A sub-character that meets the fully optimized conditions must also meet the semi-optimized conditions.
但是,反之並不成立。完全最佳化是半最佳化的一個子集。 However, the reverse is not true. Full optimization is a subset of semi-optimization.
第31圖是用來將泛化二進制子字符完全最佳化的一種高階子電路;第32圖是支持第31圖高階子電路的多個互聯子電路的電路圖;第33圖繪示 出組成第32圖中每一互聯子電路的電路圖;第34圖則繪示出第33圖的邏輯電路。 Figure 31 shows a high-level subcircuit used to fully optimize generalized binary subcharacters. Figure 32 is a circuit diagram of the multiple interconnected subcircuits that support the high-level subcircuit in Figure 31. Figure 33 shows the circuit diagram of each interconnected subcircuit in Figure 32. Figure 34 shows the logic circuit of Figure 33.
由代表加數之泛化二進制字符所產生的每一對子字符,一旦被完全最佳化後,將符合以下:‧相加後其數值等於加數的一對子字符,且每一子字符的初始值係自該加數中分裂出來;‧符合完全最佳化子字符的條件,其包括:‧在相同子字符中沒有兩個緊鄰的非零位元,亦即,在相同子字符中任何兩個非零位元之間必須相隔至少一個零位元;‧即使兩個非零位元是在不同子字符中,也不會出現兩個緊鄰的非零位元 Each pair of sub-characters generated by the generalized binary character representing the addend, once fully optimized, will meet the following requirements: ‧ The value of the sub-characters after addition is equal to the addend, and the initial value of each sub-character is split from the addend; ‧ The conditions for fully optimized sub-characters are met, which include: ‧ There are no two adjacent non-zero bits in the same sub-character, that is, any two non-zero bits in the same sub-character must be separated by at least one zero bit; ‧ There will be no two adjacent non-zero bits, even if the two non-zero bits are in different sub-characters
一對已被完全最佳化的泛化二進制子字符顯示如下,亦即,以下是一對完全最佳化的子字符: A pair of fully optimized generalized binary sub-characters is shown below. That is, the following is a pair of fully optimized sub-characters:
兩個完全最佳化的x及y子字符 Two fully optimized x and y sub-characters
‧無論在相同或不同子字符中,不存在任何兩個緊鄰的非零位元 ‧No two adjacent non-zero bits exist in the same or different sub-characters
‧另一子字符中相同位置不存在非零位元 ‧There is no non-zero bit at the same position in another sub-character
如果兩個子字符依照位元位置對齊後並列,可看到任一非零位元周圍有5個零位元。除非,一個子字符中的第一個或最後一個位置是非零位元,則非零位元周圍將僅有3個零位元。 If two sub-characters are aligned by bit position and placed side by side, there will be 5 zero bits around any non-zero bit. Unless the first or last position in a sub-character is a non-zero bit, there will only be 3 zero bits around the non-zero bit.
以下是一對未完全最佳化子字符的不正確且負面的實例。因為在兩個相鄰位置絕對不能出現兩個非零位元,即使這兩個非零位元是位在不同子字符中也是如此,這也是完全最佳化與半最佳化程序之間的差異,半最佳化容許相鄰位元出現兩個非零位元,只要這兩個非零位元是位在不同子字符中即可。 The following is an incorrect and negative example of a sub-character that is not fully optimized. This is because two non-zero bits cannot appear in two adjacent positions, even if they are in different sub-characters. This is the difference between a fully optimized program and a semi-optimized program. Semi-optimization allows two non-zero bits to appear in adjacent positions as long as they are in different sub-characters.
兩個未完全最佳化的x及y子字符 Two sub-characters x and y that are not fully optimized
換言之,在完全最佳化之泛化二進制字符的子字符中,任意兩個非零位元間至少存在一個零位元。相反的,半最佳化演算法則是確保在同一子字符中每兩個非零位元(i=,1,...,n)間至少間隔一個零位元。最佳化演算法同樣必須遵循「等效原則」。 In other words, in a fully optimized generalized binary character sub-character, there is at least one zero bit between any two non-zero bits. Conversely, a semi-optimal algorithm ensures that there is at least one zero bit between every two non-zero bits in the same sub-character ( i = ,1,..., n ). Optimized algorithms must also adhere to the "equivalence principle."
第31、32、33及34圖中的電路是依據可將一對子字符完全最佳化的演算法而設計出來的,此演算法也可以數學式來表示。 The circuits in Figures 31, 32, 33, and 34 are designed based on an algorithm that can completely optimize a pair of sub-characters. This algorithm can also be expressed mathematically.
下列數學式是與執行第31、32、33及34圖之完全最佳化演算法相關:
其中,在x i 及y i 上方的橫線代表否定數值,數值的絕對值由二元布林變數(binary Boolean variables)來表示。 The horizontal lines above x i and y i represent negative values, and the absolute values are represented by binary Boolean variables.
負數數字Negative numbers
第31、32、33及34圖邏輯電路的真值繪示於第35圖的表6a中。對讀者而言,直接閱讀真值表會較嚐試理解相關數學式及電路來得容易些。 The truth values for the logic circuits in Figures 31, 32, 33, and 34 are shown in Table 6a of Figure 35. It is easier for readers to directly read the truth table than to try to understand the associated mathematical expressions and circuits.
換言之,將資料輸入第33圖的邏輯電路後,其可依據第35圖表6a產生一個輸出結果。 In other words, after inputting data into the logic circuit in Figure 33, it can generate an output result according to Table 6a in Figure 35.
演算法本身具有回歸性,從第一輪的i=0開始,其中Z 0 及Z 1 是最先開始的兩個位元,且假設Z -1 =0。 The algorithm itself is recursive, starting from the first round i=0, where Z0 and Z1 are the first two bits, and it is assumed that Z -1 =0.
依據表6a將Z 0 Z 1 Z -1 子字符轉變,可獲得子字符(取代原來的Z 0 Z 1 Z -1 )。第二輪i=1時輸入更新的Z 2 Z 1 Z 0 子字符,並再次依據表6a將其轉變。持續回歸演算直到達到最顯著數位為止,此時i=n且Z n+1=0已完成。 According to Table 6a, convert the Z 0 Z 1 Z -1 sub-character to obtain Sub-character (replacing the original Z 0 Z 1 Z -1 ). In the second round, when i = 1, the updated Z 2 Z 1 Z 0 sub-character is input and again transformed according to Table 6a. The regression algorithm continues until the most significant digit is reached, at which point i = n and Z n +1 = 0 is completed.
透過理解半最佳化,可能會比較容易理解完全最佳化演算。在此情況下,可透過能達成以下目的之演算法,將每一個半最佳化之泛化二進制字符進一步最佳化為一個完全最佳化之泛化二進制字符:1)移除周圍所有非零位元,使得x子字符中兩個1位元,y子字符兩個位元,以及x子字符中一個1位元和y子字符一個位元係彼此相鄰(即,x子字符中沒有1及位元,這些情況可以兩個緊鄰的0及1來取代);或是2)將以上所述位元配置以相鄰的零及非零位元來取代;且 3)如果在相同子字符中,緊鄰非零位元的下一個位元之前及之後都是零位元,則保留子字符中的任何非零位元,同時另一子字符相同位置之前及之後的位元都是零位元。 By understanding semi-optimization, it may be easier to understand the full optimization algorithm. In this case, each semi-optimized generalized binary character can be further optimized into a fully optimized generalized binary character by an algorithm that can achieve the following goals: 1) Remove all surrounding non-zero bits so that the x sub-character has two 1 bits and the y sub-character has two 1 bits. bit, and a 1 bit in the x subcharacter and a 1 bit in the y subcharacter The bits are adjacent to each other (i.e., there are no 1s and bits, these cases can be replaced by two adjacent 0 and 1); or 2) the above bits are arranged with adjacent zero and non-zero bits and 3) if the bit immediately before and after the next non-zero bit in the same sub-character is zero bits, then any non-zero bits in the sub-character are retained, while the bits before and after the same position in the other sub-character are zero bits.
半最佳化處理的其他變化Other variations of semi-optimization
上述說明可讓任一讀者理解本發明實施方式如何操作。為展示尚有其他演算法也可達成最佳化目的,本發明範疇不應僅限於上述實施方式及演算法,以下提出可達成半最佳化的兩種其他方式。 The above description should allow any reader to understand how the embodiments of the present invention operate. To demonstrate that other algorithms can achieve optimization, and that the scope of the present invention should not be limited to the above embodiments and algorithms, two other methods for achieving semi-optimization are proposed below.
將泛化二進制數字nw(一對相加後其數值等於加數的子字符)半最佳化的第一種變化包含兩個步驟: The first variation of semi-optimizing the generalized binary number n w (a pair of sub-characters whose value when added is equal to the addend) consists of two steps:
(a)以下列半最佳化轉形方程式,將任一個泛化二進制數字nw轉形成為第一種形式之部分半最佳化二進制數字:
此步驟可藉由找到將nw移動一個位數到更顯著進位(亦即,2nw)以及nw之間的差異來執行。第一種形式之部分半最佳化演算法如以下方程式及真值表6b所示:
其中,假設z n+1=z -1=z -2=0。 Here, we assume that z n +1 = z -1 = z -2 =0.
方程式(11)及相應擴張的方程式(12a)及(12b)意指將一子字符乘以2,再從乘積中減去該子字符,藉此來轉化該子字符對中的每一子字符。結果意外發現,有極少位元的位置與排列,不符合半最佳化子字符的要求。故,此方法幾乎可達成完全半最佳化。換言之,此步驟並不完美,且此演算法無法 保證達成完全半最佳化,因為其無法(i)在中有一個,如果在nw中存在有一子字符時;及(ii)在中有一個11,如果在nw中存在有一子字符時,這些都與前文中半最佳化定義相衝突。 Equation (11) and the corresponding expanded equations (12a) and (12b) imply multiplying a sub-character by 2 and then subtracting the sub-character from the product to transform each sub-character in the sub-character pair. It was unexpectedly found that there are very few bit positions and arrangements that do not meet the requirements of semi-optimal sub-characters. Therefore, this method can almost achieve complete semi-optimization. In other words, this step is not perfect, and this algorithm cannot guarantee complete semi-optimization because it cannot (i) There is one , if there exists a sub-character; and (ii) There is an 11 in n w . If there is an sub-characters, these conflict with the semi-optimal definitions above.
第37b圖顯示依據本半最佳化處理或演算法之變化中,步驟(a)之方程式而產生的真值表6b。上述方程式之半最佳化處理無法保證達成完全半最佳化,因為其無法(i)在中有一個,如果在nw中存在有一子字符時;及(ii)在中有一個11,如果在nw中存在有一子字符時,這些都與前文中半最佳化定義相衝突。 FIG37b shows the truth table 6b generated by the equations of step (a) in accordance with a variation of the present semi-optimization process or algorithm. The semi-optimization process of the above equations cannot guarantee a complete semi-optimization because it cannot (i) There is one , if there exists a sub-character; and (ii) There is an 11 in n w . If there is an sub-characters, these conflict with the semi-optimal definitions above.
(b)為了解決任一位元不符合半最佳化子字符要求的問題,將中的11或排列中的任一位元轉形成為一完全半最佳化數字,其可以下列方程式及真值表6c來表示:
第37c圖為上文所述方程式的真值表6c。以方程式(13a)及(13b)表示的位元調控,係將無法滿足方程式(11)之半最佳化要求而產生的非零組合納入考量後的結果。 Figure 37c shows the truth table 6c of the equation above. The bit manipulation represented by equations (13a) and (13b) is the result of taking into account the non-zero combinations that fail to meet the semi-optimization requirements of equation (11).
因此,步驟(b)是用來彌補步驟(a)之不足,使得可將任一數字轉形成完全半最佳化數字,或是簡單以來表示。 Therefore, step (b) is used to make up for the deficiency of step (a) so that any number can be converted into a completely semi-optimal number. , or simply To express.
組合步驟(a)及(b),並假設z n+1=z -1=z -2=z -3=0,可將方程式(12a)、(12b)、(13a)、(13b)中的半最佳化演算法組合,並產生如下方程式:
其中,可透過平行操作,而非回歸操作,將n w 的正數及負數都加以半最佳化。 In this case, both positive and negative n w can be semi-optimized through parallel operations rather than regression operations.
半最佳化輸出及僅依賴n w 中的z i ,z i-1,z i-2及z i-3。 Semi-optimal output and It depends only on z i , z i -1 , z i -2 and z i -3 in n w .
第38圖是組合步驟(a)及步驟(b)(亦即,方程式(14a)及(14b))後的真值表7。對應的邏輯電路繪示於第36圖及第37a圖中。 Figure 38 is truth table 7 after combining steps (a) and (b) (i.e., equations (14a) and (14b)). The corresponding logic circuits are shown in Figures 36 and 37a.
將泛化二進制數字nw(一對相加後其數值等於加數的子字符)半最佳化的第二種變化包含兩個步驟: The second variation of semi-optimizing the generalized binary number n w (a pair of sub-characters whose value when added is equal to the addend) consists of two steps:
(a)依據下列方程式或第41圖表8的真值表,以及第39圖及第40圖中所繪示的邏輯電路,分別將及轉化成及,
(b)應用半最佳化轉形方程式(11),以及第44圖之真值表9與第42圖和第43圖的邏輯電路,可獲得以下方程式:
其可產生半最佳化的數字及。 It produces semi-optimal numbers and .
換言之,半最佳化處理的第一種變化與第二種變化間的差異是基於倒轉應用位元調控演算法及方程式(11)這兩步驟的順序。 In other words, the difference between the first and second variations of the semi-optimal process is based on reversing the order of applying the bit manipulation algorithm and equation (11).
第二種變化中依據方程式(15a)及(15b)實施的位元調控演算法,與第一種變化中依據方程式(13a)及(13b)實施的位元調控演算法之間有差異, 此係因為需要被移除以符合一對半最佳化子字符要求之可能的非零組合(已經透過位元調控而被移除)被發現在第一及第二種變化中有差異。 The bit manipulation algorithm implemented in the second variation according to equations (15a) and (15b) differs from the bit manipulation algorithm implemented in the first variation according to equations (13a) and (13b) because the possible non-zero combinations that need to be removed to meet the one-half optimal sub-character requirement (which have been removed by bit manipulation) are found to be different in the first and second variations.
上文的實施例之記載僅以範例方式呈現,本發明所屬技術領域中具有通常知識者當可對其進行各種修飾。上文的說明書、實施例及數據提供了對本發明的示例性實施例的結構和使用的完整描述。儘管上文已描述本揭示內容中各樣的實施例有一定程度的特性,或參照一或多個各別的實施例,本發明所屬領域技術具有通常知識者仍能在不悖離本揭示內容精神及範圍情形下,對已揭示的實施例進行眾多修改。 The above description of the embodiments is presented by way of example only, and various modifications are readily apparent to those skilled in the art. The above description, examples, and figures provide a complete description of the structure and use of exemplary embodiments of the present invention. Although various embodiments of the present disclosure have been described above with a certain degree of specificity, or with reference to one or more individual embodiments, those skilled in the art will readily appreciate that numerous modifications of the disclosed embodiments can be made without departing from the spirit and scope of the present disclosure.
501、503、505、507、508、509、511、513、515、517:步驟 501, 503, 505, 507, 508, 509, 511, 513, 515, 517: Steps
Claims (18)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| TW113112601A TWI898521B (en) | 2024-04-02 | 2024-04-02 | A method of adding binary strings and a circuit therefor |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| TW113112601A TWI898521B (en) | 2024-04-02 | 2024-04-02 | A method of adding binary strings and a circuit therefor |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| TWI898521B true TWI898521B (en) | 2025-09-21 |
| TW202540832A TW202540832A (en) | 2025-10-16 |
Family
ID=97832108
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| TW113112601A TWI898521B (en) | 2024-04-02 | 2024-04-02 | A method of adding binary strings and a circuit therefor |
Country Status (1)
| Country | Link |
|---|---|
| TW (1) | TWI898521B (en) |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| TWI522906B (en) * | 2011-12-29 | 2016-02-21 | 萬國商業機器公司 | Convert to zoned format from decimal floating point format |
| CN113672198A (en) * | 2021-08-18 | 2021-11-19 | 南京英锐创电子科技有限公司 | Binary floating point number addition operation method, circuit and computing device |
| CN113961170A (en) * | 2020-07-21 | 2022-01-21 | 美光科技公司 | Arithmetic operations in memory |
| US11474791B2 (en) * | 2019-06-07 | 2022-10-18 | Chaoyang Semiconductor Jiangyin Technology Co. Ltd. | Method and apparatus for efficient multiplication to improve performance in computational machines |
| CN116414345A (en) * | 2021-12-29 | 2023-07-11 | 腾讯科技(深圳)有限公司 | Multi-input floating-point number processing method, device, processor and computer equipment |
-
2024
- 2024-04-02 TW TW113112601A patent/TWI898521B/en active
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| TWI522906B (en) * | 2011-12-29 | 2016-02-21 | 萬國商業機器公司 | Convert to zoned format from decimal floating point format |
| US11474791B2 (en) * | 2019-06-07 | 2022-10-18 | Chaoyang Semiconductor Jiangyin Technology Co. Ltd. | Method and apparatus for efficient multiplication to improve performance in computational machines |
| CN113961170A (en) * | 2020-07-21 | 2022-01-21 | 美光科技公司 | Arithmetic operations in memory |
| CN113672198A (en) * | 2021-08-18 | 2021-11-19 | 南京英锐创电子科技有限公司 | Binary floating point number addition operation method, circuit and computing device |
| CN116414345A (en) * | 2021-12-29 | 2023-07-11 | 腾讯科技(深圳)有限公司 | Multi-input floating-point number processing method, device, processor and computer equipment |
Also Published As
| Publication number | Publication date |
|---|---|
| TW202540832A (en) | 2025-10-16 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US5815422A (en) | Computer-implemented multiplication with shifting of pattern-product partials | |
| JP3244506B2 (en) | Small multiplier | |
| US5506799A (en) | Booth array multiplying circuit having carry correction | |
| EP0442356A2 (en) | Weighted-delay column adder and method of organizing same | |
| Kornerup | Reviewing high-radix signed-digit adders | |
| TWI898521B (en) | A method of adding binary strings and a circuit therefor | |
| JPH08161149A (en) | Shift device | |
| US4677583A (en) | Apparatus for decimal multiplication | |
| JP2840169B2 (en) | Automatic logic circuit design method and apparatus | |
| JPH09231055A (en) | Logical operation circuit and carry look-ahead adder | |
| US3842250A (en) | Circuit for implementing rounding in add/subtract logic networks | |
| JPH0312738B2 (en) | ||
| WO2019135355A1 (en) | Calculation circuit | |
| US5870322A (en) | Multiplier to selectively perform unsigned magnitude multiplication or signed magnitude multiplication | |
| JP5966768B2 (en) | Arithmetic circuit, arithmetic processing device, and control method of arithmetic processing device | |
| CN100517213C (en) | Multiplying device | |
| WO2025208331A1 (en) | Method and circuit of adding binary strings | |
| GB2640377A (en) | A method of adding binary strings and a circuit therefor | |
| US20080071852A1 (en) | Method to perform a subtraction of two operands in a binary arithmetic unit plus arithmetic unit to perform such a method | |
| CN113590083A (en) | Operation control method, device, system, storage medium and processor | |
| JP2606326B2 (en) | Multiplier | |
| JP3221076B2 (en) | Digital filter design method | |
| CN120150710B (en) | Cascaded full adder-based compressor for multiplication operation and partial product array compression method | |
| WO2025209407A1 (en) | Latch for binary bit pair | |
| TW202546629A (en) | Methods of multiplying binary strings and multiplier circuits implementing the same |