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 16

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

powered by: WebSVN 2.1.0

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