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

Subversion Repositories srdydrdy_lib

[/] [srdydrdy_lib/] [trunk/] [rtl/] [verilog/] [utility/] [sd_bpdrop.v] - Blame information for rev 28

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 26 ghutchis
//----------------------------------------------------------------------
2
// Srdy/drdy backpressure drop (control path only)
3
//
4
// Monitors the srdy/drdy signals and looks for backpressure on the
5
// consumer interface which exceeds a certain time (in clocks).  If
6
// the time threshold is exceeded, sinks the packet until the end
7
// of a token frame.
8
//
9
// Naming convention: c = consumer, p = producer, 
10
// n = non-timing closed (combintorial) output
11
//----------------------------------------------------------------------
12
//  Author: Guy Hutchison
13
//
14
// This block is uncopyrighted and released into the public domain.
15
//----------------------------------------------------------------------
16
 
17
// Clocking statement for synchronous blocks.  Default is for
18
// posedge clocking and positive async reset
19
`ifndef SDLIB_CLOCKING
20
 `define SDLIB_CLOCKING posedge clk or posedge reset
21
`endif
22
 
23
// delay unit for nonblocking assigns, default is to #1
24
`ifndef SDLIB_DELAY
25
 `define SDLIB_DELAY #1
26
`endif
27
 
28
module sd_bpdrop
29
  #(parameter cnt_sz = 3)
30
  (
31
   input               clk,
32
   input               reset,
33
 
34 28 ghutchis
   input               g_enable,
35 26 ghutchis
   input [cnt_sz-1:0]  g_max_count,
36 28 ghutchis
   output reg          g_drop,     // token frame was sunk
37 26 ghutchis
 
38
   input               c_srdy,
39
   input               c_fr_start, // start of frame signal
40
   input               c_fr_end,   // end of frame signal
41
   output reg          nc_drdy,
42
 
43
   output reg          np_srdy,
44
   input               p_drdy
45
   );
46
 
47
  localparam s_idle = 2'b00, s_xfer = 2'b01, s_sink = 2'b11;
48
 
49
  reg [1:0]            state, nxt_state;
50
  reg [cnt_sz-1:0]     count, nxt_count;
51
 
52
  always @*
53
    begin
54
      nc_drdy = 0;
55
      np_srdy = 0;
56
      nxt_state = state;
57
      nxt_count = count;
58 28 ghutchis
      g_drop = 0;
59 26 ghutchis
 
60
      case (state)
61
        s_idle :
62
          begin
63 28 ghutchis
            if (!g_enable)
64 26 ghutchis
              begin
65 28 ghutchis
                nc_drdy = p_drdy;
66
                np_srdy = c_srdy;
67
              end
68
            else if (c_srdy & c_fr_start)
69
              begin
70
                np_srdy = 1;
71 26 ghutchis
                if (p_drdy)
72
                  begin
73
                    nc_drdy = 1;
74
                    nxt_state = s_xfer;
75
                  end
76
                else
77
                  begin
78
                    nxt_count = count + 1;
79
                    if (count >= g_max_count)
80
                      begin
81
                        nc_drdy = 1;
82
                        nxt_state = s_sink;
83 28 ghutchis
                        g_drop = 1;
84 26 ghutchis
                      end
85
                  end
86
              end
87
            else
88
              begin
89
                nxt_count = 0;
90
 
91
                // if data other than c_fr_start shows up sink it
92
                if (c_srdy)
93
                  nc_drdy = 1;
94
              end
95
          end // case: s_idle
96
 
97
        s_xfer :
98
          begin
99
            nxt_count = 0;
100 28 ghutchis
            np_srdy = c_srdy;
101
            nc_drdy = p_drdy;
102
            if (c_srdy & p_drdy & c_fr_end)
103
              nxt_state = s_idle;
104
         end // case: s_xfer
105 26 ghutchis
 
106
        s_sink :
107
          begin
108
            nc_drdy = 1;
109
            nxt_count = 0;
110
 
111
            if (c_srdy & c_fr_end)
112
              nxt_state = s_idle;
113
          end
114
 
115
        default : nxt_state = s_idle;
116
      endcase // case (state)
117
    end // always @ *
118
 
119
  always @(`SDLIB_CLOCKING)
120
    begin
121
      if (reset)
122
        begin
123
          state <= `SDLIB_DELAY s_idle;
124
          count <= `SDLIB_DELAY 0;
125
        end
126
      else
127
        begin
128
          state <= `SDLIB_DELAY nxt_state;
129
          count <= `SDLIB_DELAY nxt_count;
130
        end
131
    end // always @ (`SDLIB_CLOCKING)
132
 
133
 
134
endmodule // sd_rrmux

powered by: WebSVN 2.1.0

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