CN1845065A - Method for processing data width and application thereof - Google Patents

Method for processing data width and application thereof Download PDF

Info

Publication number
CN1845065A
CN1845065A CN 200510082802 CN200510082802A CN1845065A CN 1845065 A CN1845065 A CN 1845065A CN 200510082802 CN200510082802 CN 200510082802 CN 200510082802 A CN200510082802 A CN 200510082802A CN 1845065 A CN1845065 A CN 1845065A
Authority
CN
China
Prior art keywords
data
word64
width
integer
negative
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN 200510082802
Other languages
Chinese (zh)
Other versions
CN100454234C (en
Inventor
蒋代林
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CNB2005100828022A priority Critical patent/CN100454234C/en
Publication of CN1845065A publication Critical patent/CN1845065A/en
Application granted granted Critical
Publication of CN100454234C publication Critical patent/CN100454234C/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Compression, Expansion, Code Conversion, And Decoders (AREA)

Abstract

The invention discloses a method for treating data width. Wherein, the applied data width is M*N bits, while M is unit data bit width, N is a positive integer not smaller than 1; dividing the applied data into N sections of M bits unit data, while the highest unit data can be negative or non-negative integer, and other unit data are non-negative integer. The invention can improve the calculating speed, and reduce the operation of code.

Description

A kind of method of processing data width and application thereof
Technical field
The present invention relates to field of computer technology, relate in particular to microcomputer data processing.
Background technology
When carrying out data processing in software or among the DSP, can run into used data width and surpass their the actual scopes that can express, such as: software or DSP can only support the data of the wideest 32 bits, but handled data width is 64 bits even wideer, just may run into this situation when verifying the IC design with software or DSP.
When carrying out data processing in software or among the DSP, need come processing data width, to solve the problem that the data width that is run into has surpassed they the actual scopes that can express with a kind of active data method for expressing.
The signed integer that present signed integer with two 32 bits is treated to one 64 bit is an example, manages the method for data width in conjunction with the plus-minus shift operation in the open.
Have the integer of symbol to represent with two's complement in computing machine, most significant digit is a sign bit, and all the other are the data significance bit.The signed integer of above-mentioned 32 bits comes to this, but the data of 64 bits are to represent with the data of two 32 bits, and how to represent then has multiple choices.
The data type of one 64 bit of definition is as follows:
#define?word32?int
typedef?struct?word64{word32?wh32;word32?wl32;}word64;
word64?w64;
The bit wide of integer in different environment or the system (int) is variant, and we suppose that it is 32 bits, and RNTO word32; Defined the new data type word64 of one 64 bit, it is by the data representation of two word32 types, is divided into height two parts, and wh32 is high field, and wl32 is low field; W64 is exactly the data of a word64 type; Wh32 and wl32 are signed number, and w64 is actual to be the number of 63 bits.
Present processing method for expressing is: when w64 is nonnegative number (positive number or zero), wh32 and wl32 are nonnegative number; When w64 was negative, wh32 and wl32 were negative; A kind of special case is when w64 is negative: wh32 is zero, and wl32 is a negative.
It is as follows that the negate of realizing with this method for expressing is counted the code of computing, additive operation, shift right operation or XOR:
A) negate computing:
word64?NEG(word64?x){
word64?z;
z.wh32=-x.wh32;
z.wl32=-x.wl32;
if(((z.wh32<0)&&(z.wl32==0))||(z.wl32==(word32)0x80000000))
If { // operation result is negative then revises to meet the data representation structure
z.wh32=z.wh32+0x1;
z.wl32=z.wl32+(word32)0x80000000;
}else;
return(z);
}
When we will calculate the negative value of new data type word64x of one 64 bit, at first x is converted to by the data representation of two word32 types, be divided into height two parts, wh32 is high field, wl32 is low field; Height two parts difference negate remerges the negative value that draws x then.
B) additive operation:
word64?ADD(word64?x,word64?y){
word64?z;
z.wh32=x.wh32+y.wh32;
z.wl32=x.wl32+y.wl32;
if((x.wl32<0)&&(y.wl32<0)&&(z.wl32>=0))
{
z.wh32=z.wh32-0x1;
z.wl32=z.wl32+(word32)0x80000000;
}
else?if((x.wl32>0)&&(y.wl32>0)&&(z.wl32<0))
{
z.wh32=z.wh32+0x1;
z.wl32=z.wl32+(word32)0x80000000;
}
if((z.wh32>0)&&(z.wl32<0))
{
z.wh32=z.wh32-0x1;
z.wl32=z.wl32+(word32)0x80000000;
}
else?if((z.wh32<0)&&(z.wl32>0))
{
z.wh32=z.wh32+0x1;
z.wl32=z.wl32+(word32)0x80000000;
}
else;
return(z);
}
When we to calculate two 64 bits new data type word64 x and y's and the time, at first x is converted to data representation by two word32 types, be divided into height two parts, wh32 is high field, wl32 is low field, converts y to by two word32 types data representation, is divided into height two parts, wh32 is high field, and wl32 is low field; Height two parts of x, y are sued for peace respectively then, remerge draw x and y and.
C) shift right operation:
word64?SHR(word64?x,short?i){//i<=31
word64?z;
if((x.wh32<0)&&(x.wl32<0))
{
z.wh32=x.wh32-(word32)0x1;
z.wl32=x.wl32+(word32)0x80000000;
}
else?z=x;
z.wl32=(z.wl32>>i)+((z.wh32<<(3l-i))&(word32)0x7fffffff);
z.wh32=(z.wh32>>i);
if((z.wh32<0)&&(z.wl32>=0))
{
z.wh32=z.wh32+(word32)0x1;
z.wl32=z.wl32+(word32)0x80000000;
}
else;
return(z);
}
When the new data type word64 x to 64 bits moves to right, at first x is converted to data representation by two word32 types, be divided into height two parts, wh32 is high field, wl32 is low field; Then x is moved to right, wherein also need middle result is revised.
D) XOR:
word64?XOR(word64?x,word64?y){
word64?z;
if((x.wl32<0)&&(x.wh32==0))x.wh32=-1;
if((y.wl32<0)&&(y.wh32==0))y.wh32=-1;
z.wh32=x.wh32^y.wh32;
z.wl32=x.wl32^y.wl32;
return?z;
}
When we will to the new data type word64 x of two 64 bits and y asks different and the time, at first x is converted to data representation by two word32 types, be divided into height two parts, wh32 is high field, wl32 is low field, converts y to by two word32 types data representation, is divided into height two parts, wh32 is high field, and wl32 is low field; Ask different respectively to height two parts of x, y then and, remerge draw the different of x and y and.
Can find out from above-mentioned code, make a lot of data correction for meeting the data representation structure, code is complicated, and this data processing method has increased code quantity and operation time undoubtedly, has reduced arithmetic speed.
Summary of the invention
The objective of the invention is to propose a kind of method and application thereof of processing data width, can reduce the software code quantity of various computings, improve the software arithmetic speed greatly.
For this reason, the present invention adopts following scheme:
A kind of method of processing data width, the application data width is the M*N bit, wherein M is the unit data bit width, N is not less than 1 positive integer, application data is resolved into the unit data of N section M bit, wherein the unit data of most significant digit can be negative or non-negative integer, and the other unit data are nonnegative integer.
Judgement should be negative integer to the unit data of described most significant digit according to application data, also is non-negative integer.
Described unit data width can be 32 bits.
To the application of this processing data width method, the computing that can be used for carrying out comprises negate computing, additive operation, shift right operation, XOR.
Adopted the present invention, the data structure easy to understand; Reduced the software code quantity of various computings; Improve the software arithmetic speed greatly, improved operation efficiency.
Description of drawings
Fig. 1 is the structural representation of processing data width of the present invention.
Embodiment
Below in conjunction with Figure of description the specific embodiment of the present invention is described.
, can handle as application data with the integer of 64 bits with 32 bit base data.As shown in Figure 1, just can find intuitively from the data of two's complement: for the integer of 64 bits, no matter it is negative or nonnegative number (integer or zero), all can be separated into two parts from the centre, separately, high field partly is one, and can bear can non-negative integer, and low field then is a nonnegative number.
It is as follows that the negate of realizing with this method for expressing is counted the code of computing, additive operation, shift right operation or XOR:
A) negate computing:
word64?NEG(word64?x){
x.wh32=-x.wh32;
x.wl32=(-x.wl32)&(word32)0x7fffffff;
if(x.wl32!=0)
If { // operation result is negative then revises to meet the data representation structure
x.wh32--;
}else;
return?x;
}
Compare with former algorithm, need the low field wl32 that has only data of correction, and correction conditions is simplified greatly.
B) additive operation:
word64?ADD(word64?x,word64?y){
x.wh32+=y.wh32;
x.wl32+=y.wl32;
if(x.wl32<0)
{
x.wl32&=(word32)0x7fffffff;
x.wh32++;
}else;
return?x;
}
Compare with former algorithm, correction conditions is greatly simplified, and the code computing is little a lot.
C) shift right operation:
word64?SHR(word64?x,short?i){//i<=31
x.wl32=((x.wl32>>i)+(x.wh32<<(31-i))&(word32)0x7fffffff);
x.wh32=(x.wh32>>i);
return?x;
}
Compare with former algorithm, saved correction conditions, lacked many numerous and diverse plus and minus calculations.
D) XOR:
word64?XOR(word64?x,word64?y){
word64?z;
z.wh32=x.wh32^y.wh32;
z.wl32=x.wl32^y.wl32;
return?z;
}
Compare with former algorithm, saved correction conditions, only need to height two parts of x, y ask different respectively and, remerge draw the different of x and y with.
Compare with the operation part of prior art, code clearly of the present invention is simple a lot, lacked many for meeting the correction that data structure is carried out, thereby improved the arithmetic speed of code, reduced operand.When the exclusive disjunction amount is big when the real-time of software is had relatively high expectations,, effectively beyond doubt with this data representation method.
This method is applicable to wideer data representation, such as the data of representing 128 bits with 32 bit numbers, the highest field can non-negative integer for bearing, and other field is non-negative integer, the realization of various operation parts is to above-mentioned similar, and the developed width of 128 Bit datas is 125 bits.
Therefore represent that with the M bit number N*M Bit data can adopt this method, the developed width of data is N* (M-1)+1, and wherein M is the unit data bit width, and N is not less than 1 positive integer.
The above; only for the preferable embodiment of the present invention, but protection scope of the present invention is not limited thereto, and anyly is familiar with the people of this technology in the disclosed technical scope of the present invention; the variation that can expect easily or replacement all should be encompassed within protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion with the protection domain of claim.

Claims (4)

1, a kind of method of processing data width, the application data width is the M*N bit, wherein M is the unit data bit width, N is not less than 1 positive integer, it is characterized in that: the unit data that application data is resolved into N section M bit, wherein the unit data of most significant digit can be negative or non-negative integer, and the other unit data are nonnegative integer.
2, the method for processing data width as claimed in claim 1 is characterized in that: judgement should be negative integer to the unit data of described most significant digit according to application data, also is non-negative integer.
3, the method for processing data width as claimed in claim 1 or 2 is characterized in that: described unit data width can be 32 bits.
4, the application of processing data width method as claimed in claim 1 is characterized in that: can use the computing that the method for described processing data width carries out and comprise negate computing, additive operation, shift right operation, XOR.
CNB2005100828022A 2005-07-08 2005-07-08 Method for processing data width and application thereof Expired - Fee Related CN100454234C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2005100828022A CN100454234C (en) 2005-07-08 2005-07-08 Method for processing data width and application thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2005100828022A CN100454234C (en) 2005-07-08 2005-07-08 Method for processing data width and application thereof

Publications (2)

Publication Number Publication Date
CN1845065A true CN1845065A (en) 2006-10-11
CN100454234C CN100454234C (en) 2009-01-21

Family

ID=37063993

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2005100828022A Expired - Fee Related CN100454234C (en) 2005-07-08 2005-07-08 Method for processing data width and application thereof

Country Status (1)

Country Link
CN (1) CN100454234C (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018020299A1 (en) * 2016-07-29 2018-02-01 Chan Kam Fu Lossless compression and decompression methods

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH05257882A (en) * 1992-03-11 1993-10-08 Nec Corp Data processor
JPH09237247A (en) * 1996-03-01 1997-09-09 Matsushita Electric Ind Co Ltd Bus width converter and bus width conversion system device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018020299A1 (en) * 2016-07-29 2018-02-01 Chan Kam Fu Lossless compression and decompression methods
US11515888B2 (en) 2016-07-29 2022-11-29 Kam Fu Chan CHAN framework, CHAN coding and CHAN code

Also Published As

Publication number Publication date
CN100454234C (en) 2009-01-21

Similar Documents

Publication Publication Date Title
CN1173501C (en) Circuit and method for generating fixed-point data
CN1655118A (en) Processor and compiler
CN1877532A (en) Compiler apparatus
CN1845213A (en) Method for realizing encryption/decryption processing in SMS4 cipher algorithm
CN1282107C (en) Method for rapidly compressing and decompressing image
CN1889045A (en) Cocurrent event processing device and method in multi-task software system
CN1530826A (en) Low-power acting controller and program optimization device
CN101043633A (en) Quantization matrix selecting method, apparatus of coding and coding/decoding method and system
CN1539103A (en) Method and device for modular multiplication
CN1845065A (en) Method for processing data width and application thereof
CN101055467A (en) IDP based industrial process dynamic optimization system and method
CN100351466C (en) Nanometer scale environment-friendly type coating special for color digital printing paper
CN1863085A (en) Method and system for ensuring network managment and element configuration data consistency
CN1492313A (en) Coordinate transformation method for digital scanning change-over device and processor
CN101060326A (en) Plus-minus counting circuit and plus-minus counting method
CN101080015A (en) System and method for uploading third party video and audio content in IPTV system
CN1598797A (en) Real-time processor system and control method
CN1324421C (en) Method and apparatus for central processor frequency conversion and central processor fan speed change
CN1535028A (en) Image encoding apparatus, method and program, and image decoding apparatus, method and program
CN1138717A (en) High speed dynamic binary incrementer
CN101067853A (en) On-line modular system and method for assisting examination and approval of countryside homestead
CN1901276A (en) Method for producing scan mark and method for scanning antenna device
CN1632740A (en) Multiply and accumulate device
CN1334597A (en) Method for extracting threshold voltage model parameters in BSIM3V3 model
CN1889061A (en) Method and apparatus for raising speed of access USB interface information safety equipment

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20090121