CN106407285B - A kind of optimization bit file compression & decompression method based on RLE and LZW - Google Patents

A kind of optimization bit file compression & decompression method based on RLE and LZW Download PDF

Info

Publication number
CN106407285B
CN106407285B CN201610752157.9A CN201610752157A CN106407285B CN 106407285 B CN106407285 B CN 106407285B CN 201610752157 A CN201610752157 A CN 201610752157A CN 106407285 B CN106407285 B CN 106407285B
Authority
CN
China
Prior art keywords
string
data
char
character
compression
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201610752157.9A
Other languages
Chinese (zh)
Other versions
CN106407285A (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.)
Xian Institute of Space Radio Technology
Original Assignee
Xian Institute of Space Radio Technology
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 Xian Institute of Space Radio Technology filed Critical Xian Institute of Space Radio Technology
Priority to CN201610752157.9A priority Critical patent/CN106407285B/en
Publication of CN106407285A publication Critical patent/CN106407285A/en
Application granted granted Critical
Publication of CN106407285B publication Critical patent/CN106407285B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/174Redundancy elimination performed by the file system
    • G06F16/1744Redundancy elimination performed by the file system using compression, e.g. sparse files

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Compression, Expansion, Code Conversion, And Decoders (AREA)

Abstract

A kind of optimization bit file compression & decompression method based on RLE and LZW, by carrying out data format analysis to FPGA configuration bit file, pluck out the head control word of bit file, since real deployment data, it uses brigade commander to carry out primary compression for 4 RLE coding, then carries out LZW compression and further promote compression ratio.It is the inverse process of compression when decompression, first carries out LZW decompression and restore intermediate data, then RLE decompression is carried out to the data portion for not including head control word, restore original FPGA configuration bit file.This method has comprehensively considered time and the compression ratio of compression/de-compression, compared with the tool of compression that Xilinx is carried, applies RLE algorithm with simple, compares using lzw algorithm merely, realize the two-win of compression ratio and compression speed.It solves the problems, such as that the advanced model FPGA configuration bit file of Xilinx is excessive, saves the expense of storage chip, provide key technology support for the in-orbit reconfiguration technique of FPGA.

Description

A kind of optimization bit file compression & decompression method based on RLE and LZW
Technical field
The optimization bit file compression & decompression method based on RLE and LZW that the present invention relates to a kind of belongs in communication and compares Special compressing file and decompression technique field.
Background technique
With the increase for applying complexity on star, the requirement to data-handling capacity on star is also higher and higher, use The device that FPGA model is had to also with the promotion using complexity using greater degree.The FPGA of these advanced models by In the more powerful of function, corresponding bit file is also become much larger, configure the bit file of the FPGA of a piece of V5130T compared with V4SX55 increases about 3 times or so, this means that needs 3 times in the past of storage resource to match to store using a piece of V5FPGA Bit is set, this is undoubtedly a problem for resource limited on star, it is necessary to take certain compression method to reduce storage Resource.And must meet the following requirement: 1) necessary lossless reduction bit file carries out decompression to bit stream and is required to Accurately recover former data;2) compression ratio wants high, and the compressed and decompressed time wants short.It is wanted for this problem and the above two o'clock It asks, a kind of optimization bit file compression & decompression method based on RLE and LZW is proposed, to realize high speed and high pressure shrinkage Bit file is compressed and decompressed.
Data compression generally includes lossy compression and two kinds of lossless compression.Lossy compression is to lose really to compress, irreversible , information will receive loss.Lossless compression is undistorted compression, the redundancy in compression process in removal data, after decompression Any information is not lost, it is preceding completely the same with compression.Lossless compression is commonly used in the compression of text, program, significant data, its energy Guarantee fully restores initial data.It carries out compression to bit stream to be required to accurately recover former data, it is therefore desirable to select Compression and decompression is carried out to bit file with lossless compressiong to solve the problems, such as the transimission and storage of configuration bit data.
Classical lossless compression algorithm mainly has: the algorithm based on statistical model, such as Shannon coding, huffman coding, calculation Art coding etc.;Algorithm based on dictionary mode, such as LZ serial algorithm;There are also some other algorithms, such as Run- Length Coding, JPEG- LS algorithm, the DEM algorithm of JPEG2000, BWT algorithm etc..Comprehensively consider design complexities and compression efficiency, the calculation of dictionary mode Method is particularly suited for bit file compression compared with the algorithm of statistical model.It is mainly used for bit file compression at present both at home and abroad Compression method is that lexicographic compresses or use Run- Length Coding technique compresses.The tool of compression of Xilinx oneself is using lexicographic LZ77 method carries out bit file compression.It can be seen that the bit file compression of Xilinx compression by subsequent experimental data Rate is not high.
Summary of the invention
Present invention solves the technical problem that are as follows: it overcomes the shortage of prior art, a kind of optimization ratio based on RLE and LZW is provided Special compressing file and decompression method, under the requirement of Fast Compression and high compression rate, the present invention passes through to bit file data Structure is analyzed, the Optimal improvements of adaptability RLE algorithm, and further promotes compression ratio in conjunction with LZW method, devises one Optimization bit file compressing/decompressing method of the kind based on RLE and LZW, this method is by dividing bit file data structure Analysis, it is creative that RLE algorithm is optimized according to bit file feature;On the basis of optimizing application RLE algorithm, in order to further Compression ratio is promoted, creatively by the RLE algorithm after optimization and in conjunction with lzw algorithm, it is compressed and decompressed to be applied to bit file. This method save storage resources, improve the design realization of computational efficiency, compression and decompression, demonstrate the correct of method Property, validity, high efficiency and feasibility.
The technical solution that the present invention solves are as follows: a kind of optimization bit file compression method based on RLE and LZW, including step It is rapid as follows:
Step 1: FPGA configuration bit file is made of multi-section divided data, include head control word, data and command word, Wherein, data and order word format are all with nybble for a unit, scratch the head control word except FPGA configuration bit file;
Initialize brigade commander's counter in RLE;By the run length of RLE bit file data characteristics according to step 1 It is set as 4;
The compression dictionary for initializing LZW, making dictionary includes all possible, and described is single entry;
Prefix pre_char is set, enables current prefix pre_char for sky;
Step 2: setup string pre_string;The FPGA configuration bit text except head control word will be scratched in step 1 The first character string of part is assigned to character string pre_string;It is described to scratch except the FPGA configuration bit file of head control word is quilt Compressed file;
Step 3: it will be compressed by compressed file, steps are as follows:
(1) judge whether there is character string to need to compress in compressed file, it is first defeated if needing to compress without character string Character string pre_string out, then the value of brigade commander's counter is exported, enter step four;
(2) if there is character string needs to compress, current string current_string is set, current string is enabled Current_string is equal to the character late string in character stream;
(3) judge whether pre_string and current_string is consistent: if pre_string and current_ String is consistent, and brigade commander's counter adds 1, judges whether brigade commander's Counter Value is counted to 255;If brigade commander's Counter Value meter to 255, Pre_string is first exported, then exports brigade commander's Counter Value, enabling brigade commander's Counter Value is 1,
The unpressed character string of file to be compressed is read to pre_string, return step three
If brigade commander's Counter Value is not counted to 255, return step three;
If pre_string is inconsistent with current_string, pre_string is exported, exports brigade commander's Counter Value, Pre_string, return step three will be assigned to by current_string at this time;
Step 4: output is arranged successively by setting current character current_char according to step 3 (1) output sequence The character stream of Cheng Xin, the first character read in the character stream are assigned to current_char;
Step 5: judge that pre_char and current_char are arranged successively the entry of composition whether in dictionary: if In dictionary, pre_char and the current_char entry for being arranged successively composition are assigned to pre_char;If not in dictionary In, then the code word of current prefix pre_char is exported, addition pre_char and current_char are arranged successively the entry of composition Into dictionary, the value of current_char is assigned to pre_char;
Step 6: judge whether need to compress there are also character in new character stream, if there is character needs to compress, will need The first character of compression is assigned to current_char, return step five;If needing to compress without character, current prefix is exported The code word of pre_char completes compression.
The compression dictionary of LZW is for storing the entry generated in compression process.
Brigade commander's counter, starts counting from 1, that is, counts 1 when reading first character string, can continuously repeat appearance encountering Character string when add 1 every time, when there are different character strings, the value of brigade commander's counter can be exported, restore initial value 1;Trip The value of long counter is 1-255, restores 1 when reaching 255.
The index value for initializing the compression dictionary of LZW is 1-4096.
A kind of optimization bit file decompression method based on RLE and LZW, comprises the following steps that
Step 1: initial decompression dictionary, making dictionary includes all possible, and described is single entry;
Step 2: setting variable pw reads wait decompress first code stream in data flow, is assigned to pw, is index with pw Inquiry decompression dictionary, reads the corresponding entry of the index, and setup string variable pre_char, and the index that pw is indicated is corresponding Entry be assigned to pre_char, and export pre_char;
Step 3: setting variable cw continues to read wait decompress next code stream in data, is assigned to cw, judges The corresponding entry of index for whether having cw to indicate in dictionary, if there is the corresponding entry of index that cw is indicated, output cw is indicated Corresponding entry is indexed, i.e. variable current_char is arranged in the corresponding string data of index that cw is indicated, cw is indicated It indexes corresponding string data and is assigned to current_char, character variable pc is set, pre_char is assigned to pc, be arranged The first character of the corresponding entry of current_char is assigned to cc, pc and cc is arranged successively composition by character variable cc Character string is added in decompression dictionary;If the value of pre_char is assigned to pc without the index corresponding entry that cw is indicated, The first character of current_char is assigned to cc, output pc and cc is arranged successively the string data of composition, and adds pc The string data of composition is arranged successively into dictionary with cc;
Step 4: judge whether there are also data need to decompress wait decompress in data flow, if needing to solve there are also data Compression, return step three;If needing to decompress without data, the output of step 3 is arranged in new character by output sequence String data identifies the head control word in new string data;Setup string head, and head control word is assigned to head;
Step 5: setup string variable current_string, from the new string data for removing head control word According to brigade commander read character string be assigned to current_string, a character after then reading the character string again is swum The value of long counter restores original compression data according to the value of the character string and brigade commander's counter that read out;
Step 6: judgement removes in the new string data of head control word whether need the data decompressed, if Have, then data to be decompressed are replaced removing the new string data of head control word, return step five;It, will if nothing Head and the data of step 5 output are arranged successively to obtain initial data, complete decompression.
The advantages of the present invention over the prior art are that:
(1) under the requirement of Fast Compression and high compression rate, the present invention by analyzing bit file data structure, The Optimal improvements of adaptability RLE algorithm, and further promote compression ratio in conjunction with LZW method, devise it is a kind of based on RLE and The optimization bit file compressing/decompressing method of LZW.This method is creative by the analysis to bit file data structure RLE algorithm is optimized according to bit file feature;On the basis of optimizing application RLE algorithm, in order to further enhance compression ratio, Creatively by the RLE algorithm after optimization and in conjunction with lzw algorithm, it is compressed and decompressed to be applied to bit file.This method is saved Storage resource, improves computational efficiency, and the design of compression and decompression is realized, demonstrates the correctness, validity, height of method Effect property and feasibility.
(2) present invention is by devising one for bit file to bit file structure and RLE and lzw algorithm analysis Optimization bit file compression and decompression technique method of the kind based on RLE and LZW, it is creative excellent according to bit file feature RLE algorithm is changed, in order to further enhance compression ratio, creatively by the RLE algorithm after optimization and in conjunction with lzw algorithm, has answered It is compressed and decompressed for bit file, compression time and a large amount of storage money are saved on the basis of guaranteeing certain compression ratio Source passes through corresponding gunzip the design verification correctness of compression method, high efficiency and feasibility.
Detailed description of the invention
Fig. 1 is the basic digital structure of the present invention;
Fig. 2 is a kind of optimization bit file compression algorithm flow chart based on RLE and LZW of the present invention;
Fig. 3 is a kind of optimization bit file decompression algorithm flow chart based on RLE and LZW of the present invention;
Fig. 4 is different compression algorithm compression ratio comparison schematic diagrams.
Specific embodiment
Basic ideas of the invention are as follows: a kind of optimization bit file compression & decompression method based on RLE and LZW is led to It crosses and data format analysis is carried out to FPGA configuration bit file, the head control word of bit file is plucked out, from real deployment data Start, brigade commander is used to carry out primary compression for 4 RLE coding, then carries out LZW compression and further promote compression ratio.When decompression For the inverse process of compression, first carry out LZW decompression and restore intermediate data, then to do not include the data portion of head control word into Row RLE decompression, restores original FPGA configuration bit file.This method comprehensively considered compression/de-compression time and Compression ratio applies RLE algorithm with simple, compares using lzw algorithm merely, realize compared with the tool of compression that Xilinx is carried The two-win of compression ratio and compression speed.It solves the problems, such as that the advanced model FPGA configuration bit file of Xilinx is excessive, saves The expense of storage chip provides key technology support for FPGA in-orbit reconfiguration technique.
The invention will be described in further detail in the following with reference to the drawings and specific embodiments.
Run- Length Coding (RLE) is also known as run-length encoding, is a kind of relatively simple data compression technique.The distance of swimming refer to by Each character continuously repeats and is formed the length of character string in the data flow that source symbol or signal sample are constituted, and the also known as distance of swimming is long Degree or brigade commander.Run- Length Coding is exactly the mark sequence of the position by the length of the character string of this character string mapping bunchiness and string Column, when given the character of stroke string, the position of string and length, it will be able to recover original data stream.The basic number of data flow Code structure is as shown in Figure 1, wherein identification code also can be omitted depending on specifically used.
According to the data flow basic structure of Run- Length Coding it is found that Run- Length Coding just has number when only run length is greater than 3 According to the function of compression.The efficiency of Run- Length Coding depends on the repetitive rate of source symbol, and repetitive rate is higher, and brigade commander is longer, compression Effect is more obvious.Distance of swimming compressed logic and hardware realization are simple, and speed is quickly.In practical projects sometimes by Run- Length Coding and Other coding methods mix together, and can obtain better compression effectiveness.
By the principle of Run- Length Coding it is recognised that the only Run- Length Coding when relatively high by compression samples repetitive rate when Compression effectiveness just can be preferable.The framework of bit file is analyzed, bit file each first has the header information of oneself, this part The repetitive rate of message sample is very low, and for entire bit file, the shared bit of header information is considerably less, therefore When compressing to bit file, header information position is plucked out, only the subsequent data of header information are compressed, it is certain in this way Compression speed and compression ratio are improved in degree.After plucking out header information, remaining bit file is still to have certain rule, that Be exactly either command word or data be all with 4 bytes be a unit, in this way apply Run- Length Coding to bit file The brigade commander of compression be chosen for 4 bytes be it is most suitable, selection will increase more brigade commander's information less than 4 bytes upon compression File in, compression ratio can be reduced;It chooses if being greater than 4 bytes, the repetitive rate of sample can reduce, meeting in file upon compression Increase identification code information, reduces compression ratio.After realizing optimization RLE compression algorithm, analysis result is also demonstrated by experiment.
Run- Length Coding is improved since compression process does not need to store, is not calculated, so compression speed is quickly, but it is limited In bit file complexity and compression algorithm itself, compression ratio is not especially high.Therefore herein optimize RLE algorithm on the basis of into One step combination lzw algorithm is further processed compressed data to promote compression ratio.
Lzw algorithm proposed that it was that the innovatory algorithm of LZ78 is gone compared with LZ78 algorithm in 1984 by Terry Welch Second field of mark is fallen.Lzw algorithm is the compression algorithm based on dictionary mode, independent of the probability distribution of information source, It is a kind of towards general data, the lossless data compression algorithms being easily achieved.Lzw algorithm is independent of any data format, tool There is very big application range, and coding rate is fast, logic is simple and has the function of adaptive, and it is real to be particularly conducive to hardware Now there is very high real-time simultaneously.
All characters in alphabet are initialised in dictionary by lzw algorithm first, usually using 8 characters, therefore Just occupied first 256 of dictionary before input data, i.e., 0~255.Because dictionary has been initialised, input Character late can be found in dictionary.Dictionary encoding is exactly the expansion to 8 character set in practice, for indicating data The character string of middle appearance, newly-increased dictionary encoding can be indicated with 9,10,11,12 even more multidigits.If such as every A character string indicates can there is 512 different 9 codes with 9.This is to say, conversion table has 512 character strings, wherein 256 list items are used to store defined character, and remaining 256 are used to store (prefix, character string).
The coding principle of lzw algorithm is as follows: firstly the need of initialization dictionary, giving 0~255 for first 256, then every reading Enter a character pre_char, must first be searched in dictionary.If having there is the character in dictionary, update current Character is pre_char, and using current character pre_char as prefix, continues to read in next character current_char work For trailing character, form a character string " pre_char, current_char ", and searched in dictionary again " pre_char, current_char".If do not had in dictionary, output character pre_char position code, and by " pre_char, current_ Char " is added in dictionary, then using current_char as prefix.Above step is repeated, until all codings are completed.
The decoding algorithm of LZW is the inverse process of coding, similarly shows as a kind of adaptive algorithm based on dictionary, one Side generates dictionary, one side decoded output.
In conclusion the invention proposes a kind of optimization bit file compression method based on RLE and LZW, including step It is as follows:
Step 1: FPGA configuration bit file is made of multi-section divided data, mainly includes head control word, data and order Word, wherein data and order word format are all with nybble for a unit, are scratched except the head of FPGA configuration bit file controls Word;
Initializing brigade commander's counter in RLE is 1;By the run length of RLE bit file data according to step 1 Feature is set as 4;
The compression dictionary of LZW is initialized as 4096 row * 32 column, making dictionary includes all possible, and described is single Entry, that is, the first column data of the 0 to 255th row of dictionary after initializing are 0-255;
Prefix pre_char is set, enables current prefix pre_char for sky;
Step 2: setup string pre_string;The FPGA configuration bit text except head control word will be scratched in step 1 The first character string of part is assigned to character string pre_string;It is described to scratch except the FPGA configuration bit file of head control word is quilt Compressed file;
Step 3:
(1) judge whether there is character string to need to compress in compressed file, it is first defeated if needing to compress without character string Character string pre_string out, then the value of brigade commander's counter is exported, enter step four;
(2) if there is character string needs to compress, current string current_string is set, current string is enabled Current_string is equal to the character late string in character stream;
(3) judge whether pre_string and current_string is consistent: if pre_string and current_ String is consistent, and brigade commander's counter adds 1, judges whether brigade commander's Counter Value is counted to 255;If brigade commander's Counter Value meter to 255, Pre_string is first exported, then exports brigade commander's Counter Value, enabling brigade commander's Counter Value is 1,
The unpressed character string of file to be compressed is read to pre_string, return step three
If brigade commander's Counter Value is not counted to 255, return step three;
If pre_string is inconsistent with current_string, pre_string is exported, exports brigade commander's Counter Value, Pre_string, return step three will be assigned to by current_string at this time;
Step 4: (1) setting current character current_char,
(2) according to step 3 (1) output sequence, output is arranged successively into new character stream, is read in the character stream First character is assigned to current_char;In order to improve compression speed, which can be same when step 3 has data output When be actuated for, then the first character that read step three exports carries out subsequent step to current_char;
Step 5: judge that pre_char and current_char are arranged successively the entry of composition whether in dictionary: if It is to pay pre_char and the current_char entry for being arranged successively composition to pre_char in dictionary;If not in word In allusion quotation, then the code word of current prefix pre_char is exported, addition pre_char and current_char are arranged successively the word of composition Item is assigned to pre_char into dictionary, by the value of current_char;
Step 6: judge whether need to compress there are also character in new character stream, if there is character needs to compress, will need The first character of compression pays current_char, return step five;If needing to compress without character, current prefix is exported The code word of pre_char completes compression.
The compression dictionary of LZW is for storing the entry generated in compression process.
Brigade commander's counter, starts counting from 1, that is, counts 1 when reading first character string, can continuously repeat appearance encountering Character string when add 1 every time, when there are different character strings, the value of brigade commander's counter can be exported, be reduced to initial value 1; The value of brigade commander's counter is 1-255.
The index value for initializing the compression dictionary of LZW is 1-4096.
In conjunction with above-mentioned optimization bit file compression algorithm and programming thinking, a kind of optimization bit based on RLE and LZW Compressing file algorithm flow is as shown in Figure 2.
After completing compression, data after corresponding to compression techniques process, decompression is that the inverse process of compression both may be used Initial data is restored to realize, can need to restore the data of optimization RLE compression using lzw algorithm, then optimizes RLE Decompression restores initial initial data.Decompression and compression thinking contrary.
A kind of preferred specific decompression method process is given below as shown in figure 3, currently preferred a kind of based on RLE It is comprised the following steps that with the optimization bit file decompression method of LZW
Step 1: initial decompression dictionary is 4096 row * 32 column, and making dictionary includes all possible, and described is Single entry, that is, the first column data of the 0 to 255th row of dictionary after initializing are 0-255;
Step 2: setting variable pw reads wait decompress first code stream in data flow, is assigned to pw, is index with pw Queries dictionary reads the corresponding entry of the index, and setup string variable pre_char, the corresponding entry of index that pw is indicated It is assigned to pre_char, and exports pre_char;If pw is 10, string data in the dictionary that search index is 10 is assigned a value of pre_char;
Step 3: setting variable cw continues to read wait decompress next code stream in data, is assigned to cw, judges The corresponding entry of index for whether having cw to indicate in dictionary, if there is the corresponding entry of index that cw is indicated, output cw is indicated Index corresponding string data (the corresponding entry of index that output cw is indicated, the i.e. corresponding character string number of index that cw is indicated According to), variable current_char is set, the cw corresponding string data of index indicated is assigned to current_char, if Character variable pc is set, pre_char is assigned to pc, character variable is set, by first of the corresponding entry of current_char Character is assigned to cc, and pc and the cc character string for being arranged successively composition are added in decompression dictionary;If the rope indicated without cw Draw corresponding entry, the value of pre_char is assigned to pc, the first character of current_char is assigned to cc, exports pc and cc It is arranged successively the string data of composition, and adds pc and cc and is arranged successively the string data of composition into dictionary;Such as wait solve Compressed data is " 9 18 300 ... ..4095 ", then reads first pw value 9, exports the character string " 9 of the 9th article of dictionary expression 256 256 ... .256 " give pre_char, and export " 9 ";Continue to read cw value 18, the value is in the dictionary of initialization, output word The character string " 18 256 256 ... .256 " of the 18th article of allusion quotation expression gives current_char, and exports " 18 ", addition " 9 18 For 256 ... .256 " into dictionary, entry index is 257;Continue to read cw value 300, the value is defeated not in the dictionary of initialization " 18 18 " out add " 18 18 256 ... .256 " into dictionary, and so on, until all data processings are completed.
Step 4: judge whether there are also data need to decompress wait decompress in data flow, if needing to solve there are also data Compression, return step three;If needing to decompress without data, the output of step 3 is arranged in new character by output sequence String data identifies the head control word in new string data;Setup string head, and head control word is assigned to head (such as new string data is " 01 CC CC CC CC of head 02 BB BB BB BB of control word AA AA AA AA 09 ... DD DD DD DD 03 ", is assigned to head for head control word, to " 02 BB BB BB BB 01 of AA AA AA AA CC CC CC CC 09 ... DD DD DD DD 03 " carries out subsequent decompression);
Step 5: setup string variable current_string, from the new string data for removing head control word According to brigade commander read character string be assigned to current_string, a character after then reading the character string again is swum The value of long counter restores original compression data according to the value of the character string and brigade commander's counter that read out;Such as character string " AA BB CC DD 02 ", reading current_string is " AA BB CC DD ", and brigade commander 2, and the data after reduction are " AA BB CC DD AA BB CC DD";
Step 6: judgement removes in the new string data of head control word whether need the data decompressed, if Have, then the data with compression are replaced removing the new string data of head control word, return step five;It, will if nothing Head and the data of step 5 output are arranged successively to obtain initial data, complete decompression.As there are also " AA for band decompression data 02 BB BB BB BB of AA AA AA, 01 CC CC CC CC 09 ... DD DD DD DD 03 " first reads " AA AA AA AA ", according to " 02 ", restoring data is " AA AA AA AA AA AA AA AA ";" BB BB BB BB " is read again, according to " 01 ", restoring data are " BB BB BB BB ", successively run through all data, until reading " DD DD DD DD ", according to " 03 ", Restoring data is that " DD DD DD DD DD DD DD DD DD DD DD DD " (is completed complete original with the splicing of head control word Data decompression is condensed to " head control word AA AA AA AA AA AA AA AA BB BB BB BB ... DD DD DD DD DD DD DD DD DD DD DD DD”)。
6, variable current_char decompresses corresponding string data in dictionary as call number.
Data after corresponding to compression techniques process, decompression technique restore optimization firstly the need of using lzw algorithm The data of RLE compression, then optimize RLE decompression and restore initial initial data.Algorithm mentality of designing and compression algorithm Similar, specific decompression algorithm process is as shown in Figure 3.
After the completion of compression and decompression programming, compressed using the bit file of five kinds of different resource utilization rates Rate test and decompression reduction test, the data after reduction are consistent with initial data, demonstrate the correctness of algorithm realization.Compression Rate size is as shown in the table:
1 compression test data of table
Graphic software platform experimental result as shown in figure 4, from experimental result it can be seen that
With the increase of resource, the compression ratio of all compression methods is all declining;Considerably less data are used for resource (1%), three kinds of method compression ratios that we develop all only have 85% in the compression ratio of 95% or more, Xilinx;
For resource using very more data (99%), the compression method compression ratio of Xilinx is only than the pressure of optimization RLE Shrinkage is slightly higher, but far below LZW and optimization RLE_LZW compression method;
For the slightly more data (20%, 56%, 81%) of resource, the compression ratio of LZW compression method and other three kinds of methods Comparing is highest (percent seventy or eighty), and the compression ratio of Xilinx is minimum (can only achieve percent twenty or thirty);
RLE_LZW optimizes compression method, and bit compression rate higher for resource utilization is slightly below LZW, and difference is not It is very big, but many is improved compared with LZW method on compression time, this is because data to be compressed first pass through optimization RLE algorithm pressure Contracting, the more uncompressed data of data volume have reduced much when being then sent through LZW compression.It is not time-consuming to optimize RLE algorithm itself, and Compared with lzw algorithm itself needs to carry out one by one with dictionary due to data, and dictionary itself is that dynamic updates, so consuming very much When.The compression ratio of the more simple lzw algorithm loss of RLE_LZW optimization algorithm is due to the compression number after optimization RLE algorithm process Increase according to complexity compared with initial data, causing compression ratio to receive a little influences.But comprehensively consider compression time and compression Rate, a kind of optimization bit file compression & decompression technology based on RLE and LZW are optimal.

Claims (2)

1. a kind of optimization bit file compression method based on RLE and LZW, it is characterised in that: comprise the following steps that
Step 1: FPGA configuration bit file is made of multi-section divided data, includes head control word, data and command word, wherein Data and order word format are all with nybble for a unit, scratch the head control word except FPGA configuration bit file;
Initialize brigade commander's counter in RLE;The run length of RLE bit file data characteristics according to step 1 are arranged It is 4;Brigade commander's counter, starts counting from 1, that is, counts 1 when reading first character string, can encounter the word for continuously repeating appearance Add 1 every time when symbol string, when there are different character strings, the value of brigade commander's counter can be exported, restore initial value 1;Brigade commander's meter The value of number device is 1-255, restores 1 when reaching 255;
The compression dictionary for initializing LZW, making dictionary includes all possible, and described is single entry;The compression dictionary of LZW For storing the entry generated in compression process, the index value for compressing dictionary is 1-4096;
Prefix pre_char is set, enables current prefix pre_char for sky;
Step 2: setup string pre_string;The FPGA configuration bit file for removing head control word will be scratched in step 1 First character string is assigned to character string pre_string;It is described to scratch except the FPGA configuration bit file of head control word is to be compressed File;
Step 3: it will be compressed by compressed file, steps are as follows:
(1) judge whether there is character string to need to compress in compressed file, if needing to compress without character string, first output word Symbol string pre_string, then the value of brigade commander's counter is exported, enter step four;
(2) if there is character string needs to compress, current string current_string is set, current string current_ is enabled String is equal to the character late string in character stream;
(3) judge whether pre_string and current_string is consistent: if pre_string and current_string Unanimously, brigade commander's counter adds 1, judges whether brigade commander's Counter Value is counted to 255;If brigade commander's Counter Value meter is first exported to 255 Pre_string, then brigade commander's Counter Value is exported, enabling brigade commander's Counter Value is 1,
The unpressed character string of file to be compressed is read to pre_string, return step three
If brigade commander's Counter Value is not counted to 255, return step three;
If pre_string is inconsistent with current_string, pre_string is exported, brigade commander's Counter Value is exported, by this When current_string be assigned to pre_string, return step three;
Step 4: output is arranged successively into new by setting current character current_char according to step 3 (1) output sequence Character stream, the first character read in the character stream is assigned to current_char;
Step 5: judge that pre_char and current_char are arranged successively the entry of composition whether in dictionary: if in word In allusion quotation, pre_char and the current_char entry for being arranged successively composition are assigned to pre_char;If not in dictionary, Export the code word of current prefix pre_char, addition pre_char and current_char are arranged successively the entry of composition to dictionary In, the value of current_char is assigned to pre_char;
Step 6: judging whether need to compress there are also character in new character stream, if there is character needs to compress, will need to compress First character be assigned to current_char, return step five;If needing to compress without character, current prefix pre_ is exported The code word of char completes compression.
2. a kind of decompression method of optimization bit file compression method based on RLE and LZW according to claim 1, It is characterized by comprising steps are as follows:
Step 1: initial decompression dictionary, making dictionary includes all possible, and described is single entry;
Step 2: setting variable pw reads wait decompress first code stream in data flow, pw is assigned to, using pw as search index Dictionary is decompressed, the corresponding entry of the index is read, setup string variable pre_char, the corresponding word of index that pw is indicated Item is assigned to pre_char, and exports pre_char;
Step 3: setting variable cw continues to read wait decompress next code stream in data, is assigned to cw, judges in dictionary In whether have cw indicate the corresponding entry of index, if there is cw indicate the corresponding entry of index, output cw indicate index Variable current_char is arranged in the corresponding string data of index that corresponding entry, i.e. cw indicate, the index that cw is indicated Corresponding string data is assigned to current_char, and character variable pc is arranged, and pre_char is assigned to pc, character is arranged The first character of the corresponding entry of current_char is assigned to cc, pc and cc is arranged successively to the character of composition by variable cc String is added in decompression dictionary;It, will if the value of pre_char is assigned to pc without the index corresponding entry that cw is indicated The first character of current_char is assigned to cc, and output pc and cc is arranged successively the string data of composition, and add pc and Cc is arranged successively the string data of composition into dictionary;
Step 4: judging whether there are also data need to decompress wait decompress in data flow, if needing to decompress there are also data, Return step three;If needing to decompress without data, the output of step 3 is arranged in new character string number by output sequence According to identifying the head control word in new string data;Setup string head, and head control word is assigned to head;
Step 5: setup string variable current_string, from the new string data for remove head control word by Character string, which is read, according to brigade commander is assigned to current_string, a character after then reading the character string again, i.e. brigade commander meter The value of number device, restores original compression data according to the value of the character string and brigade commander's counter that read out;
Step 6: judgement removes in the new string data of head control word whether need the data decompressed, if so, then Data to be decompressed are replaced removing the new string data of head control word, return step five;If nothing, by head with The data of step 5 output are arranged successively to obtain initial data, complete decompression.
CN201610752157.9A 2016-08-26 2016-08-26 A kind of optimization bit file compression & decompression method based on RLE and LZW Active CN106407285B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610752157.9A CN106407285B (en) 2016-08-26 2016-08-26 A kind of optimization bit file compression & decompression method based on RLE and LZW

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610752157.9A CN106407285B (en) 2016-08-26 2016-08-26 A kind of optimization bit file compression & decompression method based on RLE and LZW

Publications (2)

Publication Number Publication Date
CN106407285A CN106407285A (en) 2017-02-15
CN106407285B true CN106407285B (en) 2019-11-29

Family

ID=58003710

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610752157.9A Active CN106407285B (en) 2016-08-26 2016-08-26 A kind of optimization bit file compression & decompression method based on RLE and LZW

Country Status (1)

Country Link
CN (1) CN106407285B (en)

Families Citing this family (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110799959B (en) * 2017-05-26 2024-02-27 深圳配天智能技术研究院有限公司 Data compression method, decompression method and related equipment
CN107294538B (en) * 2017-06-09 2020-09-01 深圳市华星光电半导体显示技术有限公司 Compression method and decompression method for compensation gauge of OLED display device
CN107483055B (en) * 2017-08-04 2020-06-16 北京世纪铭辰科技有限公司 Lossless compression method and system
CN108259041A (en) * 2017-12-29 2018-07-06 中国电子科技集团公司第二十研究所 A kind of Big Dipper data expansion method based on modified LZW Coding Compression Technologies
CN108184082A (en) * 2018-01-22 2018-06-19 豪威科技(上海)有限公司 Image data transmission system and method
CN108832935B (en) * 2018-05-31 2022-05-10 郑州云海信息技术有限公司 RLE algorithm implementation method, system, equipment and computer storage medium
CN112134644B (en) 2019-06-25 2022-07-15 比亚迪股份有限公司 Encoding method, apparatus and storage medium
CN110518917B (en) * 2019-07-17 2023-01-03 华东计算技术研究所(中国电子科技集团公司第三十二研究所) LZW data compression method and system based on Huffman coding
CN110719105B (en) * 2019-09-16 2023-03-28 上海御渡半导体科技有限公司 Lossless compression and decompression method for test vector
CN110928809A (en) * 2019-11-25 2020-03-27 航天科技控股集团股份有限公司 Method for programming image data to external Flash through CAN bus
CN112579128B (en) * 2020-12-23 2023-05-09 恒为科技(上海)股份有限公司 Data processing method, upper computer, singlechip and system
CN112968706B (en) * 2021-01-29 2023-02-24 上海联影医疗科技股份有限公司 Data compression method, FPGA chip and FPGA online upgrading method
CN113709144B (en) * 2021-08-26 2023-02-07 哈尔滨工业大学 High-frequency signal compression method

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105630999A (en) * 2015-12-28 2016-06-01 华为技术有限公司 Data compressing method and device of server

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105630999A (en) * 2015-12-28 2016-06-01 华为技术有限公司 Data compressing method and device of server

Also Published As

Publication number Publication date
CN106407285A (en) 2017-02-15

Similar Documents

Publication Publication Date Title
CN106407285B (en) A kind of optimization bit file compression & decompression method based on RLE and LZW
CN101783788B (en) File compression method, file compression device, file decompression method, file decompression device, compressed file searching method and compressed file searching device
WO2019153700A1 (en) Encoding and decoding method, apparatus and encoding and decoding device
CA2371375C (en) Bitwise adaptive encoding using prefix prediction
CN116681036B (en) Industrial data storage method based on digital twinning
CN107565971B (en) Data compression method and device
CN110518917B (en) LZW data compression method and system based on Huffman coding
CN110021369B (en) Gene sequencing data compression and decompression method, system and computer readable medium
CN116610265B (en) Data storage method of business information consultation system
CN101534124B (en) Compression algorithm for short natural language
US6518895B1 (en) Approximate prefix coding for data compression
JP2003524983A (en) Method and apparatus for optimized lossless compression using multiple coders
CN104156990A (en) Lossless compressed encoding method and system supporting oversize data window
US6748520B1 (en) System and method for compressing and decompressing a binary code image
CN117177100B (en) Intelligent AR polarized data transmission method
CN108880559B (en) Data compression method, data decompression method, compression equipment and decompression equipment
CN104682966B (en) The lossless compression method of table data
CN108932315A (en) A kind of method and relevant apparatus of data decompression
CN116471337A (en) Message compression and decompression method and device based on BWT and LZW
CN206712982U (en) A kind of Huffman coded systems for VLSI designs
Kaur et al. An algorithm for lossless text data compression
Mahmood et al. Efficient compression scheme for large natural text using zipf distribution
JPH0628149A (en) Method for compressing plural kinds of data
Mahmoudi et al. Comparison of Compression Algorithms in text data for Data Mining
Kaur et al. Lossless text data compression using modified Huffman Coding-A review

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant