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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [rtl/] [verilog/] [isqrt.v] - Diff between revs 12 and 26

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

Rev 12 Rev 26
Line 1... Line 1...
`timescale 1ns / 1ps
`timescale 1ns / 1ps
// ============================================================================
// ============================================================================
//        __
//        __
//   \\__/ o\    (C) 2010-2018  Robert Finch, Waterloo
//   \\__/ o\    (C) 2010-2019  Robert Finch, Waterloo
//    \  __ /    All rights reserved.
//    \  __ /    All rights reserved.
//     \/_//     robfinch<remove>@finitron.ca
//     \/_//     robfinch<remove>@finitron.ca
//       ||
//       ||
//
//
//      isqrt.v
//      isqrt.v
//      - integer square root
//      - integer square root
 
//  - uses the standard long form calc.
 
//      - geared towards use in an floating point unit
 
//      - calculates to WID fractional precision (double width output)
//
//
//
//
// This source file is free software: you can redistribute it and/or modify 
// This source file is free software: you can redistribute it and/or modify 
// it under the terms of the GNU Lesser General Public License as published 
// it under the terms of the GNU Lesser General Public License as published 
// by the Free Software Foundation, either version 3 of the License, or     
// by the Free Software Foundation, either version 3 of the License, or     
Line 21... Line 24...
// GNU General Public License for more details.                             
// GNU General Public License for more details.                             
//                                                                          
//                                                                          
// You should have received a copy of the GNU General Public License        
// You should have received a copy of the GNU General Public License        
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
//                                                                          
//                                                                          
//      Floating Point Multiplier / Divider
 
//
 
// ============================================================================
// ============================================================================
 
 
module isqrt(rst, clk, ce, ld, a, o, done);
module isqrt(rst, clk, ce, ld, a, o, done);
parameter WID = 32;
parameter WID = 32;
localparam MSB = WID-1;
localparam MSB = WID-1;
Line 83... Line 84...
                // Shift the remainder high
                // Shift the remainder high
                remHi <= doesGoInto ? remHiShift - testDiv: remHiShift;
                remHi <= doesGoInto ? remHiShift - testDiv: remHiShift;
                // Shift the root
                // Shift the root
                root <= {root+doesGoInto,1'b0}; // root * 2 + 1/0
                root <= {root+doesGoInto,1'b0}; // root * 2 + 1/0
        end
        end
        else
        else begin
 
                cnt <= 8'h00;
                state <= DONE;
                state <= DONE;
 
        end
DONE:
DONE:
        begin
        begin
 
                cnt <= cnt + 8'd1;
 
                if (cnt == 8'd6)
                state <= IDLE;
                state <= IDLE;
        end
        end
endcase
endcase
end
end
assign cnt_done = (cnt==WID);
assign cnt_done = (cnt==WID);

powered by: WebSVN 2.1.0

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