2021-10-06 13:26:09 +00:00
|
|
|
///////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Written: James Stine
|
|
|
|
// Modified: 8/1/2018
|
|
|
|
//
|
|
|
|
// Purpose: Bipartite Lookup for divide portion of fpdivsqrt
|
|
|
|
//
|
|
|
|
// A component of the Wally configurable RISC-V project.
|
|
|
|
//
|
|
|
|
// Copyright (C) 2021 Harvey Mudd College & Oklahoma State University
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
|
|
|
// files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
|
|
|
// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
|
|
|
|
// is furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
|
|
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
|
|
|
|
// OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
///////////////////////////////////////////
|
|
|
|
|
2021-07-19 12:59:27 +00:00
|
|
|
module sbtm_div (input logic [11:0] a, output logic [10:0] ia_out);
|
2021-04-04 18:09:13 +00:00
|
|
|
|
2021-07-18 18:03:37 +00:00
|
|
|
// bit partitions
|
|
|
|
logic [3:0] x0;
|
|
|
|
logic [2:0] x1;
|
|
|
|
logic [3:0] x2;
|
|
|
|
logic [2:0] x2_1cmp;
|
|
|
|
// mem outputs
|
|
|
|
logic [12:0] y0;
|
2021-07-24 18:59:57 +00:00
|
|
|
logic [4:0] y1;
|
2021-07-18 18:03:37 +00:00
|
|
|
// input to CPA
|
|
|
|
logic [14:0] op1;
|
|
|
|
logic [14:0] op2;
|
|
|
|
logic [14:0] p;
|
2021-07-24 18:59:57 +00:00
|
|
|
logic cout;
|
2021-04-04 18:09:13 +00:00
|
|
|
|
2021-07-18 18:03:37 +00:00
|
|
|
assign x0 = a[10:7];
|
|
|
|
assign x1 = a[6:4];
|
|
|
|
assign x2 = a[3:0];
|
2021-04-04 18:09:13 +00:00
|
|
|
|
2021-07-18 18:03:37 +00:00
|
|
|
sbtm_a0 mem1 ({x0, x1}, y0);
|
|
|
|
// 1s cmp per sbtm/stam
|
|
|
|
assign x2_1cmp = x2[3] ? ~x2[2:0] : x2[2:0];
|
|
|
|
sbtm_a1 mem2 ({x0, x2_1cmp}, y1);
|
|
|
|
assign op1 = {1'b0, y0, 1'b0};
|
|
|
|
// 1s cmp per sbtm/stam
|
|
|
|
assign op2 = x2[3] ? {1'b1, {8{1'b1}}, ~y1, 1'b1} :
|
|
|
|
{1'b0, 8'b0, y1, 1'b1};
|
2021-07-24 18:59:57 +00:00
|
|
|
// CPA
|
2021-07-18 18:03:37 +00:00
|
|
|
assign {cout, p} = op1 + op2;
|
|
|
|
assign ia_out = p[14:4];
|
2021-04-04 18:09:13 +00:00
|
|
|
|
2021-07-18 18:03:37 +00:00
|
|
|
endmodule // sbtm
|