mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Updated radix 2 divider to work with integers and floats in new structure. Integers still might not work.
This commit is contained in:
parent
54938c7abf
commit
3a40c68549
@ -1 +1 @@
|
|||||||
Subproject commit be67c99bd461742aa1c100bcc0732657faae2230
|
Subproject commit 307c77b26e070ae85ffea665ad9b642b40e33c86
|
@ -94,9 +94,9 @@
|
|||||||
`define BIAS2 ((`F_SUPPORTED & (`LEN1 != `S_LEN)) ? `S_BIAS : `H_BIAS)
|
`define BIAS2 ((`F_SUPPORTED & (`LEN1 != `S_LEN)) ? `S_BIAS : `H_BIAS)
|
||||||
|
|
||||||
// largest length in IEU/FPU
|
// largest length in IEU/FPU
|
||||||
`define CVTLEN ((`NF<`XLEN) ? `XLEN : `NF)
|
`define CVTLEN ((`NF<`XLEN) ? (`XLEN) : (`NF))
|
||||||
`define DIVLEN ((`NF < `XLEN) ? `XLEN : `NF)
|
`define DIVLEN ((`NF < `XLEN) ? (`XLEN) : (`NF))
|
||||||
`define LLEN ((`FLEN<`XLEN) ? `XLEN : `FLEN)
|
`define LLEN ((`FLEN<`XLEN) ? (`XLEN) : (`FLEN))
|
||||||
`define LOGCVTLEN $unsigned($clog2(`CVTLEN+1))
|
`define LOGCVTLEN $unsigned($clog2(`CVTLEN+1))
|
||||||
`define NORMSHIFTSZ ((`DIVLEN+`NF+3) > (3*`NF+8) ? (`DIVLEN+`NF+3) : (3*`NF+9))
|
`define NORMSHIFTSZ ((`DIVLEN+`NF+3) > (3*`NF+8) ? (`DIVLEN+`NF+3) : (3*`NF+9))
|
||||||
`define CORRSHIFTSZ ((`DIVLEN+`NF+3) > (3*`NF+8) ? (`DIVLEN+`NF+3) : (3*`NF+6))
|
`define CORRSHIFTSZ ((`DIVLEN+`NF+3) > (3*`NF+8) ? (`DIVLEN+`NF+3) : (3*`NF+6))
|
||||||
|
@ -46,7 +46,7 @@ void main(void)
|
|||||||
int i, j;
|
int i, j;
|
||||||
int bias = 1023;
|
int bias = 1023;
|
||||||
|
|
||||||
if ((fptr = fopen("testvectors","w")) == NULL) {
|
if ((fptr = fopen("testvectors","w")) == NULL) {
|
||||||
fprintf(stderr, "Couldn't write testvectors file\n");
|
fprintf(stderr, "Couldn't write testvectors file\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// srt.sv
|
// srt.sv
|
||||||
//
|
//
|
||||||
// Written: David_Harris@hmc.edu 13 January 2022
|
// Written: David_Harris@hmc.edu 13 January 2022
|
||||||
// Modified:
|
// Modified: cturek@hmc.edu June 2022
|
||||||
//
|
//
|
||||||
// Purpose: Combined Divide and Square Root Floating Point and Integer Unit
|
// Purpose: Combined Divide and Square Root Floating Point and Integer Unit
|
||||||
//
|
//
|
||||||
@ -29,10 +29,8 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
`include "wally-config.vh"
|
`include "wally-config.vh"
|
||||||
|
`define EXTRAFRACBITS ((`NF<(`XLEN)) ? (`XLEN - `NF) : 0)
|
||||||
`define DIVLEN ((`NF<(`XLEN+1)) ? (`XLEN + 1) : `NF)
|
`define EXTRAINTBITS ((`NF<(`XLEN)) ? 0 : (`NF - `XLEN))
|
||||||
`define EXTRAFRACBITS ((`NF<(`XLEN+1)) ? (`XLEN - `NF + 1) : 0)
|
|
||||||
`define EXTRAINTBITS ((`NF<(`XLEN+1)) ? 0 : (`NF - `XLEN))
|
|
||||||
|
|
||||||
module srt (
|
module srt (
|
||||||
input logic clk,
|
input logic clk,
|
||||||
@ -131,11 +129,11 @@ module srtpreproc (
|
|||||||
lzc #(`XLEN) lzcA (PosA, zeroCntA);
|
lzc #(`XLEN) lzcA (PosA, zeroCntA);
|
||||||
lzc #(`XLEN) lzcB (PosB, zeroCntB);
|
lzc #(`XLEN) lzcB (PosB, zeroCntB);
|
||||||
|
|
||||||
assign ExtraA = {1'b0, PosA, {`EXTRAINTBITS{1'b0}}};
|
assign ExtraA = {PosA, {`EXTRAINTBITS{1'b0}}};
|
||||||
assign ExtraB = {1'b0, PosB, {`EXTRAINTBITS{1'b0}}};
|
assign ExtraB = {PosB, {`EXTRAINTBITS{1'b0}}};
|
||||||
|
|
||||||
assign PreprocA = ExtraA << zeroCntA;
|
assign PreprocA = ExtraA << zeroCntA;
|
||||||
assign PreprocB = ExtraB << (zeroCntB + 1);
|
assign PreprocB = ExtraB << zeroCntB;
|
||||||
assign PreprocX = {SrcXFrac, {`EXTRAFRACBITS{1'b0}}};
|
assign PreprocX = {SrcXFrac, {`EXTRAFRACBITS{1'b0}}};
|
||||||
assign PreprocY = {SrcYFrac, {`EXTRAFRACBITS{1'b0}}};
|
assign PreprocY = {SrcYFrac, {`EXTRAFRACBITS{1'b0}}};
|
||||||
|
|
||||||
@ -228,14 +226,15 @@ module otfc2 #(parameter N=65) (
|
|||||||
//
|
//
|
||||||
// QM is Q-1. It allows us to write negative bits
|
// QM is Q-1. It allows us to write negative bits
|
||||||
// without using a costly CPA.
|
// without using a costly CPA.
|
||||||
logic [N+2:0] Q, QM, QNext, QMNext;
|
logic [N+2:0] Q, QM, QNext, QMNext, QMMux;
|
||||||
// QR and QMR are the shifted versions of Q and QM.
|
// QR and QMR are the shifted versions of Q and QM.
|
||||||
// They are treated as [N-1:r] size signals, and
|
// They are treated as [N-1:r] size signals, and
|
||||||
// discard the r most significant bits of Q and QM.
|
// discard the r most significant bits of Q and QM.
|
||||||
logic [N+1:0] QR, QMR;
|
logic [N+1:0] QR, QMR;
|
||||||
|
|
||||||
flopr #(N+3) Qreg(clk, Start, QNext, Q);
|
flopr #(N+3) Qreg(clk, Start, QNext, Q);
|
||||||
flopr #(N+3) QMreg(clk, Start, QMNext, QM);
|
mux2 #(`DIVLEN+3) QMmux(QMNext, {`DIVLEN+3{1'b1}}, Start, QMMux);
|
||||||
|
flop #(`DIVLEN+3) QMreg(clk, QMMux, QM);
|
||||||
|
|
||||||
always_comb begin
|
always_comb begin
|
||||||
QR = Q[N+1:0];
|
QR = Q[N+1:0];
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
`define DIVLEN 65
|
`define DIVLEN 64
|
||||||
|
|
||||||
/////////////
|
/////////////
|
||||||
// counter //
|
// counter //
|
||||||
@ -17,7 +17,7 @@ module counter(input logic clk,
|
|||||||
|
|
||||||
always @(posedge clk)
|
always @(posedge clk)
|
||||||
begin
|
begin
|
||||||
if (count == `DIVLEN+1) done <= #1 1;
|
if (count == `DIVLEN + 2) done <= #1 1;
|
||||||
else if (done | req) done <= #1 0;
|
else if (done | req) done <= #1 0;
|
||||||
if (req) count <= #1 0;
|
if (req) count <= #1 0;
|
||||||
else count <= #1 count+1;
|
else count <= #1 count+1;
|
||||||
@ -101,8 +101,8 @@ module testbench;
|
|||||||
b = Vec[`memb];
|
b = Vec[`memb];
|
||||||
{bsign, bExp, bfrac} = b;
|
{bsign, bExp, bfrac} = b;
|
||||||
nextr = Vec[`memr];
|
nextr = Vec[`memr];
|
||||||
r = Quot[`DIVLEN:`DIVLEN - 52];
|
r = Quot[(`DIVLEN - 1):(`DIVLEN - 52)];
|
||||||
rOTFC = QuotOTFC[`DIVLEN:`DIVLEN - 52];
|
rOTFC = QuotOTFC[(`DIVLEN - 1):(`DIVLEN - 52)];
|
||||||
req <= #5 1;
|
req <= #5 1;
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -110,8 +110,8 @@ module testbench;
|
|||||||
|
|
||||||
always @(posedge clk)
|
always @(posedge clk)
|
||||||
begin
|
begin
|
||||||
r = Quot[`DIVLEN:`DIVLEN - 52];
|
r = Quot[(`DIVLEN - 1):(`DIVLEN - 52)];
|
||||||
rOTFC = QuotOTFC[`DIVLEN:`DIVLEN - 52];
|
rOTFC = QuotOTFC[(`DIVLEN - 1):(`DIVLEN - 52)];
|
||||||
if (done)
|
if (done)
|
||||||
begin
|
begin
|
||||||
req <= #5 1;
|
req <= #5 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user