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

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [beta_2.0/] [rtl/] [Module_FixedPointSquareRoot.v] - Diff between revs 213 and 230

Show entire file | Details | Blame | View Log

Rev 213 Rev 230
Line 154... Line 154...
 
 
module FixedPointSquareRoot
module FixedPointSquareRoot
(
(
        input wire                                                      Clock,
        input wire                                                      Clock,
        input wire                                                      Reset,
        input wire                                                      Reset,
        input wire[`LONG_WIDTH-1:0]      Operand,
        input wire[`LONG_WIDTH-1:0]      iOperand,
        input wire                                                      iInputReady,
        input wire                                                      iInputReady,
        output  wire                                            OutputReady,
        output  wire                                            oOutputReady,
        output  wire [`WIDTH-1:0]                Result
        output  wire [`WIDTH-1:0]                oResult
);
);
 
 
 
 
FFD_POSEDGE_SYNCRONOUS_RESET # (1) FFDelay1
FFD_POSEDGE_SYNCRONOUS_RESET # (1) FFDelay1
(
(
        .Clock( Clock ),
        .Clock( Clock ),
        .Reset( Reset ),
        .Reset( Reset ),
        .Enable(1'b1 ),
        .Enable(1'b1 ),
        .D( iInputReady ),
        .D( iInputReady ),
        .Q( OutputReady )
        .Q( oOutputReady )
);
);
 
 
//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 = iOperand[7+`SCALE];
//If the value is not on the LUT then divide by 64, 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 ) ?
   {Operand[`WIDTH-1:`SCALE],{`SCALE{1'b0}}} :     //Aproximate the Square root to an integer value
   {iOperand[`WIDTH-1:`SCALE],{`SCALE{1'b0}}} :     //Aproximate the Square root to an integer value
        {6'b0,Operand[`WIDTH-1:`SCALE+6],{`SCALE{1'b0}}};  //Shift right two bits (divide by 4)
        {6'b0,iOperand[`WIDTH-1:`SCALE+6],{`SCALE{1'b0}}};  //Shift right two bits (divide by 4)
 
 
wire [`WIDTH-1:0] wResult,wScaleResult;
wire [`WIDTH-1:0] wResult,wScaleResult;
SQUAREROOT_LUT SQRT
SQUAREROOT_LUT SQRT
(
(
.I(wScaledOperand),
.I(wScaledOperand),
Line 201... Line 201...
(
(
        .Clock( Clock ),
        .Clock( Clock ),
        .Reset( Reset ),
        .Reset( Reset ),
        .Enable(1'b1 ),
        .Enable(1'b1 ),
        .D( wResult ),
        .D( wResult ),
        .Q( Result )
        .Q( oResult )
);
);
 
 
 
 
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
endmodule
endmodule

powered by: WebSVN 2.1.0

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