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

Subversion Repositories thor

[/] [thor/] [trunk/] [FT64/] [rtl/] [twoway/] [FT64_stomp.v] - Blame information for rev 47

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

Line No. Rev Author Line
1 43 robfinch
// ============================================================================
2
//        __
3
//   \\__/ o\    (C) 2017-2018  Robert Finch, Waterloo
4
//    \  __ /    All rights reserved.
5
//     \/_//     robfinch<remove>@finitron.ca
6
//       ||
7
//
8
//      FT64_stomp.v
9
//
10
// This source file is free software: you can redistribute it and/or modify 
11
// it under the terms of the GNU Lesser General Public License as published 
12
// by the Free Software Foundation, either version 3 of the License, or     
13
// (at your option) any later version.                                      
14
//                                                                          
15
// This source file is distributed in the hope that it will be useful,      
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
18
// GNU General Public License for more details.                             
19
//                                                                          
20
// You should have received a copy of the GNU General Public License        
21
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
22
//
23
// ============================================================================
24
//
25
`define QBITS   2:0
26
 
27
module FT64_stomp(branchmiss,branchmiss_thrd,missid,head0,thread_en,thrd,iqentry_v,stomp);
28
parameter QENTRIES = 8;
29
input branchmiss;
30
input branchmiss_thrd;
31
input [`QBITS] missid;
32
input [`QBITS] head0;
33
input thread_en;
34
input [QENTRIES-1:0] thrd;
35
input [QENTRIES-1:0] iqentry_v;
36
output reg [QENTRIES-1:0] stomp;
37
 
38
// Stomp logic for branch miss.
39
 
40
integer n;
41
reg [QENTRIES-1:0] stomp2;
42
reg [`QBITS] contid;
43
always @*
44
if (branchmiss) begin
45
    stomp2 = 8'h00;
46
 
47
    // If missed at the head, all queue entries but the head are stomped on.
48
    if (head0==missid) begin
49
        for (n = 0; n < QENTRIES; n = n + 1)
50
            if (n!=missid) begin
51
                if (thread_en) begin
52
                        if (thrd[n]==branchmiss_thrd)
53
                                stomp2[n] = iqentry_v[n];
54
                end
55
                else
56
                        stomp2[n] = iqentry_v[n];
57
            end
58
    end
59
    // If head0 is after the missid queue entries between the missid and
60
    // head0 are stomped on.
61
    else if (head0 > missid) begin
62
        for (n = 0; n < QENTRIES; n = n + 1)
63
            if (n > missid && n < head0) begin
64
                if (thread_en) begin
65
                        if (thrd[n]==branchmiss_thrd)
66
                                stomp2[n] = iqentry_v[n];
67
                end
68
                else
69
                        stomp2[n] = iqentry_v[n];
70
            end
71
    end
72
    // Otherwise still queue entries between missid and head0 are stomped on
73
    // but the range 'wraps around'.
74
    else begin
75
        for (n = 0; n < QENTRIES; n = n + 1)
76
            if (n < head0) begin
77
                if (thread_en) begin
78
                        if (thrd[n]==branchmiss_thrd)
79
                                stomp2[n] = iqentry_v[n];
80
                end
81
                else
82
                        stomp2[n] = iqentry_v[n];
83
            end
84
        for (n = 0; n < QENTRIES; n = n + 1)
85
            if (n >= missid + 1) begin
86
                if (thread_en) begin
87
                        if (thrd[n]==branchmiss_thrd)
88
                                stomp2[n] = iqentry_v[n];
89
                end
90
                else
91
                        stomp2[n] = iqentry_v[n];
92
            end
93
    end
94
    /*
95
    // Not sure this logic is worth it for the few cases where the target
96
    // of the branch is in the queue already and there are no target
97
    // registers in code stepped over.
98
    if (BRANCH_PRED) begin
99
        // If the next instruction in the queue is the target for the miss
100
        // then no instructions should have been stomped on. Undo the stomp.
101
        // In this case there would be no branchmiss.
102
        if (iqentry_stomp2[idp1(missid)] && iqentry_pc[idp1(missid)]==misspc) begin
103
            iqentry_stomp = 8'h00;
104
        end
105
        else if (iqentry_stomp2[idp2(missid)] && iqentry_pc[idp2(missid)]==misspc) begin
106
            if (iqentry_tgt[idp1(missid)]==12'h000) begin
107
                iqentry_stomp = 8'h00;
108
                setpred[(missid+1)&7] = `INV;
109
            end
110
            else
111
                iqentry_stomp = iqentry_stomp2;
112
        end
113
        else if (iqentry_stomp2[(missid+3)&7] && iqentry_pc[(missid+3)&7]==misspc) begin
114
            if (iqentry_tgt[(missid+1)&7]==8'h00 &&
115
                iqentry_tgt[(missid+2)&7]==8'h00) begin
116
                iqentry_stomp = 8'h00;
117
                setpred[(missid+1)&7] = `INV;
118
                setpred[(missid+2)&7] = `INV;
119
            end
120
            else
121
                iqentry_stomp = iqentry_stomp2;
122
        end
123
        else if (iqentry_stomp2[(missid+4)&7] && iqentry_pc[(missid+4)&7]==misspc) begin
124
            if (iqentry_tgt[(missid+1)&7]==8'h00 &&
125
                iqentry_tgt[(missid+2)&7]==8'h00 &&
126
                iqentry_tgt[(missid+3)&7]==8'h00
127
                ) begin
128
                iqentry_stomp = 8'h00;
129
                setpred[(missid+1)&7] = `INV;
130
                setpred[(missid+2)&7] = `INV;
131
                setpred[(missid+3)&7] = `INV;
132
            end
133
            else
134
                iqentry_stomp = iqentry_stomp2;
135
        end
136
        else if (iqentry_stomp2[(missid+5)&7] && iqentry_pc[(missid+5)&7]==misspc) begin
137
            if (iqentry_tgt[(missid+1)&7]==8'h00 &&
138
                iqentry_tgt[(missid+2)&7]==8'h00 &&
139
                iqentry_tgt[(missid+3)&7]==8'h00 &&
140
                iqentry_tgt[(missid+4)&7]==8'h00
141
                ) begin
142
                iqentry_stomp = 8'h00;
143
                setpred[(missid+1)&7] = `INV;
144
                setpred[(missid+2)&7] = `INV;
145
                setpred[(missid+3)&7] = `INV;
146
                setpred[(missid+4)&7] = `INV;
147
            end
148
            else
149
                iqentry_stomp = iqentry_stomp2;
150
        end
151
        else if (iqentry_stomp2[(missid+6)&7] && iqentry_pc[(missid+6)&7]==misspc) begin
152
            if (iqentry_tgt[(missid+1)&7]==8'h00 &&
153
                iqentry_tgt[(missid+2)&7]==8'h00 &&
154
                iqentry_tgt[(missid+3)&7]==8'h00 &&
155
                iqentry_tgt[(missid+4)&7]==8'h00 &&
156
                iqentry_tgt[(missid+5)&7]==8'h00
157
            ) begin
158
                iqentry_stomp = 8'h00;
159
                setpred[(missid+1)&7] = `INV;
160
                setpred[(missid+2)&7] = `INV;
161
                setpred[(missid+3)&7] = `INV;
162
                setpred[(missid+4)&7] = `INV;
163
                setpred[(missid+5)&7] = `INV;
164
            end
165
            else
166
                iqentry_stomp = iqentry_stomp2;
167
        end
168
        else if (iqentry_stomp2[(missid+7)&7] && iqentry_pc[(missid+7)&7]==misspc) begin
169
            if (iqentry_tgt[(missid+1)&7]==8'h00 &&
170
                iqentry_tgt[(missid+2)&7]==8'h00 &&
171
                iqentry_tgt[(missid+3)&7]==8'h00 &&
172
                iqentry_tgt[(missid+4)&7]==8'h00 &&
173
                iqentry_tgt[(missid+5)&7]==8'h00 &&
174
                iqentry_tgt[(missid+6)&7]==8'h00
175
            ) begin
176
                iqentry_stomp = 8'h00;
177
                setpred[(missid+1)&7] = `INV;
178
                setpred[(missid+2)&7] = `INV;
179
                setpred[(missid+3)&7] = `INV;
180
                setpred[(missid+4)&7] = `INV;
181
                setpred[(missid+5)&7] = `INV;
182
                setpred[(missid+6)&7] = `INV;
183
            end
184
            else
185
                iqentry_stomp = iqentry_stomp2;
186
        end
187
        else
188
            iqentry_stomp = iqentry_stomp2;
189
    end
190
    else
191
        iqentry_stomp = iqentry_stomp2;
192
    */
193
    stomp = stomp2;
194
end
195
else begin
196
    stomp = {QENTRIES{1'b0}};
197
end
198
 
199
endmodule

powered by: WebSVN 2.1.0

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