2022-06-23 23:01:30 +00:00
|
|
|
`include "wally-config.vh"
|
|
|
|
|
|
|
|
module divshiftcalc(
|
2022-07-22 22:02:04 +00:00
|
|
|
input logic [`DIVb-(`RADIX/4):0] DivQm,
|
2022-07-07 23:01:33 +00:00
|
|
|
input logic [`FMTBITS-1:0] Fmt,
|
2022-07-22 22:02:04 +00:00
|
|
|
input logic Sqrt,
|
2022-07-12 01:30:21 +00:00
|
|
|
input logic [`DURLEN-1:0] DivEarlyTermShift,
|
2022-07-18 17:31:17 +00:00
|
|
|
input logic [`NE+1:0] DivQe,
|
2022-06-23 23:01:30 +00:00
|
|
|
output logic [$clog2(`NORMSHIFTSZ)-1:0] DivShiftAmt,
|
2022-06-24 21:02:50 +00:00
|
|
|
output logic [`NORMSHIFTSZ-1:0] DivShiftIn,
|
2022-06-28 00:16:22 +00:00
|
|
|
output logic DivResDenorm,
|
|
|
|
output logic [`NE+1:0] DivDenormShift
|
2022-06-23 23:01:30 +00:00
|
|
|
);
|
2022-06-24 21:02:50 +00:00
|
|
|
logic [`NE+1:0] NormShift;
|
2022-06-25 00:04:53 +00:00
|
|
|
|
|
|
|
// is the result denromalized
|
|
|
|
// if the exponent is 1 then the result needs to be normalized then the result is denormalizes
|
2022-07-18 17:31:17 +00:00
|
|
|
assign DivResDenorm = DivQe[`NE+1]|(~|DivQe[`NE+1:0]);
|
2022-06-27 20:43:55 +00:00
|
|
|
|
2022-06-25 00:04:53 +00:00
|
|
|
// if the result is denormalized
|
2022-07-18 17:31:17 +00:00
|
|
|
// 00000000x.xxxxxx... Exp = DivQe
|
|
|
|
// .00000000xxxxxxx... >> NF+1 Exp = DivQe+NF+1
|
|
|
|
// .00xxxxxxxxxxxxx... << DivQe+NF+1 Exp = +1
|
2022-06-25 00:04:53 +00:00
|
|
|
// .0000xxxxxxxxxxx... >> 1 Exp = 1
|
2022-07-18 17:31:17 +00:00
|
|
|
// Left shift amount = DivQe+NF+1-1
|
|
|
|
assign DivDenormShift = (`NE+2)'(`NF)+DivQe;
|
2022-06-27 20:43:55 +00:00
|
|
|
// if the result is normalized
|
2022-07-18 17:31:17 +00:00
|
|
|
// 00000000x.xxxxxx... Exp = DivQe
|
|
|
|
// .00000000xxxxxxx... >> NF+1 Exp = DivQe+NF+1
|
|
|
|
// 00000000.xxxxxxx... << NF Exp = DivQe+1
|
|
|
|
// 00000000x.xxxxxx... << NF Exp = DivQe (extra shift done afterwards)
|
|
|
|
// 00000000xx.xxxxx... << 1? Exp = DivQe-1 (determined after)
|
2022-06-28 00:16:22 +00:00
|
|
|
// inital Left shift amount = NF
|
2022-07-15 20:16:59 +00:00
|
|
|
// shift one more if the it's a minimally redundent radix 4 - one entire cycle needed for integer bit
|
2022-07-07 23:01:33 +00:00
|
|
|
assign NormShift = (`NE+2)'(`NF);
|
2022-06-27 17:04:51 +00:00
|
|
|
// if the shift amount is negitive then dont shift (keep sticky bit)
|
2022-07-12 01:30:21 +00:00
|
|
|
// need to multiply the early termination shift by LOGR*DIVCOPIES = left shift of log2(LOGR*DIVCOPIES)
|
2022-07-22 22:02:04 +00:00
|
|
|
assign DivShiftAmt = (DivResDenorm ? DivDenormShift[$clog2(`NORMSHIFTSZ)-1:0]&{$clog2(`NORMSHIFTSZ){~DivDenormShift[`NE+1]}} : NormShift[$clog2(`NORMSHIFTSZ)-1:0])+{{$clog2(`NORMSHIFTSZ)-`DURLEN-$clog2(`LOGR*`DIVCOPIES){1'b0}}, DivEarlyTermShift&{`DURLEN{~(DivDenormShift[`NE+1]|Sqrt)}}, {$clog2(`LOGR*`DIVCOPIES){1'b0}}};
|
2022-06-24 21:02:50 +00:00
|
|
|
|
2022-07-22 22:02:04 +00:00
|
|
|
assign DivShiftIn = {{`NF{1'b0}}, DivQm, {`NORMSHIFTSZ-`DIVb+1+(`RADIX/4)-`NF{1'b0}}};
|
2022-06-23 23:01:30 +00:00
|
|
|
|
|
|
|
endmodule
|