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

Subversion Repositories rtf8088

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 robfinch
//=============================================================================
2
//  Fetch instruction
3
//
4
//
5 8 robfinch
//  (C) 2009,2010,2012,2013 Robert Finch, Stratford
6
//  robfinch<remove>@finitron.ca
7 2 robfinch
//
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 8 robfinch
                $display("\r\n******************************************************");
40
                $display("time: %d", $time);
41 7 robfinch
                $display("CSIP: %h", csip);
42 8 robfinch
                $display("AX=%h  SI=%h", ax, si);
43
                $display("BX=%h  DI=%h", bx, di);
44
                $display("CX=%h  BP=%h", cx, bp);
45
                $display("DX=%h  SP=%h", dx, sp);
46 2 robfinch
                // Reset all instruction processing flags at instruction fetch
47
                cyc_type <= `CT_PASSIVE;
48
                mod <= 2'd0;
49
                rrr <= 3'd0;
50
                rm <= 3'd0;
51
                sxi <= 1'b0;
52
                hasFetchedModrm <= 1'b0;
53
                hasFetchedDisp8 <= 1'b0;
54
                hasFetchedDisp16 <= 1'b0;
55
                hasFetchedVector <= 1'b0;
56
                hasStoredData <= 1'b0;
57
                hasFetchedData <= 1'b0;
58
                data16 <= 16'h0000;
59
                cnt <= 7'd0;
60
//              if (prefix1!=8'h00 && prefix2 !=8'h00 && is_prefix)
61
//                      state <= TRIPLE_PREFIX;
62
                if (is_prefix) begin
63
                        prefix1 <= ir;
64
                        prefix2 <= prefix1;
65
                end
66
                else begin
67
                        prefix1 <= 8'h00;
68
                        prefix2 <= 8'h00;
69
                end
70
 
71
        if (pe_nmi & checkForInts) begin
72
            state <= INT2;
73
            rst_nmi <= 1'b1;
74
            int_num <= 8'h02;
75
            ir <= `NOP;
76
        end
77
        else if (irq_i & ie & checkForInts) begin
78
            state <= INTA0;
79
            ir <= `NOP;
80
        end
81
        else if (ir==`HLT) begin
82
                        state <= IFETCH;
83
                cyc_type <= `CT_HALT;
84
        end
85
        else begin
86
                        state <= IFETCH_ACK;
87 7 robfinch
                        read(`CT_CODE,csip);
88 2 robfinch
                        inta_o <= 1'b0;
89
                        mio_o <= 1'b1;
90
                        lock_o <= bus_locked;
91
                end
92
        end
93
 
94
IFETCH_ACK:
95
        if (ack_i) begin
96 7 robfinch
                nack_ir();
97 8 robfinch
                $display("CSIP: %h IR: %h",csip,dat_i);
98 2 robfinch
                if (!hasPrefix)
99
                        ir_ip <= ip;
100
//              ir_ip <= dat_i;
101
                w <= dat_i[0];
102
                d <= dat_i[1];
103 4 robfinch
                v <= dat_i[1];
104 2 robfinch
                sxi <= dat_i[1];
105
                sreg2 <= dat_i[4:3];
106
                sreg3 <= {1'b0,dat_i[4:3]};
107
                ir2 <= 8'h00;
108
                state <= DECODE;
109
        end
110
 
111
// Fetch extended opcode
112
//
113
XI_FETCH:
114
        begin
115 7 robfinch
                read(`CT_CODE,csip);
116 2 robfinch
                state <= XI_FETCH_ACK;
117
        end
118
 
119
XI_FETCH_ACK:
120
        if (ack_i) begin
121 7 robfinch
                nack_ir2();
122 2 robfinch
                state <= DECODER2;
123
        end

powered by: WebSVN 2.1.0

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