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

Subversion Repositories srdydrdy_lib

[/] [srdydrdy_lib/] [trunk/] [examples/] [bridge/] [rtl/] [pkt_parse.v] - Blame information for rev 8

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

Line No. Rev Author Line
1 8 ghutchis
// packet parser
2
//
3
// Takes input packet on rxg interface and copies packet to pdo
4
// interface, without changing packet data.  If packet is too
5
// short to be parsed, converts packet to an error code.
6
//
7
// If packet parses correctly and is not an error packet, sends
8
// a parse result to the FIB for lookup.  Otherwise aborts the
9
// packet so it is flushed from the packet FIFO.
10
module pkt_parse
11
  (input          clk,
12
   input          reset,
13
 
14
   input          rxg_srdy,
15
   output         rxg_drdy,
16
   input  [1:0]   rxg_code,
17
   input [7:0]    rxg_data,
18
 
19
   output reg     p2f_srdy,
20
   input          p2f_drdy,
21
   output reg [`PAR_DATA_SZ-1:0] p2f_data,
22
 
23
   output         pdo_srdy,
24
   input          pdo_drdy,
25
   output [1:0]   pdo_code,
26
   output [7:0]   pdo_data
27
   );
28
 
29
  wire            lp_srdy;
30
  reg             lp_drdy;
31
  wire [1:0]       lp_code;
32
  wire [7:0]       lp_data;
33
  reg             lc_srdy;
34
  wire            lc_drdy;
35
  reg [1:0]        lc_code;
36
 
37
  reg [3:0]        count, nxt_count;
38
  reg             nxt_p2f_srdy;
39
  reg [`PAR_DATA_SZ-1:0] nxt_p2f_data;
40
 
41
  sd_input #(8+2) rxg_in
42
    (
43
     // Outputs
44
     .c_drdy                            (rxg_drdy),
45
     .ip_srdy                           (lp_srdy),
46
     .ip_data                           ({lp_code,lp_data}),
47
     // Inputs
48
     .clk                               (clk),
49
     .reset                             (reset),
50
     .c_srdy                            (rxg_srdy),
51
     .c_data                            ({rxg_code,rxg_data}),
52
     .ip_drdy                           (lp_drdy));
53
 
54
  always @*
55
    begin
56
      nxt_p2f_srdy = p2f_srdy;
57
      nxt_p2f_data = p2f_data;
58
      nxt_count = count;
59
      lc_code = lp_code;
60
 
61
      if (p2f_srdy)
62
        begin
63
          lp_drdy = 0;
64
          lc_srdy = 0;
65
          if (p2f_drdy)
66
            nxt_p2f_srdy = 0;
67
        end
68
      else if (lp_srdy & lc_drdy)
69
        begin
70
          lp_drdy = 1;
71
          lc_srdy = 1;
72
 
73
          case (count)
74
            0, 1, 2, 3, 4, 5 :
75
              begin
76
                if (count == 0)
77
                  nxt_p2f_data = 0;
78
 
79
                if ((lp_code == `PCC_EOP) || (lp_code == `PCC_BADEOP))
80
                  begin
81
                    lc_code = `PCC_BADEOP;
82
                    nxt_count = 0;
83
                  end
84
                else
85
                  begin
86
                    nxt_p2f_data[`PAR_MACDA] = { p2f_data[`PAR_MACDA] << 8, lp_data };
87
                    nxt_count = count + 1;
88
                  end
89
              end // case: 0, 1, 2, 3, 4, 5
90
 
91
            6, 7, 8, 9, 10, 11 :
92
              begin
93
                if ((lp_code == `PCC_EOP) || (lp_code == `PCC_BADEOP))
94
                  begin
95
                    lc_code = `PCC_BADEOP;
96
                    nxt_count = 0;
97
                  end
98
                else
99
                  begin
100
                    nxt_p2f_data[`PAR_MACSA] = { p2f_data[`PAR_MACSA] << 8, lp_data };
101
                    nxt_count = count + 1;
102
                  end
103
              end // case: 6, 7, 8, 9, 10, 11
104
 
105
            // done with parsing, wait for packet EOP
106
            12 :
107
              begin
108
                if (lp_code == `PCC_EOP)
109
                  begin
110
                    nxt_p2f_srdy = 1;
111
                    nxt_count = 0;
112
                  end
113
                else if (lp_code == `PCC_BADEOP)
114
                  nxt_count = 0;
115
              end
116
 
117
            default : nxt_count = 0;
118
          endcase // case (count)
119
        end
120
      else
121
        begin
122
          lp_drdy = 0;
123
          lc_srdy = 0;
124
        end // else: !if(lp_srdy & lc_drdy)
125
    end // always @ *
126
 
127
  always @(posedge clk)
128
    begin
129
      if (reset)
130
        begin
131
          /*AUTORESET*/
132
          // Beginning of autoreset for uninitialized flops
133
          count <= 4'h0;
134
          p2f_data <= {(1+(`PAR_DATA_SZ-1)){1'b0}};
135
          p2f_srdy <= 1'h0;
136
          // End of automatics
137
        end
138
      else
139
        begin
140
          p2f_srdy <= #1 nxt_p2f_srdy;
141
          p2f_data <= #1 nxt_p2f_data;
142
          count <= #1 nxt_count;
143
        end
144
    end
145
 
146
  sd_output #(8+2) par_out
147
    (
148
     // Outputs
149
     .ic_drdy                           (lc_drdy),
150
     .p_srdy                            (pdo_srdy),
151
     .p_data                            ({pdo_code,pdo_data}),
152
     // Inputs
153
     .clk                               (clk),
154
     .reset                             (reset),
155
     .ic_srdy                           (lc_srdy),
156
     .ic_data                           ({lp_code,lp_data}),
157
     .p_drdy                            (pdo_drdy));
158
 
159
endmodule // pkt_parse
160
// Local Variables:
161
// verilog-library-directories:("." "../../../rtl/verilog/closure" "../../../rtl/verilog/memory" "../../../rtl/verilog/forks")
162
// End:  
163
 
164
 

powered by: WebSVN 2.1.0

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