mirror of
				https://github.com/openhwgroup/cvw
				synced 2025-02-11 06:05:49 +00:00 
			
		
		
		
	various formatting fixes and comments
This commit is contained in:
		
							parent
							
								
									286e43807a
								
							
						
					
					
						commit
						fb9a0c797f
					
				| @ -69,8 +69,8 @@ module fdivsqrtexpcalc( | |||||||
|   end |   end | ||||||
|   assign SXExp = {2'b0, Xe} - {{(`NE+1-`DIVBLEN){1'b0}}, ell} - (`NE+2)'(`BIAS); |   assign SXExp = {2'b0, Xe} - {{(`NE+1-`DIVBLEN){1'b0}}, ell} - (`NE+2)'(`BIAS); | ||||||
|   assign SExp  = {SXExp[`NE+1], SXExp[`NE+1:1]} + {2'b0, Bias}; |   assign SExp  = {SXExp[`NE+1], SXExp[`NE+1:1]} + {2'b0, Bias}; | ||||||
|  |    | ||||||
|   // correct exponent for denormalized input's normalization shifts
 |   // correct exponent for denormalized input's normalization shifts
 | ||||||
|   assign DExp  = ({2'b0, Xe} - {{(`NE+1-`DIVBLEN){1'b0}}, ell} - {2'b0, Ye} + {{(`NE+1-`DIVBLEN){1'b0}}, m} + {3'b0, Bias}) & {`NE+2{~XZero}}; |   assign DExp  = ({2'b0, Xe} - {{(`NE+1-`DIVBLEN){1'b0}}, ell} - {2'b0, Ye} + {{(`NE+1-`DIVBLEN){1'b0}}, m} + {3'b0, Bias}) & {`NE+2{~XZero}}; | ||||||
|    |  | ||||||
|   assign Qe = Sqrt ? SExp : DExp; |   assign Qe = Sqrt ? SExp : DExp; | ||||||
| endmodule | endmodule | ||||||
|  | |||||||
| @ -39,9 +39,9 @@ module fdivsqrtfgen2 ( | |||||||
|   logic [`DIVb+3:0] FP, FN, FZ; |   logic [`DIVb+3:0] FP, FN, FZ; | ||||||
|   logic [`DIVb+3:0] SExt, SMExt, CExt; |   logic [`DIVb+3:0] SExt, SMExt, CExt; | ||||||
| 
 | 
 | ||||||
|   assign SExt = {3'b0, U}; |   assign SExt  = {3'b0, U}; | ||||||
|   assign SMExt = {3'b0, UM}; |   assign SMExt = {3'b0, UM}; | ||||||
|   assign CExt = {2'b11, C}; // extend C from Q2.k to Q4.k
 |   assign CExt  = {2'b11, C}; // extend C from Q2.k to Q4.k
 | ||||||
| 
 | 
 | ||||||
|   // Generate for both positive and negative bits
 |   // Generate for both positive and negative bits
 | ||||||
|   assign FP = ~(SExt << 1) & CExt; |   assign FP = ~(SExt << 1) & CExt; | ||||||
|  | |||||||
| @ -42,14 +42,13 @@ module fdivsqrtfgen4 ( | |||||||
|   assign F1  = ~(U << 1) & C; |   assign F1  = ~(U << 1) & C; | ||||||
|   assign F0  = '0; |   assign F0  = '0; | ||||||
|   assign FN1 = (UM << 1) | (C & ~(C << 3)); |   assign FN1 = (UM << 1) | (C & ~(C << 3)); | ||||||
|   assign FN2 = (UM << 2) | ((C << 2)&~(C << 4)); |   assign FN2 = (UM << 2) | ((C << 2) & ~(C << 4)); | ||||||
| 
 | 
 | ||||||
|   // Choose which adder input will be used
 |   // Choose which adder input will be used
 | ||||||
| 
 |  | ||||||
|   always_comb |   always_comb | ||||||
|     if (udigit[3])       F = F2; |     if (udigit[3])       F = F2; | ||||||
|     else if (udigit[2])  F = F1; |     else if (udigit[2])  F = F1; | ||||||
|     else if (udigit[1])  F = FN1; |     else if (udigit[1])  F = FN1; | ||||||
|     else if (udigit[0])  F = FN2; |     else if (udigit[0])  F = FN2; | ||||||
|     else            F = F0; |     else                 F = F0; | ||||||
| endmodule | endmodule | ||||||
| @ -96,7 +96,7 @@ module fdivsqrtpostproc( | |||||||
|   // Determine if sticky bit is negative  // *** look for ways to optimize this.  Shift shouldn't be needed.
 |   // Determine if sticky bit is negative  // *** look for ways to optimize this.  Shift shouldn't be needed.
 | ||||||
|   assign Sum = WC + WS; |   assign Sum = WC + WS; | ||||||
|   assign NegStickyM = Sum[`DIVb+3]; |   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) preqmmux(FirstU, FirstUM, NegStickyM, PreQmM); // Select U or U-1 depending on negative sticky bit
 | ||||||
|   mux2 #(`DIVb+1)    qmmux(PreQmM, (PreQmM << 1), SqrtM, QmM); |   mux2 #(`DIVb+1)    qmmux(PreQmM, (PreQmM << 1), SqrtM, QmM); | ||||||
| 
 | 
 | ||||||
|   if (`IDIV_ON_FPU) begin // Int supported
 |   if (`IDIV_ON_FPU) begin // Int supported
 | ||||||
|  | |||||||
| @ -68,6 +68,9 @@ module fdivsqrtpreproc ( | |||||||
| 
 | 
 | ||||||
|     // Extract inputs, signs, zero, depending on W64 mode if applicable
 |     // Extract inputs, signs, zero, depending on W64 mode if applicable
 | ||||||
|     assign signedDiv = ~Funct3E[0]; |     assign signedDiv = ~Funct3E[0]; | ||||||
|  |     assign NegQuotE = AsE ^ BsE; // Quotient is negative
 | ||||||
|  | 
 | ||||||
|  |     // Source handling
 | ||||||
|     if (`XLEN==64) begin // 64-bit, supports W64
 |     if (`XLEN==64) begin // 64-bit, supports W64
 | ||||||
|       mux2 #(1) azeromux(~(|ForwardedSrcAE), ~(|ForwardedSrcAE[31:0]), W64E, AZeroE); |       mux2 #(1) azeromux(~(|ForwardedSrcAE), ~(|ForwardedSrcAE[31:0]), W64E, AZeroE); | ||||||
|       mux2 #(1) bzeromux(~(|ForwardedSrcBE), ~(|ForwardedSrcBE[31:0]), W64E, BZeroE); |       mux2 #(1) bzeromux(~(|ForwardedSrcBE), ~(|ForwardedSrcBE[31:0]), W64E, BZeroE); | ||||||
| @ -86,9 +89,6 @@ module fdivsqrtpreproc ( | |||||||
|       assign BZeroE = ~(|ForwardedSrcBE); |       assign BZeroE = ~(|ForwardedSrcBE); | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     // Quotient is negative
 |  | ||||||
|     assign NegQuotE = AsE ^ BsE; |  | ||||||
|      |  | ||||||
|     // Force integer inputs to be postiive
 |     // Force integer inputs to be postiive
 | ||||||
|     mux2 #(`XLEN) posamux(AE, -AE, AsE, PosA); |     mux2 #(`XLEN) posamux(AE, -AE, AsE, PosA); | ||||||
|     mux2 #(`XLEN) posbmux(BE, -BE, BsE, PosB); |     mux2 #(`XLEN) posbmux(BE, -BE, BsE, PosB); | ||||||
|  | |||||||
| @ -56,6 +56,6 @@ module fdivsqrtqsel2 ( | |||||||
| 
 | 
 | ||||||
|   // Produce digit = +1, 0, or -1
 |   // Produce digit = +1, 0, or -1
 | ||||||
|   assign up = magnitude & ~sign; |   assign up = magnitude & ~sign; | ||||||
|   assign uz  = ~magnitude; |   assign uz = ~magnitude; | ||||||
|   assign un = magnitude & sign; |   assign un = magnitude & sign; | ||||||
| endmodule | endmodule | ||||||
|  | |||||||
| @ -31,10 +31,10 @@ | |||||||
| `include "wally-config.vh" | `include "wally-config.vh" | ||||||
| 
 | 
 | ||||||
| module fdivsqrtqsel4 ( | module fdivsqrtqsel4 ( | ||||||
|   input logic [2:0] Dmsbs, |   input  logic [2:0] Dmsbs, | ||||||
|   input logic [4:0] Smsbs, |   input  logic [4:0] Smsbs, | ||||||
|   input logic [7:0] WSmsbs, WCmsbs, |   input  logic [7:0] WSmsbs, WCmsbs, | ||||||
|   input logic Sqrt, j1, |   input  logic Sqrt, j1, | ||||||
|   output logic [3:0] udigit |   output logic [3:0] udigit | ||||||
| ); | ); | ||||||
| 	logic [6:0] Wmsbs; | 	logic [6:0] Wmsbs; | ||||||
|  | |||||||
| @ -31,10 +31,10 @@ | |||||||
| `include "wally-config.vh" | `include "wally-config.vh" | ||||||
| 
 | 
 | ||||||
| module fdivsqrtqsel4cmp ( | module fdivsqrtqsel4cmp ( | ||||||
|   input logic [2:0] Dmsbs, |   input  logic [2:0] Dmsbs, | ||||||
|   input logic [4:0] Smsbs, |   input  logic [4:0] Smsbs, | ||||||
|   input logic [7:0] WSmsbs, WCmsbs, |   input  logic [7:0] WSmsbs, WCmsbs, | ||||||
|   input logic SqrtE, j1, |   input  logic SqrtE, j1, | ||||||
|   output logic [3:0] udigit |   output logic [3:0] udigit | ||||||
| ); | ); | ||||||
| 	logic [6:0] Wmsbs; | 	logic [6:0] Wmsbs; | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| ///////////////////////////////////////////
 | ///////////////////////////////////////////
 | ||||||
| // fdivsqrtstage2.sv
 | // fdivsqrtstage2.sv
 | ||||||
| //
 | //
 | ||||||
| // Written: David_Harris@hmc.edu, me@KatherineParry.com, Cedar Turek
 | // Written: David_Harris@hmc.edu, me@KatherineParry.com, cturek@hmc.edu
 | ||||||
| // Modified:13 January 2022
 | // Modified:13 January 2022
 | ||||||
| //
 | //
 | ||||||
| // Purpose: Combined Divide and Square Root Floating Point and Integer Unit stage
 | // Purpose: Combined Divide and Square Root Floating Point and Integer Unit stage
 | ||||||
| @ -67,12 +67,13 @@ module fdivsqrtstage2 ( | |||||||
|   // Divisor multiple
 |   // Divisor multiple
 | ||||||
|   always_comb |   always_comb | ||||||
|     if      (up) Dsel = DBar; |     if      (up) Dsel = DBar; | ||||||
|     else if (uz) Dsel = '0; // qz
 |     else if (uz) Dsel = '0; | ||||||
|     else         Dsel = {3'b000, 1'b1, D}; // un
 |     else         Dsel = {3'b000, 1'b1, D}; // un
 | ||||||
| 
 | 
 | ||||||
|   // Partial Product Generation
 |   // Partial Product Generation
 | ||||||
|   //  WSA, WCA = WS + WC - qD
 |   //  WSA, WCA = WS + WC - qD
 | ||||||
|   assign AddIn = SqrtE ? F : Dsel; |   mux2 #(`DIVb+4) addinmux(F, Dsel, SqrtE, AddIn); | ||||||
|  |   //assign AddIn = SqrtE ? F : Dsel;
 | ||||||
|   csa #(`DIVb+4) csa(WS, WC, AddIn, up&~SqrtE, WSA, WCA); |   csa #(`DIVb+4) csa(WS, WC, AddIn, up&~SqrtE, WSA, WCA); | ||||||
|   assign WSNext = WSA << 1; |   assign WSNext = WSA << 1; | ||||||
|   assign WCNext = WCA << 1; |   assign WCNext = WCA << 1; | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| ///////////////////////////////////////////
 | ///////////////////////////////////////////
 | ||||||
| // fdivsqrtstage4.sv
 | // fdivsqrtstage4.sv
 | ||||||
| //
 | //
 | ||||||
| // Written: David_Harris@hmc.edu, me@KatherineParry.com, Cedar Turek
 | // Written: David_Harris@hmc.edu, me@KatherineParry.com, cturek@hmc.edu
 | ||||||
| // Modified:13 January 2022
 | // Modified:13 January 2022
 | ||||||
| //
 | //
 | ||||||
| // Purpose: Combined Divide and Square Root Floating Point and Integer Unit stage
 | // Purpose: Combined Divide and Square Root Floating Point and Integer Unit stage
 | ||||||
|  | |||||||
| @ -43,7 +43,7 @@ module fdivsqrtuotfc2( | |||||||
|   //  bits to the quotient as they come.
 |   //  bits to the quotient as they come.
 | ||||||
|   logic [`DIVb:0] K; |   logic [`DIVb:0] K; | ||||||
| 
 | 
 | ||||||
|   assign K = (C[`DIVb:0] & ~(C[`DIVb:0] << 1)); |   assign K = (C[`DIVb:0] & ~(C[`DIVb:0] << 1)); // Thermometer to one hot encoding
 | ||||||
| 
 | 
 | ||||||
|   always_comb begin |   always_comb begin | ||||||
|     if (up) begin |     if (up) begin | ||||||
|  | |||||||
| @ -46,19 +46,19 @@ module fdivsqrtuotfc4( | |||||||
|   assign K3 = (C & ~(C << 2));      // 3K
 |   assign K3 = (C & ~(C << 2));      // 3K
 | ||||||
| 
 | 
 | ||||||
|   always_comb begin |   always_comb begin | ||||||
|     if (udigit[3]) begin           // +2
 |     if (udigit[3]) begin            // +2
 | ||||||
|       UNext  = U | K2; |       UNext  = U | K2; | ||||||
|       UMNext = U | K1; |       UMNext = U | K1; | ||||||
|     end else if (udigit[2]) begin  // +1
 |     end else if (udigit[2]) begin   // +1
 | ||||||
|       UNext  = U | K1; |       UNext  = U | K1; | ||||||
|       UMNext = U; |       UMNext = U; | ||||||
|     end else if (udigit[1]) begin  // -1
 |     end else if (udigit[1]) begin   // -1
 | ||||||
|       UNext  = UM | K3; |       UNext  = UM | K3; | ||||||
|       UMNext = UM | K2; |       UMNext = UM | K2; | ||||||
|     end else if (udigit[0]) begin  // -2
 |     end else if (udigit[0]) begin   // -2
 | ||||||
|       UNext  = UM | K2; |       UNext  = UM | K2; | ||||||
|       UMNext = UM | K1; |       UMNext = UM | K1; | ||||||
|     end else begin                    // 0
 |     end else begin                  // 0
 | ||||||
|       UNext  = U; |       UNext  = U; | ||||||
|       UMNext = UM | K3; |       UMNext = UM | K3; | ||||||
|     end  |     end  | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user