Commit 08370a57 authored by Claudiu Mihali's avatar Claudiu Mihali
Browse files

Added decompression in hw; need to optimize it

parent 0e97c14c
......@@ -91,6 +91,7 @@ reg [7:0] window_read_byte;
reg [$clog2(WORD_SIZE)-1:0] out_data_addr;
reg first_out_byte_flag = 1; // must be set every time I wait for a new BLOCK
reg read_delay_flag;
always @(posedge clk) begin
......@@ -200,8 +201,9 @@ always @(posedge clk) begin
end else begin
uncompressed_block_size[uncompressed_block_size_addr +: 7] <= cur_word[cur_byte_addr +: 7];
out_data[out_data_addr +: 7] <= cur_word[cur_byte_addr +: 7];
out_data_addr <= 32;
out_data_addr <= 16;
cur_byte_addr <= cur_byte_addr + 8;
prev_state <= GET_UNCOMPRESSED_BLOCK_SIZE;
state <= GET_BOUNDARY_BYTE;
end
end
......@@ -214,6 +216,9 @@ always @(posedge clk) begin
state <= WAIT_WORD;
end else begin
in_ready <= 0;
if (prev_state == GET_UNCOMPRESSED_BLOCK_SIZE) begin
out_data[0 +: 16] <= out_data[0 +: 16] + 2;
end
prev_state <= GET_BOUNDARY_BYTE;
case (cur_word[cur_byte_addr +: 2])
`LITERAL_TAG: begin
......
......@@ -21,10 +21,9 @@
module decompress_group_512to64
#(
parameter META_WIDTH = 96,
parameter MEMORY_WIDTH = 512,
parameter DECOMPRESS_MODE_SIZE = 8,
parameter DECOMPRESS_ENGINES_NO = 16,
parameter DECOMPRESS_ENGINES_NO = 24,
parameter VALUE_SIZE_BYTES_NO = 2,
localparam WORD_SIZE = 512,
localparam DECOMPRESS_WORD_SIZE = 64
......@@ -37,18 +36,18 @@ module decompress_group_512to64
input wire in_valid,
output reg in_ready,
input wire [1+META_WIDTH+MEMORY_WIDTH-1:0] in_predconf_data,
input wire in_predconf_valid,
output reg in_predconf_ready,
input wire [MEMORY_WIDTH-1:0] in_pred_data,
input wire in_pred_valid,
output reg in_pred_ready,
output reg [WORD_SIZE-1:0] out_data,
output reg out_valid,
output reg out_last,
input wire out_ready,
output reg [1+META_WIDTH+MEMORY_WIDTH-1:0] out_predconf_data,
output reg out_predconf_valid,
input wire out_predconf_ready
output reg [MEMORY_WIDTH-1:0] out_pred_data,
output reg out_pred_valid,
input wire out_pred_ready
);
reg [DECOMPRESS_MODE_SIZE-1:0] mode_data_buf;
......@@ -177,8 +176,8 @@ always @(posedge clk) begin
value_bytes_counter <= 0;
in_last <= 0;
in_ready <= 1;
in_predconf_ready <= 1;
out_predconf_valid <= 0;
in_pred_ready <= 1;
out_pred_valid <= 0;
out_valid <= 0;
out_last <= 0;
out_data <= 0;
......@@ -196,26 +195,25 @@ always @(posedge clk) begin
in_data_decompress <= 0;
end else begin
// mode data round-robin logic
if (in_predconf_valid == 1 && in_predconf_ready == 1) begin
if (in_predconf_data[1+META_WIDTH +: 8*VALUE_SIZE_BYTES_NO] == 0 || in_predconf_data[1+META_WIDTH +: 8*VALUE_SIZE_BYTES_NO] == 2) begin
if (in_pred_valid == 1 && in_pred_ready == 1) begin
if (in_pred_data[0 +: 8*VALUE_SIZE_BYTES_NO] == 0 || in_pred_data[0 +: 8*VALUE_SIZE_BYTES_NO] == 2) begin
mode_data_buf <= 0;
out_predconf_data[1+META_WIDTH +: MEMORY_WIDTH] <= in_predconf_data[1+META_WIDTH +: MEMORY_WIDTH];
out_pred_data <= in_pred_data;
end else begin
mode_data_buf <= in_predconf_data[1+META_WIDTH+8*VALUE_SIZE_BYTES_NO +: DECOMPRESS_MODE_SIZE];
out_predconf_data[1+META_WIDTH +: 8*VALUE_SIZE_BYTES_NO] <= in_predconf_data[1+META_WIDTH +: 8*VALUE_SIZE_BYTES_NO] - 1;
out_predconf_data[1+META_WIDTH+8*VALUE_SIZE_BYTES_NO +: MEMORY_WIDTH-8*VALUE_SIZE_BYTES_NO] <= // shift
in_predconf_data[1+META_WIDTH+8*VALUE_SIZE_BYTES_NO+DECOMPRESS_MODE_SIZE +: MEMORY_WIDTH-8*VALUE_SIZE_BYTES_NO-DECOMPRESS_MODE_SIZE];
mode_data_buf <= in_pred_data[8*VALUE_SIZE_BYTES_NO +: DECOMPRESS_MODE_SIZE];
out_pred_data[0 +: 8*VALUE_SIZE_BYTES_NO] <= in_pred_data[0 +: 8*VALUE_SIZE_BYTES_NO] - DECOMPRESS_MODE_SIZE/8;
out_pred_data[8*VALUE_SIZE_BYTES_NO +: MEMORY_WIDTH-8*VALUE_SIZE_BYTES_NO] <= // shift
in_pred_data[8*VALUE_SIZE_BYTES_NO+DECOMPRESS_MODE_SIZE +: MEMORY_WIDTH-8*VALUE_SIZE_BYTES_NO-DECOMPRESS_MODE_SIZE];
end
in_predconf_ready <= 0;
in_pred_ready <= 0;
mode_valids[cur_in_engine_addr] <= 1;
out_predconf_data[0 +: 1+META_WIDTH] <= in_predconf_data[0 +: 1+META_WIDTH];
out_predconf_valid <= 1;
out_pred_valid <= 1;
end else begin
if (mode_readys[cur_in_engine_addr] == 1) begin
mode_valids <= 0;
end
if (out_predconf_valid == 1 && out_predconf_ready == 1) begin
out_predconf_valid <= 0;
if (out_pred_valid == 1 && out_pred_ready == 1) begin
out_pred_valid <= 0;
end
end
......@@ -253,6 +251,10 @@ always @(posedge clk) begin
in_valids[cur_in_engine_addr] <= 1;
in_data_buf_addr <= in_data_buf_addr + DECOMPRESS_WORD_SIZE;
if (in_data_buf_addr == WORD_SIZE - DECOMPRESS_WORD_SIZE) begin
in_ready <= 1;
end
if (value_bytes_counter <= DECOMPRESS_WORD_SIZE/8) begin
in_last <= 1;
first_word_flag <= 1;
......@@ -267,7 +269,7 @@ always @(posedge clk) begin
in_valids <= 0;
if (in_last == 1) begin
in_last <= 0;
in_predconf_ready <= 1;
in_pred_ready <= 1;
if (cur_in_engine_addr == DECOMPRESS_ENGINES_NO-1) begin
cur_in_engine_addr <= 0;
end else begin
......
......@@ -1711,6 +1711,15 @@ wire cond_valid;
wire cond_ready;
wire cond_drop;
wire [511:0] value_read_data_decompress;
wire value_read_valid_decompress;
wire value_read_last_decompress;
wire value_read_ready_decompress;
wire [511:0] pred_data_decompress;
wire pred_valid_decompress;
wire pred_ready_decompress;
generate
if (PRIVACY_ENABLED==0) begin
//no filters in the project, cuts out whole part
......@@ -1725,26 +1734,47 @@ generate
end
else begin
//need to wire in filters
decompress_group_512to64 decompressor (
.clk(clk),
.rst(rst),
.in_data(value_read_data_buf),
.in_valid(value_read_valid_buf),
.in_ready(value_read_ready_buf),
.in_pred_data(predconf_b_data[EXT_META_WIDTH +: MEMORY_WIDTH]),
.in_pred_valid(predconf_b_valid),
.in_pred_ready(predconf_b_ready),
.out_data(value_read_data_decompress),
.out_valid(value_read_valid_decompress),
.out_last(value_read_last_decompress),
.out_ready(value_read_ready_decompress),
.out_pred_data(pred_data_decompress),
.out_pred_valid(pred_valid_decompress),
.out_pred_ready(pred_ready_decompress)
);
nukv_Privacy_Pipeline priv_pipe (
.clk(clk),
.rst(rst),
.pred_data(predconf_b_data[EXT_META_WIDTH +: MEMORY_WIDTH]),
.pred_valid(predconf_b_valid),
.pred_ready(predconf_b_ready),
.pred_data(pred_data_decompress),
.pred_valid(pred_valid_decompress),
.pred_ready(pred_ready_decompress),
.value_data(value_read_data_buf),
.value_valid(value_read_valid_buf),
.value_ready(value_read_ready_buf),
.value_data(value_read_data_decompress),
.value_valid(value_read_valid_decompress),
.value_last(value_read_last_decompress),
.value_ready(value_read_ready_decompress),
.output_valid(value_frompipe_valid),
.output_ready(value_frompipe_ready),
.output_data(value_frompipe_data),
.output_last(value_frompipe_last)
);
);
assign value_frompipe_drop = 0;
......
......@@ -3,8 +3,7 @@ module ColToRow
parameter MEMORY_WIDTH = 512, // constraint: 8 * (VALUE_SIZE_BYTES_NO + VALUE_HEADER_BYTES_NO) <= MEMORY_WIDTH
parameter COL_COUNT = 3,
parameter COL_WIDTH = 64,
parameter VALUE_SIZE_BYTES_NO = 2,
parameter VALUE_HEADER_BYTES_NO = 3
parameter VALUE_SIZE_BYTES_NO = 2
)
(
input wire clk,
......@@ -128,24 +127,24 @@ always @(posedge clk) begin
if (buffer_output_ready[idx] == 0 && assembled_valid_pre[idx] == 0) begin
if (first_word_flag[idx] == 1) begin
// we have to strip the page header whose size is not always the same
if (colword_buf[idx][8*(VALUE_SIZE_BYTES_NO+VALUE_HEADER_BYTES_NO) +: 16] == 16'h0002) begin
value_bytes_counter[idx] <= colword_buf[idx][0 +: 8*VALUE_SIZE_BYTES_NO] - VALUE_SIZE_BYTES_NO - VALUE_HEADER_BYTES_NO - 6;
colword_addr[idx] <= 8 * (VALUE_SIZE_BYTES_NO + VALUE_HEADER_BYTES_NO + 6);
// HACK: there are some unwanted bytes in the beginning of the page
if (colword_buf[idx][8*VALUE_SIZE_BYTES_NO +: 8] == 8'h02) begin
value_bytes_counter[idx] <= colword_buf[idx][0 +: 8*VALUE_SIZE_BYTES_NO] - VALUE_SIZE_BYTES_NO - 6;
colword_addr[idx] <= 8 * (VALUE_SIZE_BYTES_NO + 6);
first_word_flag[idx] <= 0;
if (idx == 0) begin
value_size_data <= colword_buf[idx][0 +: 8*VALUE_SIZE_BYTES_NO] - VALUE_HEADER_BYTES_NO - 6;
value_size_data <= colword_buf[idx][0 +: 8*VALUE_SIZE_BYTES_NO] - 6;
end
offset[idx] <= (MEMORY_WIDTH/8-(VALUE_SIZE_BYTES_NO+VALUE_HEADER_BYTES_NO + 6)) % (COL_WIDTH/8);
offset[idx] <= (MEMORY_WIDTH/8-(VALUE_SIZE_BYTES_NO + 6)) % (COL_WIDTH/8);
end else begin
if (colword_buf[idx][8*(VALUE_SIZE_BYTES_NO+VALUE_HEADER_BYTES_NO) +: 16] == 16'h0300) begin
value_bytes_counter[idx] <= colword_buf[idx][0 +: 8*VALUE_SIZE_BYTES_NO] - VALUE_SIZE_BYTES_NO - VALUE_HEADER_BYTES_NO - 8;
colword_addr[idx] <= 8 * (VALUE_SIZE_BYTES_NO + VALUE_HEADER_BYTES_NO + 8);
if (colword_buf[idx][8*VALUE_SIZE_BYTES_NO +: 8] == 8'h03) begin
value_bytes_counter[idx] <= colword_buf[idx][0 +: 8*VALUE_SIZE_BYTES_NO] - VALUE_SIZE_BYTES_NO - 7;
colword_addr[idx] <= 8 * (VALUE_SIZE_BYTES_NO + 7);
first_word_flag[idx] <= 0;
if (idx == 0) begin
value_size_data <= colword_buf[idx][0 +: 8*VALUE_SIZE_BYTES_NO] - VALUE_HEADER_BYTES_NO - 8;
value_size_data <= colword_buf[idx][0 +: 8*VALUE_SIZE_BYTES_NO] - 7;
end
offset[idx] <= (MEMORY_WIDTH/8-(VALUE_SIZE_BYTES_NO+VALUE_HEADER_BYTES_NO + 8)) % (COL_WIDTH/8);
offset[idx] <= (MEMORY_WIDTH/8-(VALUE_SIZE_BYTES_NO + 7)) % (COL_WIDTH/8);
end
end
end else begin
......
......@@ -21,8 +21,7 @@ module nukv_Privacy_Pipeline
parameter MEMORY_WIDTH = 512,
parameter COL_COUNT = 3,
parameter COL_WIDTH = 64,
parameter VALUE_SIZE_BYTES_NO = 2,
parameter VALUE_HEADER_BYTES_NO = 41
parameter VALUE_SIZE_BYTES_NO = 2
)
(
input wire clk,
......@@ -34,6 +33,7 @@ module nukv_Privacy_Pipeline
(* mark_debug = "true" *)input wire [MEMORY_WIDTH-1:0] value_data,
(* mark_debug = "true" *)input wire value_valid,
(* mark_debug = "true" *)input wire value_last,
(* mark_debug = "true" *)output wire value_ready,
(* mark_debug = "true" *)output wire [MEMORY_WIDTH-1:0] output_data,
......@@ -162,19 +162,24 @@ module nukv_Privacy_Pipeline
assign ic_ready = ic_ready_fifo & seg_valid & seg_last & seg_ready;
assign ic_valid_masked = ic_valid & ic_ready;
assign seg_data = value_data;
assign seg_valid = segmenter_valid;
assign seg_last = value_last;
assign segmenter_ready = seg_ready;
nukv_Value_Segmenter segmenter (
.clk(clk),
.rst(rst),
.value_data(value_data),
.value_valid(segmenter_valid),
.value_ready(segmenter_ready),
// nukv_Value_Segmenter segmenter (
// .clk(clk),
// .rst(rst),
// .value_data(value_data),
// .value_valid(segmenter_valid),
// .value_ready(segmenter_ready),
.output_data(seg_data),
.output_last(seg_last),
.output_valid(seg_valid),
.output_ready(seg_ready)
);
// .output_data(seg_data),
// .output_last(seg_last),
// .output_valid(seg_valid),
// .output_ready(seg_ready)
// );
assign imed_data[0] = seg_data;
assign imed_last[0] = seg_last;
......@@ -224,8 +229,7 @@ module nukv_Privacy_Pipeline
.MEMORY_WIDTH(MEMORY_WIDTH),
.COL_COUNT(COL_COUNT),
.COL_WIDTH(COL_WIDTH),
.VALUE_SIZE_BYTES_NO(VALUE_SIZE_BYTES_NO),
.VALUE_HEADER_BYTES_NO(VALUE_HEADER_BYTES_NO)
.VALUE_SIZE_BYTES_NO(VALUE_SIZE_BYTES_NO)
) rotation_perturb (
.clk(clk),
.rst(rst),
......
......@@ -3,8 +3,7 @@ module nukv_Rotation_Module
parameter MEMORY_WIDTH = 512,
parameter COL_COUNT = 3,
parameter COL_WIDTH = 64,
parameter VALUE_SIZE_BYTES_NO = 2,
parameter VALUE_HEADER_BYTES_NO = 49
parameter VALUE_SIZE_BYTES_NO = 2
)
(
input wire clk,
......@@ -52,8 +51,7 @@ module nukv_Rotation_Module
.MEMORY_WIDTH(MEMORY_WIDTH),
.COL_COUNT(COL_COUNT),
.COL_WIDTH(COL_WIDTH),
.VALUE_SIZE_BYTES_NO(VALUE_SIZE_BYTES_NO),
.VALUE_HEADER_BYTES_NO(VALUE_HEADER_BYTES_NO)
.VALUE_SIZE_BYTES_NO(VALUE_SIZE_BYTES_NO)
) col_to_row (
.clk(clk),
.rst(rst),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment