1 |
9 |
robfinch |
// ============================================================================
|
2 |
|
|
// __
|
3 |
|
|
// \\__/ o\ (C) 2015 Robert Finch, Stratford
|
4 |
|
|
// \ __ / All rights reserved.
|
5 |
|
|
// \/_// robfinch<remove>@finitron.ca
|
6 |
|
|
// ||
|
7 |
|
|
//
|
8 |
|
|
// This source file is free software: you can redistribute it and/or modify
|
9 |
|
|
// it under the terms of the GNU Lesser General Public License as published
|
10 |
|
|
// by the Free Software Foundation, either version 3 of the License, or
|
11 |
|
|
// (at your option) any later version.
|
12 |
|
|
//
|
13 |
|
|
// This source file is distributed in the hope that it will be useful,
|
14 |
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
|
|
// GNU General Public License for more details.
|
17 |
|
|
//
|
18 |
|
|
// You should have received a copy of the GNU General Public License
|
19 |
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
20 |
|
|
//
|
21 |
|
|
//
|
22 |
|
|
// Establish the source queue id for a target register after a branch.
|
23 |
|
|
// Makes use of the fact that in Verilog later instructions override
|
24 |
|
|
// earlier ones. So if there are two queue entries that use the same
|
25 |
|
|
// target register, the later queue entry will become the valid source
|
26 |
|
|
// as it's written after the earlier queue entry.
|
27 |
|
|
//
|
28 |
|
|
// This code uses a tree approach rather than loop logic which races to the
|
29 |
|
|
// the right value. The timing from the toolset is a little more reliable
|
30 |
|
|
// that way.
|
31 |
|
|
//
|
32 |
|
|
// ============================================================================
|
33 |
|
|
//
|
34 |
|
|
if (branchmiss) begin
|
35 |
|
|
// Default the entire register file as valid, then invalidate target
|
36 |
|
|
// registers as they are found in the queue.
|
37 |
|
|
for (n = 1; n < NREGS; n = n + 1)
|
38 |
|
|
rf_v[n] = `VAL;
|
39 |
|
|
// Missed at head0, one instruction (current one) to worry about.
|
40 |
|
|
if (missid==head0) begin
|
41 |
|
|
rf_source[iqentry_tgt[head0]] <= { iqentry_mem[head0], head0};
|
42 |
|
|
rf_v[iqentry_tgt[head0]] = `INV;
|
43 |
|
|
end
|
44 |
|
|
else if (missid==head1) begin
|
45 |
|
|
rf_source[iqentry_tgt[head0]] <= { iqentry_mem[head0], head0};
|
46 |
|
|
rf_v[iqentry_tgt[head0]] = `INV;
|
47 |
|
|
rf_source[iqentry_tgt[head1]] <= { iqentry_mem[head1], head1};
|
48 |
|
|
rf_v[iqentry_tgt[head1]] = `INV;
|
49 |
|
|
end
|
50 |
|
|
else if (missid==head2) begin
|
51 |
|
|
rf_source[iqentry_tgt[head0]] <= { iqentry_mem[head0], head0};
|
52 |
|
|
rf_v[iqentry_tgt[head0]] = `INV;
|
53 |
|
|
rf_source[iqentry_tgt[head1]] <= { iqentry_mem[head1], head1};
|
54 |
|
|
rf_v[iqentry_tgt[head1]] = `INV;
|
55 |
|
|
rf_source[iqentry_tgt[head2]] <= { iqentry_mem[head2], head2};
|
56 |
|
|
rf_v[iqentry_tgt[head2]] = `INV;
|
57 |
|
|
end
|
58 |
|
|
else if (missid==head3) begin
|
59 |
|
|
rf_source[iqentry_tgt[head0]] <= { iqentry_mem[head0], head0};
|
60 |
|
|
rf_v[iqentry_tgt[head0]] = `INV;
|
61 |
|
|
rf_source[iqentry_tgt[head1]] <= { iqentry_mem[head1], head1};
|
62 |
|
|
rf_v[iqentry_tgt[head1]] = `INV;
|
63 |
|
|
rf_source[iqentry_tgt[head2]] <= { iqentry_mem[head2], head2};
|
64 |
|
|
rf_v[iqentry_tgt[head2]] = `INV;
|
65 |
|
|
rf_source[iqentry_tgt[head3]] <= { iqentry_mem[head3], head3};
|
66 |
|
|
rf_v[iqentry_tgt[head3]] = `INV;
|
67 |
|
|
end
|
68 |
|
|
else if (missid==head4) begin
|
69 |
|
|
rf_source[iqentry_tgt[head0]] <= { iqentry_mem[head0], head0};
|
70 |
|
|
rf_v[iqentry_tgt[head0]] = `INV;
|
71 |
|
|
rf_source[iqentry_tgt[head1]] <= { iqentry_mem[head1], head1};
|
72 |
|
|
rf_v[iqentry_tgt[head1]] = `INV;
|
73 |
|
|
rf_source[iqentry_tgt[head2]] <= { iqentry_mem[head2], head2};
|
74 |
|
|
rf_v[iqentry_tgt[head2]] = `INV;
|
75 |
|
|
rf_source[iqentry_tgt[head3]] <= { iqentry_mem[head3], head3};
|
76 |
|
|
rf_v[iqentry_tgt[head3]] = `INV;
|
77 |
|
|
rf_source[iqentry_tgt[head4]] <= { iqentry_mem[head4], head4};
|
78 |
|
|
rf_v[iqentry_tgt[head4]] = `INV;
|
79 |
|
|
end
|
80 |
|
|
else if (missid==head5) begin
|
81 |
|
|
rf_source[iqentry_tgt[head0]] <= { iqentry_mem[head0], head0};
|
82 |
|
|
rf_v[iqentry_tgt[head0]] = `INV;
|
83 |
|
|
rf_source[iqentry_tgt[head1]] <= { iqentry_mem[head1], head1};
|
84 |
|
|
rf_v[iqentry_tgt[head1]] = `INV;
|
85 |
|
|
rf_source[iqentry_tgt[head2]] <= { iqentry_mem[head2], head2};
|
86 |
|
|
rf_v[iqentry_tgt[head2]] = `INV;
|
87 |
|
|
rf_source[iqentry_tgt[head3]] <= { iqentry_mem[head3], head3};
|
88 |
|
|
rf_v[iqentry_tgt[head3]] = `INV;
|
89 |
|
|
rf_source[iqentry_tgt[head4]] <= { iqentry_mem[head4], head4};
|
90 |
|
|
rf_v[iqentry_tgt[head4]] = `INV;
|
91 |
|
|
rf_source[iqentry_tgt[head5]] <= { iqentry_mem[head5], head5};
|
92 |
|
|
rf_v[iqentry_tgt[head5]] = `INV;
|
93 |
|
|
end
|
94 |
|
|
else if (missid==head6) begin
|
95 |
|
|
rf_source[iqentry_tgt[head0]] <= { iqentry_mem[head0], head0};
|
96 |
|
|
rf_v[iqentry_tgt[head0]] = `INV;
|
97 |
|
|
rf_source[iqentry_tgt[head1]] <= { iqentry_mem[head1], head1};
|
98 |
|
|
rf_v[iqentry_tgt[head1]] = `INV;
|
99 |
|
|
rf_source[iqentry_tgt[head2]] <= { iqentry_mem[head2], head2};
|
100 |
|
|
rf_v[iqentry_tgt[head2]] = `INV;
|
101 |
|
|
rf_source[iqentry_tgt[head3]] <= { iqentry_mem[head3], head3};
|
102 |
|
|
rf_v[iqentry_tgt[head3]] = `INV;
|
103 |
|
|
rf_source[iqentry_tgt[head4]] <= { iqentry_mem[head4], head4};
|
104 |
|
|
rf_v[iqentry_tgt[head4]] = `INV;
|
105 |
|
|
rf_source[iqentry_tgt[head5]] <= { iqentry_mem[head5], head5};
|
106 |
|
|
rf_v[iqentry_tgt[head5]] = `INV;
|
107 |
|
|
rf_source[iqentry_tgt[head6]] <= { iqentry_mem[head6], head6};
|
108 |
|
|
rf_v[iqentry_tgt[head6]] = `INV;
|
109 |
|
|
end
|
110 |
|
|
else if (missid==head7) begin
|
111 |
|
|
rf_source[iqentry_tgt[head0]] <= { iqentry_mem[head0], head0};
|
112 |
|
|
rf_v[iqentry_tgt[head0]] = `INV;
|
113 |
|
|
rf_source[iqentry_tgt[head1]] <= { iqentry_mem[head1], head1};
|
114 |
|
|
rf_v[iqentry_tgt[head1]] = `INV;
|
115 |
|
|
rf_source[iqentry_tgt[head2]] <= { iqentry_mem[head2], head2};
|
116 |
|
|
rf_v[iqentry_tgt[head2]] = `INV;
|
117 |
|
|
rf_source[iqentry_tgt[head3]] <= { iqentry_mem[head3], head3};
|
118 |
|
|
rf_v[iqentry_tgt[head3]] = `INV;
|
119 |
|
|
rf_source[iqentry_tgt[head4]] <= { iqentry_mem[head4], head4};
|
120 |
|
|
rf_v[iqentry_tgt[head4]] = `INV;
|
121 |
|
|
rf_source[iqentry_tgt[head5]] <= { iqentry_mem[head5], head5};
|
122 |
|
|
rf_v[iqentry_tgt[head5]] = `INV;
|
123 |
|
|
rf_source[iqentry_tgt[head6]] <= { iqentry_mem[head6], head6};
|
124 |
|
|
rf_v[iqentry_tgt[head6]] = `INV;
|
125 |
|
|
rf_source[iqentry_tgt[head7]] <= { iqentry_mem[head7], head7};
|
126 |
|
|
rf_v[iqentry_tgt[head7]] = `INV;
|
127 |
|
|
end
|
128 |
|
|
// The following registers are always valid
|
129 |
|
|
rf_v[7'h00] = `VAL;
|
130 |
|
|
rf_v[7'h50] = `VAL; // C0
|
131 |
|
|
rf_v[7'h5F] = `VAL; // C15 (PC)
|
132 |
|
|
rf_v[7'h72] = `VAL; // tick
|
133 |
|
|
end
|
134 |
|
|
|