Changeset 9096

Show
Ignore:
Timestamp:
07/31/08 20:21:43
Author:
matt
Message:

fixed major bug in xfer_state state machine which would cause it to refill with junk when there was an underflow.
Also added fifo level outputs and adapted to the new interface for the fifo full/empty connections.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • usrp2/trunk/fpga/sdr_lib/tx_control.v

    r8632 r9096  
    2323     input strobe, 
    2424 
     25     // FIFO Levels 
     26     output [15:0] fifo_occupied, 
     27     output fifo_full, 
     28     output fifo_empty, 
     29 
     30     // Debug 
    2531     output [31:0] debug 
    2632     ); 
     
    4147     if(rst) 
    4248       xfer_state <= XFER_IDLE; 
    43      else  
    44        case(xfer_state) 
    45          XFER_IDLE : 
    46            if(rd_sop_i) 
    47              xfer_state <= XFER_1; 
    48          XFER_1 : 
    49            begin 
    50               xfer_state <= XFER_2; 
    51               held_flags <= rd_dat_i[2:0]; 
    52            end 
    53          XFER_2 : 
    54            if(~full_ctrl) 
    55              xfer_state <= XFER_DATA; 
    56          XFER_DATA : 
    57            if(rd_eop_i & ~full_data) 
    58              xfer_state <= XFER_IDLE; 
    59        endcase // case(xfer_state) 
     49     else 
     50       if(clear_state) 
     51         xfer_state <= XFER_IDLE; 
     52       else 
     53         case(xfer_state) 
     54           XFER_IDLE : 
     55             if(rd_sop_i) 
     56               xfer_state <= XFER_1; 
     57           XFER_1 : 
     58             begin 
     59                xfer_state <= XFER_2; 
     60                held_flags <= rd_dat_i[2:0]; 
     61             end 
     62           XFER_2 : 
     63             if(~full_ctrl) 
     64               xfer_state <= XFER_DATA; 
     65           XFER_DATA : 
     66             if(rd_eop_i & ~full_data) 
     67               xfer_state <= XFER_IDLE; 
     68         endcase // case(xfer_state) 
    6069    
    6170   assign write_data = (xfer_state == XFER_DATA) & ~full_data; 
     
    6978   wire        sop_o, eop_o, eob, sob, send_imm; 
    7079   wire [31:0] sendtime; 
     80   wire [4:0]  occ_ctrl; 
    7181    
    7282   cascadefifo2 #(.WIDTH(34),.SIZE(FIFOSIZE)) txctrlfifo 
    7383     (.clk(clk),.rst(rst),.clear(clear_state), 
    7484      .datain({rd_sop_i,rd_eop_i,rd_dat_i}), .write(write_data), .full(full_data), 
    75       .dataout({sop_o,eop_o,data_o}), .read(read_data), .empty(empty_data) ); 
     85      .dataout({sop_o,eop_o,data_o}), .read(read_data), .empty(empty_data), 
     86      .space(), .occupied(fifo_occupied) ); 
     87   assign      fifo_full = full_data; 
     88   assign      fifo_empty = empty_data; 
    7689 
    7790   shortfifo #(.WIDTH(35)) ctrlfifo 
    7891     (.clk(clk),.rst(rst),.clear(clear_state), 
    7992      .datain({held_flags[2:0],rd_dat_i}), .write(write_ctrl), .full(full_ctrl), 
    80       .dataout({send_imm,sob,eob,sendtime}), .read(read_ctrl), .empty(empty_ctrl) ); 
     93      .dataout({send_imm,sob,eob,sendtime}), .read(read_ctrl), .empty(empty_ctrl), 
     94      .space(), .occupied(occ_ctrl) ); 
    8195 
    8296   // Internal FIFO to DSP interface 
     
    140154   assign      sample = data_o; 
    141155 
    142    assign      debug = { 16'd0
    143                          {eop_o, eob, send_imm ,too_late, go_now, ibs_state[2:0] },  
    144                          empty_data, empty_ctrl, read_data, read_ctrl, strobe, clear_state, run, underrun}; 
     156   assign      debug = { {16'b0}
     157                         { read_data, write_data, read_ctrl, write_ctrl, xfer_state[1:0],full_ctrl,empty_ctrl }, 
     158                         { occ_ctrl, eop_o, clear_state, underrun} }; 
    145159    
    146160endmodule // tx_control