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

Subversion Repositories klc32

[/] [klc32/] [trunk/] [rtl/] [verilog/] [IFETCH.v] - Blame information for rev 11

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 robfinch
// ============================================================================
2
// (C) 2011 Robert Finch
3
// All Rights Reserved.
4
// robfinch<remove>@opencores.org
5
//
6
// KLC32 - 32 bit CPU
7
// IFETCH.v - fetch instructions
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 10 robfinch
//                
22
//                                                   
23
// Check for halted state and interrupts, then fetch instruction if no
24
// halt or interrupt.
25 2 robfinch
// ============================================================================
26
//
27
IFETCH:
28
        if (!cyc_o) begin
29
                if (halt_i) begin
30
                        // empty - do nothing until non-halted
31
                end
32
                else if (nmi_edge) begin
33
                        sr1 <= sr;
34
                        im <= ipl_i;
35
                        tf <= 1'b0;
36
                        sf <= 1'b1;
37 10 robfinch
                        iplr <= ipl_i;
38
                        state <= INTA;
39 2 robfinch
                        nmi_edge <= 1'b0;
40
                end
41
                else if (ipl_i > im) begin
42
                        sr1 <= sr;
43
                        im <= ipl_i;
44
                        tf <= 1'b0;
45
                        sf <= 1'b1;
46
                        iplr <= ipl_i;
47
                        state <= INTA;
48
                end
49
                else if (tf) begin
50
                        sr1 <= sr;
51
                        tf <= 1'b0;
52
                        sf <= 1'b1;
53
                        vector <= `TRACE_VECTOR;
54
                        state <= TRAP;
55
                end
56
                else begin
57
                        fc_o <= {sf,2'b10};
58
                        cyc_o <= 1'b1;
59
                        stb_o <= 1'b1;
60
                        sel_o <= 4'b1111;
61
                        adr_o <= pc;
62
                end
63
        end
64
        else if (ack_i) begin
65
                cyc_o <= 1'b0;
66
                stb_o <= 1'b0;
67
                pc <= pc + 32'd4;
68
                ir <= dat_i;
69
                Rn <= dat_i[25:21];
70
                state <= REGFETCHA;
71
        end
72
        else if (err_i) begin
73
                cyc_o <= 1'b0;
74
                stb_o <= 1'b0;
75
                sel_o <= 4'b0000;
76
                vector <= `BUS_ERR_VECTOR;
77
                state <= TRAP;
78
        end

powered by: WebSVN 2.1.0

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