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

Subversion Repositories rtf8088

[/] [rtf8088/] [trunk/] [rtl/] [verilog/] [DIVIDE.v] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 robfinch
//============================================================================
2
//  DIVIDE.v
3
//
4
//  (C) 2009-2012 Robert Finch
5
//  Stratford
6
//  robfinch<remove>@opencores.org
7
//
8
//
9
// This source file is free software: you can redistribute it and/or modify 
10
// it under the terms of the GNU Lesser General Public License as published 
11
// by the Free Software Foundation, either version 3 of the License, or     
12
// (at your option) any later version.                                      
13
//                                                                          
14
// This source file is distributed in the hope that it will be useful,      
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
17
// GNU General Public License for more details.                             
18
//                                                                          
19
// You should have received a copy of the GNU General Public License        
20
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
21
//
22
//
23
//=============================================================================
24
//
25
// Check for divide by zero
26
// Load the divider
27
DIVIDE1:
28
        begin
29
                state <= DIVIDE2;
30
                // Check for divide by zero
31
                if (w) begin
32
                        if (b[15:0]==16'h0000) begin
33
                                $display("Divide by zero");
34
                                int_num <= 8'h00;
35
                                state <= INT2;
36
                        end
37
                        else
38
                                ld_div32 <= 1'b1;
39
                end
40
                else begin
41
                        if (b[7:0]==8'h00) begin
42
                                $display("Divide by zero");
43
                                int_num <= 8'h00;
44
                                state <= INT2;
45
                        end
46
                        else
47
                                ld_div16 <= 1'b1;
48
                end
49
        end
50
DIVIDE2:
51
        begin
52 7 robfinch
                $display("DIVIDE2");
53 6 robfinch
                ld_div32 <= 1'b0;
54
                ld_div16 <= 1'b0;
55
                state <= DIVIDE2a;
56
        end
57
DIVIDE2a:
58
        begin
59 7 robfinch
                $display("DIVIDE2a");
60 6 robfinch
                if (w & div32_done)
61
                        state <= DIVIDE3;
62
                else if (!w & div16_done)
63
                        state <= DIVIDE3;
64
        end
65
 
66
// Assign results to registers
67
// Trap on divider overflow
68
DIVIDE3:
69
        begin
70 7 robfinch
                $display("DIVIDE3 state <= IFETCH");
71 6 robfinch
                state <= IFETCH;
72
                if (w) begin
73
                        ax <= q32[15:0];
74
                        dx <= r32[15:0];
75
                        if (TTT[0]) begin
76
                                if (q32[31:16]!={16{q32[15]}}) begin
77 7 robfinch
                                        $display("DIVIDE Overflow");
78 6 robfinch
                                        int_num <= 8'h00;
79
                                        state <= INT2;
80
                                end
81
                        end
82
                        else begin
83
                                if (q32[31:16]!=16'h0000) begin
84 7 robfinch
                                        $display("DIVIDE Overflow");
85 6 robfinch
                                        int_num <= 8'h00;
86
                                        state <= INT2;
87
                                end
88
                        end
89
                end
90
                else begin
91
                        ax[ 7:0] <= q16[7:0];
92
                        ax[15:8] <= r16;
93
                        if (TTT[0]) begin
94
                                if (q16[15:8]!={8{q16[7]}}) begin
95 7 robfinch
                                        $display("DIVIDE Overflow");
96 6 robfinch
                                        int_num <= 8'h00;
97
                                        state <= INT2;
98
                                end
99
                        end
100
                        else begin
101
                                if (q16[15:8]!=8'h00) begin
102 7 robfinch
                                        $display("DIVIDE Overflow");
103 6 robfinch
                                        int_num <= 8'h00;
104
                                        state <= INT2;
105
                                end
106
                        end
107
                end
108
        end

powered by: WebSVN 2.1.0

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