Skip to content

Commit

Permalink
modules/dbe: simplify Lz4 encoder, improve naming
Browse files Browse the repository at this point in the history
- Simplify Lz4 encoder by removing corner case handling required by Lz4
  block format. This allows to remove 1 FIFO, 2 FSM states, and a bunch
  of convoluted logic that can be easily moved to an external module.
- Hash function is factored out into a separate function
- Variable naming is improved

Signed-off-by: Roman Dobrodii <rdobrodii@antmicro.com>
  • Loading branch information
rdob-ant committed Aug 29, 2023
1 parent 8308c49 commit c7992e1
Show file tree
Hide file tree
Showing 4 changed files with 623 additions and 594 deletions.
4 changes: 1 addition & 3 deletions xls/modules/dbe/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ xls_dslx_library(
deps = [
":dbe_common_dslx",
"//xls/examples:ram_dslx",
# decoder is referenced by test code
":dbe_lz4_decoder_dslx",
],
)

Expand All @@ -136,7 +134,7 @@ xls_dslx_ir(
xls_ir_opt_ir(
name = "dbe_lz4_encoder_8k_opt_ir",
src = "dbe_lz4_encoder_8k_ir.ir",
top = "__lz4_encoder__encoder_8k__encoder_base_0__16_3_13_12_13_65536_8192_4_16_8_next",
top = "__lz4_encoder__encoder_8k__encoder_base_0__1_4_13_16_16_8_next",
ram_rewrites = [
":lz4_encoder_8k_ram1r1w_rewrites.textproto",
],
Expand Down
23 changes: 13 additions & 10 deletions xls/modules/dbe/common.x
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,24 @@ pub fn is_error(mark: Mark) -> bool {
}

pub enum TokenKind : u2 {
LITERAL = 0,
COPY_POINTER = 1,
MARK = 2,
UNMATCHED_SYMBOL = 0,
MATCHED_SYMBOL = 1,
MATCH = 2,
MARKER = 3,
}

pub struct Token<SYM_WIDTH: u32, PTR_WIDTH: u32, CNT_WIDTH: u32> {
pub struct Token<
SYMBOL_WIDTH: u32, MATCH_OFFSET_WIDTH: u32, MATCH_COUNT_WIDTH: u32
>{
kind: TokenKind,
literal: uN[SYM_WIDTH],
copy_pointer_offset: uN[PTR_WIDTH],
copy_pointer_count: uN[CNT_WIDTH],
symbol: uN[SYMBOL_WIDTH],
match_offset: uN[MATCH_OFFSET_WIDTH],
match_count: uN[MATCH_COUNT_WIDTH],
mark: Mark
}

pub struct PlainData<DATA_WIDTH: u32> {
is_mark: bool,
data: uN[DATA_WIDTH], // symbol
mark: Mark, // marker code
is_marker: bool,
data: uN[DATA_WIDTH],
mark: Mark,
}
Loading

0 comments on commit c7992e1

Please sign in to comment.