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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_26/] [or1200/] [rtl/] [verilog/] [or1200_ic_fsm.v] - Blame information for rev 617

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

Line No. Rev Author Line
1 504 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's IC FSM                                             ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/or1k/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Data cache state machine                                    ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   - make it smaller and faster                               ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Damjan Lampret, lampret@opencores.org                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44
// CVS Revision History
45
//
46
// $Log: not supported by cvs2svn $
47 617 lampret
// Revision 1.2  2002/01/14 06:18:22  lampret
48
// Fixed mem2reg bug in FAST implementation. Updated debug unit to work with new genpc/if.
49
//
50 562 lampret
// Revision 1.1  2002/01/03 08:16:15  lampret
51
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
52
//
53 504 lampret
// Revision 1.9  2001/10/21 17:57:16  lampret
54
// Removed params from generic_XX.v. Added translate_off/on in sprs.v and id.v. Removed spr_addr from ic.v and ic.v. Fixed CR+LF.
55
//
56
// Revision 1.8  2001/10/19 23:28:46  lampret
57
// Fixed some synthesis warnings. Configured with caches and MMUs.
58
//
59
// Revision 1.7  2001/10/14 13:12:09  lampret
60
// MP3 version.
61
//
62
// Revision 1.1.1.1  2001/10/06 10:18:35  igorm
63
// no message
64
//
65
// Revision 1.2  2001/08/09 13:39:33  lampret
66
// Major clean-up.
67
//
68
// Revision 1.1  2001/07/20 00:46:03  lampret
69
// Development version of RTL. Libraries are missing.
70
//
71
//
72
 
73
// synopsys translate_off
74
`include "timescale.v"
75
// synopsys translate_on
76
`include "or1200_defines.v"
77
 
78
`define OR1200_ICFSM_IDLE       3'd0
79
`define OR1200_ICFSM_DOLOAD     3'd1
80
`define OR1200_ICFSM_LREFILL3   3'd2
81
 
82
//
83
// Data cache FSM for cache line of 16 bytes (4x singleword)
84
//
85
 
86
module or1200_ic_fsm(
87
        // Clock and reset
88
        clk, rst,
89
 
90
        // Internal i/f to top level IC
91
        ic_en, icimmu_cyc_i, icimmu_stb_i, icimmu_ci_i, icpu_sel_i,
92
        tagcomp_miss, biudata_valid, biudata_error, start_addr, saved_addr,
93
        icram_we, biu_read, first_hit_ack, first_miss_ack, first_miss_err,
94
        burst
95
);
96
 
97
//
98
// I/O
99
//
100
input                           clk;
101
input                           rst;
102
input                           ic_en;
103
input                           icimmu_cyc_i;
104
input                           icimmu_stb_i;
105
input                           icimmu_ci_i;
106
input   [3:0]                    icpu_sel_i;
107
input                           tagcomp_miss;
108
input                           biudata_valid;
109
input                           biudata_error;
110
input   [31:0]                   start_addr;
111
output  [31:0]                   saved_addr;
112
output  [3:0]                    icram_we;
113
output                          biu_read;
114
output                          first_hit_ack;
115
output                          first_miss_ack;
116
output                          first_miss_err;
117
output                          burst;
118
 
119
//
120
// Internal wires and regs
121
//
122
reg     [31:0]                   saved_addr;
123
reg     [2:0]                    state;
124
reg     [2:0]                    cnt;
125
reg                             hitmiss_eval;
126
reg                             load;
127
 
128
//
129
// Generate of ICRAM write enables
130
//
131
assign icram_we = {4{load & biudata_valid}};
132
 
133
//
134
// BIU read and write
135
//
136
assign biu_read = (hitmiss_eval & tagcomp_miss) | (!hitmiss_eval & load);
137
 
138
//
139
// Assert for cache hit first word ready
140
// Assert for cache miss first word stored/loaded OK
141
// Assert for cache miss first word stored/loaded with an error
142
//
143
assign first_hit_ack = (state == `OR1200_ICFSM_DOLOAD) & hitmiss_eval & !tagcomp_miss & !icimmu_ci_i;
144
assign first_miss_ack = (state == `OR1200_ICFSM_DOLOAD) & (tagcomp_miss | icimmu_ci_i) & biudata_valid;
145
assign first_miss_err = (state == `OR1200_ICFSM_DOLOAD) & (tagcomp_miss | icimmu_ci_i) & biudata_error;
146
 
147
//
148
// Assert burst when doing reload of complete cache line
149
//
150
assign burst = (state == `OR1200_ICFSM_DOLOAD) & tagcomp_miss
151
                | (state == `OR1200_ICFSM_LREFILL3);
152
 
153
//
154
// Main IC FSM
155
//
156
always @(posedge clk or posedge rst) begin
157
        if (rst) begin
158
                state <= #1 `OR1200_ICFSM_IDLE;
159
                saved_addr <= #1 32'b0;
160
                hitmiss_eval <= #1 1'b0;
161
                load <= #1 1'b0;
162
                cnt <= #1 3'b000;
163
        end
164
        else
165
        case (state)    // synopsys parallel_case
166
                `OR1200_ICFSM_IDLE :
167
                        if (ic_en & icimmu_cyc_i & icimmu_stb_i) begin                  // load
168
                                state <= #1 `OR1200_ICFSM_DOLOAD;
169
                                saved_addr <= #1 start_addr;
170
                                hitmiss_eval <= #1 1'b1;
171
                                load <= #1 1'b1;
172
                        end
173
                        else begin                                                      // idle
174
                                state <= #1 `OR1200_ICFSM_IDLE;
175
                                hitmiss_eval <= #1 1'b0;
176
                                load <= #1 1'b0;
177
                        end
178
                `OR1200_ICFSM_DOLOAD:
179 617 lampret
                        if (!ic_en)
180 504 lampret
                                state <= #1 `OR1200_ICFSM_IDLE;
181 617 lampret
                        else if (hitmiss_eval & !(icimmu_cyc_i & icimmu_stb_i)) begin   // load aborted (usually caused by IMMU)
182
                                state <= #1 `OR1200_ICFSM_IDLE;
183 504 lampret
                                hitmiss_eval <= #1 1'b0;
184
                                load <= #1 1'b0;
185
                        end
186
                        else if (icimmu_ci_i & biudata_valid) begin     // load from cache inhibit page
187
                                state <= #1 `OR1200_ICFSM_IDLE;
188
                                hitmiss_eval <= #1 1'b0;
189
                                load <= #1 1'b0;
190
                        end
191
                        else if (tagcomp_miss & biudata_valid) begin    // load missed, finish current external load and refill
192
                                state <= #1 `OR1200_ICFSM_LREFILL3;
193
                                saved_addr[3:2] <= #1 saved_addr[3:2] + 'd1;
194
                                hitmiss_eval <= #1 1'b0;
195
                                cnt <= #1 `OR1200_ICLS-2;
196
                        end
197
                        else if (!tagcomp_miss & !icimmu_ci_i) begin    // load hit and not cache inhibit, finish immediately
198
                                state <= #1 `OR1200_ICFSM_DOLOAD;
199
                                saved_addr <= #1 start_addr;
200
                                hitmiss_eval <= #1 1'b1;
201
                                load <= #1 1'b1;
202
                        end
203 562 lampret
                        else if (!icimmu_cyc_i | !icimmu_stb_i) begin   // load aborted (usually caused by exception)
204
                                state <= #1 `OR1200_ICFSM_IDLE;
205
                                hitmiss_eval <= #1 1'b0;
206
                                load <= #1 1'b0;
207
                        end
208 504 lampret
                        else                                            // load in-progress
209
                                hitmiss_eval <= #1 1'b0;
210
                `OR1200_ICFSM_LREFILL3 : begin
211 617 lampret
                        if (!ic_en)
212
                                state <= #1 `OR1200_ICFSM_IDLE;
213
                        else if (biudata_valid && (|cnt)) begin         // refill ack, more loads to come
214 504 lampret
                                cnt <= #1 cnt - 'd1;
215
                                saved_addr[3:2] <= #1 saved_addr[3:2] + 'd1;
216
                        end
217
                        else if (biudata_valid) begin                   // last load of line refill
218
                                state <= #1 `OR1200_ICFSM_IDLE;
219
                                saved_addr <= #1 start_addr;
220
                                hitmiss_eval <= #1 1'b0;
221
                                load <= #1 1'b0;
222
                        end
223
                end
224
                default:
225
                        state <= #1 `OR1200_ICFSM_IDLE;
226
        endcase
227
end
228
 
229
endmodule

powered by: WebSVN 2.1.0

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