OpenCores
URL https://opencores.org/ocsvn/theia_gpu/theia_gpu/trunk

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [icarus_version/] [rtl/] [Module_FixedPointSquareRoot.v] - Diff between revs 183 and 184

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 183 Rev 184
Line 160... Line 160...
        input wire                                                      iInputReady,
        input wire                                                      iInputReady,
        output  wire                                            OutputReady,
        output  wire                                            OutputReady,
        output  wire [`WIDTH-1:0]                Result
        output  wire [`WIDTH-1:0]                Result
);
);
 
 
FFD_POSEDGE_SYNCRONOUS_RESET # (1) FFDelay1
 
(
 
        .Clock( Clock ),
 
        .Reset( Reset ),
 
        .Enable(1'b1 ),
 
        .D( iInputReady ),
 
        .Q( OutputReady )
 
);
 
 
 
//LUT only has values from 0 to 127, lets see if the value is bigger than that
 
wire wNotInLUT;
 
assign wNotInLUT = Operand[7+`SCALE]; //pero para ese chiste usar 128 en lugar de 4, entonces pueden haber hasta 128*128 = 16384 valores
 
//If the value is not on the LUT then divide by 4, so SQRT(x) = SQRT(4*x/4)
 
//=2*SQRT(x/4)
 
 
 
wire[`WIDTH-1:0] wScaledOperand;
 
 
 
assign wScaledOperand = (wNotInLUT == 1'b0 ) ?
 
   {Operand[`WIDTH-1:`SCALE],{`SCALE{1'b0}}} :     //Aproximate the Square root to an integer value
 
        {2'b0,Operand[`WIDTH-1:`SCALE+2],{`SCALE{1'b0}}};  //Shift right two bits (divide by 4)
 
 
 
wire [`WIDTH-1:0] wResult,wScaleResult;
 
SQUAREROOT_LUT SQRT
 
(
 
.I(wScaledOperand),
 
//.I({Operand[`WIDTH-1:`SCALE],{`SCALE{1'b0}}}), //Aproximate the Square root to an integer value
 
.O(wScaleResult)
 
//.O(wResult)
 
);
 
 
 
 
 
 
 
assign wResult = (wNotInLUT == 1'b0 ) ? wScaleResult : {wScaleResult[`WIDTH-2:0],1'b0};
 
 
 
 
 
FFD_POSEDGE_SYNCRONOUS_RESET # (`WIDTH) FFRESULT
 
(
 
        .Clock( Clock ),
 
        .Reset( Reset ),
 
        .Enable(1'b1 ),
 
        .D( wResult ),
 
        .Q( Result )
 
);
 
 
 
//--------------------------------------------------------------------------------
 
`ifdef BIGGER
 
 
 
FFD_POSEDGE_SYNCRONOUS_RESET # (1) FFDelay1
FFD_POSEDGE_SYNCRONOUS_RESET # (1) FFDelay1
(
(
        .Clock( Clock ),
        .Clock( Clock ),
        .Reset( Reset ),
        .Reset( Reset ),
Line 219... Line 173...
);
);
 
 
//LUT only has values from 0 to 127, lets see if the value is bigger than that
//LUT only has values from 0 to 127, lets see if the value is bigger than that
wire wNotInLUT;
wire wNotInLUT;
assign wNotInLUT = Operand[7+`SCALE];
assign wNotInLUT = Operand[7+`SCALE];
//If the value is not on the LUT then divide by 4, so SQRT(x) = SQRT(64*x/64)
//If the value is not on the LUT then divide by 64, so SQRT(x) = SQRT(64*x/64)
//=16*SQRT(x/64)
//=16*SQRT(x/64)
 
 
wire[`WIDTH-1:0] wScaledOperand;
wire[`WIDTH-1:0] wScaledOperand;
 
 
assign wScaledOperand = (wNotInLUT == 1'b0 ) ?
assign wScaledOperand = (wNotInLUT == 1'b0 ) ?
Line 250... Line 204...
        .Enable(1'b1 ),
        .Enable(1'b1 ),
        .D( wResult ),
        .D( wResult ),
        .Q( Result )
        .Q( Result )
);
);
 
 
`endif
 
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
endmodule
endmodule
 
 
 No newline at end of file
 No newline at end of file
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.