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

Subversion Repositories or1k

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

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
// Revision 1.9  2001/10/21 17:57:16  lampret
48
// 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.
49
//
50
// Revision 1.8  2001/10/19 23:28:46  lampret
51
// Fixed some synthesis warnings. Configured with caches and MMUs.
52
//
53
// Revision 1.7  2001/10/14 13:12:09  lampret
54
// MP3 version.
55
//
56
// Revision 1.1.1.1  2001/10/06 10:18:35  igorm
57
// no message
58
//
59
// Revision 1.2  2001/08/09 13:39:33  lampret
60
// Major clean-up.
61
//
62
// Revision 1.1  2001/07/20 00:46:03  lampret
63
// Development version of RTL. Libraries are missing.
64
//
65
//
66
 
67
// synopsys translate_off
68
`include "timescale.v"
69
// synopsys translate_on
70
`include "or1200_defines.v"
71
 
72
`define OR1200_ICFSM_IDLE       3'd0
73
`define OR1200_ICFSM_DOLOAD     3'd1
74
`define OR1200_ICFSM_LREFILL3   3'd2
75
 
76
//
77
// Data cache FSM for cache line of 16 bytes (4x singleword)
78
//
79
 
80
module or1200_ic_fsm(
81
        // Clock and reset
82
        clk, rst,
83
 
84
        // Internal i/f to top level IC
85
        ic_en, icimmu_cyc_i, icimmu_stb_i, icimmu_ci_i, icpu_sel_i,
86
        tagcomp_miss, biudata_valid, biudata_error, start_addr, saved_addr,
87
        icram_we, biu_read, first_hit_ack, first_miss_ack, first_miss_err,
88
        burst
89
);
90
 
91
//
92
// I/O
93
//
94
input                           clk;
95
input                           rst;
96
input                           ic_en;
97
input                           icimmu_cyc_i;
98
input                           icimmu_stb_i;
99
input                           icimmu_ci_i;
100
input   [3:0]                    icpu_sel_i;
101
input                           tagcomp_miss;
102
input                           biudata_valid;
103
input                           biudata_error;
104
input   [31:0]                   start_addr;
105
output  [31:0]                   saved_addr;
106
output  [3:0]                    icram_we;
107
output                          biu_read;
108
output                          first_hit_ack;
109
output                          first_miss_ack;
110
output                          first_miss_err;
111
output                          burst;
112
 
113
//
114
// Internal wires and regs
115
//
116
reg     [31:0]                   saved_addr;
117
reg     [2:0]                    state;
118
reg     [2:0]                    cnt;
119
reg                             hitmiss_eval;
120
reg                             load;
121
 
122
//
123
// Generate of ICRAM write enables
124
//
125
assign icram_we = {4{load & biudata_valid}};
126
 
127
//
128
// BIU read and write
129
//
130
assign biu_read = (hitmiss_eval & tagcomp_miss) | (!hitmiss_eval & load);
131
 
132
//
133
// Assert for cache hit first word ready
134
// Assert for cache miss first word stored/loaded OK
135
// Assert for cache miss first word stored/loaded with an error
136
//
137
assign first_hit_ack = (state == `OR1200_ICFSM_DOLOAD) & hitmiss_eval & !tagcomp_miss & !icimmu_ci_i;
138
assign first_miss_ack = (state == `OR1200_ICFSM_DOLOAD) & (tagcomp_miss | icimmu_ci_i) & biudata_valid;
139
assign first_miss_err = (state == `OR1200_ICFSM_DOLOAD) & (tagcomp_miss | icimmu_ci_i) & biudata_error;
140
 
141
//
142
// Assert burst when doing reload of complete cache line
143
//
144
assign burst = (state == `OR1200_ICFSM_DOLOAD) & tagcomp_miss
145
                | (state == `OR1200_ICFSM_LREFILL3);
146
 
147
//
148
// Main IC FSM
149
//
150
always @(posedge clk or posedge rst) begin
151
        if (rst) begin
152
                state <= #1 `OR1200_ICFSM_IDLE;
153
                saved_addr <= #1 32'b0;
154
                hitmiss_eval <= #1 1'b0;
155
                load <= #1 1'b0;
156
                cnt <= #1 3'b000;
157
        end
158
        else
159
        case (state)    // synopsys parallel_case
160
                `OR1200_ICFSM_IDLE :
161
                        if (ic_en & icimmu_cyc_i & icimmu_stb_i) begin                  // load
162
                                state <= #1 `OR1200_ICFSM_DOLOAD;
163
                                saved_addr <= #1 start_addr;
164
                                hitmiss_eval <= #1 1'b1;
165
                                load <= #1 1'b1;
166
                        end
167
                        else begin                                                      // idle
168
                                state <= #1 `OR1200_ICFSM_IDLE;
169
                                hitmiss_eval <= #1 1'b0;
170
                                load <= #1 1'b0;
171
                        end
172
                `OR1200_ICFSM_DOLOAD:
173
                        if (hitmiss_eval & !(icimmu_cyc_i & icimmu_stb_i)) begin        // load aborted (usually caused by IMMU)
174
                                state <= #1 `OR1200_ICFSM_IDLE;
175
                                hitmiss_eval <= #1 1'b0;
176
                                load <= #1 1'b0;
177
                        end
178
                        else if (icimmu_ci_i & biudata_valid) begin     // load from cache inhibit page
179
                                state <= #1 `OR1200_ICFSM_IDLE;
180
                                hitmiss_eval <= #1 1'b0;
181
                                load <= #1 1'b0;
182
                        end
183
                        else if (tagcomp_miss & biudata_valid) begin    // load missed, finish current external load and refill
184
                                state <= #1 `OR1200_ICFSM_LREFILL3;
185
                                saved_addr[3:2] <= #1 saved_addr[3:2] + 'd1;
186
                                hitmiss_eval <= #1 1'b0;
187
                                cnt <= #1 `OR1200_ICLS-2;
188
                        end
189
                        else if (!tagcomp_miss & !icimmu_ci_i) begin    // load hit and not cache inhibit, finish immediately
190
                                state <= #1 `OR1200_ICFSM_DOLOAD;
191
                                saved_addr <= #1 start_addr;
192
                                hitmiss_eval <= #1 1'b1;
193
                                load <= #1 1'b1;
194
                        end
195
                        else                                            // load in-progress
196
                                hitmiss_eval <= #1 1'b0;
197
                `OR1200_ICFSM_LREFILL3 : begin
198
                        if (biudata_valid && (|cnt)) begin              // refill ack, more loads to come
199
                                cnt <= #1 cnt - 'd1;
200
                                saved_addr[3:2] <= #1 saved_addr[3:2] + 'd1;
201
                        end
202
                        else if (biudata_valid) begin                   // last load of line refill
203
                                state <= #1 `OR1200_ICFSM_IDLE;
204
                                saved_addr <= #1 start_addr;
205
                                hitmiss_eval <= #1 1'b0;
206
                                load <= #1 1'b0;
207
                        end
208
                end
209
                default:
210
                        state <= #1 `OR1200_ICFSM_IDLE;
211
        endcase
212
end
213
 
214
endmodule

powered by: WebSVN 2.1.0

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