8051 data compression

Looking for lightweight data compression code for the 8051. Preferably in C. Can anyone offer links to pursue? Speed is not all that important, code size is.

Thanks,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Martin Euredjian

To send private email: x@y where x = "martineu" y = "pacbell.net"

Reply to
Martin
Loading thread data ...

Hi Martin,

What are you wanting to compress? We used a lookup table to compress common html tags and sequences that repeated often. It's only really suitable if the data does not contain all 256 possible values - you use the spare values to index a lookup table.

Regards - Rocky

Reply to
Rocky

It's not possible to give a good answer without knowing what it is that you are trying to compress. The solutions will differ for, say, long strings of ASCII numeric characters versus image bitmaps versus pseudo-random values. There are general purpose compression routines, such as gzip, zip, arc, zoo (remember that one?) but general purpose means a larger code size.

What about a lossy compression? For some applications, keeping only "the important stuff" and discarding the rest is perfectly acceptable.

In addition to code size, how constrained are you with respect to variable storage? Are you limited to 128 bytes in the register space or do you have many KBs of external memory for table generation?

--
Rich Webb   Norfolk, VA
Reply to
Rich Webb

google for "zlib" Its free, in C and _not_ fast.

Reply to
Donald

Run length encoding can be very compact & RAM frugal - some versions will fit into a CPLD. If you can tune, to match repeat patterns on your data, it can get even more efficent. All compressions are very data-content dependant, and truly random data compresses the worst.

-jg

Reply to
Jim Granville

I should have been more precise. Trying to consider compressing a Virtex II bitfile. Storage would be in an external SPI FLASH device. The uncompressed bit image is just under 512K-bytes. In looking at it, there are lots of 0x00 bytes. It should compress very well.

Lossy compression is not an option, obvisouly.

-Martin

Reply to
Martin

To add to that, obviously I only need to expand with the 8051. The compression part would be done on a PC.

-Martin

Reply to
Martin

Then the PC can search for the best RLC lengths, and you can even look at adding a simple table, if the best pattern repeats are > 1 byte. Unused portions of the bitstream should compress very well.

In the most vanilla form, RLC is Value.Count, but it can expand to TableIndex.Count, expecially if a PC can do the leg-work, of checking the table values, and patterns. ZIP the bitstream, and you have a target of what complex compression gives.

-jg

Reply to
Jim Granville

I'm familiar with plain RLC. I need to research the table approach.

I did do that. 500K compressed down to 100K~112K, depending on settings. I think that I can safely assume that allocating 250K of FLASH should do the job. I need to allow for changes in code affecting compression. That's the toughest aspect of this to guestimate.

I am going to post to comp.arch.fpga to see if anyone might have statistics on attainable compression ratios for different design densities.

Thanks,

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Martin Euredjian

To send private email:
x@y
where
x  =  "martineu"
y = "pacbell.net"
Reply to
Martin

Then the easiest is probably good old run length encoding (google for RLE).

formatting link
is probably the easiest place to start; several links to pseudo-code there. Wikipedia also has a short entry on it.

--
Rich Webb   Norfolk, VA
Reply to
Rich Webb

A recent article in Circuit Cellar (November 2004), mentions just that, includingdetails of the compression algorithm used.

ted

Reply to
edaudio2000

Doesn't the Virtix II support compressed bitstreams? I've never used Xilinx devices myself, but Altera devices all support compression in the devices themselves. Trying to further compress the compressed bitstreams is a waste of effort, as you are never going to get better than a percent or two. Also, if you are using encrypted bitsteams, you are not going to be able to compress them effectively.

Reply to
David Brown

Yes. However, the form of compression they use is to match repeating frames, which isn't ideal in non-trivial designs. Almost anything else should produce better results.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Martin Euredjian

To send private email: x@y where x = "martineu" y = "pacbell.net"

Reply to
Martin

Hi Dear: Keil developmmet environmnet give you 56 bit 8051 compression sample for free. Look there, I porteed 128 rigandel public domain algorithms. It took 28k ram

code

Reply to
Sergey Uskach

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.