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

Subversion Repositories wb_z80

[/] [wb_z80/] [tags/] [arelease/] [rtl/] [memstate.v] - Blame information for rev 39

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 bporcella
///////////////////////////////////////////////////////////////////////////////////////////////////
2
//                                                                                               //
3
//  file name:   memstate.v                                                                       //
4
//  description: memory opertions for  z80                                                       //
5
//  project:     wb_z80                                                                          //
6
//                                                                                               //
7
//  Author: B.J. Porcella                                                                        //
8
//  e-mail: bporcella@sbcglobal.net                                                              //
9
//                                                                                               //
10
//                                                                                               //
11
//                                                                                               //
12
///////////////////////////////////////////////////////////////////////////////////////////////////
13
//                                                                                               //
14
// Copyright (C) 2000-2002 B.J. Porcella                                                         //
15
//                         Real Time Solutions                                                   //
16
//                                                                                               //
17
//                                                                                               //
18
// This source file may be used and distributed without                                          //
19
// restriction provided that this copyright statement is not                                     //
20
// removed from the file and that any derivative work contains                                   //
21
// the original copyright notice and the associated disclaimer.                                  //
22
//                                                                                               //
23
//     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY                                       //
24
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED                                     //
25
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS                                     //
26
// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR                                        //
27
// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,                                           //
28
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES                                      //
29
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE                                     //
30
// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR                                          //
31
// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF                                    //
32
// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT                                    //
33
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT                                    //
34
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE                                           //
35
// POSSIBILITY OF SUCH DAMAGE.                                                                   //
36
//                                                                                               //
37
//-------1---------2---------3--------Comments on file  -------------7---------8---------9--------0
38
// The memory state controller controls the wb bus, and provides address sequencing.
39
// Insructions are fetched in order (using PC) until the istate machine indicates that 
40
// a complete instruction is in the first pipline stage (ir1). In general, operands are being
41
// fetched (stored) to satisfy ir1 while concurrently instructions are being executed from ir2.
42
// this situation can result in a number of potential hazards.   As an example, if the ir2
43
// instruction changes the flag register and the ir1 instruction is a conditional jump, 
44
// a hazard is generated by the hazard logic, and execution of the ir1 operation is delayed 
45
// until the completion of the flag update.
46
//
47
// Reset starts execution at 0.  
48
// The PC and SP are described in this file.   modifications to other index registers - 
49
// HL IX and IY are computed here -- 
50
// For the block moves address updates are computed here   -- and commanded here.
51
// Strobes for the second address update are generally co-incident with count updates, but
52
// we provide seperate strobe update lines for clarity.
53
//
54
//  BASIC ARCHITECTURE OF THIS FILE   pc  and sp not shown, but are inputs to src mux.
55
//                    _____           and may be updated from adder output.
56
//                   |     |
57
//                   |     |          pc-1 register is required to implement relative jumps.
58
//                   |     |                     
59
//      _____        |lit  |      |\             
60
//     |     |       |     |      |  \           
61
//     |     |       |src2 |      |    \          _____          _____ 
62
//     |     |       |     |----->|     |        |     |        |     |
63
//     |src  |       |_____|      |adder|------->|     |        |     |
64
//     |mux  |                    |     |        |     |        |     |
65
//     |     |------------------->|    /         |2/1  |------->|wb   |
66
//     |     |              |     |  /           |mux  |        |adr  |
67
//     |_____|              |     |/             |     |        |     |
68
//                           ------------------->|     |        |     |
69
//                                               |_____|        |_____|
70
//
71
//
72
//
73
//
74
//  Operand Stores:
75
//  At first cut, I thought I'ld execute operand stores immediately from the memory sequencer
76
//  (essentially before ir2 got the store data).  While this might be modestly faster in 
77
//  systems that take multiple clocks to complete a memory store, On consideration, I decided 
78
//  to forgo the extra speed for conceptual simplicity....   execute operand stores on op_ph1,
79
//  and let the inst_exec engine suply the operand.
80
//
81
//  On second thought, above is not only wastful of time, but also inconsistent with the overall
82
//  schems of things - and so somewhat more complex. If we simply execute the OS from ir1, 
83
//  There is less state to contdend with, as well as extra speed.
84
//
85
//  Block Moves fundamentally execute from ir2.  We initiate the first operand fetch from ir1.
86
//
87
//  3/18/2004 Second time through.   In impleenting the execution logic it became clear that
88
//  there were "minor" problems with the handling of the DD and FD prefix insts (especially
89
//  DDCD and FDCB  ---  collectively called PFxCB below.  On review, I had to question the
90
//  value of "breaking up" the ir0 execution engine between the istate sequencer and the 
91
//  memstate sequencer.   While I dislike state sequencers of much more than 16 states  --  
92
//  
93
//   
94
//
95
//  Hazards:
96
//  There are 2 kinds of hazards:  mem_hazard => we are storing into the next instruction location
97
//                                 reg_hazard => we are modifying a register (ir2) that we are using
98
//                                                here (ir1)
99
//  In the former case, we throw out the instruction that arrives on the next tick, and restart the
100
//  instruction pipeline,   In the latter case, we simply wait a tick for the ir2 operaton to 
101
//  complete before starting the ir1 operation  
102
//-------1---------2---------3--------CVS Log -----------------------7---------8---------9--------0
103
//
104
//  $Id: memstate.v,v 1.1.1.1 2004-04-13 23:50:05 bporcella Exp $
105
//
106
//  $Date: 2004-04-13 23:50:05 $
107
//  $Revision: 1.1.1.1 $
108
//  $Author: bporcella $
109
//  $Locker:  $
110
//  $State: Exp $
111
//
112
// Change History:
113
//      $Log: not supported by cvs2svn $
114
//
115
//
116
//-------1---------2---------3--------Module Name and Port List------7---------8---------9--------0
117
module memstate(wb_adr, wb_we, wb_cyc, wb_stb, wb_lock, wb_tga_io,  add_out,
118
                use_sp,use_a,use_b,use_c,use_d,use_e,use_h,use_l,use_flags, // these for hazard detection                                                         
119
                ir1, ir1cb, ir1ed, ir1dd, ir1fd, ir1_exec,
120
                nn, hl, ix, iy, de, bc,
121
                stb_hl, stb_ix, stb_iy, stb_de, upd_blk_cnt,
122
                beq0, ceq0,
123
                hazard, wb_ack, clk, rst
124
 
125
 
126
 
127
 
128
);
129
 
130
//-------1---------2---------3--------Output Ports---------6---------7---------8---------9--------0
131
 
132
output [15:0]  wb_adr;
133
output         wb_we;
134
output         wb_cyc;
135
output         wb_stb;
136
output         wb_lock;     // bit set and clear insts should be atomic - could matter sometime
137
output         wb_tga_io;
138
output [15:0]  add_out;     // output of adder  (may not wb_adr)
139
 
140
output          use_sp;     // these for hazard detection
141
output          use_a;
142
output          use_b;
143
output          use_c;
144
output          use_d
145
output          use_e;
146
output          use_h;
147
output          use_l;
148
output          use_flags;
149
 
150
 
151
 
152
 
153
 
154
 
155
 
156
 
157
//-------1---------2---------3--------Input Ports----------6---------7---------8---------9--------0
158
 
159
input [9:0]     ir1;
160
input           ir1cb;
161
input           ir1ed;
162
input           ir1_exec;    // ir1 data is ready to execute.
163
input           mem_hazard;      // throw out next inst and restart inst pipeline
164
input           reg_hazard;      // wait a tick to execute. (this signal is slow) 
165
input           beq0, ceq0;
166
 
167
 
168
 
169
 
170
//-------1---------2---------3--------Parameters-----------6---------7---------8---------9--------0
171
`include "opcodes.v"            //  states of the main memory sequencer
172
parameter   MEM_IDLE  = 4'h0,
173
            MEM_HALT  = 4'h1,   //  go here after a HALT instruction
174
            MEM_IF1   = 4'h2,   //  start the instruction fetch pipt
175
            MEM_IF2   = 4'h3,   //  continue the if pipe
176
            MEM_EXEC  = 4'h4,   //  main ir1 execution state - decode and do what is needed
177
            MEM_OP1   = 4'h5,   //  go here if instruction needs more than 1 operand operation
178
            MEM_OP2   = 4'h6,   //  go here if OP1 not sufficent (rare)
179
            MEM_OP3   = 4'h7,   //  go here if OP2 not sufficient (rare but used by blk rpt
180
            MEM_RPT   = 4'h8,   //  go here for block repeat tests  (must allow interrupts)
181
            MEM_INT1  = 4'ha,   //  int sequence is messy  --  seperate states for that
182
            MEM_INT2  = 4'hb,
183
            MEM_INT3  = 4'hc;
184
            MEM_INT4  = 4'hd,
185
            MEM_INT5  = 4'he;
186
 
187
parameter   TAG_IO    = 2'b01;   // need to review general wb usage to undrstand how best to 
188
            TAG_INT   = 2'b10;   // document this. 
189
 
190
//-------1---------2---------3--------Wires----------------6---------7---------8---------9--------0
191
 
192
wire        of8;
193
wire        of16;
194
wire        os8
195
wire        os16;
196
wire        rmw8;
197
wire        jmp;
198
wire        call;
199
wire        ret;
200
wire        ioi;  // io input
201
wire        ioo;  // io output
202
wire        blk_mv;
203
wire        blk_cmp;
204
wire        blk_in;
205
wire        blk_out;
206
wire        use_sp;
207
wire        use_pc;
208
wire        use_hl;
209
wire        use_de;
210
wire        use_bc;
211
wire        use_flags;
212
wire        cb_mem;
213
wire        br_test8t;  // branch test true  (8 test field)
214
wire        br_test4t;  // branch test true  (4 test field)
215
wire        src_mux;
216
wire        src2;
217
wire        alu;
218
wire        mux21;
219
wire        mem_idle ;
220
wire        mem_halt ;
221
wire        mem_if1  ;
222
wire        mem_if2  ;
223
wire        mem_exec ;
224
wire        mem_op1  ;
225
wire        mem_op2  ;
226
wire        mem_op3  ;
227
wire        mem_int1 ;
228
wire        mem_int2 ;
229
wire        mem_int3 ;
230
wire        mem_int4 ;
231
wire        mem_int5 ;
232
wire        exec_if;    // perform an instruction fetch on mem_exec  (instruction is reg<-reg)                     
233
wire        ofos;
234
wire        any_os;   // most terms above only valid on mem_exec  this includes all stores
235
wire        wb_rdy;
236
 
237
 
238
//-------1---------2---------3--------Registers------------6---------7---------8---------9--------0
239
 
240
reg [15:0]   pc, pc_min1;
241
reg [15:0]   sp;
242
reg [15:0]   wb_adr;
243
reg          wb_we;
244
reg          wb_cyc;
245
reg          wb_stb;
246
reg          wb_lock;
247
reg          wb_tga_io
248
 
249
 
250
 
251
 
252
 
253
// don't forget that as 1r1 is executed it is transferred to ir2.  Anything I need to know
254
// about subsequent operations must be stored.
255
reg  [        mem_state
256
reg          of16_reg,  os16_reg, rmw8_reg, call_reg, ret_reg, ioi;
257
reg          push_reg;
258
reg          pop_reg;
259
//-------1---------2---------3--------Assignments----------6---------7---------8---------9--------0
260
//
261
// ir is 10 bits most significant codes ir[9:8] = { EDgrp, CBgrp }  DDgrp and FDgrp are modifiers
262
 
263
assign   cb_mem = CB_MEM = ir1[2:0];                 // CB_MEM  = 3'h110,    
264
 
265
assign   of8 = LDsA_6BC7  == ir1 |      // LD A,(BC)    ; 0A
266
               LDsA_6DE7  == ir1 |      // LD A,(DE)    ; 1A
267
               LDsB_6HL7  == ir1 |      // LD B,(HL)    ; 46
268
               LDsD_6HL7  == ir1 |      // LD D,(HL)    ; 56
269
               LDsH_6HL7  == ir1 |      // LD H,(HL)    ; 66
270
               ADDsA_6HL7 == ir1 |      // ADD A,(HL)   ; 86
271
               SUBs6HL7   == ir1 |      // SUB (HL)     ; 96
272
               ANDs6HL7   == ir1 |      // AND (HL)     ; A6
273
               ORs6HL7    == ir1 |      // OR (HL)      ; B6
274
               LDsC_6HL7  == ir1 |      // LD C,(HL)    ; 4E
275
               LDsE_6HL7  == ir1 |      // LD E,(HL)    ; 5E
276
               LDsL_6HL7  == ir1 |      // LD L,(HL)    ; 6E
277
               LDsA_6HL7  == ir1 |      // LD A,(HL)    ; 7E
278
               ADCsA_6HL7 == ir1 |      // ADC A,(HL)   ; 8E
279
               SBCs6HL7   == ir1 |      // SBC (HL)     ; 9E
280
               XORs6HL7   == ir1 |      // XOR (HL)     ; AE
281
               CPs6HL7    == ir1 |      // CP (HL)      ; BE
282
               LDsA_6NN7  == ir1 |      // LD A,(NN)    ; 3A XX XX
283
               cb_mem &  CB_BIT  == ir2[9:6];    // (HL) these must be compaired with ir[7:6]
284
 
285
assign   of16;  LDsHL_6NN7   == ir1 |  //      LD HL,(NN)   ; 2A XX XX
286
                POPsAF       == ir1 |  //      POP AF       ; F1   AF<- (SP++ ++)  
287
                POPsBC       == ir1 |  //      POP BC       ; C1   BC<- (SP++ ++)  
288
                POPsDE       == ir1 |  //      POP DE       ; D1   DE<- (SP++ ++)  
289
                POPsHL       == ir1 |  //      POP HL       ; E1   HL<- (SP++ ++)  
290
                ED_LDsREG_6NN7 == {ir[7:6],ir[3:0]}   //   REG = BC,DE,HL,SP
291
 
292
assign   os8  = LDs6HL7_N    == ir1 |  //      LD (HL),N    ; 36 XX
293
                LDs6BC7_A    == ir1 |  //      LD (BC),A    ; 02 
294
                LDs6DE7_A    == ir1 |  //      LD (DE),A    ; 12
295
                LDs6HL7_A    == ir1 |  //      LD (HL),A    ; 77
296
                LDs6HL7_B    == ir1 |  //      LD (HL),B    ; 70
297
                LDs6HL7_C    == ir1 |  //      LD (HL),C    ; 71
298
                LDs6HL7_D    == ir1 |  //      LD (HL),D    ; 72
299
                LDs6HL7_E    == ir1 |  //      LD (HL),E    ; 73
300
                LDs6HL7_H    == ir1 |  //      LD (HL),H    ; 74
301
                LDs6HL7_L    == ir1 |  //      LD (HL),L    ; 75
302
                LDs6NN7_A    == ir1 ;  //      LD (NN),A    ; 32 XX XX
303
 
304
assign  os16 = PUSHsAF      == ir1 |      //      PUSH AF      ; F5   (-- --SP) <- AF
305
               PUSHsBC      == ir1 |      //      PUSH BC      ; C5   (-- --SP) <- BC
306
               PUSHsDE      == ir1 |      //      PUSH DE      ; D5   (-- --SP) <- DE
307
               PUSHsHL      == ir1 |      //      PUSH HL      ; E5   (-- --SP) <- HL
308
               LDs6NN7_HL   == ir1 |            //      LD (NN),HL   ; 22 XX XX
309
               ED_LDs6NN7_REG = {ir[7:6],ir[3:0]}; //REG = BC,DE,HL,SP                    
310
 
311
 
312
// these are executed  ; exec(of) ; op1(nop); op2(os) ; if2
313
assign  rmw8 = INCs6HL7        == ir1     | //  INC (HL)     ; 34
314
               DECs6HL7        == ir1     | //  DEC (HL)     ; 35 
315
               cb_mem & CB_RLC == ir1[9:3] |  //(HL)
316
               cb_mem & CB_RRC == ir1[9:3] |  //(HL)
317
               cb_mem & CB_RL  == ir1[9:3] |  //(HL)
318
               cb_mem & CB_RR  == ir1[9:3] |  //(HL)
319
               cb_mem & CB_SLA == ir1[9:3] |  //(HL)
320
               cb_mem & CB_SRA == ir1[9:3] |  //(HL)
321
               cb_mem & CB_SRL == ir1[9:3] |  //(HL)
322
               cb_mem & CB_RES == ir1[9:6] |   //(HL)
323
               cb_mem & CB_SET == ir1[9:6] ;   //(HL)
324
 
325
// this is executd   exec(of) ; op1(os) ; op2(of) ; op3(os) ; if2              
326
assign xchng16 =  EXs6SP7_HL  == ir1; //      EX (SP),HL   ; E3               
327
 
328
// cond jumps are executed exec cond_t?  pc,wb_adr<-adr if goto if2 : if goto exec
329
wire  c_jmp8 = JPsC  == ir1  |     // JP C,$+3     ; DA XX  XX
330
               JPsM  == ir1  |     // JP M,$+3     ; FA XX  XX
331
               JPsNC == ir1  |     // JP NC,$+3    ; D2 XX  XX
332
               JPsNZ == ir1  |     // JP NZ,$+3    ; C2 XX  XX
333
               JPsPE == ir1  |     // JP PE,$+3    ; EA XX  XX
334
               JPsPO == ir1  |     // JP PO,$+3    ; E2 XX  XX
335
               JPsP  == ir1  |     // JP P,$+3     ; F2 XX  XX
336
               JPsZ  == ir1  ;     // JP Z,$+3     ; CA XX  XX
337
 
338
wire c_jmp4 = JRsC_$t2     == ir1  |
339
              JRsNC_$t2    == ir1  |
340
              JRsNZ_$t2    == ir1  |
341
              JRsZ_$t2     == ir1  ;
342
 
343
assign jmp =  JRs$t2       == ir1  |     // JR $+2       ; 18  XX
344
              DJNZs$t2     == ir1  |     // DJNZ $+2     ; 10 XX  XX
345
              JPs          == ir1  |     // JP $+3       ; C3 XX  XX
346
              JPsHL == ir1         |     // JP HL        ; E9 // documented as indirect is not
347
              c_jmp4 & br_test4t   |   // JR C,$+2     ; 38
348
              c_jmp8 & br_test8t   |     // JP C,$+3     ; DA XX  XX
349
              RSTs0        == ir1  |     // RST 0        ; C7
350
              RSTs8H       == ir1  |     // RST 8H       ; CF 
351
              RSTs10H      == ir1  |     // RST 10H      ; D7
352
              RSTs18H      == ir1  |     // RST 18H      ; DF
353
              RSTs20H      == ir1  |     // RST 20H      ; E7
354
              RSTs28H      == ir1  |     // RST 28H      ; EF        
355
              RSTs30H      == ir1  |     // RST 30H      ; F7
356
              RSTs38H      == ir1  ;     // RST 38H      ; FF
357
 
358
wire c_call  =  CALLsC_NN    == ir1   |  //XX XX  (-- --SP) <- PC, PC<-NN
359
                CALLsM_NN    == ir1   |
360
                CALLsNC_NN   == ir1   |
361
                CALLsNZ_NN   == ir1   |
362
                CALLsPE_NN   == ir1   |
363
                CALLsPO_NN   == ir1   |
364
                CALLsP_NN    == ir1   |
365
                CALLsZ_NN    == ir1   ;
366
 
367
 
368
//  these are executed exec(ossp) ; op1(ossp); op2(ifnn p<-n+1)goto if2 
369
assign   call = CALLsNN      == ir1 |  //    XX XX  (-- --SP) <- PC, PC<-NN
370
                c_call & br_test8t  ;  //    XX XX  (-- --SP) <- PC, PC<-NN
371
 
372
wire c_ret =  RETsC        == ir1 & br_test8t | //      RET C        ; D8  PC <- (SP++ ++)
373
              RETsM        == ir1 & br_test8t | //      RET M        ; F8  PC <- (SP++ ++)
374
              RETsNC       == ir1 & br_test8t | //      RET NC       ; D0  PC <- (SP++ ++)
375
              RETsNZ       == ir1 & br_test8t | //      RET NZ       ; C0  PC <- (SP++ ++)
376
              RETsP        == ir1 & br_test8t | //      RET P        ; F0  PC <- (SP++ ++)
377
              RETsPE       == ir1 & br_test8t | //      RET PE       ; E8  PC <- (SP++ ++)
378
              RETsPO       == ir1 & br_test8t | //      RET PO       ; E0  PC <- (SP++ ++)
379
              RETsZ        == ir1 & br_test8t ; //      RET Z        ; C8  PC <- (SP++ ++)
380
 
381
assign   ret =RET          == ir1 |             //      RET          ; C9  PC <- (SP++ ++)
382
              ED_RETN      == {ir[9:6],ir[2:0]}| // compair with {ir[7:6],ir[2:0]} and !reti
383
              c_ret & br_test8t  ;
384
 
385
assign   ioi = INsA_6N7     == ir1 |               //      IN A,(N)     ; DB XX    A<-(Nio) 
386
               ED_INsREG_6C7 == {ir[9:6],ir[2:0]} ;// really (BCio)
387
 
388
assign   ioo  = OUTs6N7_A    == ir1 |             //      OUT (N),A    ; D3 XX     A-> (Nio)
389
                ED_OUTs6C7_REG == {ir[9:6],ir[2:0]} ;
390
 
391
// execution of     |  exec   |   rpt_t     |  op3     |
392
// repeats          |         |(if done if2 |goto rpt_t|
393
// rel to mem_state | of BC-- |  os         | of BC--  |
394
// rpt test must allow for interrupts - pc and BC must be properly rolled back 
395
 
396
assign   blk_mv = ED_LDI  == ir1 | //  (DE++) <= (HL++) , BC-- 
397
                  ED_LDD  == ir1 | //  (DE--) <= (HL--) , BC--
398
                  ED_LDIR == ir1 | //  (DE++) <= (HL++) , BC-- Repeat 
399
                  ED_LDDR == ir1 ; //  (DE--) <= (HL--) , BC-- Repeat 
400
 
401
 
402
// execution of     |  exec   |  op3     |    rpt_t     |
403
// repeats          | goto op3|goto rpt_t|  if done if2 |
404
// rel to mem_state | of BC-- | nop      |  else of BC--|
405
//
406
// rpt test must allow for interrupts - pc and BC must be properly rolled back 
407
// lets goto a special state for this - 
408
//  bj -think - pc must be rolled back in any case - how does that happen? notes for main_state
409
//    already have this being done on MEM_INT1   --- on reflection, BC is correct  - post decrement
410
//    we tested the decremented value.   Mental test here ---   start with 1 - get 0 stop.
411
//    (um states explicitly that if you start with 0 you get 64k)
412
//    start with 2 get interrupt  (we now have 1) interrupt with 1 in bc  ok.
413
//
414
assign   blk_cmp = ED_CPI  == ir1 | //  CPI  ; ED A1    A - (HL++) , BC--
415
                   ED_CPD  == ir1 | //  CPD  ; ED A9    A - (HL--) , BC--
416
                   ED_CPIR == ir1 | //  CPIR ; ED B1    A - (HL++) , BC-- repeat if(|B
417
                   ED_CPDR == ir1 ; //  CPDR ; ED B9    A - (HL--) , BC-- repeat if(|B
418
 
419
 
420
 
421
 
422
assign blk_in = ED_INI  == ir1 | // INI  ; ED A2   (HL++) <- (Cio) , B--;
423
                ED_IND  == ir1 | // IND  ; ED AA   (HL--) <- (Cio) , B--
424
                ED_INIR == ir1 | // INIR ; ED B2   (HL++) <- (Cio) , B-- repeat if(|B)
425
                ED_INDR == ir1 ; // INDR ; ED BA   (HL--) <- (Cio) , B-- repeat if(|B)
426
 
427
 
428
 
429
assign  blk_out = ED_OUTI  == ir1 | // OUTI  ED A3  (Cio)  <-(HL++) , B--
430
                  ED_OUTD  == ir1 | // OUTD  ED AB  (Cio)  <-(HL--) , B--
431
                  ED_OTIR  == ir1 | // OTIR  ED B3  (Cio)  <-(HL++) , B--  rpt if(|B)
432
                  ED_OTDR  == ir1 ; // OTDR  ED BB  (Cio)  <-(HL--) , B--  rpt if(|B)
433
 
434
 
435
assign  blk_rpt =  ED_LDIR == ir1 | //  (DE++) <= (HL++) , BC-- Repeat 
436
                   ED_LDDR == ir1 | //  (DE--) <= (HL--) , BC-- Repeat 
437
                   ED_CPIR == ir1 | //  CPIR ; ED B1    A - (HL++) , BC-- repeat if(|B
438
                   ED_CPDR == ir1 | //  CPDR ; ED B9    A - (HL--) , BC-- repeat if(|B
439
                   ED_INIR == ir1 | // INIR ; ED B2   (HL++) <- (Cio) , B-- repeat if(|B)
440
                   ED_INDR == ir1 | // INDR ; ED BA   (HL--) <- (Cio) , B-- repeat if(|B)
441
                   ED_OTIR == ir1 | // OTIR  ED B3  (Cio)  <-(HL++) , B--  rpt if(|B)
442
                   ED_OTDR == ir1 ; // OTDR  ED BB  (Cio)  <-(HL--) , B--  rpt if(|B)
443
 
444
assign   blk_inc = ED_LDI  == ir1  | //  (DE++) <= (HL++) , BC-- 
445
                   ED_LDIR == ir1  | //  (DE++) <= (HL++) , BC-- Repeat 
446
                   ED_CPI  == ir1  | //  CPI  ; ED A1    A - (HL++) , BC--
447
                   ED_CPIR == ir1  | //  CPIR ; ED B1    A - (HL++) , BC-- repeat if(|B
448
                   ED_INI  == ir1  | // INI  ; ED A2   (HL++) <- (Cio) , B--;
449
                   ED_INIR == ir1  | // INIR ; ED B2   (HL++) <- (Cio) , B-- repeat if(|B)
450
                   ED_OUTI  == ir1 | // OUTI  ED A3  (Cio)  <-(HL++) , B--
451
                   ED_OTDR  == ir1 ; // OTDR  ED BB  (Cio)  <-(HL--) , B--  rpt if(|B)
452
 
453
 
454
wire   push    =  PUSHsAF   == ir1 | //      PUSH AF      ; F5   (-- --SP) <- AF
455
                  PUSHsBC   == ir1 | //      PUSH BC      ; C5   (-- --SP) <- BC
456
                  PUSHsDE   == ir1 | //      PUSH DE      ; D5   (-- --SP) <- DE
457
                  PUSHsHL   == ir1 ; //      PUSH HL      ; E5   (-- --SP) <- HL
458
 
459
 
460
 
461
wire   pop =      POPsAF    == ir1 | //      POP AF       ; F1   AF<- (SP++ ++)  
462
                  POPsBC    == ir1 | //      POP BC       ; C1   BC<- (SP++ ++)  
463
                  POPsDE    == ir1 | //      POP DE       ; D1   DE<- (SP++ ++)  
464
                  POPsHL    == ir1 ; //      POP HL       ; E1   HL<- (SP++ ++) 
465
 
466
assign use_sp = push | pop | call | ret;
467
assign ofos = cb_mem | of8 | of16 | os8 | os16 | rmw8 | xchng16 | jmp | call | ret |
468
                 ioi  | ioo | blk_mv | blk_cmp | blk_in | blk_out | push | pop         ;
469
assign exec_if = mem_exec & !ofos;
470
 
471
 
472
// wires below can be used to select os data - with the addition of 
473
// ED_LDs6NN7_REG = {ir[7:6],ir[3:0]}; //REG = BC,DE,HL,SP - These cannot cause
474
// hazards as ir2 is executed as ED is decoded.
475
// so what???  include them anyway....   Hazard detection is disabled after ir2 is executed. kiss
476
//
477
wire os_a  =  LDs6BC7_A    == ir1 |  //      LD (BC),A    ; 02
478
              LDs6DE7_A    == ir1 |  //      LD (DE),A    ; 12
479
              LDs6HL7_A    == ir1 |  //      LD (HL),A    ; 77
480
              LDs6NN7_A    == ir1 |  //      LD (NN),A    ; 32 XX XX
481
              PUSHsAF      == ir1 |
482
              OUTs6N7_A    == ir1 |
483
              ED_OUTs6C7_REG ==  {ir[7:6],ir[2:0] && REG8_A == ir[5:3]} ;
484
 
485
wire os_b = LDs6HL7_B    == ir1 |  //      LD (HL),B    ; 70
486
            PUSHsBC      == ir1 |      //      PUSH BC
487
            ED_LDs6NN7_REG == {ir[7:6],ir[3:0] && DBL_REG_BC == ir[5:4] |
488
            ED_OUTs6C7_REG ==  {ir[7:6],ir[2:0] && REG8_B == ir[5:3]} ;
489
 
490
wire os_c = LDs6HL7_C    == ir1  |  //      LD (HL),C    ; 71
491
            ED_OUTs6C7_REG ==  {ir[7:6],ir[2:0] && REG8_C == ir[5:3]} ;
492
wire os_d = LDs6HL7_D    == ir1 |  //      LD (HL),D    ; 72
493
            PUSHsDE      == ir1 |      //      PUSH DE
494
            ED_LDs6NN7_REG == {ir[7:6],ir[3:0] && DBL_REG_DE == ir[5:4] |
495
            ED_OUTs6C7_REG ==  {ir[7:6],ir[2:0] && REG8_D == ir[5:3]} ;
496
 
497
 
498
wire os_e = LDs6HL7_E    == ir1  |  //      LD (HL),E    ; 73
499
            ED_OUTs6C7_REG ==  {ir[7:6],ir[2:0] && REG8_E == ir[5:3]} ;
500
 
501
wire os_h = LDs6HL7_H    == ir1 |  //      LD (HL),H    ; 74
502
            LDs6NN7_HL   == ir1 |            //      LD (NN),HL   ; 22 XX XX
503
            ED_LDs6NN7_REG == {ir[7:6],ir[3:0] && DBL_REG_HL == ir[5:4] |
504
            ED_OUTs6C7_REG ==  {ir[7:6],ir[2:0] && REG8_H == ir[5:3]} ;
505
wire os_l = LDs6HL7_L    == ir1  |  //      LD (HL),L    ; 75
506
            ED_OUTs6C7_REG ==  {ir[7:6],ir[2:0] && REG8_L == ir[5:3]} ;
507
 
508
wire os_sp = ED_LDs6NN7_REG == {ir[7:6],ir[3:0] && DBL_REG_SP == ir[5:4];
509
 
510
 
511
// does not include extension stuff as we are mostly looking for hazards here
512
// course we do use these terms to build more decodes
513
//
514
wire  opadr_bc  =  LDsA_6BC7  == ir1 | LDs6BC7_A == ir1;
515
wire  opadr_de  =  LDsA_6DE7  == ir1 | LDs6DE7_A == ir1;
516
wire  opadr_hl  =  LDsB_6HL7  == ir1 | ORs6HL7    == ir1 | LDs6HL7_B == ir1 |
517
                   LDsD_6HL7  == ir1 | LDsC_6HL7  == ir1 | LDs6HL7_C == ir1 |
518
                   LDsH_6HL7  == ir1 | LDsE_6HL7  == ir1 | LDs6HL7_D == ir1 |
519
                   ADDsA_6HL7 == ir1 | LDsL_6HL7  == ir1 | LDs6HL7_E == ir1 |
520
                   SUBs6HL7   == ir1 | LDsA_6HL7  == ir1 | LDs6HL7_H == ir1 |
521
                   ANDs6HL7   == ir1 | ADCsA_6HL7 == ir1 | LDs6HL7_L == ir1 |
522
                   XORs6HL7   == ir1 | SBCs6HL7   == ir1 | CPs6HL7   == ir1 ;
523
 
524
assign  use_a = os_a;
525
assign  use_b = os_b  | opadr_bc;
526
assign  use_c = os_c  | opadr_bc;
527
assign  use_d = os_d  | opadr_de;
528
assign  use_e = os_e  | opadr_de;
529
assign  use_h = os_h  | opadr_hl;
530
assign  use_l = os_l  | opadr_hl;
531
 
532
 
533
 
534
assign   use_flags = c_jmp8 | c_jmp4 | c_call | c_ret;
535
 
536
 
537
 
538
wire bc_eq0 = beq0 & ceq0;
539
assign rpt_blk_mv = (blk_mv_reg )  & !bc_eq0     |
540
                    (blk_cmp_reg) & !bc_eq0 & (nn[7:0] != 8'h0)  |
541
                    (blk_in_reg | blk_out_reg) & !b_eq0 ;
542
 
543
 
544
 
545
 
546
 
547
 
548
 
549
//  BASIC ARCHITECTURE OF THIS FILE   pc  and sp not shown, but are inputs to src mux.
550
//                    _____           and may be updated from adder output.
551
//                   |     |
552
//                   |     |          pc-1 register is required to implement relative jumps.
553
//                   |     |                     
554
//      _____        |lit  |      |\             
555
//     |     |       |     |      |  \           
556
//     |     |       |src2 |      |    \          _____          _____ 
557
//     |     |       |     |----->|     |        |     |        |     |
558
//     |src  |       |_____|      |adder|------->|     |        |     |
559
//     |mux  |                    |     |        |     |        |     |
560
//     |     |------------------->|    /         |2/1  |------->|wb   |
561
//     |     |              |     |  /           |mux  |        |adr  |
562
//     |_____|              |     |/             |     |        |     |
563
//                           ------------------->|     |        |     |
564
//                                               |_____|        |_____|
565
//
566
// There was a time when I thought we might use wb_add  (or a copy) as a source for the 
567
// src mux ( thought I might need to save less state that way )
568
// seems like most state is needed in any case -- so this way I don't have to worry about
569
// multiple loads on wb_adr..
570
//
571
//
572
wire src_sp = (mem_exec) ? use_sp : push_reg | pop_reg | call_reg & mem_op1 | ret_reg & mem_op1;
573
 
574
wire src_pc = mem_if1 | mem_if2 | mem_exec & !exec_of;
575
wire src_nn = ir1 == LDsA_6NN7   & mem_exec   |
576
              ir1 == LDsHL_6NN7  & mem_exec   |
577
              ir1 == LDs6NN7_A   & mem_exec   |
578
              ir1 == LDs6NN7_HL  & mem_exec   |
579
              ir1 == jmp         & mem_exec   |
580
                     call_reg    & mem_op2    |
581
              ir1 == INsA_6N7    & mem_exec   |
582
              ir1 == OUTs6N7_A   & mem_exec   |
583
 
584
//  don't forget that hl source can be modified by prefix
585
wire src_hl =  ir1 ==  LDsB_6HL7  & mem_exec |      //LD B,(HL)    ; 46
586
               ir1 ==  LDsD_6HL7  & mem_exec |      //LD D,(HL)    ; 56
587
               ir1 ==  LDsH_6HL7  & mem_exec |      //LD H,(HL)    ; 66
588
               ir1 ==  ADDsA_6HL7 & mem_exec |      //ADD A,(HL)   ; 86
589
               ir1 ==  SUBs6HL7   & mem_exec |      //SUB (HL)     ; 96
590
               ir1 ==  ANDs6HL7   & mem_exec |      //AND (HL)     ; A6
591
               ir1 ==  ORs6HL7    & mem_exec |      //OR (HL)      ; B6
592
               ir1 ==  LDsC_6HL7  & mem_exec |      //LD C,(HL)    ; 4E
593
               ir1 ==  LDsE_6HL7  & mem_exec |      //LD E,(HL)    ; 5E
594
               ir1 ==  LDsL_6HL7  & mem_exec |      //LD L,(HL)    ; 6E
595
               ir1 ==  LDsA_6HL7  & mem_exec |      //LD A,(HL)    ; 7E
596
               ir1 ==  ADCsA_6HL7 & mem_exec |      //ADC A,(HL)   ; 8E
597
               ir1 ==  SBCs6HL7   & mem_exec |      //SBC (HL)     ; 9E
598
               ir1 ==  XORs6HL7   & mem_exec |      //XOR (HL)     ; AE
599
               ir1 ==  CPs6HL7    & mem_exec |      //CP (HL)      ; BE
600
               ir1 ==  LDs6HL7_N  & mem_exec |      //LD (HL),N    ; 36 XX
601
               ir1 ==  LDs6HL7_A  & mem_exec |      //LD (HL),A    ; 77
602
               ir1 ==  LDs6HL7_B  & mem_exec |      //LD (HL),B    ; 70
603
               ir1 ==  LDs6HL7_C  & mem_exec |      //LD (HL),C    ; 71
604
               ir1 ==  LDs6HL7_D  & mem_exec |      //LD (HL),D    ; 72
605
               ir1 ==  LDs6HL7_E  & mem_exec |      //LD (HL),E    ; 73
606
               ir1 ==  LDs6HL7_H  & mem_exec |      //LD (HL),H    ; 74
607
               ir1 ==  LDs6HL7_L  & mem_exec |      //LD (HL),L    ; 75
608
               // rmw 8 types
609
               ir1 ==  INCs6HL7   & mem_exec |      //INC (HL)     ; 34
610
               ir1 ==   DECs6HL7  & mem_exec |       //DEC (HL)     ; 35
611
               blk_mv             & mem_exec |
612
               blk_cmp            & mem_exec |
613
               blk_out            & mem_exec |
614
               ir1[2:0]==CB_MEM &
615
                 ir[9:8] == 2'b01 & mem_exec |
616
 
617
               blk_mv_reg         & mem_op2  |
618
               blk_cmp_reg        & mem_op2  |
619
               blk_out_reg        & mem_op2
620
                // all block moves
621
 
622
wire src_de  = ir1 ==  LDsA_6DE7 & mem_exec |
623
               ir1 ==  LDs6DE7_A & mem_exec   ;
624
 
625
 
626
wire src_bc =  ir1 ==  LDsA_6BC7 & mem_exec |
627
               ir1 ==  LDs6BC7_A & mem_exec ;
628
 
629
wire inc
630
 
631
assign src_mux =   {16{ src_sp  }} & sp |
632
                   {16{ src_pc  }} & pc |
633
                   {16{ src_nn  }} & nn |
634
                   {16{ src_hl  }} & hl |
635
                   {16{ src_de  }} & de |
636
                   {16{ src_bc  }} & bc   :
637
 
638
assign src2    = {16{ inc }}    & 16'h0001        |
639
                 {16{ dec }}    & 16'hffff        |
640
                 {16{ rel_jmp}} & {8{nn7},nn[7:0]};
641
 
642
 
643
assign alu     = src2 + src_mux;
644
 
645
assign mux21 =  pre_inc_dec ? alu : src_mux;
646
assign wb_rdy = !wb_cyc | wb_ack;
647
 
648
//-------1---------2---------3--------State Machines-------6---------7---------8---------9--------0
649
 
650
 
651
wire exec_ir1 = (MEM_EXEC == mem_state);
652
always @(posedge clk or posedge rst)
653
    if (rst)
654
    begin
655
        of16_reg    <= 1'b0;
656
        os16_reg    <= 1'b0;
657
        rmw8_reg    <= 1'b0;
658
        push_reg    <= 1'b0;
659
        pop_reg     <= 1'b0;
660
        call_reg    <= 1'b0;
661
        ret_reg     <= 1'b0;
662
        blk_mv_reg  <= 1'b0;
663
        blk_cmp_reg <= 1'b0;
664
        blk_in_reg  <= 1'b0;
665
        blk_out_reg <= 1'b0;
666
        blk_rpt_reg <= 1'b0;
667
        blk_inc_reg <= 1'b0;
668
        src_nn_reg  <= 1'b0;
669
        src_hl_reg  <= 1'b0;
670
    end
671
    else if (exec_ir1)
672
    begin
673
        of16_reg    <= of16   ;
674
        os16_reg    <= os16   ;
675
        rmw8_reg    <= rmw8   ;
676
        push_reg    <= push   ;
677
        pop_reg     <= pop    ;
678
        call_reg    <= call   ;
679
        ret_reg     <= ret    ;
680
        xchng16_reg <= xchng16 ;
681
        blk_mv_reg  <= blk_mv  ;
682
        blk_cmp_reg <= blk_cmp;
683
        blk_in_reg  <= blk_in ;
684
        blk_out_reg <= blk_out;
685
        blk_rpt_reg <= blk_rpt;
686
        blk_inc_reg <= blk_inc;
687
        src_nn_reg  <= src_nn ;
688
    end
689
 
690
// first cut at the main state machine. 
691
//      make one hot to speed up decoding  ?   leaning that way...  but no big deal till 
692
//      physical.
693
//      MEM_HALT  ---  kind of silly to sit here and wait for interrupt - but ok  gotta do something.
694
//                    
695
//      Lot of Issues here Interrupts  ( during block moves - roll back pc )
696
//                         hazards
697
//                         halt
698
//      3/17/2004 on first time through the ddcb and fdcb prefix operations were wrong - 
699
//       in fact fdfdcb is not handled as It appears it "should be".  
700
 
701
//               of16         os16    rmw8         push-pop               call
702
//
703
//MEM_EXEC      of_adr     os_adr++  of_adr   sp <=pop?++adr :--adr     --sp<=pc
704
//MEM_OP1       of_adr++   os_adr++  os_adr   sp <=pop?++adr :--adr     --sp<=pc<=NN
705
//                <IF2        <IF2   <IF2       <IF2                       <IF1
706
//
707
//              ioi           ioo
708
//MEM_IF2 
709
//MEM_EXEC      iof           ios   
710
//MEM_OP1 
711
 
712
 
713
 
714
//
715
//           ret         blk_mv       blk_cmp      blk_in blk_o      int          xchng16
716
//MEM_IDLE
717
//MEM_HALT
718
//MEM_IF1 
719
//MEM_IF2 
720
//MEM_EXEC sp<=++adr    of_6src7       of6src7    iof      of         iof              of
721
//                     > RPT_T         >OP3      >RPT_T   >RPT+T
722
//MEM_OP1                                                                           os
723
//MEM_OP2                                                                           of
724
//MEM_OP3              of RPT_T       >RPT_T        iof      of                       os >IF2 
725
//MEM_RPT_T           os done?         done?      os done? ios done?
726
//                     IF2:OP3        >IF2:of>OP3  IF2:OP3  IF2:OP3
727
//
728
//
729
//MEM_INT1                                                             (--sp)<=pcH
730
//MEM_INT2                                                             (--sp)<=PCL
731
//                                                                      pc<=I,n >IF1
732
//MEM_INT3                                                             of_n
733
//MEM_INT4                                                             of_nn
734
//MEM_INT5                                                             pc<=nn
735
 
736
wire  goto_op1 = (of16 |os16 | rmw8 | xchng16| call | ret );
737
wire  goto_op2 =  xchng16_reg;
738
wire  goto_rpt_t =  blk_mv | blk_in | blk_out;
739
wire  goto_op3   = blk_cmp;
740
wire  blk_mv_rpt =
741
 
742
 
743
always @(posedge clk or posedge rst)
744
    if (rst)  mem_state <= MEM_IDLE;
745
    else  if (wb_rdy)                   // wb rdy = wb_idle | wb_ack
746
    begin
747
        case (mem_state)
748
            MEM_IDLE:             mem_state <= MEM_IF1
749
            MEM_HALT:             mem_state <= MEM_HALT   // stay here until interrupt or reset
750
            MEM_IF1               mem_state <= MEM_IF2
751
            MEM_IF2 :             mem_state <= MEM_EXEC;
752
            MEM_EXEC :
753
                if (int)          mem_state   <= MEM_INT1;
754
                else if(halt)     mem_state   <= MEM_HALT;
755
                else if (ir1_val)
756
                begin
757
                    if(mem_hazard) mem_state <= MEM_IF1; // restart i pipe
758
                    else if(reg_hazard) mem_state <= MEM_IF2; // wait for inst execution
759
                    else if(jmp )       mem_state <= MEM_IF1;
760
                    else if(goto_op1)   mem_state <= MEM_OP1;
761
                    else if(of8 | os8)  mem_state <= MEM_IF1;
762
                    else if(goto_rpt_t) mem_state <= MEM_RPT_T;
763
                    else if(goto_op3)   mem_state <= MEM_OP3;
764
                    else                mem_state <= MEM_EXEC;
765
                end
766
            MEM_OP1 :
767
                if (xchang16   )  mem_state <= MEM_OP2;
768
                else              mem_state <= MEM_IF2;
769
            MEM_OP2 :             mem_state <= MEM_OP3;
770
            MEM_OP3 :
771
                if (xchng16_reg)  mem_state <= MEM_IF2;
772
                else              mem_state <= MEM_RPT_T;
773
            MEM_RPT_T :
774
                if (!rpt_blk_mv)  mem_state <= MEM_IF2;
775
                else if (int)     mem_state <= MEM_INT1;
776
                else
777
            MEM_INT1:             mem_state <= MEM_INT2;
778
            MEM_INT2:             mem_state <= MEM_INT3;
779
            MEM_INT3:             mem_state <= MEM_INT4;
780
            MEM_INT4:             mem_state <= MEM_INT5;
781
            MEM_INT5:             mem_state <= MEM_IF1;
782
        endcase
783
    end
784
//  some assignemnts to save on virtual paper
785
//
786
assign mem_idle = MEM_IDLE  ==mem_state;
787
assign mem_halt = MEM_HALT  ==mem_state;
788
assign mem_if1  = MEM_IF1   ==mem_state;
789
assign mem_if2  = MEM_IF2   ==mem_state;
790
assign mem_exec = MEM_EXEC  ==mem_state;
791
assign mem_op1  = MEM_OP1   ==mem_state;
792
assign mem_op2  = MEM_OP2   ==mem_state;
793
assign mem_op3  = MEM_OP3   ==mem_state;
794
assign mem_rpt_t= MEM_RPT_T == mem_state;
795
assign mem_int1 = MEM_INT1  ==mem_state;
796
assign mem_int2 = MEM_INT2  ==mem_state;
797
assign mem_int3 = MEM_INT3  ==mem_state;
798
assign mem_int4 = MEM_INT4  ==mem_state;
799
assign mem_int5 = MEM_INT5  ==mem_state;
800
 
801
 
802
assign  any_os =    os8 & mem_exec        |
803
                    os16 & mem_exec       |
804
                    call & mem_exec       |
805
                    push & mem_exec       |
806
                    os16_reg & mem_op1    |
807
                    rmw8_reg & mem_op1    |
808
                    xchng16_reg & mem_op1 |
809
                    xchng16_reg & mem_op3 |
810
                    call_reg & mem_op1    |
811
                    blk_mv_reg & mem_rpt_t|
812
                    blk_in_reg & mem_rpt_t|
813
                    int_reg  &  mem_int1  |
814
                    int_reg  & mem_int2    ;
815
 
816
 
817
assign any_ios = ioo & mem_exec | blk_out_reg & mem_rpt_t;
818
assign any_iof = ioi & mem_exe  | blk_in_reg & mem_op3;
819
 
820
 
821
 
822
//  program counter 
823
wire if_pinc = mem_if1 | mem_if2 | exec_if;
824
always @(posedge clk or posedge rst)
825
    if (rst)  pc <= 16'h0
826
    else if if_pinc pc <= alu;
827
 
828
 
829
//-------------------------- memory interface stuff ----------------------------
830
 
831
 
832
// --  wb_adr
833
always @(posedge clk) if (wb_rdy) wb_adr <= mux21
834
 
835
// --  wb_we; 
836
 
837
always @(posedge clk or posedge rst)
838
    if (rst)         wb_we <= 1'b0;
839
    else if (wb_rdy) wb_we <= (any_os | any_ios);
840
// --  wb_cyc
841
 
842
wire no_wb_start = mem_idle | mem_halt | mem_op3 & blk_cmp_reg | mem_op1 & rmw_reg;
843
always @(posedge clk or posedge rst)
844
    if (rst)         wb_cyc <= 1'b0;
845
    else if (wb_rdy) wb_cyc <= !no_wb_start
846
// --  wb_stb; 
847
 
848
always @(posedge clk or posedge rst)
849
    if (rst)         wb_cyc <= 1'b0;
850
    else if (wb_rdy) wb_cyc <= !no_wb_start
851
 
852
 
853
// --  wb_lock;
854
 
855
always @(posedge clk or posedge rst)
856
    if (rst)         wb_lock <= 1'b0;
857
    else if (wb_rdy)
858
    begin
859
        if (mem_exec & rmw)    wb_lock <= 1'b1;
860
        if (mem_if2 & rmw_reg) wb_lock <= 1'b0;
861
    end
862
 
863
 
864
// --  wb_tga_io
865
always @(posedge clk or posedge rst)
866
    if (rst)         wb_tga_io <= 2'b0;
867
    else if (wb_rdy)
868
    begin
869
        if (any_iof | any_ios)    wb_tga_io <= TAG_IO;
870
        else if (mem_exec & int ) wb_tga_io <= TAG_INT;
871
        else                      wb_tga_io <= 2'b0
872
    end
873
 
874
 
875
endmodule
876
 
877
 
878
 

powered by: WebSVN 2.1.0

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