mirror of
				https://github.com/openhwgroup/cvw
				synced 2025-02-11 06:05:49 +00:00 
			
		
		
		
	various cleanup
This commit is contained in:
		
							parent
							
								
									3170130c94
								
							
						
					
					
						commit
						545a3ff363
					
				@ -56,7 +56,7 @@ module fdivsqrtfsm(
 | 
			
		||||
 | 
			
		||||
  logic [`DURLEN-1:0] step;
 | 
			
		||||
  logic [`DURLEN-1:0] cycles;
 | 
			
		||||
  logic SpecialCaseE, FSpecialCaseE, ISpecialCaseE;
 | 
			
		||||
  logic SpecialCaseE, FSpecialCaseE;
 | 
			
		||||
 | 
			
		||||
  // FDivStartE and IDivStartE come from fctrl, reflecitng the start of floating-point and possibly integer division
 | 
			
		||||
  assign IFDivStartE = (FDivStartE | (IDivStartE & `IDIV_ON_FPU)) & (state == IDLE) & ~StallM;
 | 
			
		||||
@ -65,10 +65,8 @@ module fdivsqrtfsm(
 | 
			
		||||
 | 
			
		||||
  // terminate immediately on special cases
 | 
			
		||||
  assign FSpecialCaseE = XZeroE | (YZeroE&~SqrtE) | XInfE | YInfE | XNaNE | YNaNE | (XsE&SqrtE);
 | 
			
		||||
  if (`IDIV_ON_FPU) begin
 | 
			
		||||
    assign ISpecialCaseE = AZeroE | BZeroE; // *** why is AZeroE part of this.  Should other special cases be considered?
 | 
			
		||||
    assign SpecialCaseE  = MDUE ? ISpecialCaseE : FSpecialCaseE;
 | 
			
		||||
  end else assign SpecialCaseE = FSpecialCaseE;
 | 
			
		||||
  if (`IDIV_ON_FPU) assign SpecialCaseE = MDUE ? BZeroE : FSpecialCaseE;
 | 
			
		||||
  else              assign SpecialCaseE = FSpecialCaseE;
 | 
			
		||||
  flopenr #(1) SpecialCaseReg(clk, reset, IFDivStartE, SpecialCaseE, SpecialCaseM); // save SpecialCase for checking in fdivsqrtpostproc
 | 
			
		||||
 | 
			
		||||
// DIVN = `NF+3
 | 
			
		||||
 | 
			
		||||
@ -77,8 +77,14 @@ module fdivsqrtiter(
 | 
			
		||||
 | 
			
		||||
  // UOTFC Result U and UM registers/initialization mux
 | 
			
		||||
  // Initialize U to 1.0 and UM to 0 for square root or negative-result int division; U to 0 and UM to -1 otherwise
 | 
			
		||||
  
 | 
			
		||||
  assign initU =  SqrtE ? {1'b1, {(`DIVb){1'b0}}} : 0;
 | 
			
		||||
  assign initUM = SqrtE ? 0 : {1'b1, {(`DIVb){1'b0}}}; 
 | 
			
		||||
  
 | 
			
		||||
  /*
 | 
			
		||||
  mux2 #(`DIVb+1)  initUmux(0, {1'b1, {(`DIVb){1'b0}}}, SqrtE, initU);
 | 
			
		||||
  mux2 #(`DIVb+1) initUMmux({1'b1, {(`DIVb){1'b0}}}, 0, SqrtE, initUM);
 | 
			
		||||
  */
 | 
			
		||||
  mux2 #(`DIVb+1)      Umux(UNext[`DIVCOPIES-1],  initU,  IFDivStartE, UMux);
 | 
			
		||||
  mux2 #(`DIVb+1)     UMmux(UMNext[`DIVCOPIES-1], initUM, IFDivStartE, UMMux);
 | 
			
		||||
  flopen #(`DIVb+1)    UReg(clk, IFDivStartE|FDivBusyE, UMux,  U[0]);
 | 
			
		||||
 | 
			
		||||
@ -96,11 +96,10 @@ module fdivsqrtpostproc(
 | 
			
		||||
  // Determine if sticky bit is negative  // *** look for ways to optimize this.  Shift shouldn't be needed.
 | 
			
		||||
  assign Sum = WC + WS;
 | 
			
		||||
  assign NegStickyM = Sum[`DIVb+3];
 | 
			
		||||
  mux2 #(`DIVb+1) preqmmux(FirstU, FirstUM, NegStickyM, PreQmM);// Select U or U-1 depending on negative sticky bit
 | 
			
		||||
  mux2 #(`DIVb+1)    qmmux(PreQmM, (PreQmM << 1), SqrtM, QmM);
 | 
			
		||||
 | 
			
		||||
  assign PreQmM = NegStickyM ? FirstUM : FirstU; // Select U or U-1 depending on negative sticky bit
 | 
			
		||||
  assign QmM = SqrtM ? (PreQmM << 1) : PreQmM;
 | 
			
		||||
 | 
			
		||||
  if (`IDIV_ON_FPU) begin
 | 
			
		||||
  if (`IDIV_ON_FPU) begin // Int supported
 | 
			
		||||
    logic [`DIVBLEN:0] NormShiftM;
 | 
			
		||||
    logic [`DIVb+3:0] IntQuotM, IntRemM, NormRemM, NormRemDM;
 | 
			
		||||
 | 
			
		||||
@ -113,14 +112,12 @@ module fdivsqrtpostproc(
 | 
			
		||||
 | 
			
		||||
    // special case logic
 | 
			
		||||
    always_comb
 | 
			
		||||
      if (BZeroM) begin 
 | 
			
		||||
      if (BZeroM) begin         // Divide by zero
 | 
			
		||||
        if (RemOpM) SpecialFPIntDivResultM = AM;
 | 
			
		||||
        else        SpecialFPIntDivResultM = {(`XLEN){1'b1}};
 | 
			
		||||
      end else if (ALTBM) begin
 | 
			
		||||
      end else if (ALTBM) begin // Numerator is zero
 | 
			
		||||
        if (RemOpM) SpecialFPIntDivResultM = AM;
 | 
			
		||||
        else        SpecialFPIntDivResultM = '0;
 | 
			
		||||
 //       IntQuotM = '0;
 | 
			
		||||
 //       IntRemM  = {{(`DIVb-`XLEN+4){1'b0}}, AM};
 | 
			
		||||
      end else begin
 | 
			
		||||
        logic [`DIVb+3:0] PreIntQuotM;
 | 
			
		||||
        if (WZeroM) begin
 | 
			
		||||
@ -139,7 +136,7 @@ module fdivsqrtpostproc(
 | 
			
		||||
        if (NegQuotM) IntQuotM = -PreIntQuotM;
 | 
			
		||||
        else          IntQuotM =  PreIntQuotM;
 | 
			
		||||
        if (RemOpM) begin
 | 
			
		||||
          NormShiftM = ALTBM ? '0 : (mM + (`DIVBLEN+1)'(`DIVa)); // no postshift if forwarding input A to remainder
 | 
			
		||||
          NormShiftM = ALTBM ? 0 : (mM + (`DIVBLEN+1)'(`DIVa)); // no postshift if forwarding input A to remainder
 | 
			
		||||
          PreResultM = IntRemM;
 | 
			
		||||
        end else begin
 | 
			
		||||
          NormShiftM = ((`DIVBLEN+1)'(`DIVb) - (nM * (`DIVBLEN+1)'(`LOGR)));
 | 
			
		||||
 | 
			
		||||
@ -59,7 +59,7 @@ module fdivsqrtpreproc (
 | 
			
		||||
  logic  [`DIVBLEN:0] mE, ell;                // Leading zeros of inputs
 | 
			
		||||
  logic  NumerZeroE;                          // Numerator is zero (X or A)
 | 
			
		||||
 | 
			
		||||
  if (`IDIV_ON_FPU) begin
 | 
			
		||||
  if (`IDIV_ON_FPU) begin // Int Supported
 | 
			
		||||
    logic signedDiv, NegQuotE;
 | 
			
		||||
    logic AsBit, BsBit, AsE, BsE, ALTBE;
 | 
			
		||||
    logic [`XLEN-1:0] AE, BE, PosA, PosB;
 | 
			
		||||
@ -127,7 +127,7 @@ module fdivsqrtpreproc (
 | 
			
		||||
    flopen #(`DIVBLEN+1) mreg(clk, IFDivStartE, mE,       mM);
 | 
			
		||||
    flopen #(`XLEN)   srcareg(clk, IFDivStartE, AE,       AM);
 | 
			
		||||
 | 
			
		||||
  end else begin // Int div not supported
 | 
			
		||||
  end else begin // Int not supported
 | 
			
		||||
    assign IFNormLenX = {Xm, {(`DIVb-`NF-1){1'b0}}};
 | 
			
		||||
    assign IFNormLenD = {Ym, {(`DIVb-`NF-1){1'b0}}};
 | 
			
		||||
    assign NumerZeroE = XZeroE;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user