13 - Implementation of LZW Algorithm For Binary Lossless Data Compression
13 - Implementation of LZW Algorithm For Binary Lossless Data Compression
Abstract- When high-speed media or channels are process of compression into two separate components:
used, high-speed data compression is desired. Software modeling and coding. Modeling is the process of
implementations are often not fast enough. In this paper, constructing representation. Coding entails mapping the
we present the very high speed hardware description
modeler's representation of the source into a
language (VHDL) modeling environment ofLempel-Ziv-
compressed representation. The process of converting a
Welch (LZW) algorithm for binary data compression to
ease the description, verification, simulation and text, such as a file on disk, a string in memory, or a stream
hardware realization. The VHDL model defines a main of characters, into a compact representation is called
block, which describe the LZW algorithm for binary encoding or compression. Decoding or decompression
data compression through a behavioral and structural restores the original text from its compressed
description. The LZW algorithm for binary data representation [8-9].
compression comprises of two modules compressor and
decompressor. The input of compressor is l-bit bit stream Huffman coding is constrained to represent every
read in according to the clock cycle. The output is an 8-bit event using an integral number of bits [10-11].
integer stream fed into the decompressor, which is an Updating a Huffman tree is much more time
index that represents the memory location of the bit
consuming. Like Huffman, Shannon-Fano coding
string stored in the dictionary. The output of
requires to recognize the statistical properties of the
decompressor is 1-bit bit stream. Once detecting the
particular approaches for input, output, main block and source file i.e. the probability of occurrence of a code
different modules, the VHDL descriptions are run must be found first before the compression start [12-
through a VHDL simulator, followed by the timing 13]. But in most cases, it is not possible to determine
analysis for the validation, functionality and the statistical properties of the file due to the
performance of the designated model that supports the randomness ofthe occurrence
effectiveness ofthe model for the application.
Dictionary compression (also referred to as Ziv-
Keywords- Binary Data Compression, LZW, VHDL,
Simulation Lempel compression or textual substitution) removes
data redundancy by replacing repeated input substrings
1. INTRODUCTION by references (also called indices or pointers) to earlier
copies of the identical substring [14-17]. A dictionary of
Despite the fact that computer memory costs have characters, words or phrases that are expected to occur
decreased dramatically over the past few years, data frequently is maintained and a recurring substring is
storage still remains, and will probably always remain, encoded by the index of its corresponding dictionary
an important cost factor for many large scale data base entry. Compression is achieved by choosing indices so
applications [1-3]. Compressing data in a database that on average they require less space than the phrase
system is attractive for two reasons: data storage they encode.
reduction and performance improvement. Storage
reduction is a direct and obvious benefit, while LZW compression implements a variation of LZ78
performance improves because smaller amounts of due to Welch and initializes the dictionary with the input
physical data need to be moved for any particular character set [18]. LZW compression is a loss less,
operation on the database [4-6] One of the most adaptive and dynamic dictionary compression technique
important developments in the study of data [19-20]. LZW compress text, executable code, and
compression is the modem paradigm first presented by similar data files to about one-half their original size.
Rissanen and Langdon [7]. This paradigm divides the LZW also performs well when presented with extremely
The use of VHDL for modeling is especially size, the number of bits used is predefined. In this
appealing since it provides a formal description of the research, 8 bits are used to design an 8-bit compressor
system and allows the use of specific description styles thus the memory locations allocated is 28=256
to cover the different abstraction levels (architectural, memory locations.
register transfer and logic level) employed in the design 8·bH
-
in!eger
II bH Olllp lit Ilit
-
[21-23]. In the computation of method, the problem is I~
ream stream stre am
r
I
verification of each submodule the synthesis is then
activated. It performs the translations of hardware
description language code into an equivalent netlist of
digital cells. The synthesis helps integrate the design
."....,...---,:.1hf-1[
work and provides a higher feasibility to explore a far
Output
wider range of architectural alternative [24-27]. The select
Fig. 1: Structural view ofYHDL model
method provides a systematic approach for hardware
realization, facilitating the rapid prototyping of the
Since the decompressor decompress the output of
energy meter.
compression, the compression output is used as the
input for decompression. The decompress or adds a
II. MATERIALS AND METHODS
new string to the dictionary each time it reads a new
This research is to develop a model of LZW code. It translates each incoming code into a string and
algorithm for binary data compression using VHDL. sends it to the output. The input to the decompressor is
The model is capable of compressing l-bit bit stream an integer stream consists of 8 bits. The output of the
of binary data. decompression is a bit streams. The desired output of
decompression is binary data, which is same as the
The application ofthe model can be used in various original binary data.
data compression devices thus saving memory
Three control signals, clock, selector and output
space and reduce the transmission time. A structural
select control the operation. Clock signal is used to
view ofthe model is shown in Fig. 1
control reset, compression, or decompression Table 1
The input of compressor is a bit streams, shows the function and its corresponding control signal.
where binary data is read in one by one according to the
TABLE I
clock cycle. The input bit stream is compressed, or
Selector And Its Corresponding Function
encoded to another form. The output is an index that
represents the memory location of the bit string stored x y FUNCTION
in the dictionary called a codeword. The output of
0 0 RESET
compression is an integer stream, which consists of a
predefined number of bits. The number of bits used 0 1 COMPRESSION
in the compression determines the number of memory
1 0 DECOMPRESSION
locations allocated in the dictionary. The selection of
number of bits is important as the memory locations 1 1 UNUSED
The entity declaration specifies the name of the if (clock'event and clock='1 ')then
entity being modeled. All the interface ports, which if(selector="OO")then--resec case
include input and output, are declared in the entity
elsif (selector="Ol ")then-compression
declaration. The entity name of the model is lzw.
elsif (selector+" 1O")then-decompression
There are 7 interface ports that are declared which
contributes a total of 22 input and output. Bit stream end if:
Bit_stream<='I' after 210ns '0' after 4lOns, '0' after 6 IOns, 'I' after 810ns
TABLE 2
•e Integer_stream -:::J[J,-1 _
Variable and its function in compression "to clock 1JlnJ1.rlJ"
Name Function «) output_stl ~
1,0,0,1,0,1,1,0,1,1,0,1,1,0,0,0,1,0,0,1,0,0,1,0,1,0,0,
TABLE 3 1,0, I, I ,1,0,
Variable and its function in decompression
dock
.... [2]
fuzzy ligic. simulation.
Mohd- Yasin,
82( 12):867-881
• selector
Clock Frequency Divider. Australian Journal of Basic and
Applied Sciences, 6(7): 73-79.
block confirms the correctness of the code. The model is [10] Reaz, M.B.I., M.1. Ibrahimy, F. Mohd-Yasin, C.S. Wei and M.
also compared with a C model ofLZW algorithm where Kamada, 2007 Single core hardware module to implement
encryption in TECB mode. Infonnacije MIDEM, 37(3): 165-
the same input is being fed and the output is synonymous 171.
with the result obtained from VHDL model.
[II] Jing, Y, 2011. The Combinational Application of LZSS and
IV. CONCLUSIONS LZW Algorithms for Compression Based on Huffman. In the
Proceedings of the International Conference on Electronics and
In this paper, we present the very high speed Optoelectronics (lCEOE-20 II), pp: 397-399
hardware description language (VHDL) modeling [12] Shannon, C.E., 1948. A Mathematical Theory of
environment of Lempel-Ziv-Welch (LZW) algorithm Communication. Bell System Technical Journal,27: 379-423,
623-656.
for binary data compression to ease the description,
verification, simulation and hardware realization. By [13] Fano, R.M., 1961.Transmission of Information. Wiley, ew
York.
simulating with binary data and comparing with C model
of LZW algorithm the proposed approach of VHDL [14] Rodeh, M., YR. Pratt and S. Even, 1981. Linear Algorithm for
Data Compression via String Matching. J. ACM, 28( I): 16-24
modeling of LZW algorithm for binary data
[15] Storer, J.A. and T.G. Szymanski, 1982. Data Compression via
compression is successfully designed, implemented and
Textual Substitution. J. ACM, 29(4): 928-951.
tested. Currently, we are conducting the further research
[16] Ziv, J. and A. Lempel, 1977. A Universal Algorithm for
that considers further reductions in the hardware
Sequential Data Compression. IEEE Trans. Inf. Theory, 23(3):
complexity in terms of synthesis and ease hardware 337-343.
realization.
-- _._---------_.
[17] Ziv, J. and A. Lempel, 1975. Compression of Individual [26] Akter, M., M.B.I. Reaz, F.M. Yasin and F. Choong,200S.
Sequences via Variable-Rate Coding. IEEE Trans. Inf. Theory, Hardware Implementations of Image Compressor for Mobile
24(5): 530-536. Communications. Journal of Communications Technology and
[IS] Welch, T.A., 1984. A Technique for High- Performance Data Electronics, 53(8): 899-910.
Compression. IEEE Computer, 17(6): S-I9. [27] Reaz, M.B.I., M.T. Islam, M.S. Sulaiman, M.A.M. Ali, H.
[19] Bin, L., N. Guiqiang, L. Jianxin and Z. Xue, 20 II. BWT-based Sarwar and S. Rafique, 2003. FPGA Realization Of
Data Preprocessing for LZW .. In the Proceedings of the Multipurpose F[R Filter,. In the Proceedings of the Parallel and
International Conference on Multimedia and Signal Processing Distributed Computing, Applications and Technologies
(CMSP- 2011), pp: 37-40. (PDCAT-2003), pp: 912-915.