Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / fpga / rtl / l2_dir.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: l2_dir.v
4// Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
5// 4150 Network Circle, Santa Clara, California 95054, U.S.A.
6//
7// * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8//
9// This program is free software; you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation; version 2 of the License.
12//
13// This program 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, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21//
22// For the avoidance of doubt, and except that if any non-GPL license
23// choice is available it will apply instead, Sun elects to use only
24// the General Public License version 2 (GPLv2) at this time for any
25// software where a choice of GPL license versions is made
26// available with the language indicating that GPLv2 or any later version
27// may be used, or where a choice of which version of the GPL is applied is
28// otherwise unspecified.
29//
30// Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
31// CA 95054 USA or visit www.sun.com if you need additional information or
32// have any questions.
33//
34// ========== Copyright Header End ============================================
35`timescale 1 ns / 10 ps
36module l2_dir(clk, reset, pa_in, index, pa_wr, val, way_hit, dir_hit_way_enc,
37 rd_en);
38
39 input clk;
40 input reset;
41 input rd_en;
42 input val;
43 input [27:0] pa_in;
44 input [3:0] pa_wr;
45 input [6:0] index;
46 output [3:0] way_hit;
47 output [1:0] dir_hit_way_enc;
48
49 reg [27:0] dta_way0[127:0];
50 reg [27:0] dta_way1[127:0];
51 reg [27:0] dta_way2[127:0];
52 reg [27:0] dta_way3[127:0];
53
54 reg [127:0] valid_w0;
55 reg [127:0] valid_w1;
56 reg [127:0] valid_w2;
57 reg [127:0] valid_w3;
58 wire [3:0] wr_way_d = pa_wr;
59 reg [3:0] way_hit_r;
60 wire [6:0] index_y_d = index;
61 wire [27:0] wrtag_y = pa_in;
62 reg [3:0] squash;
63 reg mult;
64 reg dbg_en;
65 reg dbg_en2;
66 reg [3:0] wr_way_d_d;
67 reg [3:0] wr_way_d_d_d;
68
69 assign dir_hit_way_enc = (way_hit[0] ? 0 : (way_hit[1] ? 1 : (way_hit[2]
70 ? 2 : 3)));
71 assign way_hit = way_hit_r;
72
73 always @(posedge clk) begin
74 if (reset) begin
75 valid_w0 <= 0;
76 valid_w1 <= 0;
77 valid_w2 <= 0;
78 valid_w3 <= 0;
79 end
80 else
81 begin
82 if (wr_way_d[0] | squash[0]) begin
83 valid_w0[index_y_d] <= (val & (~squash[0]));
84 end
85 if (wr_way_d[1] | squash[1]) begin
86 valid_w1[index_y_d] <= (val & (~squash[1]));
87 end
88 if (wr_way_d[2] | squash[2]) begin
89 valid_w2[index_y_d] <= (val & (~squash[2]));
90 end
91 if (wr_way_d[3] | squash[3]) begin
92 valid_w3[index_y_d] <= (val & (~squash[3]));
93 end
94 end
95 end
96 always @(posedge clk) begin
97 wr_way_d_d <= wr_way_d;
98 wr_way_d_d_d <= wr_way_d_d;
99 if ((((way_hit_r[0] + way_hit_r[1]) + way_hit_r[2]) + way_hit_r[3]) >
100 1) begin
101 mult <= 1;
102 end
103 else
104 begin
105 mult <= 0;
106 end
107 if (((((way_hit_r[0] + way_hit_r[1]) + way_hit_r[2]) + way_hit_r[3]) >
108 1) & (|wr_way_d_d_d)) begin
109 squash <= (way_hit_r & (~wr_way_d_d_d));
110 end
111 else
112 begin
113 squash <= 4'b0;
114 end
115 way_hit_r <= {((dta_way3[index_y_d[6:0]] == pa_in) &
116 valid_w3[index_y_d]), ((dta_way2[index_y_d[6:0]] == pa_in) &
117 valid_w2[index_y_d]), ((dta_way1[index_y_d[6:0]] == pa_in) &
118 valid_w1[index_y_d]), ((dta_way0[index_y_d[6:0]] == pa_in) &
119 valid_w0[index_y_d])};
120 if (wr_way_d[0]) begin
121 dta_way0[index_y_d[6:0]] <= wrtag_y;
122 end
123 if (wr_way_d[1]) begin
124 dta_way1[index_y_d[6:0]] <= wrtag_y;
125 end
126 if (wr_way_d[2]) begin
127 dta_way2[index_y_d[6:0]] <= wrtag_y;
128 end
129 if (wr_way_d[3]) begin
130 dta_way3[index_y_d[6:0]] <= wrtag_y;
131 end
132 end
133endmodule