Changeset 9093

Show
Ignore:
Timestamp:
07/31/08 20:18:26
Author:
matt
Message:

Fixed major bug in determining when the fifo is full. The problem was with bit vectors being expanded quietly and signed math creeping in.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • usrp2/trunk/fpga/control_lib/longfifo.v

    r7198 r9093  
    1616     output full, 
    1717     output empty, 
    18      output [15:0] fifo_space); 
     18     output [15:0] space, 
     19     output [15:0] occupied); 
    1920 
    2021   // Read side states 
     
    2728 
    2829   wire [SIZE-1:0] fullness = wr_addr - rd_addr;  // Approximate, for simulation only 
     30   assign occupied = {{16-SIZE{1'b0}},fullness}; 
     31 
    2932   wire [SIZE-1:0] free_space = rd_addr - wr_addr - 2;  // Approximate, for SERDES flow control 
     33   assign space = {{16-SIZE{1'b0}},free_space}; 
     34           
    3035   reg    empty_reg, full_reg; 
    31    assign fifo_space = {{16-SIZE{1'b0}},free_space}; 
    32            
    3336   always @(posedge clk) 
    3437     if(rst) 
     
    9699                 rd_addr <= rd_addr + 1; 
    97100         endcase // case(read_state) 
    98     
     101 
     102   wire [SIZE-1:0] dont_write_past_me = rd_addr - 3; 
     103   wire            becoming_full = wr_addr == dont_write_past_me; 
     104      
    99105   always @(posedge clk) 
    100106     if(rst) 
     
    104110     else if(read & ~write) 
    105111       full_reg <= 0; 
    106      else if(write & ~read & (wr_addr == (rd_addr-3))) 
     112     //else if(write & ~read & (wr_addr == (rd_addr-3))) 
     113     else if(write & ~read & becoming_full) 
    107114       full_reg <= 1; 
    108115