Revision bada7617 usrp2/vrt/vita_tx_deframer.v

b/usrp2/vrt/vita_tx_deframer.v
118 118
	    <= 0;
119 119
	  seqnum_err <= 0;
120 120
       end
121
     else 
122
       if((vita_state == VITA_STORE) & fifo_space)
123
	 if(vita_eof)  
124
	   if(eof)
125
	     vita_state <= (USE_TRANS_HEADER==1) ? VITA_TRANS_HEADER : VITA_HEADER;
126
	   else if(has_trailer_reg)
127
	     vita_state <= VITA_TRAILER;
128
	   else
129
	     vita_state <= VITA_DUMP;
130
   	 else
131
	   begin
132
	      vita_state <= VITA_PAYLOAD;
133
	      pkt_len <= pkt_len - 1;
134
	   end
135
       else if(src_rdy_i)
121
     else if(src_rdy_i & dst_rdy_o) begin //valid read
136 122
	 case(vita_state)
137 123
	   VITA_TRANS_HEADER :
138 124
	     begin
......
184 170
	     vita_state <= VITA_TICS2;
185 171
	   VITA_TICS2 :
186 172
	     vita_state <= VITA_PAYLOAD;
187
	   VITA_PAYLOAD :
188
	     if(line_done)
189
	       begin
190
		  vector_phase <= 0;
191
		  vita_state <= VITA_STORE;
192
	       end
193
	     else
194
	       vector_phase <= vector_phase + 1;
173

  
174
        VITA_PAYLOAD : begin
175

  
176
            //step through each element until line done, then reset
177
            vector_phase <= (line_done)? 0: vector_phase + 1;
178

  
179
            //decrement the packet count after each line
180
            pkt_len <= (line_done)? pkt_len - 1 : pkt_len;
181

  
182
            //end of frame reached, determine next state
183
            //otherwise, keep processing through the payload
184
            if (line_done && vita_eof) begin
185

  
186
                if (eof) begin
187
                    vita_state <= (USE_TRANS_HEADER==1) ? VITA_TRANS_HEADER : VITA_HEADER;
188
                end
189
                else if (has_trailer_reg) begin
190
                    vita_state <= VITA_TRAILER;
191
                end
192
                else begin
193
                    vita_state <= VITA_DUMP;
194
                end
195

  
196
            end //line_done && vita_eof
197

  
198
        end //end VITA_PAYLOAD
199

  
195 200
	   VITA_TRAILER :
196 201
	     if(eof)
197 202
	       vita_state <= (USE_TRANS_HEADER==1) ? VITA_TRANS_HEADER : VITA_HEADER;
......
206 211
	     vita_state <= (USE_TRANS_HEADER==1) ? VITA_TRANS_HEADER : VITA_HEADER;
207 212
	 endcase // case (vita_state)
208 213

  
214
     end //valid read
215

  
209 216
   assign line_done = (vector_phase == numchan);
210 217
   
211 218
   wire [FIFOWIDTH-1:0] fifo_i;
212 219
   reg [63:0] 		      send_time;
213
   reg [31:0] 		      sample_a, sample_b, sample_c, sample_d;
214 220
   
215 221
   always @(posedge clk)
216 222
     case(vita_state)
......
219 225
       VITA_TICS2 :
220 226
	 send_time[31:0] <= data_i[31:0];
221 227
     endcase // case (vita_state)
222
   
228

  
229
   //sample registers for de-framing a vector input
230
   reg [31:0] sample_reg [1:0];
223 231
   always @(posedge clk)
224
     if(vita_state == VITA_PAYLOAD)
225
       case(vector_phase)
226
	 0: sample_a <= data_i[31:0];
227
	 1: sample_b <= data_i[31:0];
228
	 2: sample_c <= data_i[31:0];
229
	 3: sample_d <= data_i[31:0];
230
       endcase // case (vector_phase)
231
   
232
   wire 		      store = (vita_state == VITA_STORE);
232
     if(src_rdy_i && dst_rdy_o)
233
        sample_reg[vector_phase] <= data_i[31:0];
234

  
235
   wire store = (vita_state == VITA_PAYLOAD)? (src_rdy_i && line_done) : 0;
236
   assign dst_rdy_o = (vita_state == VITA_PAYLOAD)? fifo_space : 1;
237

  
233 238
   fifo_short #(.WIDTH(FIFOWIDTH)) short_tx_q
234 239
     (.clk(clk), .reset(reset), .clear(clear),
235 240
      .datain(fifo_i), .src_rdy_i(store), .dst_rdy_o(fifo_space),
236 241
      .dataout(sample_fifo_o), .src_rdy_o(sample_fifo_src_rdy_o), .dst_rdy_i(sample_fifo_dst_rdy_i) );
237 242

  
243
    //assign registered/live data to the samples vector
244
    //the numchan'th sample vector is muxed to live data
245
    wire [(32*MAXCHAN)-1:0] samples;
246
    generate
247
    genvar i;
248
    for (i=0; i < MAXCHAN; i = i +1) begin : assign_samples
249
        wire live_data = (i == (MAXCHAN-1))? 1 : numchan == i;
250
        assign samples[32*i + 31:32*i] = (live_data)? data_i[31:0] : sample_reg[i];
251
    end
252
    endgenerate
253

  
238 254
   // sob, eob, has_tics (send_at) ignored on all lines except first
239
   assign fifo_i = {sample_d,sample_c,sample_b,sample_a,seqnum_err,has_tics_reg,is_sob_reg,is_eob_reg,eop,
255
   assign fifo_i = {samples,seqnum_err,has_tics_reg,is_sob_reg,is_eob_reg,eop,
240 256
		    12'd0,seqnum_reg[3:0],send_time};
241 257

  
242
   assign dst_rdy_o = ~(vita_state == VITA_PAYLOAD) & ~((vita_state==VITA_STORE)& ~fifo_space) ;
243

  
244 258
   assign debug = { { 8'b0 },
245 259
		    { 8'b0 },
246 260
		    { eof, line_done, store, fifo_space, src_rdy_i, dst_rdy_o, vector_phase[1:0] },

Also available in: Unified diff