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

Subversion Repositories verilog_fixed_point_math_library

[/] [verilog_fixed_point_math_library/] [trunk/] [qdiv.v] - Diff between revs 7 and 8

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

Rev 7 Rev 8
Line 51... Line 51...
 
 
        initial reg_done = 1'b1;                        //      Initial state is to not be doing anything
        initial reg_done = 1'b1;                        //      Initial state is to not be doing anything
        initial reg_overflow = 1'b0;            //              And there should be no woverflow present
        initial reg_overflow = 1'b0;            //              And there should be no woverflow present
        initial reg_sign = 1'b0;                        //              And the sign should be positive
        initial reg_sign = 1'b0;                        //              And the sign should be positive
 
 
        assign o_quotient_out[N-2:0] = reg_working_quotient;     //      The division results
        initial reg_working_quotient = 0;
 
        initial reg_quotient = 0;
 
        initial reg_working_dividend = 0;
 
        initial reg_working_divisor = 0;
 
        initial reg_count = 0;
 
 
 
 
 
        assign o_quotient_out[N-2:0] = reg_quotient[N-2:0];       //      The division results
        assign o_quotient_out[N-1] = reg_sign;                                          //      The sign of the quotient
        assign o_quotient_out[N-1] = reg_sign;                                          //      The sign of the quotient
        assign o_complete = reg_done;
        assign o_complete = reg_done;
        assign o_overflow = reg_overflow;
        assign o_overflow = reg_overflow;
 
 
        always @( posedge i_clk ) begin
        always @( posedge i_clk ) begin
                if( reg_done && i_start ) begin                                                                         //      This is our startup condition
                if( reg_done && i_start ) begin                                                                         //      This is our startup condition
                        //  Need to check for a divide by zero right here, I think....
                        //  Need to check for a divide by zero right here, I think....
                        reg_done <= 1'b0;                                                                                               //      We're not done                  
                        reg_done <= 1'b0;                                                                                               //      We're not done                  
                        reg_count <= N+Q-2;                                                                                     //      Set the count
                        reg_count <= N+Q-1;                                                                                     //      Set the count
                        reg_working_quotient <= 0;                                                                       //      Clear out the quotient register
                        reg_working_quotient <= 0;                                                                       //      Clear out the quotient register
                        reg_working_dividend <= 0;                                                                       //      Clear out the dividend register 
                        reg_working_dividend <= 0;                                                                       //      Clear out the dividend register 
                        reg_working_divisor <= 0;                                                                        //      Clear out the divisor register 
                        reg_working_divisor <= 0;                                                                        //      Clear out the divisor register 
                        reg_overflow <= 1'b0;                                                                           //      Clear the overflow register
                        reg_overflow <= 1'b0;                                                                           //      Clear the overflow register
 
 
Line 84... Line 91...
                                end
                                end
 
 
                        //stop condition
                        //stop condition
                        if(reg_count == 0) begin
                        if(reg_count == 0) begin
                                reg_done <= 1'b1;                                                                               //      If we're done, it's time to tell the calling process
                                reg_done <= 1'b1;                                                                               //      If we're done, it's time to tell the calling process
 
                                reg_quotient <= reg_working_quotient;                   //      Move in our working copy to the outside world
                                if (reg_working_quotient[2*N+Q-3:N]>0)
                                if (reg_working_quotient[2*N+Q-3:N]>0)
                                        reg_overflow <= 1'b1;
                                        reg_overflow <= 1'b1;
                                        end
                                        end
                        else
                        else
                                reg_count <= reg_count - 1;
                                reg_count <= reg_count - 1;

powered by: WebSVN 2.1.0

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