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

Subversion Repositories dbg_interface

[/] [dbg_interface/] [trunk/] [rtl/] [verilog/] [dbg_wb.v] - Blame information for rev 138

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

Line No. Rev Author Line
1 82 mohor
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  dbg_wb.v                                                    ////
4
////                                                              ////
5
////                                                              ////
6
////  This file is part of the SoC/OpenRISC Development Interface ////
7
////  http://www.opencores.org/projects/DebugInterface/           ////
8
////                                                              ////
9
////  Author(s):                                                  ////
10
////       Igor Mohor (igorm@opencores.org)                       ////
11
////                                                              ////
12
////                                                              ////
13
////  All additional information is avaliable in the README.txt   ////
14
////  file.                                                       ////
15
////                                                              ////
16
//////////////////////////////////////////////////////////////////////
17
////                                                              ////
18 138 igorm
//// Copyright (C) 2000 - 2004 Authors                            ////
19 82 mohor
////                                                              ////
20
//// This source file may be used and distributed without         ////
21
//// restriction provided that this copyright statement is not    ////
22
//// removed from the file and that any derivative work contains  ////
23
//// the original copyright notice and the associated disclaimer. ////
24
////                                                              ////
25
//// This source file is free software; you can redistribute it   ////
26
//// and/or modify it under the terms of the GNU Lesser General   ////
27
//// Public License as published by the Free Software Foundation; ////
28
//// either version 2.1 of the License, or (at your option) any   ////
29
//// later version.                                               ////
30
////                                                              ////
31
//// This source is distributed in the hope that it will be       ////
32
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
33
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
34
//// PURPOSE.  See the GNU Lesser General Public License for more ////
35
//// details.                                                     ////
36
////                                                              ////
37
//// You should have received a copy of the GNU Lesser General    ////
38
//// Public License along with this source; if not, download it   ////
39
//// from http://www.opencores.org/lgpl.shtml                     ////
40
////                                                              ////
41
//////////////////////////////////////////////////////////////////////
42
//
43
// CVS Revision History
44
//
45
// $Log: not supported by cvs2svn $
46 138 igorm
// Revision 1.18  2004/01/25 14:04:18  mohor
47
// All flipflops are reset.
48
//
49 123 mohor
// Revision 1.17  2004/01/22 13:58:53  mohor
50
// Port signals are all set to zero after reset.
51
//
52 121 mohor
// Revision 1.16  2004/01/19 07:32:41  simons
53
// Reset values width added because of FV, a good sentence changed because some tools can not handle it.
54
//
55 108 simons
// Revision 1.15  2004/01/17 18:01:24  mohor
56
// New version.
57
//
58 102 mohor
// Revision 1.14  2004/01/16 14:51:33  mohor
59
// cpu registers added.
60
//
61 99 mohor
// Revision 1.13  2004/01/15 12:09:43  mohor
62
// Working.
63
//
64 97 mohor
// Revision 1.12  2004/01/14 22:59:18  mohor
65
// Temp version.
66
//
67 95 mohor
// Revision 1.11  2004/01/14 12:29:40  mohor
68
// temp version. Resets will be changed in next version.
69
//
70 94 mohor
// Revision 1.10  2004/01/13 11:28:14  mohor
71
// tmp version.
72
//
73 93 mohor
// Revision 1.9  2004/01/10 07:50:24  mohor
74
// temp version.
75
//
76 92 mohor
// Revision 1.8  2004/01/09 12:48:44  mohor
77
// tmp version.
78
//
79 91 mohor
// Revision 1.7  2004/01/08 17:53:36  mohor
80
// tmp version.
81
//
82 90 mohor
// Revision 1.6  2004/01/07 11:58:56  mohor
83
// temp4 version.
84
//
85 89 mohor
// Revision 1.5  2004/01/06 17:15:19  mohor
86
// temp3 version.
87
//
88 88 mohor
// Revision 1.4  2004/01/05 12:16:00  mohor
89
// tmp2 version.
90
//
91 87 mohor
// Revision 1.3  2003/12/23 16:22:46  mohor
92
// Tmp version.
93
//
94 86 mohor
// Revision 1.2  2003/12/23 15:26:26  mohor
95
// Small fix.
96
//
97 83 mohor
// Revision 1.1  2003/12/23 15:09:04  mohor
98
// New directory structure. New version of the debug interface.
99 82 mohor
//
100
//
101 83 mohor
//
102 82 mohor
 
103
// synopsys translate_off
104
`include "timescale.v"
105
// synopsys translate_on
106
`include "dbg_wb_defines.v"
107
 
108
// Top module
109
module dbg_wb(
110
                // JTAG signals
111
                tck_i,
112
                tdi_i,
113
                tdo_o,
114
 
115
                // TAP states
116
                shift_dr_i,
117
                pause_dr_i,
118
                update_dr_i,
119
 
120
                wishbone_ce_i,
121
                crc_match_i,
122
                crc_en_o,
123
                shift_crc_o,
124 95 mohor
                rst_i,
125 82 mohor
 
126
                // WISHBONE common signals
127 95 mohor
                wb_clk_i,
128 82 mohor
 
129
                // WISHBONE master interface
130
                wb_adr_o, wb_dat_o, wb_dat_i, wb_cyc_o, wb_stb_o, wb_sel_o,
131
                wb_we_o, wb_ack_i, wb_cab_o, wb_err_i, wb_cti_o, wb_bte_o
132
 
133
              );
134
 
135
// JTAG signals
136 97 mohor
input         tck_i;
137
input         tdi_i;
138
output        tdo_o;
139 82 mohor
 
140
// TAP states
141 97 mohor
input         shift_dr_i;
142
input         pause_dr_i;
143
input         update_dr_i;
144 82 mohor
 
145 97 mohor
input         wishbone_ce_i;
146
input         crc_match_i;
147
output        crc_en_o;
148
output        shift_crc_o;
149
input         rst_i;
150 82 mohor
// WISHBONE common signals
151 97 mohor
input         wb_clk_i;
152 82 mohor
 
153
// WISHBONE master interface
154
output [31:0] wb_adr_o;
155
output [31:0] wb_dat_o;
156
input  [31:0] wb_dat_i;
157
output        wb_cyc_o;
158
output        wb_stb_o;
159
output  [3:0] wb_sel_o;
160
output        wb_we_o;
161
input         wb_ack_i;
162
output        wb_cab_o;
163
input         wb_err_i;
164
output  [2:0] wb_cti_o;
165
output  [1:0] wb_bte_o;
166
 
167
reg           wb_cyc_o;
168
reg    [31:0] wb_adr_o;
169 88 mohor
reg    [31:0] wb_dat_o;
170 82 mohor
reg     [3:0] wb_sel_o;
171
 
172
reg           tdo_o;
173
 
174 88 mohor
reg    [50:0] dr;
175
wire          enable;
176 90 mohor
wire          cmd_cnt_en;
177 138 igorm
reg     [`DBG_WB_CMD_CNT_WIDTH -1:0] cmd_cnt;
178 88 mohor
wire          cmd_cnt_end;
179
reg           cmd_cnt_end_q;
180 90 mohor
wire          addr_len_cnt_en;
181 88 mohor
reg     [5:0] addr_len_cnt;
182
reg     [5:0] addr_len_cnt_limit;
183
wire          addr_len_cnt_end;
184 90 mohor
wire          crc_cnt_en;
185 88 mohor
reg     [5:0] crc_cnt;
186
wire          crc_cnt_end;
187
reg           crc_cnt_end_q;
188 90 mohor
wire          data_cnt_en;
189 88 mohor
reg    [18:0] data_cnt;
190
reg    [18:0] data_cnt_limit;
191
wire          data_cnt_end;
192 90 mohor
reg           data_cnt_end_q;
193 88 mohor
reg           status_reset_en;
194 82 mohor
 
195 90 mohor
reg           crc_match_reg;
196 82 mohor
 
197 92 mohor
reg     [2:0] cmd, cmd_old, dr_cmd_latched;
198
reg    [31:0] adr;
199
reg    [15:0] len;
200
reg           start_rd_tck;
201 97 mohor
reg           rd_tck_started;
202 92 mohor
reg           start_rd_sync1;
203
reg           start_wb_rd;
204
reg           start_wb_rd_q;
205
reg           start_wr_tck;
206
reg           start_wr_sync1;
207
reg           start_wb_wr;
208
reg           start_wb_wr_q;
209 88 mohor
 
210 92 mohor
wire          dr_read;
211
wire          dr_write;
212
wire          dr_go;
213 88 mohor
 
214 92 mohor
reg           dr_write_latched;
215
reg           dr_read_latched;
216
reg           dr_go_latched;
217 82 mohor
 
218 92 mohor
wire          status_cnt_end;
219 89 mohor
 
220 92 mohor
wire          byte, half, long;
221
reg           byte_q, half_q, long_q;
222 94 mohor
reg           byte_q2, half_q2, long_q2;
223 92 mohor
reg           cmd_read;
224
reg           cmd_write;
225
reg           cmd_go;
226 90 mohor
 
227 92 mohor
reg           status_cnt1, status_cnt2, status_cnt3, status_cnt4;
228 90 mohor
 
229 138 igorm
reg [`DBG_WB_STATUS_LEN -1:0] status;
230 92 mohor
 
231 97 mohor
reg           wb_error, wb_error_sync, wb_error_tck;
232
reg           wb_overrun, wb_overrun_sync, wb_overrun_tck;
233
reg           underrun_tck;
234 92 mohor
 
235 97 mohor
reg           busy_wb;
236
reg           busy_tck;
237
reg           wb_end;
238
reg           wb_end_rst;
239
reg           wb_end_rst_sync;
240
reg           wb_end_sync;
241
reg           wb_end_tck, wb_end_tck_q;
242
reg           busy_sync;
243
reg           latch_data;
244 92 mohor
 
245 97 mohor
reg           set_addr, set_addr_sync, set_addr_wb, set_addr_wb_q;
246
reg           read_cycle;
247
reg           write_cycle;
248
reg     [2:0] rw_type;
249
wire   [31:0] input_data;
250 92 mohor
 
251 97 mohor
wire          len_eq_0;
252
wire          crc_cnt_31;
253 93 mohor
 
254 97 mohor
reg     [1:0] ptr;
255
reg     [2:0] fifo_cnt;
256
wire          fifo_full;
257
wire          fifo_empty;
258
reg     [7:0] mem [0:3];
259
reg     [2:0] mem_ptr;
260
reg           wishbone_ce_sync;
261
reg           wishbone_ce_rst;
262
wire          go_prelim;
263
 
264
 
265
 
266 82 mohor
assign enable = wishbone_ce_i & shift_dr_i;
267 90 mohor
assign crc_en_o = enable & crc_cnt_end & (~status_cnt_end);
268 89 mohor
assign shift_crc_o = enable & status_cnt_end;  // Signals dbg module to shift out the CRC
269 82 mohor
 
270
 
271 97 mohor
// Selecting where to take the data from 
272 123 mohor
always @ (posedge tck_i or posedge rst_i)
273 82 mohor
begin
274 123 mohor
  if (rst_i)
275 93 mohor
    ptr <= #1 2'h0;
276 123 mohor
  else if (update_dr_i)
277
    ptr <= #1 2'h0;
278 95 mohor
  else if (read_cycle & crc_cnt_31) // first latch
279 93 mohor
    ptr <= #1 ptr + 1'b1;
280 95 mohor
  else if (read_cycle & byte & (~byte_q))
281 93 mohor
    ptr <= ptr + 1'd1;
282
end
283
 
284
 
285 97 mohor
// Shift register for shifting in and out the data
286 121 mohor
always @ (posedge tck_i or posedge rst_i)
287 93 mohor
begin
288 121 mohor
  if (rst_i)
289 90 mohor
    begin
290 121 mohor
      dr <= #1 51'h0;
291
      latch_data <= #1 1'b0;
292
    end
293
  else if (read_cycle & crc_cnt_31)
294
    begin
295 93 mohor
      dr[31:0] <= #1 input_data[31:0];
296 97 mohor
      latch_data <= #1 1'b1;
297 93 mohor
    end
298
  else if (read_cycle & crc_cnt_end)
299
    begin
300 95 mohor
      case (rw_type)  // synthesis parallel_case full_case
301 90 mohor
        `WB_READ8 : begin
302
                      if(byte & (~byte_q))
303 92 mohor
                        begin
304 93 mohor
                          case (ptr)    // synthesis parallel_case
305
                            2'b00 : dr[31:24] <= #1 input_data[31:24];
306
                            2'b01 : dr[31:24] <= #1 input_data[23:16];
307
                            2'b10 : dr[31:24] <= #1 input_data[15:8];
308
                            2'b11 : dr[31:24] <= #1 input_data[7:0];
309
                          endcase
310 97 mohor
                          latch_data <= #1 1'b1;
311 92 mohor
                        end
312 90 mohor
                      else
313 92 mohor
                        begin
314 93 mohor
                          dr[31:24] <= #1 {dr[30:24], 1'b0};
315 97 mohor
                          latch_data <= #1 1'b0;
316 92 mohor
                        end
317 90 mohor
                    end
318
        `WB_READ16: begin
319
                      if(half & (~half_q))
320 92 mohor
                        begin
321 93 mohor
                          if (ptr[1])
322 97 mohor
                            dr[31:16] <= #1 input_data[15:0];
323
                          else
324 93 mohor
                            dr[31:16] <= #1 input_data[31:16];
325 97 mohor
                          latch_data <= #1 1'b1;
326 92 mohor
                        end
327 90 mohor
                      else
328 92 mohor
                        begin
329 93 mohor
                          dr[31:16] <= #1 {dr[30:16], 1'b0};
330 97 mohor
                          latch_data <= #1 1'b0;
331 92 mohor
                        end
332 90 mohor
                    end
333
        `WB_READ32: begin
334
                      if(long & (~long_q))
335 92 mohor
                        begin
336 93 mohor
                          dr[31:0] <= #1 input_data[31:0];
337 97 mohor
                          latch_data <= #1 1'b1;
338 92 mohor
                        end
339 90 mohor
                      else
340 92 mohor
                        begin
341 93 mohor
                          dr[31:0] <= #1 {dr[30:0], 1'b0};
342 97 mohor
                          latch_data <= #1 1'b0;
343 92 mohor
                        end
344 90 mohor
                    end
345
      endcase
346
    end
347 94 mohor
  else if (enable & ((~addr_len_cnt_end) | (~cmd_cnt_end) | ((~data_cnt_end) & write_cycle)))
348 92 mohor
    begin
349 99 mohor
      dr <= #1 {dr[49:0], tdi_i};
350
      latch_data <= #1 1'b0;
351 92 mohor
    end
352 82 mohor
end
353
 
354
 
355 90 mohor
assign cmd_cnt_en = enable & (~cmd_cnt_end);
356 88 mohor
 
357 97 mohor
 
358
// Command counter
359 95 mohor
always @ (posedge tck_i or posedge rst_i)
360 82 mohor
begin
361 95 mohor
  if (rst_i)
362 138 igorm
    cmd_cnt <= #1 {`DBG_WB_CMD_CNT_WIDTH{1'b0}};
363 82 mohor
  else if (update_dr_i)
364 138 igorm
    cmd_cnt <= #1 {`DBG_WB_CMD_CNT_WIDTH{1'b0}};
365 90 mohor
  else if (cmd_cnt_en)
366 87 mohor
    cmd_cnt <= #1 cmd_cnt + 1'b1;
367 82 mohor
end
368
 
369
 
370 90 mohor
assign addr_len_cnt_en = enable & cmd_cnt_end & (~addr_len_cnt_end);
371
 
372 97 mohor
 
373
// Address/length counter
374 95 mohor
always @ (posedge tck_i or posedge rst_i)
375 87 mohor
begin
376 95 mohor
  if (rst_i)
377 108 simons
    addr_len_cnt <= #1 6'h0;
378 88 mohor
  else if (update_dr_i)
379 108 simons
    addr_len_cnt <= #1 6'h0;
380 90 mohor
  else if (addr_len_cnt_en)
381 88 mohor
    addr_len_cnt <= #1 addr_len_cnt + 1'b1;
382
end
383
 
384
 
385 95 mohor
assign data_cnt_en = enable & (~data_cnt_end) & (cmd_cnt_end & write_cycle | crc_cnt_end & read_cycle);
386 90 mohor
 
387 97 mohor
 
388
// Data counter
389 95 mohor
always @ (posedge tck_i or posedge rst_i)
390 88 mohor
begin
391 95 mohor
  if (rst_i)
392 108 simons
    data_cnt <= #1 19'h0;
393 87 mohor
  else if (update_dr_i)
394 108 simons
    data_cnt <= #1 19'h0;
395 90 mohor
  else if (data_cnt_en)
396 87 mohor
    data_cnt <= #1 data_cnt + 1'b1;
397
end
398 82 mohor
 
399 87 mohor
 
400 88 mohor
 
401 93 mohor
assign byte = data_cnt[2:0] == 3'd7;
402
assign half = data_cnt[3:0] == 4'd15;
403
assign long = data_cnt[4:0] == 5'd31;
404 88 mohor
 
405
 
406 123 mohor
always @ (posedge tck_i or posedge rst_i)
407 88 mohor
begin
408 123 mohor
  if (rst_i)
409
    begin
410
      byte_q <= #1  1'b0;
411
      half_q <= #1  1'b0;
412
      long_q <= #1  1'b0;
413
      byte_q2 <= #1 1'b0;
414
      half_q2 <= #1 1'b0;
415
      long_q2 <= #1 1'b0;
416
    end
417
  else
418
    begin
419
      byte_q <= #1 byte;
420
      half_q <= #1 half;
421
      long_q <= #1 long;
422
      byte_q2 <= #1 byte_q;
423
      half_q2 <= #1 half_q;
424
      long_q2 <= #1 long_q;
425
    end
426 88 mohor
end
427
 
428
 
429 108 simons
assign dr_read = (dr[2:0] == `WB_READ8) || (dr[2:0] == `WB_READ16) || (dr[2:0] == `WB_READ32);
430
assign dr_write = (dr[2:0] == `WB_WRITE8) || (dr[2:0] == `WB_WRITE16) || (dr[2:0] == `WB_WRITE32);
431 89 mohor
assign dr_go = dr[2:0] == `WB_GO;
432 88 mohor
 
433
 
434 97 mohor
// Latching instruction
435 123 mohor
always @ (posedge tck_i or posedge rst_i)
436 88 mohor
begin
437 123 mohor
  if (rst_i)
438 91 mohor
    begin
439 99 mohor
      dr_cmd_latched <= #1 3'h0;
440 91 mohor
      dr_read_latched  <= #1 1'b0;
441
      dr_write_latched  <= #1 1'b0;
442
      dr_go_latched  <= #1 1'b0;
443
    end
444 123 mohor
  else if (update_dr_i)
445
    begin
446
      dr_cmd_latched <= #1 3'h0;
447
      dr_read_latched  <= #1 1'b0;
448
      dr_write_latched  <= #1 1'b0;
449
      dr_go_latched  <= #1 1'b0;
450
    end
451 88 mohor
  else if (cmd_cnt_end & (~cmd_cnt_end_q))
452 91 mohor
    begin
453 99 mohor
      dr_cmd_latched <= #1 dr[2:0];
454 91 mohor
      dr_read_latched <= #1 dr_read;
455
      dr_write_latched <= #1 dr_write;
456
      dr_go_latched <= #1 dr_go;
457
    end
458 88 mohor
end
459
 
460
 
461 97 mohor
// Upper limit. Address/length counter counts until this value is reached
462 123 mohor
always @ (posedge tck_i or posedge rst_i)
463 88 mohor
begin
464 123 mohor
  if (rst_i)
465
    addr_len_cnt_limit <= #1 6'd0;
466 138 igorm
  else if (cmd_cnt == `DBG_WB_CMD_CNT_WIDTH'h2)
467 88 mohor
    begin
468 95 mohor
      if ((~dr[0])  & (~tdi_i))                                   // (current command is WB_STATUS or WB_GO)
469 99 mohor
        addr_len_cnt_limit <= #1 6'd0;
470 90 mohor
      else                                                        // (current command is WB_WRITEx or WB_READx)
471 99 mohor
        addr_len_cnt_limit <= #1 6'd48;
472 88 mohor
    end
473
end
474
 
475
 
476 94 mohor
assign go_prelim = (cmd_cnt == 2'h2) & dr[1] & (~dr[0]) & (~tdi_i);
477
 
478 88 mohor
 
479 97 mohor
// Upper limit. Data counter counts until this value is reached.
480 123 mohor
always @ (posedge tck_i or posedge rst_i)
481 94 mohor
begin
482 123 mohor
  if (rst_i)
483
    data_cnt_limit <= #1 19'h0;
484
  else if (update_dr_i)
485 99 mohor
    data_cnt_limit <= #1 {len, 3'b000};
486 94 mohor
end
487 88 mohor
 
488 90 mohor
 
489 94 mohor
assign crc_cnt_en = enable & (~crc_cnt_end) & (cmd_cnt_end & addr_len_cnt_end  & (~write_cycle) | (data_cnt_end & write_cycle));
490
 
491 97 mohor
 
492 82 mohor
// crc counter
493 95 mohor
always @ (posedge tck_i or posedge rst_i)
494 82 mohor
begin
495 95 mohor
  if (rst_i)
496 108 simons
    crc_cnt <= #1 6'h0;
497 90 mohor
  else if(crc_cnt_en)
498 82 mohor
    crc_cnt <= #1 crc_cnt + 1'b1;
499
  else if (update_dr_i)
500 108 simons
    crc_cnt <= #1 6'h0;
501 82 mohor
end
502
 
503 138 igorm
assign cmd_cnt_end  = cmd_cnt  == `DBG_WB_CMD_LEN;
504 88 mohor
assign addr_len_cnt_end = addr_len_cnt == addr_len_cnt_limit;
505 87 mohor
assign crc_cnt_end  = crc_cnt  == 6'd32;
506 93 mohor
assign crc_cnt_31 = crc_cnt  == 6'd31;
507 89 mohor
assign data_cnt_end = (data_cnt == data_cnt_limit);
508 82 mohor
 
509 123 mohor
always @ (posedge tck_i or posedge rst_i)
510 82 mohor
begin
511 123 mohor
  if (rst_i)
512
    begin
513
      crc_cnt_end_q  <= #1 1'b0;
514
      cmd_cnt_end_q  <= #1 1'b0;
515
      data_cnt_end_q <= #1 1'b0;
516
    end
517
  else
518
    begin
519
      crc_cnt_end_q  <= #1 crc_cnt_end;
520
      cmd_cnt_end_q  <= #1 cmd_cnt_end;
521
      data_cnt_end_q <= #1 data_cnt_end;
522
    end
523 82 mohor
end
524
 
525 90 mohor
 
526 97 mohor
// Status counter is made of 4 serialy connected registers
527 95 mohor
always @ (posedge tck_i or posedge rst_i)
528 82 mohor
begin
529 95 mohor
  if (rst_i)
530 90 mohor
    status_cnt1 <= #1 1'b0;
531 82 mohor
  else if (update_dr_i)
532 90 mohor
    status_cnt1 <= #1 1'b0;
533 94 mohor
  else if (data_cnt_end & read_cycle |
534 95 mohor
           crc_cnt_end & (~read_cycle)
535 90 mohor
          )
536
    status_cnt1 <= #1 1'b1;
537 82 mohor
end
538
 
539 90 mohor
 
540 95 mohor
always @ (posedge tck_i or posedge rst_i)
541 90 mohor
begin
542 95 mohor
  if (rst_i)
543 90 mohor
    begin
544
      status_cnt2 <= #1 1'b0;
545
      status_cnt3 <= #1 1'b0;
546
      status_cnt4 <= #1 1'b0;
547
    end
548
  else if (update_dr_i)
549
    begin
550
      status_cnt2 <= #1 1'b0;
551
      status_cnt3 <= #1 1'b0;
552
      status_cnt4 <= #1 1'b0;
553
    end
554
  else
555
    begin
556
      status_cnt2 <= #1 status_cnt1;
557
      status_cnt3 <= #1 status_cnt2;
558
      status_cnt4 <= #1 status_cnt3;
559
    end
560
end
561
 
562
 
563
assign status_cnt_end = status_cnt4;
564 82 mohor
 
565 97 mohor
 
566
// Status register
567 95 mohor
always @ (posedge tck_i or posedge rst_i)
568 82 mohor
begin
569 95 mohor
  if (rst_i)
570 92 mohor
    begin
571 138 igorm
    status <= #1 {`DBG_WB_STATUS_LEN{1'b0}};
572 92 mohor
    end
573
  else if(crc_cnt_end & (~crc_cnt_end_q) & (~read_cycle))
574
    begin
575 97 mohor
    status <= #1 {crc_match_i, wb_error_tck, wb_overrun_tck, busy_tck};
576 92 mohor
    end
577
  else if (data_cnt_end & (~data_cnt_end_q) & read_cycle)
578
    begin
579 97 mohor
    status <= #1 {crc_match_reg, wb_error_tck, underrun_tck, busy_tck};
580 92 mohor
    end
581 82 mohor
  else if (shift_dr_i & (~status_cnt_end))
582 92 mohor
    begin
583 138 igorm
    status <= #1 {status[0], status[`DBG_WB_STATUS_LEN -1:1]};
584 92 mohor
    end
585 82 mohor
end
586 88 mohor
// Following status is shifted out:
587 82 mohor
// 1. bit:          1 if crc is OK, else 0
588 86 mohor
// 2. bit:          1 while WB access is in progress (busy_tck), else 0
589 88 mohor
// 3. bit:          1 if overrun occured during write (data couldn't be written fast enough)
590 97 mohor
//                    or underrun occured during read (data couldn't be read fast enough)
591 82 mohor
// 4. bit:          1 if WB error occured, else 0
592
 
593
 
594 97 mohor
// TDO multiplexer
595 102 mohor
always @ (pause_dr_i or busy_tck or crc_cnt_end or crc_cnt_end_q or crc_match_i or
596
          data_cnt_end or data_cnt_end_q or read_cycle or crc_match_reg or status or dr)
597 82 mohor
begin
598
  if (pause_dr_i)
599 87 mohor
    begin
600 82 mohor
    tdo_o = busy_tck;
601 87 mohor
    end
602 95 mohor
  else if (crc_cnt_end & (~crc_cnt_end_q) & (~(read_cycle)))
603 87 mohor
    begin
604
      tdo_o = crc_match_i;
605
    end
606 93 mohor
  else if (read_cycle & crc_cnt_end & (~data_cnt_end))
607
    begin
608
    tdo_o = dr[31];
609
    end
610 94 mohor
  else if (read_cycle & data_cnt_end & (~data_cnt_end_q))     // cmd is already updated
611 87 mohor
    begin
612 90 mohor
      tdo_o = crc_match_reg;
613
    end
614 92 mohor
  else if (crc_cnt_end & data_cnt_end)  // cmd is already updated
615 90 mohor
    begin
616 87 mohor
      tdo_o = status[0];
617
    end
618 82 mohor
  else
619 87 mohor
    begin
620
      tdo_o = 1'b0;
621
    end
622 82 mohor
end
623
 
624
 
625
 
626 123 mohor
always @ (posedge tck_i or posedge rst_i)
627 82 mohor
begin
628 123 mohor
  if (rst_i)
629
    crc_match_reg <= #1 1'b0;
630
  else if(crc_cnt_end & (~crc_cnt_end_q))
631 90 mohor
    crc_match_reg <= #1 crc_match_i;
632
end
633
 
634
 
635 97 mohor
// Latching instruction
636 95 mohor
always @ (posedge tck_i or posedge rst_i)
637 91 mohor
begin
638 95 mohor
  if (rst_i)
639 91 mohor
    begin
640 108 simons
      cmd <= #1 3'h0;
641
      cmd_old <= #1 3'h0;
642 91 mohor
      cmd_read <= #1 1'b0;
643
      cmd_write <= #1 1'b0;
644
      cmd_go <= #1 1'b0;
645
    end
646
  else if(crc_cnt_end & (~crc_cnt_end_q) & crc_match_i)
647
    begin
648
      cmd <= #1 dr_cmd_latched;
649
      cmd_old <= #1 cmd;
650
      cmd_read <= #1 dr_read_latched;
651
      cmd_write <= #1 dr_write_latched;
652
      cmd_go <= #1 dr_go_latched;
653
    end
654
end
655 90 mohor
 
656 91 mohor
 
657 97 mohor
// Latching address
658 123 mohor
always @ (posedge tck_i or posedge rst_i)
659 90 mohor
begin
660 123 mohor
  if (rst_i)
661 82 mohor
    begin
662 123 mohor
      adr      <= #1 32'h0;
663
      set_addr <= #1 1'b0;
664
    end
665
  else if(crc_cnt_end & (~crc_cnt_end_q) & crc_match_i)
666
    begin
667 90 mohor
      if (dr_write_latched | dr_read_latched)
668 88 mohor
        begin
669
          adr <= #1 dr[47:16];
670
          set_addr <= #1 1'b1;
671
        end
672 82 mohor
    end
673
  else
674 88 mohor
    set_addr <= #1 1'b0;
675
end
676
 
677 93 mohor
 
678 97 mohor
// Length counter
679 123 mohor
always @ (posedge tck_i or posedge rst_i)
680 93 mohor
begin
681 123 mohor
  if (rst_i)
682
    len <= #1 16'h0;
683
  else if(crc_cnt_end & (~crc_cnt_end_q) & crc_match_i & (dr_write_latched | dr_read_latched))
684 93 mohor
    len <= #1 dr[15:0];
685 95 mohor
  else if (start_rd_tck)
686 93 mohor
    begin
687 95 mohor
      case (rw_type)  // synthesis parallel_case full_case
688 93 mohor
        `WB_READ8 : len <= #1 len - 1'd1;
689
        `WB_READ16: len <= #1 len - 2'd2;
690
        `WB_READ32: len <= #1 len - 3'd4;
691
      endcase
692
    end
693
end
694
 
695
 
696
assign len_eq_0 = len == 16'h0;
697
 
698
 
699 89 mohor
// Start wishbone read cycle
700 123 mohor
always @ (posedge tck_i or posedge rst_i)
701 88 mohor
begin
702 123 mohor
  if (rst_i)
703
    start_rd_tck <= #1 1'b0;
704
  else if (read_cycle & (~dr_go_latched) & (~len_eq_0))              // First read after cmd is entered
705 89 mohor
    start_rd_tck <= #1 1'b1;
706 97 mohor
  else if ((~start_rd_tck) & read_cycle & (~len_eq_0) & (~fifo_full) & (~rd_tck_started))
707 93 mohor
    start_rd_tck <= #1 1'b1;
708 89 mohor
  else
709
    start_rd_tck <= #1 1'b0;
710
end
711
 
712
 
713 123 mohor
always @ (posedge tck_i or posedge rst_i)
714 92 mohor
begin
715 123 mohor
  if (rst_i)
716 97 mohor
    rd_tck_started <= #1 1'b0;
717 123 mohor
  else if (update_dr_i)
718
    rd_tck_started <= #1 1'b0;
719 97 mohor
  else if (start_rd_tck)
720
    rd_tck_started <= #1 1'b1;
721
  else if (wb_end_tck & (~wb_end_tck_q))
722
    rd_tck_started <= #1 1'b0;
723
end
724
 
725
 
726 123 mohor
always @ (posedge tck_i or posedge rst_i)
727 97 mohor
begin
728 123 mohor
  if (rst_i)
729 92 mohor
    read_cycle <= #1 1'b0;
730 123 mohor
  else if (update_dr_i)
731
    read_cycle <= #1 1'b0;
732 94 mohor
  else if (cmd_read & go_prelim)
733 92 mohor
    read_cycle <= #1 1'b1;
734
end
735 89 mohor
 
736 92 mohor
 
737 121 mohor
always @ (posedge tck_i or posedge rst_i)
738 92 mohor
begin
739 121 mohor
  if (rst_i)
740
    rw_type <= #1 3'h0;
741
  else if ((cmd_read | cmd_write) & go_prelim)
742 95 mohor
    rw_type <= #1 cmd;
743 92 mohor
end
744
 
745
 
746 121 mohor
always @ (posedge tck_i or posedge rst_i)
747 94 mohor
begin
748 121 mohor
  if (rst_i)
749 94 mohor
    write_cycle <= #1 1'b0;
750 121 mohor
  else if (update_dr_i)
751
    write_cycle <= #1 1'b0;
752 94 mohor
  else if (cmd_write & go_prelim)
753
    write_cycle <= #1 1'b1;
754
end
755 92 mohor
 
756
 
757 89 mohor
// Start wishbone write cycle
758 121 mohor
always @ (posedge tck_i or posedge rst_i)
759 89 mohor
begin
760 121 mohor
  if (rst_i)
761 88 mohor
    begin
762 121 mohor
      start_wr_tck <= #1 1'b0;
763
      wb_dat_o <= #1 32'h0;
764
    end
765
  else if (write_cycle)
766
    begin
767 95 mohor
      case (rw_type)  // synthesis parallel_case full_case
768 88 mohor
        `WB_WRITE8  : begin
769 94 mohor
                        if (byte_q & (~byte_q2))
770 88 mohor
                          begin
771 89 mohor
                            start_wr_tck <= #1 1'b1;
772 88 mohor
                            wb_dat_o <= #1 {4{dr[7:0]}};
773
                          end
774
                        else
775
                          begin
776 89 mohor
                            start_wr_tck <= #1 1'b0;
777 88 mohor
                          end
778
                      end
779
        `WB_WRITE16 : begin
780 94 mohor
                        if (half_q & (~half_q2))
781 88 mohor
                          begin
782 89 mohor
                            start_wr_tck <= #1 1'b1;
783 88 mohor
                            wb_dat_o <= #1 {2{dr[15:0]}};
784
                          end
785
                        else
786
                          begin
787 89 mohor
                            start_wr_tck <= #1 1'b0;
788 88 mohor
                          end
789
                      end
790
        `WB_WRITE32 : begin
791 94 mohor
                        if (long_q & (~long_q2))
792 88 mohor
                          begin
793 89 mohor
                            start_wr_tck <= #1 1'b1;
794 88 mohor
                            wb_dat_o <= #1 dr[31:0];
795
                          end
796
                        else
797
                          begin
798 89 mohor
                            start_wr_tck <= #1 1'b0;
799 88 mohor
                          end
800
                      end
801
      endcase
802
    end
803
  else
804 89 mohor
    start_wr_tck <= #1 1'b0;
805 82 mohor
end
806
 
807
 
808 123 mohor
always @ (posedge wb_clk_i or posedge rst_i)
809 82 mohor
begin
810 123 mohor
  if (rst_i)
811
    begin
812
      start_rd_sync1  <= #1 1'b0;
813
      start_wb_rd     <= #1 1'b0;
814
      start_wb_rd_q   <= #1 1'b0;
815
 
816
      start_wr_sync1  <= #1 1'b0;
817
      start_wb_wr     <= #1 1'b0;
818
      start_wb_wr_q   <= #1 1'b0;
819
 
820
      set_addr_sync   <= #1 1'b0;
821
      set_addr_wb     <= #1 1'b0;
822
      set_addr_wb_q   <= #1 1'b0;
823
    end
824
  else
825
    begin
826
      start_rd_sync1  <= #1 start_rd_tck;
827
      start_wb_rd     <= #1 start_rd_sync1;
828
      start_wb_rd_q   <= #1 start_wb_rd;
829
 
830
      start_wr_sync1  <= #1 start_wr_tck;
831
      start_wb_wr     <= #1 start_wr_sync1;
832
      start_wb_wr_q   <= #1 start_wb_wr;
833
 
834
      set_addr_sync   <= #1 set_addr;
835
      set_addr_wb     <= #1 set_addr_sync;
836
      set_addr_wb_q   <= #1 set_addr_wb;
837
    end
838 82 mohor
end
839
 
840
 
841 97 mohor
// wb_cyc_o
842 95 mohor
always @ (posedge wb_clk_i or posedge rst_i)
843 82 mohor
begin
844 95 mohor
  if (rst_i)
845 82 mohor
    wb_cyc_o <= #1 1'b0;
846 89 mohor
  else if ((start_wb_wr & (~start_wb_wr_q)) | (start_wb_rd & (~start_wb_rd_q)))
847 82 mohor
    wb_cyc_o <= #1 1'b1;
848 88 mohor
  else if (wb_ack_i | wb_err_i)
849 82 mohor
    wb_cyc_o <= #1 1'b0;
850
end
851
 
852
 
853 97 mohor
// wb_adr_o logic
854 121 mohor
always @ (posedge wb_clk_i or posedge rst_i)
855 82 mohor
begin
856 121 mohor
  if (rst_i)
857
    wb_adr_o <= #1 32'h0;
858
  else if (set_addr_wb & (~set_addr_wb_q)) // Setting starting address
859 82 mohor
    wb_adr_o <= #1 adr;
860
  else if (wb_ack_i)
861
    begin
862 95 mohor
      if ((rw_type == `WB_WRITE8) | (rw_type == `WB_READ8))
863 82 mohor
        wb_adr_o <= #1 wb_adr_o + 1'd1;
864 95 mohor
      else if ((rw_type == `WB_WRITE16) | (rw_type == `WB_READ16))
865 82 mohor
        wb_adr_o <= #1 wb_adr_o + 2'd2;
866
      else
867
        wb_adr_o <= #1 wb_adr_o + 3'd4;
868
    end
869
end
870
 
871
 
872 89 mohor
 
873 88 mohor
//    adr   byte  |  short  |  long
874
//     0    1000     1100      1111
875
//     1    0100     err       err
876
//     2    0010     0011      err
877
//     3    0001     err       err
878 97 mohor
// wb_sel_o logic
879 95 mohor
always @ (posedge wb_clk_i or posedge rst_i)
880 82 mohor
begin
881 95 mohor
  if (rst_i)
882 91 mohor
    wb_sel_o[3:0] <= #1 4'h0;
883 95 mohor
  else
884 88 mohor
    begin
885 95 mohor
      wb_sel_o[0] <= #1 (rw_type[1:0] == 2'b11) & (wb_adr_o[1:0] == 2'b00) | (rw_type[1:0] == 2'b01) & (wb_adr_o[1:0] == 2'b11) |
886
                        (rw_type[1:0] == 2'b10) & (wb_adr_o[1:0] == 2'b10);
887
      wb_sel_o[1] <= #1 (rw_type[1:0] == 2'b11) & (wb_adr_o[1:0] == 2'b00) | (rw_type[1] ^ rw_type[0]) & (wb_adr_o[1:0] == 2'b10);
888
      wb_sel_o[2] <= #1 (rw_type[1]) & (wb_adr_o[1:0] == 2'b00) | (rw_type[1:0] == 2'b01) & (wb_adr_o[1:0] == 2'b01);
889 88 mohor
      wb_sel_o[3] <= #1 (wb_adr_o[1:0] == 2'b00);
890
    end
891 82 mohor
end
892
 
893
 
894 95 mohor
assign wb_we_o = write_cycle;
895 82 mohor
assign wb_cab_o = 1'b0;
896
assign wb_stb_o = wb_cyc_o;
897
assign wb_cti_o = 3'h0;     // always performing single access
898
assign wb_bte_o = 2'h0;     // always performing single access
899
 
900
 
901 97 mohor
// Logic for detecting end of transaction
902 95 mohor
always @ (posedge wb_clk_i or posedge rst_i)
903 82 mohor
begin
904 95 mohor
  if (rst_i)
905 86 mohor
    wb_end <= #1 1'b0;
906 88 mohor
  else if (wb_ack_i | wb_err_i)
907 86 mohor
    wb_end <= #1 1'b1;
908
  else if (wb_end_rst)
909
    wb_end <= #1 1'b0;
910 82 mohor
end
911
 
912
 
913 95 mohor
always @ (posedge tck_i or posedge rst_i)
914 82 mohor
begin
915 95 mohor
  if (rst_i)
916 82 mohor
    begin
917 86 mohor
      wb_end_sync <= #1 1'b0;
918 93 mohor
      wb_end_tck  <= #1 1'b0;
919
      wb_end_tck_q<= #1 1'b0;
920 82 mohor
    end
921
  else
922
    begin
923 86 mohor
      wb_end_sync <= #1 wb_end;
924
      wb_end_tck  <= #1 wb_end_sync;
925 93 mohor
      wb_end_tck_q<= #1 wb_end_tck;
926 82 mohor
    end
927
end
928
 
929
 
930 95 mohor
always @ (posedge wb_clk_i or posedge rst_i)
931 82 mohor
begin
932 95 mohor
  if (rst_i)
933 82 mohor
    busy_wb <= #1 1'b0;
934 86 mohor
  else if (wb_end_rst)
935 82 mohor
    busy_wb <= #1 1'b0;
936
  else if (wb_cyc_o)
937
    busy_wb <= #1 1'b1;
938
end
939
 
940
 
941 95 mohor
always @ (posedge tck_i or posedge rst_i)
942 82 mohor
begin
943 95 mohor
  if (rst_i)
944 82 mohor
    begin
945
      busy_sync <= #1 1'b0;
946
      busy_tck <= #1 1'b0;
947
    end
948
  else
949
    begin
950
      busy_sync <= #1 busy_wb;
951
      busy_tck <= #1 busy_sync;
952
    end
953
end
954
 
955
 
956 123 mohor
always @ (posedge wb_clk_i or posedge rst_i)
957 82 mohor
begin
958 123 mohor
  if (rst_i)
959
    begin
960
      wb_end_rst_sync <= #1 1'b0;
961
      wb_end_rst      <= #1 1'b0;
962
    end
963
  else
964
    begin
965
      wb_end_rst_sync <= #1 wb_end_tck;
966
      wb_end_rst  <= #1 wb_end_rst_sync;
967
    end
968 82 mohor
end
969
 
970
 
971 97 mohor
// Detecting WB error
972 95 mohor
always @ (posedge wb_clk_i or posedge rst_i)
973 82 mohor
begin
974 95 mohor
  if (rst_i)
975 82 mohor
    wb_error <= #1 1'b0;
976
  else if(wb_err_i)
977
    wb_error <= #1 1'b1;
978 88 mohor
  else if(wb_ack_i & status_reset_en) // error remains active until STATUS read is performed
979 82 mohor
    wb_error <= #1 1'b0;
980
end
981 97 mohor
 
982
 
983 123 mohor
always @ (posedge tck_i or posedge rst_i)
984 82 mohor
begin
985 123 mohor
  if (rst_i)
986
    begin
987
      wb_error_sync <= #1 1'b0;
988
      wb_error_tck  <= #1 1'b0;
989
    end
990
  else
991
    begin
992
      wb_error_sync <= #1 wb_error;
993
      wb_error_tck  <= #1 wb_error_sync;
994
    end
995 82 mohor
end
996
 
997
 
998 97 mohor
// Detecting overrun when write operation.
999 95 mohor
always @ (posedge wb_clk_i or posedge rst_i)
1000 82 mohor
begin
1001 95 mohor
  if (rst_i)
1002 88 mohor
    wb_overrun <= #1 1'b0;
1003 89 mohor
  else if(start_wb_wr & (~start_wb_wr_q) & wb_cyc_o)
1004 88 mohor
    wb_overrun <= #1 1'b1;
1005
  else if((wb_ack_i | wb_err_i) & status_reset_en) // error remains active until STATUS read is performed
1006
    wb_overrun <= #1 1'b0;
1007 82 mohor
end
1008
 
1009 123 mohor
always @ (posedge tck_i or posedge rst_i)
1010 82 mohor
begin
1011 123 mohor
  if (rst_i)
1012
    begin
1013
      wb_overrun_sync <= #1 1'b0;
1014
      wb_overrun_tck  <= #1 1'b0;
1015
    end
1016
  else
1017
    begin
1018
      wb_overrun_sync <= #1 wb_overrun;
1019
      wb_overrun_tck  <= #1 wb_overrun_sync;
1020
    end
1021 82 mohor
end
1022
 
1023
 
1024 97 mohor
// Detecting underrun when read operation
1025
always @ (posedge tck_i or posedge rst_i)
1026
begin
1027
  if (rst_i)
1028
    underrun_tck <= #1 1'b0;
1029
  else if(latch_data & fifo_empty & (~data_cnt_end))
1030
    underrun_tck <= #1 1'b1;
1031
  else if(read_cycle & status_reset_en) // error remains active until STATUS read is performed
1032
    underrun_tck <= #1 1'b0;
1033
end
1034
 
1035 87 mohor
 
1036 88 mohor
 
1037
// wb_error is locked until WB_STATUS is performed
1038 95 mohor
always @ (posedge tck_i or posedge rst_i)
1039 87 mohor
begin
1040 95 mohor
  if (rst_i)
1041 87 mohor
    status_reset_en <= 1'b0;
1042
  else if((cmd_old == `WB_STATUS) & (cmd !== `WB_STATUS))
1043
    status_reset_en <= #1 1'b1;
1044
  else
1045
    status_reset_en <= #1 1'b0;
1046
end
1047 88 mohor
 
1048 95 mohor
 
1049 123 mohor
always @ (posedge wb_clk_i or posedge rst_i)
1050 92 mohor
begin
1051 123 mohor
  if (rst_i)
1052
    begin
1053
      wishbone_ce_sync <= #1 1'b0;
1054
      wishbone_ce_rst  <= #1 1'b0;
1055
    end
1056
  else
1057
    begin
1058
      wishbone_ce_sync <= #1  wishbone_ce_i;
1059
      wishbone_ce_rst  <= #1 ~wishbone_ce_sync;
1060
    end
1061 92 mohor
end
1062 88 mohor
 
1063
 
1064 97 mohor
// Logic for latching data that is read from wishbone
1065 123 mohor
always @ (posedge wb_clk_i or posedge rst_i)
1066 92 mohor
begin
1067 123 mohor
  if (rst_i)
1068
    mem_ptr <= #1 3'h0;
1069
  else if(wishbone_ce_rst)
1070 108 simons
    mem_ptr <= #1 3'h0;
1071 92 mohor
  else if (wb_ack_i)
1072
    begin
1073 95 mohor
      if (rw_type == `WB_READ8)
1074 92 mohor
        mem_ptr <= #1 mem_ptr + 1'd1;
1075 95 mohor
      else if (rw_type == `WB_READ16)
1076 92 mohor
        mem_ptr <= #1 mem_ptr + 2'd2;
1077
    end
1078
end
1079 88 mohor
 
1080
 
1081 97 mohor
// Logic for latching data that is read from wishbone
1082 92 mohor
always @ (posedge wb_clk_i)
1083
begin
1084
  if (wb_ack_i)
1085
    begin
1086
      case (wb_sel_o)    // synthesis parallel_case full_case 
1087
        4'b1000  :  mem[mem_ptr[1:0]] <= #1 wb_dat_i[31:24];            // byte 
1088
        4'b0100  :  mem[mem_ptr[1:0]] <= #1 wb_dat_i[23:16];            // byte
1089
        4'b0010  :  mem[mem_ptr[1:0]] <= #1 wb_dat_i[15:08];            // byte
1090 93 mohor
        4'b0001  :  mem[mem_ptr[1:0]] <= #1 wb_dat_i[07:00];            // byte
1091 88 mohor
 
1092 92 mohor
        4'b1100  :                                                      // half
1093
                    begin
1094
                      mem[mem_ptr[1:0]]      <= #1 wb_dat_i[31:24];
1095
                      mem[mem_ptr[1:0]+1'b1] <= #1 wb_dat_i[23:16];
1096
                    end
1097
        4'b0011  :                                                      // half
1098
                    begin
1099
                      mem[mem_ptr[1:0]]      <= #1 wb_dat_i[15:08];
1100 93 mohor
                      mem[mem_ptr[1:0]+1'b1] <= #1 wb_dat_i[07:00];
1101 92 mohor
                    end
1102
        4'b1111  :                                                      // long
1103
                    begin
1104
                      mem[0] <= #1 wb_dat_i[31:24];
1105
                      mem[1] <= #1 wb_dat_i[23:16];
1106
                      mem[2] <= #1 wb_dat_i[15:08];
1107 93 mohor
                      mem[3] <= #1 wb_dat_i[07:00];
1108 92 mohor
                    end
1109
      endcase
1110
    end
1111
end
1112 88 mohor
 
1113 97 mohor
 
1114 92 mohor
assign input_data = {mem[0], mem[1], mem[2], mem[3]};
1115 88 mohor
 
1116 92 mohor
 
1117 97 mohor
// Fifo counter and empty/full detection
1118 123 mohor
always @ (posedge tck_i or posedge rst_i)
1119 97 mohor
begin
1120 123 mohor
  if (rst_i)
1121 108 simons
    fifo_cnt <= #1 3'h0;
1122 123 mohor
  else if (update_dr_i)
1123
    fifo_cnt <= #1 3'h0;
1124 97 mohor
  else if (wb_end_tck & (~wb_end_tck_q) & (~latch_data))  // incrementing
1125
    begin
1126
      case (rw_type)  // synthesis parallel_case full_case
1127
        `WB_READ8 : fifo_cnt <= #1 fifo_cnt + 1'd1;
1128
        `WB_READ16: fifo_cnt <= #1 fifo_cnt + 2'd2;
1129
        `WB_READ32: fifo_cnt <= #1 fifo_cnt + 3'd4;
1130
      endcase
1131
    end
1132
  else if (~(wb_end_tck & (~wb_end_tck_q)) & latch_data)  // decrementing
1133
    begin
1134
      case (rw_type)  // synthesis parallel_case full_case
1135
        `WB_READ8 : fifo_cnt <= #1 fifo_cnt - 1'd1;
1136
        `WB_READ16: fifo_cnt <= #1 fifo_cnt - 2'd2;
1137
        `WB_READ32: fifo_cnt <= #1 fifo_cnt - 3'd4;
1138
      endcase
1139
    end
1140
end
1141 92 mohor
 
1142
 
1143 97 mohor
assign fifo_full = fifo_cnt == 3'h4;
1144
assign fifo_empty = fifo_cnt == 3'h0;
1145 92 mohor
 
1146
 
1147
 
1148 97 mohor
 
1149 82 mohor
endmodule
1150
 

powered by: WebSVN 2.1.0

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