Changeset 9104

Show
Ignore:
Timestamp:
07/31/08 20:35:03
Author:
matt
Message:

pass fifo information out, do retiming of xon/xoff in here, retime rst to get it into the proper clock domain

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • usrp2/trunk/fpga/serdes/serdes_rx.v

    r8609 r9104  
    4141     output [15:0] fifo_space, 
    4242     output xon_rcvd, output xoff_rcvd, 
     43 
     44     output [15:0] fifo_occupied, output fifo_full, output fifo_empty, 
    4345     output [31:0] debug 
    4446     ); 
     
    8183   reg         write_d; 
    8284 
     85   oneshot_2clk rst_1s(.clk_in(clk),.in(rst),.clk_out(ser_rx_clk),.out(rst_rxclk)); 
     86 
    8387   /* 
    8488   ss_rcvr #(.WIDTH(18)) ss_rcvr 
     
    9094    
    9195   always @(posedge ser_rx_clk) 
    92      if(rst
     96     if(rst_rxclk
    9397       holder <= 9'd0; 
    9498     else 
     
    96100    
    97101   always @(posedge ser_rx_clk) 
    98      if(rst
     102     if(rst_rxclk
    99103       odd_data <= 18'd0; 
    100104     else 
     
    103107   assign      chosen_data = odd ? odd_data : even_data; 
    104108 
    105    assign      xon_rcvd = ({1'b1,K_XON} == {ser_rkmsb,ser_r[15:8]}) | ({1'b1,K_XON} == {ser_rklsb,ser_r[7:0]} ); 
    106    assign      xoff_rcvd = ({1'b1,K_XOFF} == {ser_rkmsb,ser_r[15:8]}) | ({1'b1,K_XOFF} == {ser_rklsb,ser_r[7:0]} ); 
    107  
     109   // Transfer xon and xoff info to the main system clock for flow control purposes 
     110   reg         xon_rcvd_rxclk, xoff_rcvd_rxclk; 
     111   always @(posedge ser_rx_clk) 
     112     xon_rcvd_rxclk = ({1'b1,K_XON} == {ser_rkmsb,ser_r[15:8]}) | ({1'b1,K_XON} == {ser_rklsb,ser_r[7:0]} ); 
     113   always @(posedge ser_rx_clk) 
     114     xoff_rcvd_rxclk = ({1'b1,K_XOFF} == {ser_rkmsb,ser_r[15:8]}) | ({1'b1,K_XOFF} == {ser_rklsb,ser_r[7:0]} ); 
     115    
     116   oneshot_2clk xon_1s(.clk_in(ser_rx_clk),.in(xon_rcvd_rxclk),.clk_out(clk),.out(xon_rcvd)); 
     117   oneshot_2clk xoff_1s(.clk_in(ser_rx_clk),.in(xoff_rcvd_rxclk),.clk_out(clk),.out(xoff_rcvd)); 
     118 
     119   // If the other side is sending xon or xoff, or is flow controlled (b/c we told them to be), don't fill the fifos 
    108120   wire        wait_here = ((chosen_data == {2'b10,K_COMMA,D_56})|| 
    109121                            (chosen_data == {2'b11,K_XON,K_XON})|| 
     
    111123 
    112124   always @(posedge ser_rx_clk) 
    113      if(rst) sop_i <= 0; 
     125     if(rst_rxclk) sop_i <= 0; 
    114126     else if(state == FIRSTLINE1) sop_i <= 1; 
    115127     else if(write_d) sop_i <= 0; 
     
    117129   reg         write_pre; 
    118130   always @(posedge ser_rx_clk) 
    119      if(rst
     131     if(rst_rxclk
    120132       begin 
    121133          state <= IDLE; 
     
    238250    
    239251   always @(posedge ser_rx_clk) 
    240      if(rst
     252     if(rst_rxclk
    241253       CRC <= 16'hFFFF; 
    242254     else if(state == IDLE) 
     
    248260 
    249261   always @(posedge ser_rx_clk) 
    250      if(rst) write_d <= 0; 
     262     if(rst_rxclk) write_d <= 0; 
    251263     else write_d <= write_pre; 
    252264 
     
    257269//`define CASC 1 
    258270`define MYFIFO 1    
    259 //`define XILFIFO
     271//`define XILFIFO
    260272 
    261273`ifdef CASC    
     
    264276      .datain({error_i,sop_i,eop_i,line_i}), .write(write), .full(full), 
    265277      .dataout({error_o,sop_o,eop_o,line_o}), .read(read), .empty(empty), 
    266       .fifo_space(fifo_space) ); 
     278      .space(fifo_space),.occupied(fifo_occupied) ); 
     279   assign fifo_full = full; 
     280   assign fifo_empty = empty; 
    267281`endif 
    268282 
     
    276290   assign              fifo_space = {{(16-FIFOSIZE){1'b0}},{FIFOSIZE{1'b1}}} -  
    277291                       {{(16-FIFOSIZE){1'b0}},level}; 
     292   assign              fifo_occupied = { {(16-FIFOSIZE){1'b0}} ,level}; 
     293   assign              fifo_full = full;   // Note -- fifo_full is in the wrong clock domain 
     294   assign              fifo_empty = empty; 
    278295`endif 
    279296 
     
    290307      .empty(empty), 
    291308      .full(full), 
    292       .rd_data_count(), 
    293       .wr_data_count(level)); 
     309      .rd_data_count(level), 
     310      .wr_data_count() ); 
    294311   assign              fifo_space = {{(16-FIFOSIZE){1'b0}},{FIFOSIZE{1'b1}}} -  
    295312                       {{(16-FIFOSIZE){1'b0}},level}; 
     313   assign              fifo_occupied = { {(16-FIFOSIZE){1'b0}}, level }; 
     314   assign              fifo_full = full;   // Note -- fifo_full is in the wrong clock domain 
     315   assign              fifo_empty = empty; 
    296316`endif //  `ifdef XILFIFO 
    297317    
     
    322342                    { 2'd0, error_i, sop_i, eop_i, error_o, sop_o, eop_o }, 
    323343                    { full, empty, write, read, xfer_active, state[2:0] } }; 
    324    */ 
    325  
    326    /* 
     344 
    327345   assign      debug = { { xoff_rcvd,xon_rcvd,sop_i,eop_i,error_i,state[2:0] }, 
    328346                         { odd, wait_here, write_pre, write_d, write, full, chosen_data[17:16]},