diff --git a/hw/Makefile b/hw/Makefile index 0c80fa2b89d285115efd8fd734c546042f3edfbc..4cdc45b3eb934297aa8035e87e5d95b65687bb5f 100644 --- a/hw/Makefile +++ b/hw/Makefile @@ -39,7 +39,7 @@ mul-6w64-tb: add-gp.vl add-bk8.vl add-bk8s.vl \ add-h64.vl mul6-stage.vl mul-6w64.vl mul64-tb.vl # When re-enabling add_h64: add-gp.vl add-h64.vl -srt-reciprocal-tb: add-bk8.vl add-bk8s.vl srt-reciprocal.vl +srt-reciprocal-tb: add-bk8.vl add-bk8s.vl carry-64.vl srt-reciprocal.vl genmask-tb: genmask.vl ctz-tb: ctz.vl diff --git a/hw/cpu-all.vl b/hw/cpu-all.vl index 072e39a62cac6f4f6aad88d434cea0124b30ffbe..0ddbc92ab424e2673bfc494d78bdeb09cd29cd37 100644 --- a/hw/cpu-all.vl +++ b/hw/cpu-all.vl @@ -36,9 +36,10 @@ `include "instr-fetch.vl" `include "ctz.vl" `include "popc.vl" -`include "srt-reciprocal.vl" `include "add-gp.vl" `include "add-bk8.vl" `include "add-bk8s.vl" `include "add-h64.vl" +`include "carry-64.vl" +`include "srt-reciprocal.vl" `include "cpu.vl" diff --git a/hw/srt-reciprocal-tb.vl b/hw/srt-reciprocal-tb.vl index 228e3bff5cb6de51cb45c56e12c63a5bab6627a1..8d5f16ac7d55f8376e190566402f5a95d207c8e9 100644 --- a/hw/srt-reciprocal-tb.vl +++ b/hw/srt-reciprocal-tb.vl @@ -18,6 +18,7 @@ `include "add-bk8.vl" `include "add-bk8s.vl" `include "add-h64.vl" +`include "carry-64.vl" `include "srt-reciprocal.vl" module main; diff --git a/hw/srt-reciprocal.vl b/hw/srt-reciprocal.vl index 718d3fc15556f748579b017e50b78edae37394df..171f80b94b459a7f6af68e1cdb299edb1ecdb371 100644 --- a/hw/srt-reciprocal.vl +++ b/hw/srt-reciprocal.vl @@ -73,8 +73,8 @@ module srt_final_q (input [2*n-1:0] q, input adjust, output [n-1:0] out); end endgenerate - assign out = q_pos + q_neg + !adjust; - // add_h64 add (q_pos, q_neg, !adjust, {dummy, out}); + // assign out = q_pos + q_neg + !adjust; + add_h64 add (q_pos, q_neg, !adjust, {dummy, out}); endmodule // srt_final_q // NOTE: Requires d input to be kept stable, in reciprocal_unit it is @@ -94,7 +94,7 @@ module srt_reciprocal(input clk, input rst, input enable, wire [1:0] q; wire [n:0] s; wire [n-3:2] c; - wire [n:1] p; + wire carry; always @(posedge clk) begin if (rst) begin @@ -123,12 +123,9 @@ module srt_reciprocal(input clk, input rst, input enable, srt_qsel qsel(s_reg[n:n-3], q); srt_update #(n) update({s_reg[n-1:0], 1'b1}, c_reg, d, q, s, c); - /* FIXME: Only need sign bit from this addition. Should be arranged - so we get the resulting sign from a Kogge-Stone tree, in - parallel with most of the addition work to construct q, with - only final carry-select logic remaining when the sign is ready. - */ - assign p = s_reg[n:1] + {3'b0, c_reg}; + /* Only need sign bit from this addition */ + carry_64 carry_adjust({s_reg[n-1:1], 1'b0}, {3'b0, c_reg, 1'b0}, 1'b0, carry); - srt_final_q #(n) final_q (q_reg, p[n], q_out); + /* Construct sign as carry ^ s_reg[n] */ + srt_final_q #(n) final_q (q_reg, carry ^ s_reg[n], q_out); endmodule // srt_reciprocal