summaryrefslogtreecommitdiff
path: root/platform/wavelet3d/gfx_fpint_lane.sv
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2024-03-09 05:19:39 -0600
committerAlejandro Soto <alejandro@34project.org>2024-03-09 05:19:39 -0600
commit5737a5e27f63e284a9e0402cdab7f86d9194457d (patch)
tree99e615c1c86deb052371d46555f15e5a0fe1ffbe /platform/wavelet3d/gfx_fpint_lane.sv
parent0a9d2b7209ffeac4aaa55ed8bc5d333d2519db6e (diff)
platform/wavelet3d: implement floating-point min/max
Diffstat (limited to '')
-rw-r--r--platform/wavelet3d/gfx_fpint_lane.sv54
1 files changed, 42 insertions, 12 deletions
diff --git a/platform/wavelet3d/gfx_fpint_lane.sv b/platform/wavelet3d/gfx_fpint_lane.sv
index 8cb77a8..b52a393 100644
--- a/platform/wavelet3d/gfx_fpint_lane.sv
+++ b/platform/wavelet3d/gfx_fpint_lane.sv
@@ -25,6 +25,9 @@ module gfx_fpint_lane
put_mul_2,
zero_b_2,
zero_flags_2,
+ abs_3,
+ swap_3,
+ zero_min_3,
copy_flags_3,
int_signed_5,
copy_flags_6,
@@ -128,6 +131,9 @@ module gfx_fpint_lane
.clk(clk),
.in(mnorm_minmax),
.out(minmax_expdiff),
+ .abs(abs_3),
+ .swap(swap_3),
+ .zero_min(zero_min_3),
.copy_flags(copy_flags_3)
);
@@ -351,25 +357,44 @@ module gfx_fpint_lane_minmax
input logic clk,
input gfx::fpint_mnorm_minmax in,
- input logic copy_flags,
+ input logic abs,
+ swap,
+ zero_min,
+ copy_flags,
output gfx::fpint_minmax_expdiff out
);
import gfx::*;
+ logic abs_b_gt_abs_a, b_gt_a;
+
+ /* Wiki dice:
+ *
+ * A property of the single- and double-precision formats is that
+ * their encoding allows one to easily sort them without using
+ * floating-point hardware, as if the bits represented sign-magnitude
+ * integers, although it is unclear whether this was a design
+ * consideration (it seems noteworthy that the earlier IBM hexadecimal
+ * floating-point representation also had this property for normalized
+ * numbers).
+ */
+ assign abs_b_gt_abs_a = {in.b.exp, in.b.mant} > {in.a.exp, in.a.mant};
+
+ always_comb begin
+ unique case ({in.b.sign, in.a.sign})
+ 2'b00: b_gt_a = abs_b_gt_abs_a;
+ 2'b01: b_gt_a = 1;
+ 2'b10: b_gt_a = 0;
+ 2'b11: b_gt_a = abs_b_gt_abs_a;
+ endcase
+
+ if (abs)
+ b_gt_a = abs_b_gt_abs_a;
+ end
+
always_ff @(posedge clk) begin
- /* Wiki dice:
- *
- * A property of the single- and double-precision formats is that
- * their encoding allows one to easily sort them without using
- * floating-point hardware, as if the bits represented sign-magnitude
- * integers, although it is unclear whether this was a design
- * consideration (it seems noteworthy that the earlier IBM hexadecimal
- * floating-point representation also had this property for normalized
- * numbers).
- */
- if ({in.b.exp, in.b.mant} > {in.a.exp, in.a.mant}) begin
+ if (b_gt_a ^ swap) begin
out.max <= in.b;
out.min <= in.a;
out.max_class <= in.b_class;
@@ -381,6 +406,11 @@ module gfx_fpint_lane_minmax
out.min_class <= in.b_class;
end
+ if (zero_min) begin
+ out.min <= 0;
+ out.min_class <= classify_float(0);
+ end
+
out.guard <= in.guard;
out.round <= in.round;
out.sticky <= in.sticky;