Changeset 8295

Show
Ignore:
Timestamp:
04/29/08 21:52:31
Author:
eb
Message:

Merged features/inband-usb -r6431:8293 into trunk.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gnuradio/trunk/mblock/src/lib/mb_message.cc

    r6044 r8295  
    2727#include <pmt_pool.h> 
    2828 
    29 static const int CACHE_LINE_SIZE = 64;         // good guess 
    30  
    31  
     29static const int CACHE_LINE_SIZE = 64;  // good guess 
     30static const int MAX_MESSAGES =  1024;  // KLUDGE max number of messages in sys 
     31                                        //   0 -> no limit 
    3232#if MB_MESSAGE_LOCAL_ALLOCATOR 
    3333 
    34 static pmt_pool global_msg_pool(sizeof(mb_message), CACHE_LINE_SIZE); 
     34static pmt_pool  
     35global_msg_pool(sizeof(mb_message), CACHE_LINE_SIZE, 16*1024, MAX_MESSAGES); 
    3536 
    3637void * 
  • gnuradio/trunk/pmt/src/lib/pmt.cc

    r8292 r8295  
    964964 
    965965pmt_t 
     966pmt_list_add(pmt_t list, pmt_t item) 
     967{ 
     968  return pmt_reverse(pmt_cons(item, pmt_reverse(list))); 
     969} 
     970 
     971pmt_t 
    966972pmt_caar(pmt_t pair) 
    967973{ 
  • gnuradio/trunk/pmt/src/lib/pmt.h

    r6307 r8295  
    610610pmt_t pmt_list6(pmt_t x1, pmt_t x2, pmt_t x3, pmt_t x4, pmt_t x5, pmt_t x6); 
    611611 
     612/*! 
     613 * \brief Return \p list with \p item added to it. 
     614 */ 
     615pmt_t pmt_list_add(pmt_t list, pmt_t item); 
     616 
    612617 
    613618/* 
  • gnuradio/trunk/pmt/src/lib/pmt_pool.cc

    r6044 r8295  
    3333} 
    3434 
    35 pmt_pool::pmt_pool(size_t itemsize, size_t alignment, size_t allocation_size) 
    36   : d_itemsize(ROUNDUP(itemsize, alignment)), 
     35pmt_pool::pmt_pool(size_t itemsize, size_t alignment, 
     36                   size_t allocation_size, size_t max_items) 
     37  : d_cond(&d_mutex), 
     38    d_itemsize(ROUNDUP(itemsize, alignment)), 
    3739    d_alignment(alignment), 
    3840    d_allocation_size(std::max(allocation_size, 16 * itemsize)), 
     41    d_max_items(max_items), d_n_items(0), 
    3942    d_freelist(0) 
    4043{ 
     
    5457  item *p; 
    5558 
     59  if (d_max_items != 0){ 
     60    while (d_n_items >= d_max_items) 
     61      d_cond.wait(); 
     62  } 
     63 
    5664  if (d_freelist){      // got something? 
    5765    p = d_freelist; 
    5866    d_freelist = p->d_next; 
     67    d_n_items++; 
    5968    return p; 
    6069  } 
     
    8089  p = d_freelist; 
    8190  d_freelist = p->d_next; 
     91  d_n_items++; 
    8292  return p; 
    8393} 
     
    94104  p->d_next = d_freelist; 
    95105  d_freelist = p; 
     106  d_n_items--; 
     107  if (d_max_items != 0) 
     108    d_cond.signal(); 
    96109} 
  • gnuradio/trunk/pmt/src/lib/pmt_pool.h

    r6044 r8295  
    3939   
    4040  omni_mutex          d_mutex; 
     41  omni_condition      d_cond; 
    4142   
    4243  size_t              d_itemsize; 
    4344  size_t              d_alignment; 
    4445  size_t              d_allocation_size; 
     46  size_t              d_max_items; 
     47  size_t              d_n_items; 
    4548  item               *d_freelist; 
    4649  std::vector<char *> d_allocations; 
     
    5154   * \param alignment alignment in bytes of all objects to be allocated (must be power-of-2). 
    5255   * \param allocation_size number of bytes to allocate at a time from the underlying allocator. 
     56   * \param max_items is the maximum number of items to allocate.  If this number is exceeded, 
     57   *          the allocate blocks.  0 implies no limit. 
    5358   */ 
    54   pmt_pool(size_t itemsize, size_t alignment = 16, size_t allocation_size = 4096); 
     59  pmt_pool(size_t itemsize, size_t alignment = 16, 
     60           size_t allocation_size = 4096, size_t max_items = 0); 
    5561  ~pmt_pool(); 
    5662 
  • gnuradio/trunk/pmt/src/lib/qa_pmt_prims.cc

    r6307 r8295  
    302302} 
    303303 
     304void 
     305qa_pmt_prims::test_lists() 
     306{ 
     307  pmt_t s0 = pmt_intern("s0"); 
     308  pmt_t s1 = pmt_intern("s1"); 
     309  pmt_t s2 = pmt_intern("s2"); 
     310  pmt_t s3 = pmt_intern("s3"); 
     311 
     312  pmt_t l1 = pmt_list4(s0, s1, s2, s3); 
     313  pmt_t l2 = pmt_list3(s0, s1, s2); 
     314  pmt_t l3 = pmt_list_add(l2, s3); 
     315  CPPUNIT_ASSERT(pmt_equal(l1, l3)); 
     316} 
     317 
    304318// ------------------------------------------------------------------------ 
    305319 
  • gnuradio/trunk/pmt/src/lib/qa_pmt_prims.h

    r6044 r8295  
    4141  CPPUNIT_TEST(test_any); 
    4242  CPPUNIT_TEST(test_io); 
     43  CPPUNIT_TEST(test_lists); 
    4344  CPPUNIT_TEST(test_serialize); 
    4445  CPPUNIT_TEST_SUITE_END(); 
     
    5758  void test_any(); 
    5859  void test_io(); 
     60  void test_lists(); 
    5961  void test_serialize(); 
    6062}; 
  • gnuradio/trunk/usrp/fpga/Makefile.extra

    r6777 r8295  
    55        inband_lib/channel_ram.v                     \ 
    66        inband_lib/cmd_reader.v                      \ 
    7         inband_lib/data_packet_fifo.v                \ 
    87        inband_lib/packet_builder.v                  \ 
    98        inband_lib/register_io.v                     \ 
     
    1110        inband_lib/tx_buffer_inband.v                \ 
    1211        inband_lib/tx_packer.v                       \ 
    13         inband_lib/usb_fifo_reader.v                 \ 
    14         inband_lib/usb_fifo_writer.v                 \ 
    1512        inband_lib/usb_packet_fifo.v                 \ 
    1613        megacells/accum32.bsf                        \ 
  • gnuradio/trunk/usrp/fpga/inband_lib/chan_fifo_reader.v

    r6429 r8295  
    11module chan_fifo_reader  
    2   ( reset, tx_clock, tx_strobe, adc_time, samples_format, 
     2  (reset, tx_clock, tx_strobe, timestamp_clock, samples_format, 
    33    fifodata, pkt_waiting, rdreq, skip, tx_q, tx_i, 
    44    underrun, tx_empty, debug, rssi, threshhold, rssi_wait) ; 
    55 
    6     input   wire                     reset ; 
    7     input   wire                     tx_clock ; 
    8     input   wire                     tx_strobe ; //signal to output tx_i and tx_q 
    9     input   wire              [31:0] adc_time ; //current time 
    10     input   wire               [3:0] samples_format ;// not useful at this point 
    11     input   wire              [31:0] fifodata ; //the data input 
    12     input   wire                     pkt_waiting ; //signal the next packet is ready 
    13     output  reg                      rdreq ; //actually an ack to the current fifodata 
    14     output  reg                      skip ; //finish reading current packet 
    15     output  reg               [15:0] tx_q ; //top 16 bit output of fifodata 
    16     output  reg               [15:0] tx_i ; //bottom 16 bit output of fifodata 
    17     output  reg                      underrun ;  
    18     output  reg                      tx_empty ; //cause 0 to be the output 
    19     input       wire                      [31:0] rssi; 
    20     input       wire                      [31:0] threshhold; 
    21         input   wire                      [31:0] rssi_wait; 
    22  
    23         output wire [14:0] debug; 
    24         assign debug = {reader_state, trash, skip, timestamp[4:0], adc_time[4:0]}; 
    25     // Should not be needed if adc clock rate < tx clock rate 
    26     // Used only to debug 
    27     `define JITTER                   5 
     6   input   wire                     reset ; 
     7   input   wire                     tx_clock ; 
     8   input   wire                     tx_strobe ; //signal to output tx_i and tx_q 
     9   input   wire              [31:0] timestamp_clock ; //current time 
     10   input   wire               [3:0] samples_format ;// not useful at this point 
     11   input   wire              [31:0] fifodata ; //the data input 
     12   input   wire                     pkt_waiting ; //signal the next packet is ready 
     13   output  reg                      rdreq ; //actually an ack to the current fifodata 
     14   output  reg                      skip ; //finish reading current packet 
     15   output  reg               [15:0] tx_q ; //top 16 bit output of fifodata 
     16   output  reg               [15:0] tx_i ; //bottom 16 bit output of fifodata 
     17   output  reg                      underrun ;  
     18   output  reg                      tx_empty ; //cause 0 to be the output 
     19   input   wire              [31:0] rssi; 
     20   input   wire              [31:0] threshhold; 
     21   input   wire              [31:0] rssi_wait; 
     22 
     23   output wire [14:0] debug; 
     24   assign debug = {7'd0, rdreq, skip, reader_state, pkt_waiting, tx_strobe, tx_clock}; 
     25    
     26   //Samples format 
     27   // 16 bits interleaved complex samples 
     28   `define QI16                     4'b0 
    2829     
    29     //Samples format 
    30     // 16 bits interleaved complex samples 
    31     `define QI16                     4'b0 
    32      
    33     // States 
    34     parameter IDLE           =     3'd0;     
    35         parameter HEADER         =     3'd1; 
    36     parameter TIMESTAMP      =     3'd2; 
    37     parameter WAIT           =     3'd3; 
    38     parameter WAITSTROBE     =     3'd4; 
    39     parameter SEND           =     3'd5; 
    40  
    41     // Header format 
    42     `define PAYLOAD                  8:2 
    43     `define ENDOFBURST               27 
    44     `define STARTOFBURST            28 
    45     `define RSSI_FLAG                            26 
     30   // States 
     31   parameter IDLE           =     3'd0;     
     32   parameter HEADER         =     3'd1; 
     33   parameter TIMESTAMP      =     3'd2; 
     34   parameter WAIT           =     3'd3; 
     35   parameter WAITSTROBE     =     3'd4; 
     36   parameter SEND           =     3'd5; 
     37 
     38   // Header format 
     39   `define PAYLOAD                  8:2 
     40   `define ENDOFBURST               27 
     41   `define STARTOFBURST             28 
     42   `define RSSI_FLAG                26 
    4643         
    4744 
    48     /* State registers */ 
    49     reg                        [2:0] reader_state; 
    50        /* Local registers */   
    51     reg                        [6:0] payload_len; 
    52     reg                        [6:0] read_len; 
    53     reg                       [31:0] timestamp; 
    54     reg                              burst; 
    55        reg                                                              trash; 
    56        reg                                                              rssi_flag; 
    57        reg                                               [31:0] time_wait; 
     45   /* State registers */ 
     46   reg                        [2:0] reader_state; 
     47   /* Local registers */   
     48   reg                        [6:0] payload_len; 
     49   reg                        [6:0] read_len; 
     50   reg                       [31:0] timestamp; 
     51   reg                              burst; 
     52   reg                              trash; 
     53   reg                              rssi_flag; 
     54   reg                      [31:0] time_wait; 
    5855    
    59     always @(posedge tx_clock) 
    60     begin 
    61         if (reset)  
    62           begin 
    63             reader_state <= IDLE; 
    64             rdreq <= 0; 
    65             skip <= 0; 
    66             underrun <= 0; 
    67             burst <= 0; 
    68             tx_empty <= 1; 
    69             tx_q <= 0; 
    70             tx_i <= 0; 
    71                        trash <= 0; 
    72                        rssi_flag <= 0; 
    73                        time_wait <= 0; 
     56   always @(posedge tx_clock) 
     57    begin 
     58       if (reset)  
     59         begin 
     60           reader_state <= IDLE; 
     61           rdreq <= 0; 
     62           skip <= 0; 
     63           underrun <= 0; 
     64           burst <= 0; 
     65           tx_empty <= 1; 
     66           tx_q <= 0; 
     67           tx_i <= 0; 
     68           trash <= 0; 
     69           rssi_flag <= 0; 
     70           time_wait <= 0; 
    7471         end 
    7572       else  
    76                   begin 
     73         begin 
    7774           case (reader_state) 
    78                IDLE: 
     75             IDLE: 
    7976               begin 
    80                                 /* 
    81                                  * reset all the variables and wait for a tx_strobe 
    82                                  * it is assumed that the ram connected to this fifo_reader  
    83                                  * is a short hand fifo meaning that the header to the next packet 
    84                                  * is already available to this fifo_reader when pkt_waiting is on 
    85                                  */ 
    86                    skip <=0; 
    87                                    time_wait <= 0; 
    88                    if (pkt_waiting == 1) 
    89                      begin 
    90                         reader_state <= HEADER; 
    91                         rdreq <= 1; 
    92                         underrun <= 0; 
    93                      end 
    94                    if (burst == 1 && pkt_waiting == 0) 
    95                         underrun <= 1; 
    96                          
    97                    if (tx_strobe == 1) 
    98                        tx_empty <= 1 ; 
     77               /* 
     78                * reset all the variables and wait for a tx_strobe 
     79                * it is assumed that the ram connected to this fifo_reader  
     80                * is a short hand fifo meaning that the header to the next packet 
     81                * is already available to this fifo_reader when pkt_waiting is on 
     82                */ 
     83                 skip <=0; 
     84                 time_wait <= 0; 
     85                 if (pkt_waiting == 1) 
     86                   begin 
     87                     reader_state <= HEADER; 
     88                     rdreq <= 1; 
     89                     underrun <= 0; 
     90                   end 
     91                 if (burst == 1 && pkt_waiting == 0) 
     92                     underrun <= 1; 
     93                 if (tx_strobe == 1) 
     94                     tx_empty <= 1 ; 
    9995               end 
    10096 
    101                                   /* Process header */ 
     97               /* Process header */ 
    10298               HEADER: 
    103                begin 
     99                 begin 
    104100                   if (tx_strobe == 1) 
    105101                       tx_empty <= 1 ; 
     
    115111                       burst <= 0; 
    116112 
    117                                        if (trash == 1 && fifodata[`STARTOFBURST] == 0) 
    118                                        begin 
    119                                                skip <= 1; 
    120                                                reader_state <= IDLE; 
    121                                                rdreq <= 0; 
    122                                        end  
    123                     else 
    124                                        begin    
    125                                payload_len <= fifodata[`PAYLOAD] ; 
    126                                read_len <= 0; 
    127                         rdreq <= 1; 
    128                                                reader_state <= TIMESTAMP; 
    129                                        end 
    130                end 
     113                   if (trash == 1 && fifodata[`STARTOFBURST] == 0) 
     114                     begin 
     115                       skip <= 1; 
     116                       reader_state <= IDLE; 
     117                       rdreq <= 0; 
     118                     end  
     119                   else 
     120                     begin    
     121                       payload_len <= fifodata[`PAYLOAD] ; 
     122                       read_len <= 0; 
     123                       rdreq <= 1; 
     124                       reader_state <= TIMESTAMP; 
     125                     end 
     126                 end 
    131127 
    132128               TIMESTAMP:  
    133                begin 
     129                 begin 
    134130                   timestamp <= fifodata; 
    135131                   reader_state <= WAIT; 
     
    137133                       tx_empty <= 1 ; 
    138134                   rdreq <= 0; 
    139                end 
     135                 end 
    140136                                 
    141                                   // Decide if we wait, send or discard samples 
     137               // Decide if we wait, send or discard samples 
    142138               WAIT:  
    143                begin 
     139                 begin 
    144140                   if (tx_strobe == 1) 
    145141                       tx_empty <= 1 ; 
    146142                     
    147143                   time_wait <= time_wait + 32'd1; 
    148                                   // Outdated 
    149                    if ((timestamp < adc_time) || 
    150                                                        (time_wait >= rssi_wait && rssi_wait != 0 && rssi_flag)) 
    151                      begin 
    152                                                trash <= 1; 
    153                         reader_state <= IDLE; 
    154                         skip <= 1; 
     144                   // Outdated 
     145                   if ((timestamp < timestamp_clock) || 
     146                      (time_wait >= rssi_wait && rssi_wait != 0 && rssi_flag)) 
     147                     begin 
     148                       trash <= 1; 
     149                       reader_state <= IDLE; 
     150                       skip <= 1; 
    155151                     end   
    156152                   // Let's send it                                      
    157                    else if ((timestamp <= adc_time + `JITTER  
    158                              && timestamp > adc_time) 
     153                   else if (timestamp == timestamp_clock  
    159154                             || timestamp == 32'hFFFFFFFF) 
    160                                         begin 
    161                                                 if (rssi <= threshhold || rssi_flag == 0) 
    162                                                   begin 
    163                                                     trash <= 0; 
    164                             reader_state <= WAITSTROBE;  
    165                           end 
    166                                                 else 
    167                                                     reader_state <= WAIT; 
    168                                         end 
    169                                    else 
    170                                                 reader_state <= WAIT; 
    171                    // Wait a little bit more 
    172                    //else if (timestamp > adc_time + `JITTER) 
    173                    //    reader_state <= WAIT; 
    174                end 
     155                     begin 
     156                       if (rssi <= threshhold || rssi_flag == 0) 
     157                         begin 
     158                           trash <= 0; 
     159                           reader_state <= WAITSTROBE;  
     160                         end 
     161                       else 
     162                         reader_state <= WAIT; 
     163                     end 
     164                   else 
     165                       reader_state <= WAIT; 
     166                 end 
    175167                  
    176168               // Wait for the transmit chain to be ready 
    177169               WAITSTROBE: 
    178                begin 
     170                 begin 
    179171                   // If end of payload... 
    180172                   if (read_len == payload_len) 
     
    190182                       rdreq <= 1; 
    191183                     end 
    192                end 
     184                 end 
    193185                
    194                           // Send the samples to the tx_chain 
     186               // Send the samples to the tx_chain 
    195187               SEND: 
    196                begin 
     188                 begin 
    197189                   reader_state <= WAITSTROBE;  
    198190                   read_len <= read_len + 7'd1; 
     
    214206                        end  
    215207                   endcase 
    216                end 
     208                 end 
    217209                
    218210               default: 
    219                begin 
    220                                        //error handling 
     211                 begin 
     212                   //error handling 
    221213                   reader_state <= IDLE; 
    222                end 
     214                 end 
    223215           endcase 
    224216       end 
  • gnuradio/trunk/usrp/fpga/inband_lib/channel_demux.v

    r6307 r8295  
    11module channel_demux 
    2  #(parameter NUM_CHAN = 2, parameter CHAN_WIDTH = 2) (     //usb Side 
    3                        input [31:0]usbdata_final, 
    4                        input WR_final,  
    5                          
    6                         // TX Side 
    7                        input reset
    8                        input txclk
    9                        output reg [CHAN_WIDTH:0] WR_channel
    10                         output reg [31:0] ram_data, 
    11                         output reg [CHAN_WIDTH:0] WR_done_channel ); 
    12 /* Parse header and forward to ram */ 
    13        reg [2:0]reader_state; 
    14        reg [4:0]channel ; 
    15        reg [6:0]read_length ; 
     2 #(parameter NUM_CHAN = 2) (     //usb Side 
     3   input [31:0]usbdata_final, 
     4   input WR_final,  
     5   // TX Side 
     6   input reset, 
     7   input txclk
     8   output reg [NUM_CHAN:0] WR_channel
     9   output reg [31:0] ram_data
     10   output reg [NUM_CHAN:0] WR_done_channel ); 
     11   /* Parse header and forward to ram */ 
     12         
     13    reg [2:0]reader_state; 
     14    reg [4:0]channel ; 
     15    reg [6:0]read_length ; 
    1616         
    1717         // States 
    18     parameter IDLE             =       3'd0; 
    19     parameter HEADER   =       3'd1; 
    20     parameter WAIT             =       3'd2; 
    21     parameter FORWARD  =       3'd3; 
     18    parameter IDLE      =    3'd0; 
     19    parameter HEADER    =    3'd1; 
     20    parameter WAIT      =    3'd2; 
     21    parameter FORWARD   =    3'd3; 
    2222         
    2323        `define CHANNEL 20:16 
     
    2828         
    2929        always @(posedge txclk) 
    30         begin 
     30          begin 
    3131            if (reset) 
    3232              begin 
  • gnuradio/trunk/usrp/fpga/inband_lib/channel_ram.v

    r6429 r8295  
    11module channel_ram  
    2         ( // System 
    3         input txclk, 
    4         input reset, 
     2   ( // System 
     3     input txclk, input reset, 
     4     // USB side 
     5     input [31:0] datain, input WR, input WR_done, output have_space, 
     6     // Reader side  
     7     output [31:0] dataout, input RD, input RD_done, output packet_waiting); 
    58         
    6         // USB side 
    7         input [31:0] datain,  
    8         input WR,  
    9         input WR_done, 
    10         output have_space, 
     9   reg [6:0] wr_addr, rd_addr; 
     10   reg [1:0] which_ram_wr, which_ram_rd; 
     11   reg [2:0] nb_packets; 
     12         
     13   reg [31:0] ram0 [0:127]; 
     14   reg [31:0] ram1 [0:127]; 
     15   reg [31:0] ram2 [0:127]; 
     16   reg [31:0] ram3 [0:127]; 
     17         
     18   reg [31:0] dataout0; 
     19   reg [31:0] dataout1; 
     20   reg [31:0] dataout2; 
     21   reg [31:0] dataout3; 
     22         
     23   wire wr_done_int; 
     24   wire rd_done_int; 
     25   wire [6:0] rd_addr_final; 
     26   wire [1:0] which_ram_rd_final; 
     27         
     28   // USB side 
     29   always @(posedge txclk) 
     30       if(WR & (which_ram_wr == 2'd0)) ram0[wr_addr] <= datain; 
     31                         
     32   always @(posedge txclk) 
     33       if(WR & (which_ram_wr == 2'd1)) ram1[wr_addr] <= datain; 
    1134 
    12         // Reader side 
    13         output [31:0] dataout, 
    14         input RD, 
    15         input RD_done, 
    16         output packet_waiting); 
    17          
    18         reg [6:0] wr_addr, rd_addr; 
    19         reg [1:0] which_ram_wr, which_ram_rd; 
    20         reg [2:0] nb_packets; 
    21          
    22         reg [31:0] ram0 [0:127]; 
    23         reg [31:0] ram1 [0:127]; 
    24         reg [31:0] ram2 [0:127]; 
    25         reg [31:0] ram3 [0:127]; 
    26          
    27         reg [31:0] dataout0; 
    28         reg [31:0] dataout1; 
    29         reg [31:0] dataout2; 
    30         reg [31:0] dataout3; 
    31          
    32         wire wr_done_int; 
    33         wire rd_done_int; 
    34         wire [6:0] rd_addr_final; 
    35         wire [1:0] which_ram_rd_final; 
    36          
    37         // USB side 
    38         always @(posedge txclk) 
    39                 if(WR & (which_ram_wr == 2'd0)) ram0[wr_addr] <= datain; 
    40                          
    41         always @(posedge txclk) 
    42                 if(WR & (which_ram_wr == 2'd1)) ram1[wr_addr] <= datain; 
     35   always @(posedge txclk) 
     36       if(WR & (which_ram_wr == 2'd2)) ram2[wr_addr] <= datain; 
    4337 
    44         always @(posedge txclk) 
    45                 if(WR & (which_ram_wr == 2'd2)) ram2[wr_addr] <= datain; 
    46  
    47         always @(posedge txclk) 
    48                 if(WR & (which_ram_wr == 2'd3)) ram3[wr_addr] <= datain; 
     38   always @(posedge txclk) 
     39       if(WR & (which_ram_wr == 2'd3)) ram3[wr_addr] <= datain; 
    4940 
    5041   assign wr_done_int = ((WR && (wr_addr == 7'd127)) || WR_done); 
    5142    
    52        always @(posedge txclk) 
    53                if(reset) 
    54                        wr_addr <= 0; 
    55                else if (WR_done) 
    56                        wr_addr <= 0; 
    57                else if (WR)  
    58                        wr_addr <= wr_addr + 7'd1; 
     43   always @(posedge txclk) 
     44       if(reset) 
     45           wr_addr <= 0; 
     46       else if (WR_done) 
     47           wr_addr <= 0; 
     48       else if (WR)  
     49           wr_addr <= wr_addr + 7'd1; 
    5950                 
    60        always @(posedge txclk) 
    61                if(reset) 
    62                        which_ram_wr <= 0; 
    63                else if (wr_done_int)  
    64                        which_ram_wr <= which_ram_wr + 2'd1; 
     51   always @(posedge txclk) 
     52      if(reset) 
     53          which_ram_wr <= 0; 
     54      else if (wr_done_int)  
     55          which_ram_wr <= which_ram_wr + 2'd1; 
    6556         
    66        assign have_space = (nb_packets < 3'd3); 
     57   assign have_space = (nb_packets < 3'd3); 
    6758                 
    68        // Reader side 
    69        // short hand fifo 
    70        // rd_addr_final is what rd_addr is going to be next clock cycle 
    71        // which_ram_rd_final is what which_ram_rd is going to be next clock cycle 
    72        always @(posedge txclk)  dataout0 <= ram0[rd_addr_final]; 
    73        always @(posedge txclk)  dataout1 <= ram1[rd_addr_final]; 
    74        always @(posedge txclk)  dataout2 <= ram2[rd_addr_final]; 
    75        always @(posedge txclk)  dataout3 <= ram3[rd_addr_final]; 
     59   // Reader side 
     60   // short hand fifo 
     61   // rd_addr_final is what rd_addr is going to be next clock cycle 
     62   // which_ram_rd_final is what which_ram_rd is going to be next clock cycle 
     63   always @(posedge txclk)  dataout0 <= ram0[rd_addr_final]; 
     64   always @(posedge txclk)  dataout1 <= ram1[rd_addr_final]; 
     65   always @(posedge txclk)  dataout2 <= ram2[rd_addr_final]; 
     66   always @(posedge txclk)  dataout3 <= ram3[rd_addr_final]; 
    7667         
    77        assign dataout = (which_ram_rd_final[1]) ?  
    78                                                (which_ram_rd_final[0] ? dataout3 : dataout2) : 
    79                                                (which_ram_rd_final[0] ? dataout1 : dataout0); 
     68   assign dataout = (which_ram_rd_final[1]) ?  
     69                    (which_ram_rd_final[0] ? dataout3 : dataout2) : 
     70                    (which_ram_rd_final[0] ? dataout1 : dataout0); 
    8071 
    81        //RD_done is the only way to signal the end of one packet 
    82        assign rd_done_int = RD_done;    
     72   //RD_done is the only way to signal the end of one packet 
     73   assign rd_done_int = RD_done;    
    8374 
    84