1 Star 3 Fork 4

WangXuan95 / FPGA-Gzip-compressor

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
GPL-3.0

语言 仿真 部署 部署

English | 中文

 

FPGA GZIP compressor

An FPGA-based streaming GZIP (deflate) compressor supports both LZ77 and dynamic huffman. For universal lossless data compression. Input raw data and output the standard GZIP format (as known as .gz / .tar.gz file format).

 

diagram_en.png

 

Features

  • Pure RTL design which is universal for all FPGA platforms.
  • Simple streaming input/output interface
    • AXI-stream input interface:

      • 8-bit data width, each cycle can input 1B (byte).
      • Each input AXI-stream packet with length ≥32B will be compressed into an independent GZIP data stream.
      • Input AXI-stream packet with length <32B will be discarded internally, since not worthy for compression.
    • AXI-stream output interface:

      • Each output AXI-stream packet is a GZIP data stream (including header/footer).
  • Performance
    • If there is no back pressure at the output interface, i.e. o_tready=1 always, then the input interface will also have no back pressure, i.e. o_tready=1 always (even in the worst case).
      • This is a deliberate design. The advantage is that when the external bandwidth is sufficient, this module can run at a certain and highest performance (input throughput=clock frequency)
    • Clock frequency reaches 128 MHz on Xilinx Artix-7 xc7a35ticsg324-1L. i.e., input performance = 128MB/s
  • Resource Usage:8200×LUT and 25×BRAM36K on Xilinx FPGA.
  • Support almost complete deflate algorithm:
    • Complies with deflate algorithm specification (RFC1951 [1]) and GZIP format specification (RFC1952 [2]).

    • deflate block :

      • Input AXI-stream packets ≤16384B are treated as one deflate block
      • Input AXI-stream packets >16384B are splitted to multiple deflate block
    • LZ77 Compression:

      • Maximum search distance is 16383, which covers the entire deflate block.
      • Use hash table for matching, hash table size = 4096.
    • Dynamic huffman coding

      • Build dynamic huffman tree for large deflate blocks, including literal code tree and distance code tree.
      • Use static huffman tree for small deflate blocks.
    • The compression ratio of this design:

      • is close to .gz files generated by 7ZIP software under the "fast compression" option.
      • is significantly better than previous open-sourced hardware deflate compressors. See Evaluation
    • According to GZIP spec, calculates CRC32 of raw data and places it at GZIP footer.

  • Unsupported algorithm features:
    • Do not build dynamic code length tree , but use a fixed one. Because its benefits/costs are not as high as dynamic literal code trees and distance code trees.
    • Do not dynamically adjust the size of deflate block to improve compression rate. The goal is to reduce complexity.

 

 

Module Usage

The design source code is in RTL directory. In which gzip_compressor_top.v is the top module.

Module in/out signals

The in/out signals of gzip_compressor_top is as follows:

module gzip_compressor_top # (
    parameter          SIMULATION = 0     // 0:disable simulation assert (for normal use)  1: enable simulation assert (for simulation)
) (
    input  wire        rstn,              // asynchronous reset.   0:reset   1:normally use
    input  wire        clk,
    // input  stream : AXI-stream slave,  1 byte width (thus do not need tkeep and tstrb)
    output wire        i_tready,
    input  wire        i_tvalid,
    input  wire [ 7:0] i_tdata,
    input  wire        i_tlast,
    // output stream : AXI-stream master, 4 byte width
    input  wire        o_tready,
    output reg         o_tvalid,
    output reg  [31:0] o_tdata,
    output reg         o_tlast,
    output reg  [ 3:0] o_tkeep            // At the end of packet (tlast=1), tkeep may be 4'b0001, 4'b0011, 4'b0111, or 4'b1111. In other cases, tkeep can only be 4'b1111
);

 

Reset

  • reset when rstn=0
  • On most FPGAs, it can actually work without resetting. On some FPGAs that do not support initial register, it is necessary to reset before use.

 

Input AXI-stream

The input interface is a standard 8-bit wide AXI-stream slave.

  • i_tvalid handshakes with i_tready . Successfully input 1 data only when i_tvalid=1 and i_tready=1 simultaneously (see following figure).
  • i_tdata is one-byte input data.
  • i_tlast is the boundary mark of the package, i_tlast=1 means that the current byte is the last byte of a packet, and the next transmitted byte is the first byte of the next packet. Each packet is compressed into an independent GZIP data stream.
              _    __    __    __    __    __    __    __    __    __    __    __
     clk       \__/  \__/  \__/  \__/  \__/  \__/  \__/  \__/  \__/  \__/  \__/  \
                          _____________________________             _____
    tvalid    ___________/                             \___________/     \________
              _________________                   ________________________________
    tready                     \_________________/
                          _____ _______________________             _____
    tdata     XXXXXXXXXXXX__D1_X___________D2__________XXXXXXXXXXXXX__D3_XXXXXXXXX  

 

Output AXI-stream

The output interface is a standard 32 bit (4byte) wide AXI-stream master.

  • o_tvalid handshakes with o_tready . Successfully input one data only when i_tvalid=1 and i_tready=1 simultaneously (as same as input AXI-stream).
  • o_tdata is 4-byte output data. According to AXI-stream spec, o_tdata is small endian, i.e. o_tdata[7:0] is the earliest byte, o_tdata[31:24] is the latest byte.
  • o_tlast is the boundary mark of the package. Each packet an GZIP data stream.
  • o_tkeep is byte-valid signal :
    • o_tkeep[0]=1 means o_tdata[7:0] exist,
    • o_tkeep[1]=1 means o_tdata[15:8] exist,
    • o_tkeep[2]=1 means o_tdata[23:16] exist,
    • o_tkeep[3]=1 means o_tdata[31:24] exist.
  • When the byte number of the output packet is not an integer multiple of 4, at the end of the packet (when o_tlast=1), o_tkeep be 4'b0001, 4'b0011, or 4'b0111
  • Otherwise, o_tkeep=4’b1111 always.

 

Output format

The output data of AXI-stream satisfies GZIP format standard. After storing each AXI-stream packet in an .gz file, this file can be decompressed by compression softwares (7ZIP, WinRAR, etc.).

Tip: .gz is GZIP compressed files. More well-known files are .tar.gz. In fact, TAR packages multiple files into a single .tar file, and then compresses this .tar file to obtain a .tar.gz file. If a single file is compressed, it can be directly compressed into a .gz without TAR packaging. For example, compress data.txt to data.txt.gz

For example, a total of 987 handshakes were performed on the output AXI-stream interface, and the last handshake was o_tlast=1 , indicating that the 987 cycles of data are an independent GZIP stream. Assuming the last handshake o_tkeep=4'b0001, then the last cycle only carries 1 byte of data, thus the GZIP stream contains a total of 986×4+1=3949 bytes. If you save these bytes into a. gz file, it should be:

.gz file 1st byte = o_tdata[7:0] of 1st cycle
.gz file 2nd byte = o_tdata[15:8] of 1st cycle
.gz file 3rd byte = o_tdata[23:16] of 1st cycle
.gz file 4th byte = o_tdata[31:24] of 1st cycle
.gz file 5th byte = o_tdata[7:0] of 2nd cycle
.gz file 6th byte = o_tdata[15:8] of 2nd cycle
.gz file 7th byte = o_tdata[23:16] of 2nd cycle
.gz file 8th byte = o_tdata[31:24] of 2nd cycle
......
.gz file 3945th byte = o_tdata[7:0] of 986th cycle
.gz file 3946th byte = o_tdata[15:8] of 986th cycle
.gz file 3947th byte = o_tdata[23:16] of 986th cycle
.gz file 3948th byte = o_tdata[31:24] of 986th cycle
.gz file 3949th byte = o_tdata[7:0] of 987th cycle

 

Other considerations

  • If there is no back pressure at the output interface, i.e. o_tready=1 always, then the input interface will also have no back pressure, i.e. o_tready=1 always (even in the worst case).
    • With this feature, if the external bandwidth is sufficient to always ensure o_tready=1 , then we can ignore i_tready . The module can runs in the stable maximum performance.
  • The deflate algorithm requires the entire deflate block to construct a dynamic huffman tree, so the end-to-end latency of this module is high:
    • When the input AXI-stream packet is 32~16384B, the first data of the corresponding compressed packet can only be obtained on the output AXI-stream interface after the complete packet has been input (and after some time has passed).
    • When the input AXI-stream packet is >16384B, each time when we input 16384 bytes completely, we can get the corresponding compressed data related to them.
  • When the input AXI-stream packet is <32B, the module will discard it internally and will not generate any output data for it.
  • To achieve a high compression ratio, try to keep the packet length>7000 bytes, otherwise the module may not choose to use dynamic huffman, and the search range of LZ77 will also be limited. If the data that needs to be compressed logically consists of many very small AXI-stream packets, a preprocessor can be added to merge them into a large packet.

 

 

Evaluation

Comparison objects

To evaluate the comprehensive performance of this design, I compare it with the following three deflate compression schemes:

  • Software Compression:Run 7ZIP software on computer
    • Config : Format=gzip, Compression Level=Fast, Algorithm=Deflate, Dictionary Size=32KB, Word Size=32
  • HDL-deflate [3]:An FPGA-based deflate compressor/decompressor
    • Its compressor supports LZ77+static huffman, but without dynamic huffman 。In LZ77, it does not use a hash table for searching.
    • Config : In this test, we use its the highest configuration (also the default configuration) : LOWLUT=False, COMPRESS=True , DECOMPRESS=False , MATCH10=True ,FAST=True
  • HT-Deflate-FPGA [4]:An FPGA-based multi-core deflate compressor/decompressor
    • It also only uses LZ77+static huffman, but without dynamic huffman. In LZ77, it uses hash tables, which is the same as my design.
    • It is a multi-core parallel deflate compressor on Xilinx AWS cloud FPGA, which has extremely high performance but uses many resources. In contrast, both HDL-deflate and my design are single-core compressor designed for embedded applications.
    • This design does not provide hands-on simulation project, making it difficult to quickly run. Therefore, it is not included in actual testing here, only qualitative comparison is conducted.

Comparison platforms

  • Software compression runs on my personal computer (Intel Core i7-12700H, 16GB DDR4).
  • Both HDL-deflate and my design deploy on Artix-7 Arty Board .

Benchmark

The data to be compressed for comparison is raw.hex located in Arty-example/python directory, with a size of 512kB.

Result

The following table shows the comparison results. Note that ↑ represents the larger the better, ↓ represents the smaller the better.

indicators Software My design HDL-deflate HT-Deflate-FPGA
LZ77 ? :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
hash-based LZ77 search ? :heavy_check_mark: :heavy_check_mark: :x: :heavy_check_mark:
dynamic literal code tree ? :heavy_check_mark: :heavy_check_mark: :x: :x:
dynamic distance code tree ? :heavy_check_mark: :heavy_check_mark: :x: :x:
dynamic length code tree ? :heavy_check_mark: :x: :x: :x:
FPGA logic resource (↓) - 8200×LUT 2854×LUT ? (huge)
FPGA memory resource (↓) - 25×BRAM36K 8.5×BRAM36K ? (huge)
Clock frequency (↑) - 128 MHz 95 MHz ?
Clock cycles consumed (↓) - 524288 1449901 ?
Input Bytes/cycle (↑) - 1.0 0.36 ?
Overall Performance (↑) 44 MB/s 128 MB/s 35 MB/s 10 GB/s level
Power (↓) High Low Low High
Compressed size (↓) 287 kB 299 kB 395 kB ?
Compression ratio (↑) 44% 41% 23% between 23% & 41% :warning:

:warning: The compression ratio of HT-Deflate-FPGA may larger than HDL-deflate , but smaller than My design. This conclusion is analyzed based on the algorithm characteristics it supports.

 

 

Deployment result

The implement result of gzip_compressor_top on multiple FPGAs:

FPGA series FPGA part logic logic (%) on-chip-mem on-chip-mem (%) frequency
Xilinx Artix-7 xc7a35ticsg324-1L 8218*LUT 40% 25*BRAM36K 50% 128 MHz
Xilinx Zynq-7 xc7z020clg484-1 8218*LUT 16% 25*BRAM36K 18% 128 MHz
Xilinx Virtex-7 xc7vx485tffg1761-1 8201*LUT 3% 25*BRAM36K 3% 160 MHz
Xilinx ZU+ xczu3eg-sbva484-2-e 8180*LUT 12% 24*BRAM36K 11% 280 MHz
Altera Cyclone4 EP4CE55F23C8 16807*LE 30% 807398 bits 34% 74 MHz

 

 

Simulation

The simulation source code is in SIM directory. In which tb_gzip_compressor.v is the top module.

The diagram of this testbench is as follows:

testbench_diagram_en.png

 

Among them, the random data packet generator (tb_random_data_source.v) will generate four types of data packets with different characteristics (random bytes with uniform distribution, random bytes with non-uniform distribution, randomly continuously changing data, and sparse data), which will be sent to the design under test (gzip_compressor_top) for compression, and then tb_save_result_to_file.v module will store the compressed results into files. Each packet is stored into a independent .gz file.

tb_print_crc32 is responsible for calculating the CRC32 of the raw data and printing it. Note that the CRC32 is also calculated internally in gzip_compressor_top and filled into the footer. These two CRC32 calculators are independent (the former is only used for simulation to verify whether the CRC32 generated by the module under test is correct). You can compare the simulated printed CRC32 with the CRC32 in the GZIP file on your own.

 

Simulate using iverilog

You can follow the following steps to simulate using iverilog:

  • Install iverilog, see iverilog_usage
  • In Windows, double click tb_gzip_compressor_run_iverilog.bat to run simulation. Where tb_gzip_compressor_run_iverilog.bat contains the simulation compilation and running commands.
  • When simulation, the random packet generator will generate 10 packets by default, the simulation usually takes about ten minutes to complete. You can modify the macro FILE_COUNT in tb_random_data_source.v.
  • The GZIP compressed stream generated by simulation will be stored in sim_data directory. (you can modify it by modifying macro OUT_FILE_PATH in tb_save_result_to_file.v)
    • You can use compression software such as 7ZIP and WinRAR to extract these .gz files.
  • To batch check the files generated by simulation for formatting errors, you can run a Python source fin sim_data directory. You need to open a command line in sim_data directory, and run command:
python check_gz_file.py .

The command means: check all .gz files in current directory (. ), i.e. sim_data.

Simulate using other simulators

In addition to iverilog, you can use other simulators. Just add all the .v files in RTL and SIM directories to the simulation project, and set tb_gzip_compressor.v to be the top-level file for simulation.

 

 

FPGA demo

I provided an demo which runs on Arty development board (this demo is also a pure RTL design, which can be ported to other FPGAs).

The FPGA project receives UART (serial port) data, feeds it into the GZIP compressor, and sends the resulting GZIP stream through the serial port (UART: baud rate 115200, no parity).

On the computer, we run a Python program. The execution steps of the program are:

  • Read a file from the computer's disk (user specifies the file name through the command line);
  • List all serial ports on the computer. The user needs to select the one corresponds to FPGA (if only one serial port is found, select it directly);
  • Send all bytes of the file to FPGA through the serial port;
  • Simultaneously receiving data from FPGA;
  • Storing the received data into a .gz file;
  • Finally, call Python's gzip library to extract the .gz file and compare it with the original data to see if it is equal. If not equal, report an error.

The serial port speed is much lower than the maximum performance that gzip_compressor_top can achieve, so this project is only used for demonstration. To achieve higher performance of the module, another high-speed communication interfaces need to be used.

The following figure is the block diagram of this demo.

fpga_test_diagram_en.png

 

Files related to the project:

  • Arty-example/RTL includes FPGA sources (except gzip_compressor_top, it is in ./RTL directory)
  • Arty-example/vivado is the vivado project
  • Arty-example/python includes python program (fpga_uart_gz_file.py)

After programming the FPGA, open a command line in Arty_example/python directory and run the following command:

python fpga_uart_gz_file.py <file_name_to_compress>

For example, running the following command to compress raw.hex :

python fpga_uart_gz_file.py raw.hex

If the compression is successful, we can get raw.hex without any errors.

 

 

 

FPGA GZIP compressor

基于 FPGA 的流式的 GZIP (deflate 算法) 压缩器。用于通用无损数据压缩:输入原始数据,输出标准的 GZIP 格式,即常见的 .gz / .tar.gz 文件的格式。

 

diagram.png

 

特性

  • 纯 RTL 设计,在各种 FPGA 型号上都可以部署。
  • 极简流式接口
    • AXI-stream 输入接口

      • 数据位宽 8-bit ,每周期可输入 1 字节的待压缩数据
      • 输入的长度 ≥32 字节的 AXI-stream 包 (packet) 会被压缩为一个独立的 GZIP 数据流
      • 输入的长度 <32 字节的 AXI-stream 包会被模块丢弃 (不值得压缩) ,不会产生任何输出
    • AXI-stream 输出接口

      • 每个输出的 AXI-stream 包是一个独立的 GZIP 数据流 (包括GZIP文件头和文件尾)
  • 性能
    • 如果输出接口无反压,也即 o_tready 始终=1,则输入接口也一定无反压,也即 o_tready 始终=1 (即使在最坏情况下) 。
      • 这是我刻意设计的,好处是当外部带宽充足时,本模块可跑在确定且最高的性能下 (输入吞吐率=时钟频率)
    • 在 Xilinx Artix-7 xc7a35ticsg324-1L 上时钟频率跑到 128MHz (输入性能为 128MByte/s)
  • 资源:在 Xilinx FPGA 上约占 8200×LUT 和 25×BRAM36K
  • 支持几乎完整的 deflate 算法
    • 依照 deflate 算法规范 (RFC1951 [1]) 和 GZIP 格式规范 (RFC1952 [2]) 编写

    • deflate block :

      • 小于 16384 字节的输入 AXI-stream 包当作一个 deflate block
      • 大于 16384 字节的输入 AXI-stream 包分为多个 deflate block , 每个不超过 16384
    • LZ77 游程压缩:

      • 搜索距离为 16383 , 范围覆盖整个 deflate block
      • 使用哈希表匹配搜索,哈希表大小=4096
    • 动态 huffman 编码

      • 当 deflate block 较大时,建立动态 huffman tree ,包括 literal code tree 和 distance code tree
      • 当 deflate block 较小时,使用静态 huffman tree 进行编码
    • 由于支持了以上功能,本设计的压缩率:

      • 接近 7ZIP 软件在“快速压缩”选项下生成的 .gz 文件。
      • 显著大于其它现有的开源 deflate 压缩器。见 对比和评估
    • 依照 GZIP 的规定,生成原始数据的 CRC32 放在 GZIP 的末尾,用于校验。

  • 不支持的特性:
    • 不构建动态 code length tree , 而是使用固定 code length tree ,因为它的收益代价比不像动态 literal code tree 和 distance code tree 那么高。
    • 不会为了提高压缩率而动态调整 deflate block 大小,目的是降低复杂度。

 

 

使用方法

RTL 目录包含了 GZIP 压缩器的设计源码,其中的 gzip_compressor_top.v 是 IP 的顶层模块。

模块信号

gzip_compressor_top 的输入输出信号如下

module gzip_compressor_top # (
    parameter          SIMULATION = 0     // 0:disable simulation assert (for normal use)  1: enable simulation assert (for simulation)
) (
    input  wire        rstn,              // asynchronous reset.   0:reset   1:normally use
    input  wire        clk,
    // input  stream : AXI-stream slave,  1 byte width (thus do not need tkeep and tstrb)
    output wire        i_tready,
    input  wire        i_tvalid,
    input  wire [ 7:0] i_tdata,
    input  wire        i_tlast,
    // output stream : AXI-stream master, 4 byte width
    input  wire        o_tready,
    output reg         o_tvalid,
    output reg  [31:0] o_tdata,
    output reg         o_tlast,
    output reg  [ 3:0] o_tkeep            // At the end of packet (tlast=1), tkeep may be 4'b0001, 4'b0011, 4'b0111, or 4'b1111. In other cases, tkeep can only be 4'b1111
);

 

复位

  • 令 rstn=0 可复位,之后正常工作时都保持 rstn=1。
  • 在大多数 FPGA 上其实可以不用复位就能工作。在少数不支持 initial 寄存器初始化的 FPGA 上,使用前必须复位。

 

输入接口

输入接口是标准的 8-bit 位宽的 AXI-stream slave

  • i_tvalidi_tready 构成握手信号,只有同时=1时才成功输入了1个数据 (如下图)。
  • i_tdata 是1字节的输入数据。
  • i_tlast 是包 (packet) 的分界标志,i_tlast=1 意味着当前传输的是一个包的末尾字节,而下一个传输的字节就是下一包的首字节。每个包会被压缩为一个独立的 GZIP 数据流。
              _    __    __    __    __    __    __    __    __    __    __    __
     clk       \__/  \__/  \__/  \__/  \__/  \__/  \__/  \__/  \__/  \__/  \__/  \
                          _____________________________             _____
    tvalid    ___________/                             \___________/     \________
              _________________                   ________________________________
    tready                     \_________________/
                          _____ _______________________             _____
    tdata     XXXXXXXXXXXX__D1_X___________D2__________XXXXXXXXXXXXX__D3_XXXXXXXXX  

 

输出接口

输出接口是标准的 32-bit (4字节) 位宽的 AXI-stream master

  • o_tvalido_tready 构成握手信号,只有同时=1时才成功输出了1个数据 (类似输入接口) 。
  • o_tdata 是4字节的输出数据。按照 AXI-stream 的规定,o_tdata 是小端序,o_tdata[7:0] 是最靠前的字节,o_data[31:24] 是最靠后的字节。
  • o_tlast 是包的分界标志。每个包是一个独立的 GZIP 数据流。
  • o_tkeep 是字节有效信号:
    • o_tkeep[0]=1 意为 o_tdata[7:0] 有效,否则无效
    • o_tkeep[1]=1 意为 o_tdata[15:8] 有效,否则无效
    • o_tkeep[2]=1 意为 o_tdata[23:16] 有效,否则无效
    • o_tkeep[3]=1 意为 o_tdata[31:24] 有效,否则无效
  • 当输出包的字节数量不能整除4时,只有在包的末尾 (o_tlast=1 时) ,o_tkeep 才可能为 4'b0001, 4'b0011, 4'b0111
  • 其余情况下 o_tkeep=4’b1111

 

输出格式

AXI-stream 接口输出的是满足 GZIP 格式标准的数据,将每个 AXI-stream 包的数据独立存入一个 .gz 文件后,这个文件就可以被众多压缩软件 (7ZIP, WinRAR 等) 解压。

提示: .gz 是 GZIP 压缩文件的概念。更为人熟知的是 .tar.gz 。实际上 TAR 是把多个文件打包成一个 .tar 文件,然后再对这一个 .tar 文件进行 GZIP 压缩得到 .tar.gz 文件。如果对单个文件进行压缩,则可以不用 TAR 打包,直接压缩为一个 .gz 。例如 data.txt 压缩为 data.txt.gz

例如,AXI-stream 接口上一共成功握手了 987 次,最后一次握手时 o_tlast=1 ,说明这 987 拍数据是一个独立的 GZIP 流。假设最后一次握手时 o_tkeep=4'b0001 ,则最后一拍只携带1字节的数据,则该 GZIP 流一共包含 986×4+1=3949 字节。如果将这些字节存入 .gz 文件,则应该:

.gz 文件的第1字节 对应 第1拍的 o_tdata[7:0]
.gz 文件的第2字节 对应 第1拍的 o_tdata[15:8]
.gz 文件的第3字节 对应 第1拍的 o_tdata[23:16]
.gz 文件的第4字节 对应 第1拍的 o_tdata[31:24]
.gz 文件的第5字节 对应 第2拍的 o_tdata[7:0]
.gz 文件的第6字节 对应 第2拍的 o_tdata[15:8]
.gz 文件的第7字节 对应 第2拍的 o_tdata[23:16]
.gz 文件的第8字节 对应 第2拍的 o_tdata[31:24]
......
.gz 文件的第3945字节 对应 第986拍的 o_tdata[7:0]
.gz 文件的第3946字节 对应 第986拍的 o_tdata[15:8]
.gz 文件的第3947字节 对应 第986拍的 o_tdata[23:16]
.gz 文件的第3948字节 对应 第986拍的 o_tdata[31:24]
.gz 文件的第3949字节 对应 第987拍的 o_tdata[7:0]

 

其它注意事项

  • 如果输出接口无反压,也即 o_tready 始终=1,则输入接口也一定无反压,也即 o_tready 始终=1 (即使在最坏情况下) 。
    • 借助这个特性,如果外部带宽充足稳定,以至于可以保证 o_tready 始终=1 ,则可忽略 i_tready 信号,任何时候都可以让 i_tvalid=1 来输入一个字节。
  • deflate 算法需要用整个 deflate block 来构建动态 huffman 树,因此本模块的端到端延迟较高:
    • 当输入 AXI-stream 包长度为 32~16384 时,只有在输入完完整的包 (并还需要过一段时间后) ,才能在输出 AXI-stream 接口上拿到对应的压缩包的第一个数据。
    • 当输入 AXI-stream 包长度 >16384 时,每完整地输入完 16384 字节 (并还需要过一段时间后),才能在输出 AXI-stream 接口上拿到对应的有关这部分数据的压缩数据、
  • 当输入 AXI-stream 包长度为 <32 时,模块内部会丢弃该包,并且不会针对它产生任何输出数据。
  • 要想获得高压缩率,尽量让包长度 >7000 字节,否则模块很可能不会选择使用动态 huffman ,且 LZ77 的搜索范围也会很受限。如果需要压缩的数据在逻辑上是很多很小的 AXI-stream 包,可以在前面加一个预处理器,把它们合并为一个几千或几万字节的大包来送入 gzip_compressor_top 。

 

 

对比和评估

对比对象

为了评估本设计的综合表现,我将本设计与以下 3 种 deflate 压缩方案进行对比:

  • 软件压缩:在电脑上运行 7ZIP 压缩软件
    • 配置:压缩格式=gzip,压缩等级=极速压缩,压缩方法=Deflate,字典大小=32KB,单词大小=32
  • HDL-deflate [3]:一个基于 FPGA 的 deflate 压缩器/解压器。
    • 它的压缩器只使用了 LZ77 + 静态 huffman,而没有使用动态 huffman 。在 LZ77 中,它没有使用哈希表来搜索。
    • 在本测试中,使用了它的压缩器的最高配置 (也是默认配置) : LOWLUT=False, COMPRESS=True , DECOMPRESS=False , MATCH10=True ,FAST=True
  • HT-Deflate-FPGA [4]:一个基于 FPGA 的多核的 deflate 压缩器。
    • 它也只使用了 LZ77 + 静态 huffman ,而没有使用动态 huffman 。在 LZ77 中,它使用了哈希表来搜索,这与本设计相同。
    • 这个设计是面向 Xilinx-AWS 云平台的多核并行的 deflate 压缩,性能很高,但占用的资源较多。相比之下,HDL-deflate 和本设计都是单核的压缩,面向嵌入式应用设计。
    • 由于这个设计并没有提供上手仿真的工程,很难快速run起来,因此这里没有让它参与实际测试对比,只对它进行定性对比。

对比平台

  • 软件压缩运行在个人电脑 (Intel Core i7-12700H, 16GB DDR4) 上。
  • 本设计和 HDL-deflate 都部署在 Artix-7 Arty开发板 上。

测试数据

用于对比的待压缩数据是 Arty-example/python 目录下的 raw.hex ,它的大小是 512kB 。

对比结果

下表展示对比结果。在指标中,↑代表越大越好, ↓代表越小越好

评价指标 软件压缩 本设计 HDL-deflate HT-Deflate-FPGA
支持 LZ77 ? :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
支持哈希表搜索 LZ77 ? :heavy_check_mark: :heavy_check_mark: :x: :heavy_check_mark:
支持动态 literal code tree ? :heavy_check_mark: :heavy_check_mark: :x: :x:
支持动态 distance code tree ? :heavy_check_mark: :heavy_check_mark: :x: :x:
支持动态 length code tree ? :heavy_check_mark: :x: :x: :x:
FPGA逻辑资源 (↓) - 8200×LUT 2854×LUT ? (较大)
FPGA存储资源 (↓) - 25×BRAM36K 8.5×BRAM36K ? (较大)
时钟频率 (↑) - 128 MHz 95 MHz ?
消耗时钟周期数 (↓) - 524288 1449901 ?
每周期输入字节数 (↑) - 1.0 0.36 ?
实际性能 (↑) 44 MB/s 128 MB/s 35 MB/s 10 GB/s 级别
功耗 (↓)
压缩后大小 (↓) 287 kB 299 kB 395 kB ?
压缩率 (↑) 44% 41% 23% 介于 23% 和 41% :warning:

:warning: HT-Deflate-FPGA 的压缩率应该高于 HDL-deflate ,但低于本设计。这是根据它所支持的算法特性分析出来的。

 

 

部署结果

gzip_compressor_top 在各种 FPGA 上实现的结果:

FPGA 系列 FPGA 型号 逻辑资源 逻辑资源(%) 片上存储 片上存储(%) 最高频率
Xilinx Artix-7 xc7a35ticsg324-1L 8218*LUT 40% 25*BRAM36K 50% 128 MHz
Xilinx Zynq-7 xc7z020clg484-1 8218*LUT 16% 25*BRAM36K 18% 128 MHz
Xilinx Virtex-7 xc7vx485tffg1761-1 8201*LUT 3% 25*BRAM36K 3% 160 MHz
Xilinx ZU+ xczu3eg-sbva484-2-e 8180*LUT 12% 24*BRAM36K 11% 280 MHz
Altera Cyclone4 EP4CE55F23C8 16807*LE 30% 807398 bits 34% 74 MHz

 

 

仿真

SIM 目录包含了 GZIP 压缩器的 testbench 源码。该 testbench 的框图如下:

testbench_diagram.png

 

其中随机数据包生成器 (tb_random_data_source.v) 会4种生成特性不同的数据包 (字节概率均匀分布的随机数据、字节概率非均匀分布的随机数据、随机连续变化的数据、稀疏数据) ,送入待测模块 (gzip_compressor_top) 进行压缩,然后 tb_save_result_to_file 模块会把压缩结果存入文件,每个独立的数据包存入一个独立的 .gz 文件。

tb_print_crc32 负责计算原始数据的 CRC32 并打印,注意:待测模块内部也会计算 CRC32 并封装入 GZIP 数据流,这两个 CRC32 计算器是独立的 (前者仅用于仿真,用来验证待测模块生成的 CRC32 是否正确)。你可以自行将仿真打印的 CRC32 与 生成的 GZIP 文件中的 CRC32 进行对比。

 

使用 iverilog 仿真

你可以按照以下步骤进行 iverilog 仿真:

  • 需要先安装 iverilog ,见教程:iverilog_usage
  • 然后直接双击 tb_gzip_compressor_run_iverilog.bat 文件就能运行仿真 (仅限Windows) 。tb_gzip_compressor_run_iverilog.bat 包含了执行 iverilog 仿真的命令。
  • 随机数据包生成器默认会生成 10 个数据包,你可以通过修改 tb_random_data_source.v 里的宏名 FILE_COUNT 来修改数量。在10个文件的情况下,仿真一般要运行十几分钟才能结束。
  • 仿真生成的 GZIP 压缩流会存放于 sim_data 目录 (你可以通过修改 tb_save_result_to_file.v 里的宏名 OUT_FILE_PATH 来修改存放的目录)
    • 你可以直接用 7ZIP 、WinRAR 等压缩软件来解压这些 .gz 文件。
  • 为了批量检查仿真生成的文件有没有格式错误, 可以运行 sim_data 目录里的 python 源文件 check_gz_file.py ,你需要在 sim_data 目录里打开命令行 (CMD) 用以下指令来运行:
python check_gz_file.py .

以上命令意为:对当前目录 . ,也即 sim_data 目录下的所有 .gz 文件进行批量检查。

使用其它仿真器

除了 iverilog ,你也可以用其它仿真器来仿真。只需要把 RTL 和 SIM 目录里的所有 .v 文件加入仿真工程,并以 tb_gzip_compressor.v 为仿真顶层进行仿真即可。

 

 

FPGA 部署运行

我提供了一个基于串口的 FPGA 部署运行示例,该工程跑在 Arty开发板 上 (该工程也全都是纯 RTL 设计,可以直接移植到其它 FPGA 型号上)。

该 FPGA 工程接收串口数据,将数据送入 GZIP 压缩器,并将得到的 GZIP 压缩数据流用串口发出去 (串口格式: 波特率115200, 无校验位)。

在电脑 (上位机) 上,编写了一个 python 程序,该程序的执行步骤是:

  • 从电脑的磁盘中读入一个文件 (用户通过命令行指定文件名);
  • 列出电脑上的所有串口,用户需要选择 FPGA 对应的串口 (如果只发现一个串口,则直接选择这个串口)
  • 将该文件的所有字节通过串口发给 FPGA;
  • 同时接收 FPGA 发来的数据;
  • 将接收到的数据存入一个 .gz 文件,相当于调用 FPGA 进行了文件压缩。
  • 最终,调用 python 的 gzip 库解压该 .gz 文件,并与原始数据相比,看是否相等。如果不相等则报错。

由于串口速度远小于 gzip_compressor_top 能达到的最高性能,因此该工程仅仅用于展示。要想让 gzip_compressor_top 发挥更高性能,需要用其它高速通信接口。

下图是该工程的框图。

fpga_test_diagram.png

 

有关该工程的文件:

  • Arty-example/RTL 里是 FPGA 工程源码 (除了 gzip_compressor_top 的源码,gzip_compressor_top 的源码在根目录的 ./RTL 里)
  • Arty-example/vivado 里是 vivado 工程
  • Arty-example/python 里是 python 上位机程序 (fpga_uart_gz_file.py)

FPGA 工程烧录后,在 Arty-example/python 目录下打开命令行,运行以下命令:

python fpga_uart_gz_file.py <需要压缩的文件名>

例如,运行以下命令来压缩 raw.hex :

python fpga_uart_gz_file.py raw.hex

如果压缩成功,会得到 raw.hex.gz 文件,且不会打印报错信息。

 

 

 

References

[1] RFC 1951 : DEFLATE Compressed Data Format Specification version 1.3. https://www.rfc-editor.org/rfc/rfc1951

[2] RFC 1952 : GZIP file format specification version 4.3. https://www.rfc-editor.org/rfc/rfc1952

[3] HDL-deflate : https://github.com/tomtor/HDL-deflate

[4] HT-Deflate-FPGA : https://github.com/UCLA-VAST/HT-Deflate-FPGA

GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> Copyright (C) <year> <name of author> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: <program> Copyright (C) <year> <name of author> This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <https://www.gnu.org/licenses/>. The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <https://www.gnu.org/licenses/why-not-lgpl.html>.

简介

FPGA-based GZIP (deflate) compressor. Input raw data and output standard GZIP format (as known as .gz file format). 基于 FPGA 的流式 GZIP 压缩器。输入原始数据,输出标准的 GZIP 格式,即常见的 .gz / .tar.gz 文件的格式。 展开 收起
Verilog 等 3 种语言
GPL-3.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/wangxuan95/FPGA-Gzip-compressor.git
git@gitee.com:wangxuan95/FPGA-Gzip-compressor.git
wangxuan95
FPGA-Gzip-compressor
FPGA-Gzip-compressor
main

搜索帮助

53164aa7 5694891 3bd8fe86 5694891