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

Subversion Repositories rtf65002

[/] [rtf65002/] [trunk/] [rtl/] [verilog/] [store.v] - Blame information for rev 37

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

Line No. Rev Author Line
1 20 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
// Memory store states
22
// The store states work for either eight bit or 32 bit mode              
23
// ============================================================================
24
//
25
// Stores always write through to memory, then optionally update the cache if
26
// there was a write hit.
27
STORE1:
28
        begin
29 30 robfinch
                case(store_what)
30 35 robfinch
                `STW_ACC:       wb_write(0,acc);
31
                `STW_X:         wb_write(0,x);
32
                `STW_Y:         wb_write(0,y);
33
                `STW_PC:        wb_write(0,pc);
34
                `STW_PC2:       wb_write(0,pc + 32'd2);
35
                `STW_PCHWI:     wb_write(0,pc+{30'b0,~hwi,1'b0});
36
                `STW_OPC:       wb_write(0,opc);
37
                `STW_SR:        wb_write(0,sr);
38
                `STW_RFA:       wb_write(0,rfoa);
39
                `STW_RFA8:      wb_write(1,{4{rfoa[7:0]}});
40
                `STW_A:         wb_write(0,a);
41
                `STW_B:         wb_write(0,b);
42
                `STW_CALC:      wb_write(0,res[31:0]);
43 30 robfinch
`ifdef SUPPORT_EM8
44 35 robfinch
                `STW_ACC8:      wb_write(1,{4{acc8}});
45
                `STW_X8:        wb_write(1,{4{x8}});
46
                `STW_Y8:        wb_write(1,{4{y8}});
47
                `STW_Z8:        wb_write(1,{4{8'h00}});
48
                `STW_PC3124:    wb_write(1,{4{pc[31:24]}});
49
                `STW_PC2316:    wb_write(1,{4{pc[23:16]}});
50
                `STW_PC158:             wb_write(1,{4{pc[15:8]}});
51
                `STW_PC70:              wb_write(1,{4{pc[7:0]}});
52
                `STW_SR70:              wb_write(1,{4{sr8}});
53
                `STW_DEF8:              wb_write(1,wdat);
54 30 robfinch
`endif
55 35 robfinch
                default:        wb_write(0,wdat);
56 30 robfinch
                endcase
57
`ifdef SUPPORT_DCACHE
58 20 robfinch
                radr <= wadr;           // Do a cache read to test the hit
59 30 robfinch
`endif
60 36 robfinch
                if (ir9==`PUSH)
61
                        Rt <= 4'h0;
62 20 robfinch
                state <= STORE2;
63
        end
64
 
65
// Terminal state for stores. Update the data cache if there was a cache hit.
66
// Clear any previously set lock status
67
STORE2:
68 35 robfinch
        // On a retry operation, restore the stack pointer which may have been
69
        // modified, then go back to the decode state to pick up original 
70
        // addresses and data. This doesn't work for block move/store
71
        if (rty_i) begin
72
                wb_nack();
73
                isp <= oisp;
74
                state <= DECODE;
75
        end
76
        else if (ack_i) begin
77 30 robfinch
                wdat <= dat_o;
78
                if (isMove|isSts) begin
79 23 robfinch
                        state <= MVN3;
80 30 robfinch
                        retstate <= MVN3;
81
                end
82
                else begin
83 32 robfinch
                        if (em) begin
84
                                state <= BYTE_IFETCH;
85
                                retstate <= BYTE_IFETCH;
86
                        end
87
                        else begin
88
                                state <= IFETCH;
89
                                retstate <= IFETCH;
90
                        end
91 30 robfinch
                end
92 20 robfinch
                lock_o <= 1'b0;
93 35 robfinch
                wb_nack();
94 30 robfinch
                case(store_what)
95 32 robfinch
                `STW_PC,`STW_PC2,`STW_PCHWI,`STW_OPC:
96
                        if (isBrk|isBusErr) begin
97 30 robfinch
                                radr <= isp_dec;
98
                                wadr <= isp_dec;
99
                                isp <= isp_dec;
100
                                store_what <= `STW_SR;
101
                                state <= STORE1;
102
                                retstate <= STORE1;
103
                        end
104
                `STW_SR:
105 32 robfinch
                        if (isBrk|isBusErr) begin
106 30 robfinch
                                load_what <= `PC_310;
107
                                state <= LOAD_MAC1;
108
                                retstate <= LOAD_MAC1;
109 35 robfinch
                                radr <= vect[33:2];
110 32 robfinch
                                ttrig <= 1'b0;
111
                                tf <= 1'b0;                     // turn off trace mode
112
                                im <= 1'b1;
113 30 robfinch
                                em <= 1'b0;                     // make sure we process in native mode; we might have been called up during emulation mode
114
                        end
115 32 robfinch
                `STW_RFA:
116
                        if (isPusha) begin
117
                                if (ir[11:8]==4'hF) begin
118
                                        state <= IFETCH;
119
                                        retstate <= IFETCH;
120
                                end
121
                                else begin
122
                                        state <= STORE1;
123
                                        retstate <= STORE1;
124
                                        radr <= isp_dec;
125
                                        wadr <= isp_dec;
126
                                        isp <= isp_dec;
127
                                end
128
                                ir[11:8] <= ir[11:8] + 4'd1;
129
                        end
130 30 robfinch
`ifdef SUPPORT_EM8
131
                `STW_PC3124:
132
                        begin
133 32 robfinch
                                radr <= {spage[31:8],sp[7:2]};
134
                                wadr <= {spage[31:8],sp[7:2]};
135
                                radr2LSB <= sp[1:0];
136
                                wadr2LSB <= sp[1:0];
137 30 robfinch
                                store_what <= `STW_PC2316;
138 32 robfinch
                                sp <= sp_dec;
139 35 robfinch
                                retstate <= STORE1;
140 30 robfinch
                                state <= STORE1;
141
                        end
142
                `STW_PC2316:
143
                        begin
144 32 robfinch
                                radr <= {spage[31:8],sp[7:2]};
145
                                wadr <= {spage[31:8],sp[7:2]};
146
                                radr2LSB <= sp[1:0];
147
                                wadr2LSB <= sp[1:0];
148
                                sp <= sp_dec;
149 30 robfinch
                                store_what <= `STW_PC158;
150 35 robfinch
                                retstate <= STORE1;
151 30 robfinch
                                state <= STORE1;
152
                        end
153
                `STW_PC158:
154
                        begin
155 32 robfinch
                                radr <= {spage[31:8],sp[7:2]};
156
                                wadr <= {spage[31:8],sp[7:2]};
157
                                radr2LSB <= sp[1:0];
158
                                wadr2LSB <= sp[1:0];
159
                                sp <= sp_dec;
160 30 robfinch
                                store_what <= `STW_PC70;
161 35 robfinch
                                retstate <= STORE1;
162 30 robfinch
                                state <= STORE1;
163
                        end
164
                `STW_PC70:
165
                        begin
166 32 robfinch
                                case({1'b0,ir[7:0]})
167
                                `BRK:   begin
168
                                                radr <= {spage[31:8],sp[7:2]};
169
                                                wadr <= {spage[31:8],sp[7:2]};
170
                                                radr2LSB <= sp[1:0];
171
                                                wadr2LSB <= sp[1:0];
172
                                                sp <= sp_dec;
173
                                                store_what <= `STW_SR70;
174 35 robfinch
                                                retstate <= STORE1;
175 32 robfinch
                                                state <= STORE1;
176
                                                end
177
                                `JSR:   begin
178 35 robfinch
                                                pc[15:0] <= ir[23:8];
179 32 robfinch
                                                end
180
                                `JSL:   begin
181
                                                pc <= ir[39:8];
182
                                                end
183
                                `JSR_INDX:
184
                                                begin
185
                                                state <= LOAD_MAC1;
186
                                                retstate <= LOAD_MAC1;
187
                                                load_what <= `PC_70;
188
                                                radr <= absx_address[31:2];
189
                                                radr2LSB <= absx_address[1:0];
190
                                                end
191
                                endcase
192
                        end
193
                `STW_SR70:
194
                        begin
195 30 robfinch
                                if (ir[7:0]==`BRK) begin
196 32 robfinch
                                        load_what <= `PC_70;
197
                                        state <= LOAD_MAC1;
198
                                        retstate <= LOAD_MAC1;
199
                                        pc[31:16] <= abs8[31:16];
200 35 robfinch
                                        radr <= vect[33:2];
201 32 robfinch
                                        radr2LSB <= vect[1:0];
202
                                        im <= hwi;
203 30 robfinch
                                end
204
                        end
205
`endif
206 32 robfinch
                default:
207
                        if (isJsrIndx) begin
208
                                load_what <= `PC_310;
209
                                state <= LOAD_MAC1;
210
                                retstate <= LOAD_MAC1;
211
                                radr <= ir[39:8] + x;
212
                        end
213
                        else if (isJsrInd) begin
214
                                load_what <= `PC_310;
215
                                state <= LOAD_MAC1;
216
                                retstate <= LOAD_MAC1;
217
                                radr <= ir[39:8];
218
                        end
219 30 robfinch
                endcase
220
`ifdef SUPPORT_DCACHE
221 32 robfinch
                if (!dhit && write_allocate) begin
222
                        state <= DCACHE1;
223 20 robfinch
                end
224 30 robfinch
`endif
225 20 robfinch
        end
226 30 robfinch
`ifdef SUPPORT_BERR
227 21 robfinch
        else if (err_i) begin
228
                lock_o <= 1'b0;
229 35 robfinch
                wb_nack();
230
                if (em | isStb)
231
                        derr_address <= adr_o[31:0];
232
                else
233
                        derr_address <= adr_o[33:2];
234
                intno <= 9'd508;
235 21 robfinch
                state <= BUS_ERROR;
236
        end
237 30 robfinch
`endif

powered by: WebSVN 2.1.0

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