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

Subversion Repositories rtf8088

[/] [rtf8088/] [trunk/] [rtl/] [verilog/] [IFETCH.v] - Blame information for rev 4

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

Line No. Rev Author Line
1 2 robfinch
//=============================================================================
2
//  Fetch instruction
3
//
4
//
5
//  (C) 2009,2010,2012 Robert Finch, 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
// - All of the state control flags are reset.
24
//
25
// - If the current instruction is a prefix then we want to shift it
26
//   into the prefix buffer before fetching the instruction. Also
27
//   interrupts are blocked if the previous instruction is a prefix.
28
//
29
// - two bytes are fetched at once if the instruction is aligned on
30
//   an even address. This saves a bus cycle most of the time.
31
//
32
// ToDo:
33
// - add an exception if more than two prefixes are present.
34
//
35
//=============================================================================
36
//
37
IFETCH:
38
        begin
39
                // Reset all instruction processing flags at instruction fetch
40
                cyc_type <= `CT_PASSIVE;
41
                mod <= 2'd0;
42
                rrr <= 3'd0;
43
                rm <= 3'd0;
44
                sxi <= 1'b0;
45
                hasFetchedModrm <= 1'b0;
46
                hasFetchedDisp8 <= 1'b0;
47
                hasFetchedDisp16 <= 1'b0;
48
                hasFetchedVector <= 1'b0;
49
                hasStoredData <= 1'b0;
50
                hasFetchedData <= 1'b0;
51
                data16 <= 16'h0000;
52
                cnt <= 7'd0;
53
//              if (prefix1!=8'h00 && prefix2 !=8'h00 && is_prefix)
54
//                      state <= TRIPLE_PREFIX;
55
                if (is_prefix) begin
56
                        prefix1 <= ir;
57
                        prefix2 <= prefix1;
58
                end
59
                else begin
60
                        prefix1 <= 8'h00;
61
                        prefix2 <= 8'h00;
62
                end
63
 
64
        if (pe_nmi & checkForInts) begin
65
            state <= INT2;
66
            rst_nmi <= 1'b1;
67
            int_num <= 8'h02;
68
            ir <= `NOP;
69
        end
70
        else if (irq_i & ie & checkForInts) begin
71
            state <= INTA0;
72
            ir <= `NOP;
73
        end
74
        else if (ir==`HLT) begin
75
                        state <= IFETCH;
76
                cyc_type <= `CT_HALT;
77
        end
78
        else begin
79
                        state <= IFETCH_ACK;
80
                        `INITIATE_CODE_READ
81
                        inta_o <= 1'b0;
82
                        mio_o <= 1'b1;
83
                        lock_o <= bus_locked;
84
                end
85
        end
86
 
87
IFETCH_ACK:
88
        if (ack_i) begin
89
                `TERMINATE_CODE_READ
90
                ir <= dat_i;
91
                $display("IR: %h",dat_i);
92
                if (!hasPrefix)
93
                        ir_ip <= ip;
94
//              ir_ip <= dat_i;
95
                w <= dat_i[0];
96
                d <= dat_i[1];
97 4 robfinch
                v <= dat_i[1];
98 2 robfinch
                sxi <= dat_i[1];
99
                sreg2 <= dat_i[4:3];
100
                sreg3 <= {1'b0,dat_i[4:3]};
101
                ir2 <= 8'h00;
102
                state <= DECODE;
103
        end
104
 
105
// Fetch extended opcode
106
//
107
XI_FETCH:
108
        begin
109
                `INITIATE_CODE_READ
110
                state <= XI_FETCH_ACK;
111
        end
112
 
113
XI_FETCH_ACK:
114
        if (ack_i) begin
115
                `TERMINATE_CODE_READ
116
                ir2 <= dat_i;
117
                state <= DECODER2;
118
        end

powered by: WebSVN 2.1.0

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