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

powered by: WebSVN 2.1.0

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