minor update

This commit is contained in:
Blaise Tine
2021-01-10 22:03:23 -08:00
parent e770824d47
commit 7e93d253f2
7 changed files with 174 additions and 39 deletions

View File

@@ -1,5 +1,8 @@
`include "VX_define.vh"
/// Modified port of cast module from fpnew Libray
/// reference: https://github.com/pulp-platform/fpnew
`ifndef SYNTHESIS
`include "float_dpi.vh"
`endif
@@ -91,14 +94,14 @@ module VX_fp_cvt #(
wire [LANES-1:0] mant_is_zero; // for integer zeroes
for (genvar i = 0; i < LANES; ++i) begin
// Leading zero counter for cancellations
wire mant_is_nonzero;
VX_lzc #(
.DATAW (INT_MAN_WIDTH)
.WIDTH (INT_MAN_WIDTH),
.MODE (1)
) lzc (
.data_in (encoded_mant[i]),
.data_out (renorm_shamt[i]),
.valid_out (mant_is_nonzero)
.in_i (encoded_mant[i]),
.cnt_o (renorm_shamt[i]),
.valid_o (mant_is_nonzero)
);
assign mant_is_zero[i] = ~mant_is_nonzero;
end

View File

@@ -38,6 +38,27 @@ module VX_fp_div #(
);
for (genvar i = 0; i < LANES; i++) begin
`ifdef VERILATOR
reg [31:0] r;
fflags_t f;
always @(*) begin
dpi_fdiv (dataa[i], datab[i], frm, r, f);
end
`UNUSED_VAR (f)
VX_shift_register #(
.DATAW (32),
.DEPTH (`LATENCY_FDIV),
.RESETW (1)
) shift_req_dpi (
.clk (clk),
.reset (_reset),
.enable (enable),
.data_in (r),
.data_out (result[i])
);
`else
acl_fdiv fdiv (
.clk (clk),
.areset (_reset),
@@ -46,6 +67,7 @@ module VX_fp_div #(
.b (datab[i]),
.q (result[i])
);
`endif
end
VX_shift_register #(

View File

@@ -59,6 +59,27 @@ module VX_fp_fma #(
end
end
`ifdef VERILATOR
reg [31:0] r;
fflags_t f;
always @(*) begin
dpi_fmadd (a, b, c, frm, r, f);
end
`UNUSED_VAR (f)
VX_shift_register #(
.DATAW (32),
.DEPTH (`LATENCY_FMA),
.RESETW (1)
) shift_req_dpi (
.clk (clk),
.reset (reset),
.enable (enable),
.data_in (r),
.data_out (result[i])
);
`else
acl_fmadd fmadd (
.clk (clk),
.areset (reset),
@@ -68,6 +89,7 @@ module VX_fp_fma #(
.c (c),
.q (result[i])
);
`endif
end
VX_shift_register #(

View File

@@ -1,5 +1,8 @@
`include "VX_define.vh"
/// Modified port of noncomp module from fpnew Libray
/// reference: https://github.com/pulp-platform/fpnew
module VX_fp_ncomp #(
parameter TAGW = 1,
parameter LANES = 1
@@ -87,7 +90,8 @@ module VX_fp_ncomp #(
VX_pipe_register #(
.DATAW (1 + TAGW + `FPU_BITS + `FRM_BITS + LANES * (2 * 32 + 1 + 1 + 8 + 23 + 2 * $bits(fp_type_t) + 1 + 1)),
.RESETW (1)
.RESETW (1),
.DEPTH (0)
) pipe_reg0 (
.clk (clk),
.reset (reset),

View File

@@ -1,6 +1,9 @@
`include "VX_define.vh"
/// Modified port of rouding module from fpnew Libray
/// reference: https://github.com/pulp-platform/fpnew
module VX_fp_rounding #(
parameter DAT_WIDTH = 2 // Width of the abolute value, without sign bit
) (
@@ -17,17 +20,17 @@ module VX_fp_rounding #(
output wire exact_zero_o // output is an exact zero
);
reg round_up; // Rounding decision
reg round_up; // Rounding decision
// Take the rounding decision according to RISC-V spec
// RoundMode | Mnemonic | Meaning
// :--------:|:--------:|:-------
// 000 | RNE | Round to Nearest, ties to Even
// 001 | RTZ | Round towards Zero
// 010 | RDN | Round Down (towards -\infty)
// 011 | RUP | Round Up (towards \infty)
// 100 | RMM | Round to Nearest, ties to Max Magnitude
// others | | *invalid*
// Take the rounding decision according to RISC-V spec
// RoundMode | Mnemonic | Meaning
// :--------:|:--------:|:-------
// 000 | RNE | Round to Nearest, ties to Even
// 001 | RTZ | Round towards Zero
// 010 | RDN | Round Down (towards -\infty)
// 011 | RUP | Round Up (towards \infty)
// 100 | RMM | Round to Nearest, ties to Max Magnitude
// others | | *invalid*
always @(*) begin
case (rnd_mode_i)
@@ -47,15 +50,15 @@ module VX_fp_rounding #(
endcase
end
// Perform the rounding, exponent change and overflow to inf happens automagically
assign abs_rounded_o = abs_value_i + DAT_WIDTH'(round_up);
// Perform the rounding, exponent change and overflow to inf happens automagically
assign abs_rounded_o = abs_value_i + DAT_WIDTH'(round_up);
// True zero result is a zero result without dirty round/sticky bits
assign exact_zero_o = (abs_value_i == 0) && (round_sticky_bits_i == 0);
// True zero result is a zero result without dirty round/sticky bits
assign exact_zero_o = (abs_value_i == 0) && (round_sticky_bits_i == 0);
// In case of effective subtraction (thus signs of addition operands must have differed) and a
// true zero result, the result sign is '-' in case of RDN and '+' for other modes.
assign sign_o = (exact_zero_o && effective_subtraction_i) ? (rnd_mode_i == `FRM_RDN)
: sign_i;
// In case of effective subtraction (thus signs of addition operands must have differed) and a
// true zero result, the result sign is '-' in case of RDN and '+' for other modes.
assign sign_o = (exact_zero_o && effective_subtraction_i) ? (rnd_mode_i == `FRM_RDN)
: sign_i;
endmodule

View File

@@ -37,6 +37,27 @@ module VX_fp_sqrt #(
);
for (genvar i = 0; i < LANES; i++) begin
`ifdef VERILATOR
reg [31:0] r;
fflags_t f;
always @(*) begin
dpi_fsqrt (dataa[i], frm, r, f);
end
`UNUSED_VAR (f)
VX_shift_register #(
.DATAW (32),
.DEPTH (`LATENCY_FSQRT),
.RESETW (1)
) shift_req_dpi (
.clk (clk),
.reset (_reset),
.enable (enable),
.data_in (r),
.data_out (result[i])
);
`else
acl_fsqrt fsqrt (
.clk (clk),
.areset (_reset),
@@ -44,6 +65,7 @@ module VX_fp_sqrt #(
.a (dataa[i]),
.q (result[i])
);
`endif
end
VX_shift_register #(