Skip to content

Commit

Permalink
[hardware] Parametrize FPU support for lzc module in operand_queue.sv
Browse files Browse the repository at this point in the history
  • Loading branch information
Shafi10x authored and mp-17 committed Aug 23, 2024
1 parent 9a6be56 commit 4c0a102
Showing 1 changed file with 29 additions and 26 deletions.
55 changes: 29 additions & 26 deletions hardware/src/lane/operand_queue.sv
Original file line number Diff line number Diff line change
Expand Up @@ -155,42 +155,45 @@ module operand_queue import ara_pkg::*; import rvv_pkg::*; import cf_math_pkg::i
// Helper to fill with neutral values the last packet
logic incomplete_packet, last_packet;

// To convert subnormal numbers to normalized form in floating-point numbers,
// it is necessary to determine the number of leading zeros in the mantissa.
// This is typically accomplished using a lzc (leading zero count) module,
// which can accurately count the number of leading zeros in a given number.
// By knowing the number of leading zeros in the mantissa, we can properly
// adjust the exponent and shift the binary point to achieve a normalized
// representation of the number.

logic [3:0] lzc_count16[2];
logic [4:0] lzc_count32;

fp16_t fp16[2];
fp32_t fp32;

// sew: 16-bit
for (genvar i = 0; i < 2; i = i + 1) begin
if (FPUSupport != FPUSupportNone) begin
// To convert subnormal numbers to normalized form in floating-point numbers,
// it is necessary to determine the number of leading zeros in the mantissa.
// This is typically accomplished using a lzc (leading zero count) module,
// which can accurately count the number of leading zeros in a given number.
// By knowing the number of leading zeros in the mantissa, we can properly
// adjust the exponent and shift the binary point to achieve a normalized
// representation of the number.

// sew: 16-bit
for (genvar i = 0; i < 2; i = i + 1) begin
lzc #(
.WIDTH(10),
.MODE (1 )
) leading_zero_e16_i (
.in_i ( fp16[i].m ),
.cnt_o ( lzc_count16[i] ),
.empty_o ( /*Unused*/ )
);
end

// sew: 32-bit
lzc #(
.WIDTH(10),
.MODE (1 )
) leading_zero_e16_i (
.in_i ( fp16[i].m ),
.cnt_o ( lzc_count16[i] ),
.empty_o ( /*Unused*/ )
);
.WIDTH (23),
.MODE (1 )
) leading_zero_e32(
.in_i ( fp32.m ),
.cnt_o ( lzc_count32 ),
.empty_o ( /*Unused*/ )
);
end

// sew: 32-bit
lzc #(
.WIDTH (23),
.MODE (1 )
) leading_zero_e32(
.in_i ( fp32.m ),
.cnt_o ( lzc_count32 ),
.empty_o ( /*Unused*/ )
);

always_comb begin: type_conversion
// Shuffle the input operand
automatic logic [idx_width(StrbWidth)-1:0] select = deshuffle_index(select_q, 1, cmd.eew);
Expand Down

0 comments on commit 4c0a102

Please sign in to comment.