Skip to content

Commit

Permalink
modules/zstd: Add FSE probability frequency decoder
Browse files Browse the repository at this point in the history
Internal-tag: [#55149]
Signed-off-by: Robert Winkler <rwinkler@antmicro.com>
  • Loading branch information
rw1nkler committed Mar 28, 2024
1 parent 8824cf8 commit f2a9d34
Show file tree
Hide file tree
Showing 3 changed files with 713 additions and 1 deletion.
16 changes: 16 additions & 0 deletions xls/modules/zstd/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -677,3 +677,19 @@ xls_dslx_test(
},
library = ":shift_buffer_dslx",
)

xls_dslx_library(
name = "fse_proba_freq_dec_dslx",
srcs = ["fse_proba_freq_dec.x"],
deps = [
":shift_buffer_dslx",
":common_dslx",
"//xls/examples:ram_dslx",
],
)

xls_dslx_test(
name = "fse_proba_freq_dec_dslx_test",
dslx_test_args = {"compare": "none"},
library = ":fse_proba_freq_dec_dslx",
)
32 changes: 31 additions & 1 deletion xls/modules/zstd/common.x
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ pub const DATA_WIDTH = u32:64;
pub const MAX_ID = u32::MAX;
pub const SYMBOL_WIDTH = u32:8;
pub const BLOCK_SIZE_WIDTH = u32:21;
pub const BLOCK_PACKET_WIDTH = u32:32;
pub const FSE_MAX_SYMBOLS = u32:256;
pub const FSE_MAX_ACCURACY_LOG = u32:9;

pub type BlockData = bits[DATA_WIDTH];
pub type BlockPacketLength = u32;
pub type BlockPacketLength = bits[BLOCK_PACKET_WIDTH];
pub type BlockSize = bits[BLOCK_SIZE_WIDTH];
pub type CopyOrMatchContent = BlockData;
pub type CopyOrMatchLength = u64;
Expand Down Expand Up @@ -54,3 +57,30 @@ pub struct SequenceExecutorPacket {
content: CopyOrMatchContent, // Literal data or match offset
last: bool, // Last packet in frame
}

pub enum CompressionMode : u2 {
PredefinedMode = 0,
RLEMode = 1,
FSECompressedMode = 2,
RepeatMode = 3,
}

pub struct SequenceConf {
sequence_count: u17,
literals_mode: CompressionMode,
offset_mode: CompressionMode,
match_mode: CompressionMode,
}

pub struct SequencePathCtrl {
literals_count: u20,
last_block: bool,
id: u32,
sequence_conf: SequenceConf,
}

pub struct SequenceData {
bytes: bits[64],
length: u32,
last: bool,
}

0 comments on commit f2a9d34

Please sign in to comment.