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

Subversion Repositories rtf8088

[/] [rtf8088/] [trunk/] [rtl/] [verilog/] [DIVIDE.v] - Diff between revs 6 and 7

Only display areas with differences | Details | Blame | View Log

Rev 6 Rev 7
//============================================================================
//============================================================================
//  DIVIDE.v
//  DIVIDE.v
//
//
//  (C) 2009-2012 Robert Finch
//  (C) 2009-2012 Robert Finch
//  Stratford
//  Stratford
//  robfinch<remove>@opencores.org
//  robfinch<remove>@opencores.org
//
//
//
//
// 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     
// (at your option) any later version.                                      
// (at your option) any later version.                                      
//                                                                          
//                                                                          
// This source file is distributed in the hope that it will be useful,      
// This source file is distributed in the hope that it will be useful,      
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
// 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/>.    
//
//
//
//
//=============================================================================
//=============================================================================
//
//
// Check for divide by zero
// Check for divide by zero
// Load the divider
// Load the divider
DIVIDE1:
DIVIDE1:
        begin
        begin
                state <= DIVIDE2;
                state <= DIVIDE2;
                // Check for divide by zero
                // Check for divide by zero
                if (w) begin
                if (w) begin
                        if (b[15:0]==16'h0000) begin
                        if (b[15:0]==16'h0000) begin
                                $display("Divide by zero");
                                $display("Divide by zero");
                                int_num <= 8'h00;
                                int_num <= 8'h00;
                                state <= INT2;
                                state <= INT2;
                        end
                        end
                        else
                        else
                                ld_div32 <= 1'b1;
                                ld_div32 <= 1'b1;
                end
                end
                else begin
                else begin
                        if (b[7:0]==8'h00) begin
                        if (b[7:0]==8'h00) begin
                                $display("Divide by zero");
                                $display("Divide by zero");
                                int_num <= 8'h00;
                                int_num <= 8'h00;
                                state <= INT2;
                                state <= INT2;
                        end
                        end
                        else
                        else
                                ld_div16 <= 1'b1;
                                ld_div16 <= 1'b1;
                end
                end
        end
        end
DIVIDE2:
DIVIDE2:
        begin
        begin
 
                $display("DIVIDE2");
                ld_div32 <= 1'b0;
                ld_div32 <= 1'b0;
                ld_div16 <= 1'b0;
                ld_div16 <= 1'b0;
                state <= DIVIDE2a;
                state <= DIVIDE2a;
        end
        end
DIVIDE2a:
DIVIDE2a:
        begin
        begin
 
                $display("DIVIDE2a");
                if (w & div32_done)
                if (w & div32_done)
                        state <= DIVIDE3;
                        state <= DIVIDE3;
                else if (!w & div16_done)
                else if (!w & div16_done)
                        state <= DIVIDE3;
                        state <= DIVIDE3;
        end
        end
 
 
// Assign results to registers
// Assign results to registers
// Trap on divider overflow
// Trap on divider overflow
DIVIDE3:
DIVIDE3:
        begin
        begin
 
                $display("DIVIDE3 state <= IFETCH");
                state <= IFETCH;
                state <= IFETCH;
                if (w) begin
                if (w) begin
                        ax <= q32[15:0];
                        ax <= q32[15:0];
                        dx <= r32[15:0];
                        dx <= r32[15:0];
                        if (TTT[0]) begin
                        if (TTT[0]) begin
                                if (q32[31:16]!={16{q32[15]}}) begin
                                if (q32[31:16]!={16{q32[15]}}) begin
 
                                        $display("DIVIDE Overflow");
                                        int_num <= 8'h00;
                                        int_num <= 8'h00;
                                        state <= INT2;
                                        state <= INT2;
                                end
                                end
                        end
                        end
                        else begin
                        else begin
                                if (q32[31:16]!=16'h0000) begin
                                if (q32[31:16]!=16'h0000) begin
 
                                        $display("DIVIDE Overflow");
                                        int_num <= 8'h00;
                                        int_num <= 8'h00;
                                        state <= INT2;
                                        state <= INT2;
                                end
                                end
                        end
                        end
                end
                end
                else begin
                else begin
                        ax[ 7:0] <= q16[7:0];
                        ax[ 7:0] <= q16[7:0];
                        ax[15:8] <= r16;
                        ax[15:8] <= r16;
                        if (TTT[0]) begin
                        if (TTT[0]) begin
                                if (q16[15:8]!={8{q16[7]}}) begin
                                if (q16[15:8]!={8{q16[7]}}) begin
 
                                        $display("DIVIDE Overflow");
                                        int_num <= 8'h00;
                                        int_num <= 8'h00;
                                        state <= INT2;
                                        state <= INT2;
                                end
                                end
                        end
                        end
                        else begin
                        else begin
                                if (q16[15:8]!=8'h00) begin
                                if (q16[15:8]!=8'h00) begin
 
                                        $display("DIVIDE Overflow");
                                        int_num <= 8'h00;
                                        int_num <= 8'h00;
                                        state <= INT2;
                                        state <= INT2;
                                end
                                end
                        end
                        end
                end
                end
        end
        end
 
 

powered by: WebSVN 2.1.0

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