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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [Projects/] [opencores.org/] [adv_debug_sys/] [Hardware/] [adv_dbg_if/] [rtl/] [verilog/] [adbg_jfifo_module.v] - Blame information for rev 135

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 131 jt_eaton
/////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  adbg_jfifo_module.v                                         ////
4
////                                                              ////
5
////                                                              ////
6
////  This file is part of the SoC Advanced Debug Interface.      ////
7
////                                                              ////
8
////  Author(s):                                                  ////
9
////       Nathan Yawn (nathan.yawn@opencores.org)                ////
10
////                                                              ////
11
////                                                              ////
12
////                                                              ////
13
//////////////////////////////////////////////////////////////////////
14
////                                                              ////
15
//// Copyright (C) 2010       Authors                             ////
16
////                                                              ////
17
//// This source file may be used and distributed without         ////
18
//// restriction provided that this copyright statement is not    ////
19
//// removed from the file and that any derivative work contains  ////
20
//// the original copyright notice and the associated disclaimer. ////
21
////                                                              ////
22
//// This source file is free software; you can redistribute it   ////
23
//// and/or modify it under the terms of the GNU Lesser General   ////
24
//// Public License as published by the Free Software Foundation; ////
25
//// either version 2.1 of the License, or (at your option) any   ////
26
//// later version.                                               ////
27
////                                                              ////
28
//// This source is distributed in the hope that it will be       ////
29
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
30
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
31
//// PURPOSE.  See the GNU Lesser General Public License for more ////
32
//// details.                                                     ////
33
////                                                              ////
34
//// You should have received a copy of the GNU Lesser General    ////
35
//// Public License along with this source; if not, download it   ////
36
//// from http://www.opencores.org/lgpl.shtml                     ////
37
////                                                              ////
38
//////////////////////////////////////////////////////////////////////
39
 
40
 
41
 
42
 
43
// Module interface
44
module `VARIANT`JFIFO_MODULE (
45
                         // JTAG signals
46
                         tck_i,
47
                         module_tdo_o,
48
                         tdi_i,
49
 
50
                         // TAP states
51
                         capture_dr_i,
52
                         shift_dr_i,
53
                         update_dr_i,
54
 
55
                         data_register_i,  // the data register is at top level, shared between all modules
56
                         module_select_i,
57
                         rst_i,
58
 
59
                         jsp_data_out,
60
                         biu_wr_strobe,
61
 
62
                         // WISHBONE 
63
                         wb_clk_i, wb_dat_i, wb_stb_i
64
 
65
                         );
66
 
67
   // JTAG signals
68
   input         tck_i;
69
   output        module_tdo_o;
70
   input         tdi_i;  // This is only used by the CRC module - data_register_i[MSB] is delayed a cycle
71
 
72
   // TAP states
73
   input         capture_dr_i;
74
   input         shift_dr_i;
75
   input         update_dr_i;
76
   input [52:0]  data_register_i;
77
   input         module_select_i;
78
   input         rst_i;
79
   output [7:0]  jsp_data_out;
80
   output        biu_wr_strobe;
81
 
82
 
83
   // WISHBONE slave interface
84
   input         wb_clk_i;
85
   input  [7:0]  wb_dat_i;
86
   input         wb_stb_i;
87
 
88
 
89
 
90
 
91
 
92
 
93
 
94
 
95
 
96
 
97
 
98
 
99
 
100
 
101
 
102
 
103
   reg [7:0]   jsp_data_out;
104
 
105
   // Declare inputs / outputs as wires / registers
106
   wire          module_tdo_o;
107
 
108
 
109
   // NOTE:  For the rest of this file, "input" and the "in" direction refer to bytes being transferred
110
   // from the PC, through the JTAG, and into the BIU FIFO.  The "output" direction refers to data being
111
   // transferred from the BIU FIFO, through the JTAG to the PC.
112
 
113
   // The read and write bit counts are separated to allow for JTAG chains with multiple devices.
114
   // The read bit count starts right away (after a single throwaway bit), but the write count
115
   // waits to receive a '1' start bit.
116
 
117
   // Registers to hold state etc.
118
   reg [3:0]      read_bit_count;            // How many bits have been shifted out
119
   reg [3:0]   write_bit_count;      // How many bits have been shifted in
120
   reg [3:0]      input_word_count;     // space (bytes) remaining in input FIFO (from JTAG)
121
   reg [3:0]     output_word_count;    // bytes remaining in output FIFO (to JTAG)
122
   reg [3:0]      user_word_count;     // bytes user intends to send from PC
123
   reg [7:0]      data_out_shift_reg;  // parallel-load output shift register
124
 
125
 
126
   // Control signals for the various counters / registers / state machines
127
   reg           rd_bit_ct_en;         // enable bit counter
128
   reg           rd_bit_ct_rst;        // reset (zero) bit count register
129
   reg           wr_bit_ct_en;         // enable bit counter
130
   reg           wr_bit_ct_rst;        // reset (zero) bit count register   
131
   reg           in_word_ct_sel;       // Selects data for byte counter.  0 = data_register_i, 1 = decremented byte count
132
   reg           out_word_ct_sel;       // Selects data for byte counter.  0 = data_register_i, 1 = decremented byte count
133
   reg           in_word_ct_en;     // Enable input byte counter register
134
   reg           out_word_ct_en;    // Enable output byte count register
135
   reg           user_word_ct_en;   // Enable user byte count registere
136
   reg           user_word_ct_sel;  // selects data for user byte counter.  0 = user data, 1 = decremented byte count
137
   reg           out_reg_ld_en;     // Enable parallel load of data_out_shift_reg
138
   reg           out_reg_shift_en;  // Enable shift of data_out_shift_reg
139
   reg           out_reg_data_sel;  // 0 = BIU data, 1 = byte count data (also from BIU)
140
   reg           biu_rd_strobe;      // Indicates that the bus unit should ACK the last read operation + start another
141
   reg           biu_wr_strobe;   // Indicates BIU should latch input + begin a write operation
142
 
143
 
144
   // Status signals
145
   wire          in_word_count_zero;   // true when input byte counter is zero
146
   wire          out_word_count_zero;   // true when output byte counter is zero
147
   wire          user_word_count_zero; // true when user byte counter is zero
148
   wire          rd_bit_count_max;     // true when bit counter is equal to current word size
149
   wire          wr_bit_count_max;     // true when bit counter is equal to current word size
150
 
151
   // Intermediate signals
152
   wire [3:0]     data_to_in_word_counter;  // output of the mux in front of the input byte counter reg
153
   wire [3:0]     data_to_out_word_counter;  // output of the mux in front of the output byte counter reg
154
   wire [3:0]     data_to_user_word_counter;  // output of mux in front of user word counter
155
   wire [3:0]     decremented_in_word_count;
156
   wire [3:0]     decremented_out_word_count;
157
   wire [3:0]     decremented_user_word_count;
158
   wire [3:0]     count_data_in;         // from data_register_i
159
   wire [7:0]     data_to_biu;           // from data_register_i
160
   wire [7:0]     data_from_biu;         // to data_out_shift_register
161
   wire [3:0]     biu_space_available;
162
   wire [3:0]     biu_bytes_available;
163
   wire [7:0]     out_reg_data;           // parallel input to the output shift register
164
   wire [7:0]     count_data_from_biu;
165
 
166
 
167
 
168
 
169
   //////////////////////////////////////
170
 
171
 
172
   always @ (posedge tck_i or posedge rst_i)
173
     begin
174
        if(rst_i)                   jsp_data_out <= 8'h00;
175
        else if(biu_wr_strobe)      jsp_data_out <= data_to_biu;
176
        else                        jsp_data_out <= jsp_data_out;
177
     end
178
 
179
 
180
 
181
   /////////////////////////////////////////////////
182
   // Combinatorial assignments
183
 
184
   assign count_data_from_biu = {biu_bytes_available, biu_space_available};
185
   assign count_data_in = {tdi_i,data_register_i[52:50]};  // Second nibble of user data
186
   assign data_to_biu   = {tdi_i,data_register_i[52:46]};
187
 
188
   //////////////////////////////////////
189
   // Input bit counter
190
 
191
   always @ (posedge tck_i or posedge rst_i)
192
     begin
193
        if(rst_i)             write_bit_count <= 4'h0;
194
        else if(wr_bit_ct_rst)   write_bit_count <= 4'h0;
195
        else if(wr_bit_ct_en)    write_bit_count <= write_bit_count + 4'h1;
196
     end
197
 
198
   assign wr_bit_count_max = (write_bit_count == 4'h7) ? 1'b1 : 1'b0;
199
 
200
   //////////////////////////////////////
201
   // Output bit counter
202
 
203
   always @ (posedge tck_i or posedge rst_i)
204
     begin
205
        if(rst_i)             read_bit_count <= 4'h0;
206
        else if(rd_bit_ct_rst)   read_bit_count <= 4'h0;
207
        else if(rd_bit_ct_en)    read_bit_count <= read_bit_count + 4'h1;
208
     end
209
 
210
   assign rd_bit_count_max = (read_bit_count == 4'h7) ? 1'b1 : 1'b0;
211
 
212
   ////////////////////////////////////////
213
   // Input word counter
214
 
215
   assign data_to_in_word_counter = (in_word_ct_sel) ?  decremented_in_word_count : biu_space_available;
216
   assign decremented_in_word_count = input_word_count - 4'h1;
217
 
218
   always @ (posedge tck_i or posedge rst_i)
219
     begin
220
        if(rst_i)
221
          input_word_count <= 4'h0;
222
        else if(in_word_ct_en)
223
          input_word_count <= data_to_in_word_counter;
224
     end
225
 
226
   assign in_word_count_zero = (input_word_count == 4'h0);
227
 
228
   ////////////////////////////////////////
229
   // Output word counter
230
 
231
   assign data_to_out_word_counter = (out_word_ct_sel) ?  decremented_out_word_count : biu_bytes_available;
232
   assign decremented_out_word_count = output_word_count - 4'h1;
233
 
234
   always @ (posedge tck_i or posedge rst_i)
235
     begin
236
        if(rst_i)
237
          output_word_count <= 4'h0;
238
        else if(out_word_ct_en)
239
          output_word_count <= data_to_out_word_counter;
240
     end
241
 
242
   assign out_word_count_zero = (output_word_count == 4'h0);
243
 
244
   ////////////////////////////////////////
245
   // User word counter
246
 
247
   assign data_to_user_word_counter = (user_word_ct_sel) ?  decremented_user_word_count : count_data_in;
248
   assign decremented_user_word_count = user_word_count - 4'h1;
249
 
250
   always @ (posedge tck_i or posedge rst_i)
251
     begin
252
        if(rst_i)                 user_word_count <= 4'h0;
253
        else if(user_word_ct_en)  user_word_count <= data_to_user_word_counter;
254
     end
255
 
256
   assign user_word_count_zero = (user_word_count == 4'h0);
257
 
258
   /////////////////////////////////////////////////////
259
   // Output register and TDO output MUX
260
 
261
 
262
   assign out_reg_data = (out_reg_data_sel) ? count_data_from_biu   : data_from_biu;
263
 
264
   always @ (posedge tck_i or posedge rst_i)
265
     begin
266
        if(rst_i)                 data_out_shift_reg     <= 8'h0;
267
        else if(out_reg_ld_en)    data_out_shift_reg     <= out_reg_data;
268
        else if(out_reg_shift_en) data_out_shift_reg     <= {1'b0, data_out_shift_reg[7:1]};
269
     end
270
 
271
   assign module_tdo_o = data_out_shift_reg[0];
272
 
273
   ////////////////////////////////////////
274
   // Bus Interface Unit (to JTAG  UART)
275
   // It is assumed that the BIU has internal registers, and will
276
   // latch write data (and ack read data) on rising clock edge 
277
   // when strobe is asserted
278
 
279
   `VARIANT`JFIFO_BIU jsp_biu_i (
280
                           // Debug interface signals
281
                           .tck_i             (tck_i),
282
                           .rst_i             (rst_i),
283
                           .data_o            (data_from_biu),
284
                           .bytes_available_o (biu_bytes_available),
285
                           .bytes_free_o      (biu_space_available),
286
                           .rd_strobe_i       (biu_rd_strobe),
287
                           .wr_strobe_i       (biu_wr_strobe),
288
 
289
                           // Wishbone slave signals
290
                           .wb_clk_i        (wb_clk_i),
291
                           .wb_dat_i        (wb_dat_i),
292
                           .wb_stb_i        (wb_stb_i)
293
 
294
                           );
295
 
296
 
297
   ////////////////////////////////////////
298
   // Input Control FSM
299
 
300
   // Definition of machine state values.
301
   // Don't worry too much about the state encoding, the synthesis tool
302
   // will probably re-encode it anyway.
303
 
304
`define STATE_wr_idle     3'h0
305
`define STATE_wr_wait     3'h1
306
`define STATE_wr_counts   3'h2
307
`define STATE_wr_xfer     3'h3
308
 
309
   reg [2:0] wr_module_state;       // FSM state
310
   reg [2:0] wr_module_next_state;  // combinatorial signal, not actually a register
311
 
312
 
313
 
314
 
315 135 jt_eaton
`ifndef SYNTHESIS
316 131 jt_eaton
 
317
reg [8*16-1:0] wr_module_string;
318
 
319
always @(*) begin
320
   case (wr_module_state)
321
      `STATE_wr_idle:      wr_module_string = "wr_idle";
322
      `STATE_wr_wait:      wr_module_string = "wr_wait";
323
      `STATE_wr_counts:    wr_module_string = "wr_counts";
324
      `STATE_wr_xfer:      wr_module_string = "wr_xfer";
325
      default:             wr_module_string = "-XXXXXX-";
326
   endcase
327
 
328
   $display("%t  %m   JFifo wr_module State   = %s",$realtime, wr_module_string);
329
end
330
 
331 135 jt_eaton
`endif //  `ifndef SYNTHESIS
332 131 jt_eaton
 
333
 
334
 
335
 
336
 
337
 
338
 
339
 
340
   // sequential part of the FSM
341
   always @ (posedge tck_i or posedge rst_i)
342
     begin
343
        if(rst_i)
344
          wr_module_state <= `STATE_wr_idle;
345
        else
346
          wr_module_state <= wr_module_next_state;
347
     end
348
 
349
 
350
   // Determination of next state; purely combinatorial
351
   always @ (wr_module_state or module_select_i or update_dr_i or capture_dr_i
352
             or shift_dr_i or wr_bit_count_max or tdi_i)
353
     begin
354
        case(wr_module_state)
355
          `STATE_wr_idle:
356
            begin
357
`ifdef ADBG_JSP_SUPPORT_MULTI
358
               if(module_select_i && capture_dr_i) wr_module_next_state = `STATE_wr_wait;
359
`else
360
               if(module_select_i && capture_dr_i) wr_module_next_state = `STATE_wr_counts;
361
`endif
362
               else wr_module_next_state = `STATE_wr_idle;
363
            end
364
           `STATE_wr_wait:
365
           begin
366
                 if(update_dr_i) wr_module_next_state = `STATE_wr_idle;
367
                  else if(module_select_i && tdi_i  && shift_dr_i     ) wr_module_next_state = `STATE_wr_counts;  // got start bit
368
               else wr_module_next_state = `STATE_wr_wait;
369
           end
370
          `STATE_wr_counts:
371
            begin
372
               if(update_dr_i)                                 wr_module_next_state = `STATE_wr_idle;
373
               else if(wr_bit_count_max   && shift_dr_i )      wr_module_next_state = `STATE_wr_xfer;
374
               else                                            wr_module_next_state = `STATE_wr_counts;
375
            end
376
 
377
          `STATE_wr_xfer:
378
            begin
379
               if(update_dr_i) wr_module_next_state = `STATE_wr_idle;
380
               else wr_module_next_state = `STATE_wr_xfer;
381
            end
382
 
383
          default: wr_module_next_state = `STATE_wr_idle;  // shouldn't actually happen...
384
        endcase
385
     end
386
 
387
 
388
   // Outputs of state machine, pure combinatorial
389
   always @ (wr_module_state or wr_module_next_state or module_select_i or update_dr_i or capture_dr_i or shift_dr_i
390
             or in_word_count_zero or out_word_count_zero or wr_bit_count_max or decremented_in_word_count
391
             or decremented_out_word_count or user_word_count_zero)
392
     begin
393
        // Default everything to 0, keeps the case statement simple
394
        wr_bit_ct_en = 1'b0;         // enable bit counter
395
        wr_bit_ct_rst = 1'b0;        // reset (zero) bit count register
396
        in_word_ct_sel = 1'b0;       // Selects data for byte counter.  0 = data_register_i, 1 = decremented byte count
397
        user_word_ct_sel = 1'b0;  // selects data for user byte counter, 0 = user data, 1 = decremented count
398
        in_word_ct_en = 1'b0;     // Enable input byte counter register
399
        user_word_ct_en = 1'b0;   // enable user byte count register
400
        biu_wr_strobe = 1'b0;    // Indicates BIU should latch input + begin a write operation
401
 
402
        case(wr_module_state)
403
          `STATE_wr_idle:
404
            begin
405
               in_word_ct_sel = 1'b0;
406
 
407
               // Going to transfer; enable count registers and output register
408
               if(wr_module_next_state != `STATE_wr_idle) begin
409
                  wr_bit_ct_rst = 1'b1;
410
                  in_word_ct_en = 1'b1;
411
               end
412
            end
413
 
414
          // This state is only used when support for multi-device JTAG chains is enabled.
415
          `STATE_wr_wait:
416
            begin
417
               wr_bit_ct_en = 1'b0;  // Don't do anything, just wait for the start bit.
418
            end
419
 
420
          `STATE_wr_counts:
421
            begin
422
               if(shift_dr_i) begin // Don't do anything in PAUSE or EXIT states...
423
                  wr_bit_ct_en = 1'b1;
424
                  user_word_ct_sel = 1'b0;
425
 
426
                  if(wr_bit_count_max) begin
427
                     wr_bit_ct_rst = 1'b1;
428
                     user_word_ct_en = 1'b1;
429
                  end
430
               end
431
            end
432
 
433
          `STATE_wr_xfer:
434
            begin
435
               if(shift_dr_i) begin  // Don't do anything in PAUSE or EXIT states
436
                  wr_bit_ct_en = 1'b1;
437
                  in_word_ct_sel = 1'b1;
438
                  user_word_ct_sel = 1'b1;
439
 
440
                  if(wr_bit_count_max) begin  // Start biu transactions, if word counts allow
441
                     wr_bit_ct_rst = 1'b1;
442
 
443
                     if(!(in_word_count_zero || user_word_count_zero)) begin
444
                        biu_wr_strobe = 1'b1;
445
                        in_word_ct_en = 1'b1;
446
                        user_word_ct_en = 1'b1;
447
                     end
448
 
449
                  end
450
               end
451
            end
452
 
453
          default: ;
454
        endcase
455
     end
456
 
457
   ////////////////////////////////////////
458
   // Output Control FSM
459
 
460
   // Definition of machine state values.
461
   // Don't worry too much about the state encoding, the synthesis tool
462
   // will probably re-encode it anyway.
463
 
464
`define STATE_rd_idle     3'h0
465
`define STATE_rd_counts   3'h1
466
`define STATE_rd_rdack   3'h2
467
`define STATE_rd_xfer  3'h3
468
 
469
// We do not send the equivalent of a 'start bit' (like the one the input FSM
470
// waits for when support for multi-device JTAG chains is enabled).  Since the
471
// input and output are going to be offset anyway, why bother...
472
 
473
   reg [2:0] rd_module_state;       // FSM state
474
   reg [2:0] rd_module_next_state;  // combinatorial signal, not actually a register
475
 
476
 
477
 
478
 
479
 
480
 
481
 
482
 
483
 
484 135 jt_eaton
`ifndef SYNTHESIS
485 131 jt_eaton
 
486
reg [8*16-1:0] rd_module_string;
487
 
488
always @(*) begin
489
   case (rd_module_state)
490
      `STATE_rd_idle:      rd_module_string = "rd_idle";
491
      `STATE_rd_counts:    rd_module_string = "rd_counts";
492
      `STATE_rd_rdack:     rd_module_string = "rd_rdack";
493
      `STATE_rd_xfer:      rd_module_string = "rd_xfer";
494
      default:             rd_module_string = "-XXXXXX-";
495
   endcase
496
 
497
   $display("%t  %m   JFifo rd_module State   = %s",$realtime, rd_module_string);
498
end
499
 
500 135 jt_eaton
`endif //  `ifndef SYNTHESIS
501 131 jt_eaton
 
502
 
503
 
504
 
505
 
506
 
507
 
508
 
509
   // sequential part of the FSM
510
   always @ (posedge tck_i or posedge rst_i)
511
     begin
512
        if(rst_i)
513
          rd_module_state <= `STATE_rd_idle;
514
        else
515
          rd_module_state <= rd_module_next_state;
516
     end
517
 
518
 
519
   // Determination of next state; purely combinatorial
520
   always @ (rd_module_state or module_select_i or update_dr_i or capture_dr_i or shift_dr_i or rd_bit_count_max)
521
     begin
522
        case(rd_module_state)
523
          `STATE_rd_idle:
524
            begin
525
               if(module_select_i && capture_dr_i) rd_module_next_state = `STATE_rd_counts;
526
               else rd_module_next_state = `STATE_rd_idle;
527
            end
528
          `STATE_rd_counts:
529
            begin
530
               if(update_dr_i) rd_module_next_state = `STATE_rd_idle;
531
               else if(rd_bit_count_max  && shift_dr_i ) rd_module_next_state = `STATE_rd_rdack;
532
               else rd_module_next_state = `STATE_rd_counts;
533
            end
534
          `STATE_rd_rdack:
535
            begin
536
               if(update_dr_i) rd_module_next_state = `STATE_rd_idle;
537
               else if(shift_dr_i ) rd_module_next_state = `STATE_rd_xfer;
538
               else rd_module_next_state = `STATE_rd_rdack;
539
            end
540
          `STATE_rd_xfer:
541
            begin
542
               if(update_dr_i) rd_module_next_state = `STATE_rd_idle;
543
               else if(rd_bit_count_max  && shift_dr_i ) rd_module_next_state = `STATE_rd_rdack;
544
               else rd_module_next_state = `STATE_rd_xfer;
545
            end
546
 
547
          default: rd_module_next_state = `STATE_rd_idle;  // shouldn't actually happen...
548
        endcase
549
     end
550
 
551
 
552
   // Outputs of state machine, pure combinatorial
553
   always @ (rd_module_state or rd_module_next_state or module_select_i or update_dr_i or capture_dr_i or shift_dr_i
554
             or in_word_count_zero or out_word_count_zero or rd_bit_count_max or decremented_in_word_count
555
             or decremented_out_word_count)
556
     begin
557
        // Default everything to 0, keeps the case statement simple
558
        rd_bit_ct_en = 1'b0;         // enable bit counter
559
        rd_bit_ct_rst = 1'b0;        // reset (zero) bit count register
560
        out_word_ct_sel = 1'b0;       // Selects data for byte counter.  0 = data_register_i, 1 = decremented byte count
561
        out_word_ct_en = 1'b0;    // Enable output byte count register
562
        out_reg_ld_en = 1'b0;     // Enable parallel load of data_out_shift_reg
563
        out_reg_shift_en = 1'b0;  // Enable shift of data_out_shift_reg
564
        out_reg_data_sel = 1'b0;  // 0 = BIU data, 1 = byte count data (also from BIU)
565
        biu_rd_strobe = 1'b0;     // Indicates that the bus unit should ACK the last read operation + start another
566
 
567
        case(rd_module_state)
568
          `STATE_rd_idle:
569
            begin
570
               out_reg_data_sel = 1'b1;
571
               out_word_ct_sel = 1'b0;
572
 
573
               // Going to transfer; enable count registers and output register
574
               if(rd_module_next_state != `STATE_rd_idle) begin
575
                  out_reg_ld_en = 1'b1;
576
                  rd_bit_ct_rst = 1'b1;
577
                  out_word_ct_en = 1'b1;
578
               end
579
            end
580
 
581
          `STATE_rd_counts:
582
            begin
583
               if(shift_dr_i) begin // Don't do anything in PAUSE or EXIT states...
584
                  rd_bit_ct_en = 1'b1;
585
                  out_reg_shift_en = 1'b1;
586
 
587
                  if(rd_bit_count_max) begin
588
                     rd_bit_ct_rst = 1'b1;
589
 
590
                     // Latch the next output word, but don't ack until STATE_rd_rdack
591
                     if(!out_word_count_zero) begin
592
                        out_reg_ld_en = 1'b1;
593
                        out_reg_shift_en = 1'b0;
594
                     end
595
                  end
596
               end
597
            end
598
 
599
          `STATE_rd_rdack:
600
            begin
601
               if(shift_dr_i) begin  // Don't do anything in PAUSE or EXIT states
602
                  rd_bit_ct_en = 1'b1;
603
                  out_reg_shift_en = 1'b1;
604
                  out_reg_data_sel = 1'b0;
605
 
606
                  // Never have to worry about bit_count_max here.
607
 
608
                  if(!out_word_count_zero) begin
609
                     biu_rd_strobe = 1'b1;
610
                  end
611
               end
612
            end
613
 
614
          `STATE_rd_xfer:
615
            begin
616
               if(shift_dr_i) begin  // Don't do anything in PAUSE or EXIT states
617
                  rd_bit_ct_en = 1'b1;
618
                  out_word_ct_sel = 1'b1;
619
                  out_reg_shift_en = 1'b1;
620
                  out_reg_data_sel = 1'b0;
621
 
622
                  if(rd_bit_count_max) begin  // Start biu transaction, if word count allows
623
                     rd_bit_ct_rst = 1'b1;
624
 
625
                     // Don't ack the read byte here, we do it in STATE_rdack
626
                     if(!out_word_count_zero) begin
627
                        out_reg_ld_en = 1'b1;
628
                        out_reg_shift_en = 1'b0;
629
                        out_word_ct_en = 1'b1;
630
                     end
631
                  end
632
               end
633
            end
634
 
635
          default: ;
636
        endcase
637
     end
638
 
639
 
640
endmodule
641
 

powered by: WebSVN 2.1.0

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