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

Subversion Repositories rtf65002

[/] [rtf65002/] [trunk/] [rtl/] [verilog/] [rtf65002_itagmem2way.v] - Blame information for rev 32

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

Line No. Rev Author Line
1 32 robfinch
// ============================================================================
2
//        __
3
//   \\__/ o\    (C) 2013  Robert Finch, Stratford
4
//    \  __ /    All rights reserved.
5
//     \/_//     robfinch<remove>@opencores.org
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
//
23
module rtf65002_itagmem2way(whichrd, whichwr, wclk, wr, adr, rclk, pc, hit0, hit1);
24
output reg [1:0] whichrd;
25
input whichwr;
26
input wclk;
27
input wr;
28
input [33:0] adr;
29
input rclk;
30
input [31:0] pc;
31
output reg hit0;
32
output reg hit1;
33
 
34
wire [31:0] pcp8 = pc + 32'd8;
35
wire [31:0] tag0a,tag0b;
36
wire [31:0] tag1a,tag1b;
37
reg [31:0] rpc;
38
reg [31:0] rpcp8;
39
wire hit0a,hit1a;
40
wire hit0b,hit1b;
41
 
42
always @(posedge rclk)
43
        rpc <= pc;
44
always @(posedge rclk)
45
        rpcp8 <= pcp8;
46
 
47
syncRam512x32_1rw1r ram0 (
48
        .wrst(1'b0),
49
        .wclk(wclk),
50
        .wce(adr[3:2]==2'b11 && !whichwr),
51
        .we(wr),
52
        .wadr(adr[12:4]),
53
        .i(adr[31:0]),
54
        .wo(),
55
 
56
        .rrst(1'b0),
57
        .rclk(rclk),
58
        .rce(1'b1),
59
        .radr(pc[12:4]),
60
        .o(tag0a)
61
);
62
 
63
syncRam512x32_1rw1r ram1 (
64
        .wrst(1'b0),
65
        .wclk(wclk),
66
        .wce(adr[3:2]==2'b11 && !whichwr),
67
        .we(wr),
68
        .wadr(adr[12:4]),
69
        .i(adr[31:0]),
70
        .wo(),
71
 
72
        .rrst(1'b0),
73
        .rclk(rclk),
74
        .rce(1'b1),
75
        .radr(pcp8[12:4]),
76
        .o(tag1a)
77
);
78
 
79
syncRam512x32_1rw1r ram2 (
80
        .wrst(1'b0),
81
        .wclk(wclk),
82
        .wce(adr[3:2]==2'b11 && whichwr),
83
        .we(wr),
84
        .wadr(adr[12:4]),
85
        .i(adr[31:0]),
86
        .wo(),
87
 
88
        .rrst(1'b0),
89
        .rclk(rclk),
90
        .rce(1'b1),
91
        .radr(pc[12:4]),
92
        .o(tag0b)
93
);
94
 
95
syncRam512x32_1rw1r ram3 (
96
        .wrst(1'b0),
97
        .wclk(wclk),
98
        .wce(adr[3:2]==2'b11 && whichwr),
99
        .we(wr),
100
        .wadr(adr[12:4]),
101
        .i(adr[31:0]),
102
        .wo(),
103
 
104
        .rrst(1'b0),
105
        .rclk(rclk),
106
        .rce(1'b1),
107
        .radr(pcp8[12:4]),
108
        .o(tag1b)
109
);
110
 
111
assign hit0a = tag0a[31:13]==rpc[31:13] && tag0a[0];
112
assign hit1a = tag1a[31:13]==rpcp8[31:13] && tag1a[0];
113
assign hit0b = tag0b[31:13]==rpc[31:13] && tag0b[0];
114
assign hit1b = tag1b[31:13]==rpcp8[31:13] && tag1b[0];
115
 
116
always @(hit0a or hit1a or hit0b or hit1b or whichwr)
117
if (hit0a & hit1a) begin
118
        hit0 <= 1'b1;
119
        hit1 <= 1'b1;
120
        whichrd <= 2'b00;
121
end
122
else if (hit0b & hit1b) begin
123
        hit0 <= 1'b1;
124
        hit1 <= 1'b1;
125
        whichrd <= 2'b01;
126
end
127
else if (hit0a & hit1b) begin
128
        hit0 <= 1'b1;
129
        hit1 <= 1'b1;
130
        whichrd <= 2'b10;
131
end
132
else if (hit0b & hit1a) begin
133
        hit0 <= 1'b1;
134
        hit1 <= 1'b1;
135
        whichrd <= 2'b11;
136
end
137
else begin
138
        whichrd <= 2'b00;
139
        if (whichwr) begin
140
                hit0 <= hit0b;
141
                hit1 <= hit1b;
142
        end
143
        else begin
144
                hit0 <= hit0a;
145
                hit1 <= hit1a;
146
        end
147
end
148
 
149
 
150
endmodule

powered by: WebSVN 2.1.0

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