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

Subversion Repositories or1k

[/] [or1k/] [branches/] [mp3_stable/] [or1200/] [rtl/] [verilog/] [ic_fsm.v] - Blame information for rev 161

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

Line No. Rev Author Line
1 161 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
////  Instruction 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
//
48
 
49
`include "general.h"
50
 
51
`define ICFSM_IDLE      'd0
52
`define ICFSM_DOLOAD    'd1
53
`define ICFSM_LREFILL3  'd2
54
 
55
// Insn cache FSM for cache line of 16 bytes (4x singleword)
56
 
57
module ic_fsm(clk, rst, fetch_op, miss, biudata_valid, start_addr, saved_addr, refill, refill_first, refill_prepare, icram_we, biu_read, refill_rest, cntrbusy);
58
 
59
input clk;
60
input rst;
61
input miss;
62
input biudata_valid;
63
input [31:0] start_addr;
64
input [`FETCHOP_WIDTH-1:0] fetch_op;
65
output [31:0] saved_addr;
66
output refill;
67
output refill_first;
68
output refill_prepare;
69
output [3:0] icram_we;
70
output biu_read;
71
output refill_rest;
72
output cntrbusy;
73
 
74
wire icache_off = 1'b0;
75
 
76
reg [31:0] saved_addr;
77
reg refill;
78
 
79
reg [3:0] icram_we;
80
reg [2:0] state;
81
reg [2:0] cnt;
82
reg refill_first;
83
reg refill_prepare;
84
reg biu_read;
85
reg refill_rest;
86
reg cntrbusy;
87
 
88
always @(refill_first or refill or biudata_valid or fetch_op or start_addr) begin
89
        if (refill_first || !refill)
90
                case(fetch_op)
91
                        `FETCHOP_LW : icram_we <= #1 4'b0000 ^ {4{refill_first}};
92
                        default : icram_we <= #1 4'b0000;
93
                endcase
94
        else
95
                icram_we <= #1 {4{refill & biudata_valid}};
96
end
97
 
98
always @(posedge clk or posedge rst) begin
99
        if (rst) begin
100
                refill <= #1 1'b0;
101
                state <= #1 3`ICFSM_DOLOAD;
102
                biu_read <= #1 1'b0;
103
                saved_addr <= #1 32'b0;
104
                refill_first <= #1 1'b0;
105
                refill_prepare <= #1 1'b0;
106
                refill_rest <= #1 1'b0;
107
                cntrbusy <= #1 1'b0;
108
                cnt <= #1 3'b0;
109
        end
110
        else
111
        case (state)    // synopsys full_case parallel_case
112
                `ICFSM_IDLE :
113
                        case(fetch_op)
114
                                `FETCHOP_LW: begin
115
                                        $display("%t: IC_FSM Load op %h  start_addr %h", $time, fetch_op, start_addr);
116
                                        state <= #1 3`ICFSM_DOLOAD;
117
                                        refill <= #1 1'b0;
118
                                        saved_addr <= #1 start_addr;
119
                                        refill_first <= #1 1'b0;
120
                                        refill_prepare <= #1 1'b1;
121
                                        biu_read <= #1 1'b0;
122
                                        refill_rest <= #1 1'b0;
123
                                        cntrbusy <= #1 1'b0;
124
                                end
125
                                default: begin
126
                                        state <= #1 3`ICFSM_IDLE;
127
                                        refill <= #1 1'b0;
128
                                        refill_first <= #1 1'b0;
129
                                        refill_prepare <= #1 1'b0;
130
                                        refill_rest <= #1 1'b0;
131
                                        biu_read <= #1 1'b0;
132
                                        cntrbusy <= #1 1'b0;
133
                                end
134
                        endcase
135
                `ICFSM_DOLOAD:
136
                        if (icache_off) begin
137
//                              $display("%t: IC_FSM ICache off", $time);
138
                                state <= #1 3`ICFSM_DOLOAD;
139
                                refill <= #1 1'b1;
140
                                refill_first <= #1 1'b1;
141
                                refill_prepare <= #1 1'b0;
142
                                refill_rest <= #1 1'b0;
143
                                biu_read <= #1 1'b1;
144
                                if (biudata_valid) begin
145
                                        refill <= #1 1'b0;
146
                                        refill_first <= #1 1'b0;
147
                                        biu_read <= #1 1'b0;
148
                                        saved_addr <= #1 start_addr;
149
                                end
150
                        end else
151
                        if (miss) begin
152
                                $display("%t: IC_FSM Load miss", $time);
153
                                state <= #1 3`ICFSM_LREFILL3;
154
                                refill <= #1 1'b1;
155
                                refill_first <= #1 1'b1;
156
                                refill_prepare <= #1 1'b0;
157
                                refill_rest <= #1 1'b0;
158
                                cnt <= #1 3'd3;
159
                                biu_read <= #1 1'b1;
160
                        end
161
                        else begin
162
                                $display("%t: IC_FSM Load hit", $time);
163
                                state <= #1 3`ICFSM_DOLOAD;
164
                                saved_addr <= #1 start_addr;
165
                                refill <= #1 1'b0;
166
                                refill_first <= #1 1'b0;
167
                                refill_prepare <= #1 1'b0;
168
                                refill_rest <= #1 1'b0;
169
                                cntrbusy <= #1 (fetch_op) ? 1'b1 : 1'b0;
170
                        end
171
                `ICFSM_LREFILL3 : begin
172
                        if (biudata_valid && cnt) begin
173
                                $display("%t: IC_FSM Load refill %d", $time, cnt);
174
                                cnt <= #1 cnt - 'd1;
175
                                saved_addr[3:2] <= #1 saved_addr[3:2] + 'd1;
176
                                refill_first <= #1 1'b0;
177
                        end
178
                        else if (biudata_valid) begin
179
                                $display("%t: IC_FSM Load refill end", $time, cnt);
180
                                state <= #1 3`ICFSM_DOLOAD;
181
                                saved_addr[3:2] <= #1 saved_addr[3:2] + 'd1;
182
                                refill <= #1 1'b1;
183
                                refill_first <= #1 1'b0;
184
                                biu_read <= #1 1'b0;
185
                                cntrbusy <= #1 (fetch_op) ? 1'b1 : 1'b0;
186
                        end
187
                        refill_rest <= #1 ~refill_first & refill;
188
                end
189
        endcase
190
end
191
 
192
endmodule

powered by: WebSVN 2.1.0

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