Ignore:
Timestamp:
Apr 15, 2015, 4:02:12 PM (9 years ago)
Author:
cfuguet
Message:

reconf: dont test the locality of global to local requests.

  • This is to support segment reallocation.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/reconfiguration/modules/dspin_local_crossbar/caba/source/src/dspin_local_crossbar.cpp

    r976 r977  
    66  *
    77  * SOCLIB_LGPL_HEADER_BEGIN
    8   * 
     8  *
    99  * This file is part of SoCLib, GNU LGPLv2.1.
    10   * 
     10  *
    1111  * SoCLib is free software; you can redistribute it and/or modify it
    1212  * under the terms of the GNU Lesser General Public License as published
    1313  * by the Free Software Foundation; version 2.1 of the License.
    14   * 
     14  *
    1515  * SoCLib is distributed in the hope that it will be useful, but
    1616  * WITHOUT ANY WARRANTY; without even the implied warranty of
    1717  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1818  * Lesser General Public License for more details.
    19   * 
     19  *
    2020  * You should have received a copy of the GNU Lesser General Public
    2121  * License along with SoCLib; if not, write to the Free Software
     
    3939//                  constructor
    4040//////////////////////////////////////////////////////////
    41 tmpl(/**/)::DspinLocalCrossbar( sc_module_name       name, 
     41tmpl(/**/)::DspinLocalCrossbar( sc_module_name       name,
    4242                                const MappingTable   &mt,
    4343                                const size_t         x,
     
    123123        r_fifo_in  = (GenericFifo<internal_flit_t>*)
    124124        malloc(sizeof(GenericFifo<internal_flit_t>) * (m_local_inputs + 1));
    125        
     125
    126126        r_fifo_out = (GenericFifo<internal_flit_t>*)
    127127        malloc(sizeof(GenericFifo<internal_flit_t>) * (m_local_outputs + 1));
     
    179179    ////////////////////////////////////////////////////////////////////////////
    180180    tmpl(size_t)::route( sc_uint<flit_width> data,     // first flit
    181                          size_t              input )   // input port index 
     181                         size_t              input )   // input port index
    182182    {
    183183        size_t   output;   // selected output port
     
    185185        size_t   y_dest  = (size_t)(data >> m_y_shift) & m_y_mask;
    186186
    187         if ( (x_dest == m_local_x) and (y_dest == m_local_y) and
    188              (m_local_outputs > 0) )          // local dest
     187        // there are two types of local request:
     188        //  - when destination coordinates correspond to local coordinates
     189        //  - when there is a segment reallocation and the new host is local
     190        // to support the second case, the locality of the global-to-local
     191        // requests is not checked.
     192        bool local_dest = ((x_dest == m_local_x) and (y_dest == m_local_y)) or
     193                           (input == m_local_inputs);
     194
     195        if ( local_dest and (m_local_outputs > 0) )             // local dest
    189196        {
    190197            if ( m_use_routing_table )
     
    194201                {
    195202                    uint64_t address;
    196                     if (flit_width >= m_addr_width) 
     203                    if (flit_width >= m_addr_width)
    197204                        address = data>>(flit_width - m_addr_width);
    198                     else                         
     205                    else
    199206                        address = data<<(m_addr_width - flit_width);
    200207                    output = m_cmd_rt[ address ];
    201208                }
    202209                else
    203                 {   
     210                {
    204211                    uint32_t srcid = data >> m_l_shift;
    205212                    output = m_rsp_rt[ srcid ];
     
    209216            {
    210217                output = (size_t)(data >> m_l_shift) & m_l_mask;
    211  
     218
    212219                if ( output >= m_local_outputs )
    213220                {
     
    218225            }
    219226        }
    220         else                                                            // global dest
    221         {
    222             if ( input  == m_local_inputs )
    223             {
    224                 std::cout << "ERROR in DSPIN_LOCAL_CROSSBAR: " << name()
    225                           << " illegal global to global request" << std::endl;
    226                 exit(0);
    227             }
    228 
     227        else                                                    // global dest
     228        {
    229229            output = m_local_outputs;
    230230        }
     
    243243        const char* infsm_str[] = { "IDLE", "REQ", "ALLOC", "REQ_BC", "ALLOC_BC" };
    244244
    245         std::cout << "DSPIN_LOCAL_CROSSBAR " << name() << std::hex; 
     245        std::cout << "DSPIN_LOCAL_CROSSBAR " << name() << std::hex;
    246246
    247247        for( size_t i = 0 ; i <= m_local_inputs ; i++)  // loop on input ports
    248248        {
    249             std::cout << " / infsm[" << std::dec << i 
     249            std::cout << " / infsm[" << std::dec << i
    250250                      << "] = " << infsm_str[r_fsm_in[i].read()];
    251251        }
     
    257257                size_t in = r_index_out[out];
    258258                std::cout << " / in[" << in << "] -> out[" << out << "]";
    259             }   
     259            }
    260260        }
    261261        std::cout << std::endl;
     
    273273        // control signals for the input fifos
    274274        bool                fifo_in_write[m_local_inputs+1];
    275         bool                fifo_in_read[m_local_inputs+1];   
     275        bool                fifo_in_read[m_local_inputs+1];
    276276        internal_flit_t     fifo_in_wdata[m_local_inputs+1];
    277277
     
    281281        internal_flit_t     fifo_out_wdata[m_local_outputs+1];
    282282
    283         // reset 
    284         if ( p_resetn.read() == false ) 
    285         {
    286             for(size_t j = 0 ; j <= m_local_outputs ; j++) 
     283        // reset
     284        if ( p_resetn.read() == false )
     285        {
     286            for(size_t j = 0 ; j <= m_local_outputs ; j++)
    287287            {
    288288                r_alloc_out[j] = false;
     
    290290                r_fifo_out[j].init();
    291291            }
    292             for(size_t i = 0 ; i <= m_local_inputs ; i++) 
     292            for(size_t i = 0 ; i <= m_local_inputs ; i++)
    293293            {
    294294                r_index_in[i]  = 0;
     
    300300
    301301        // fifo_in signals default values
    302         for(size_t i = 0 ; i < m_local_inputs ; i++) 
    303         {
    304             fifo_in_read[i]        = false;   
     302        for(size_t i = 0 ; i < m_local_inputs ; i++)
     303        {
     304            fifo_in_read[i]        = false;
    305305            fifo_in_write[i]       = p_local_in[i].write.read();
    306306            fifo_in_wdata[i].data  = p_local_in[i].data.read();
     
    313313
    314314        // fifo_out signals default values
    315         for(size_t j = 0 ; j < m_local_outputs ; j++) 
     315        for(size_t j = 0 ; j < m_local_outputs ; j++)
    316316        {
    317317            fifo_out_read[j]  = p_local_out[j].read.read();
    318             fifo_out_write[j] = false; 
     318            fifo_out_write[j] = false;
    319319        }
    320320        fifo_out_read[m_local_outputs]  = p_global_out.read.read();
    321         fifo_out_write[m_local_outputs] = false;     
     321        fifo_out_write[m_local_outputs] = false;
    322322
    323323        // loop on the output ports:
     
    326326        for ( size_t j = 0 ; j <= m_local_outputs ; j++ )
    327327        {
    328             if( r_alloc_out[j].read() and (r_fifo_out[j].wok()) ) 
     328            if( r_alloc_out[j].read() and (r_fifo_out[j].wok()) )
    329329            {
    330330                get_out[j] = r_index_out[j].read();
    331331            }
    332332            else
    333             {                       
    334                 get_out[j] = 0xFFFFFFFF; 
    335             }
    336         }
    337 
    338         // loop on the input ports (including global input port, 
     333            {
     334                get_out[j] = 0xFFFFFFFF;
     335            }
     336        }
     337
     338        // loop on the input ports (including global input port,
    339339        // with the convention index[global] = m_local_inputs)
    340         // The port state is defined by r_fsm_in[i], r_index_in[i] 
     340        // The port state is defined by r_fsm_in[i], r_index_in[i]
    341341        // The req_in[i] computation uses the route() function.
    342342        // Both put_in[i] and req_in[i] depend on the input port state.
     
    351351                    if ( r_fifo_in[i].rok() ) // packet available in input fifo
    352352                    {
    353                         if ( is_broadcast(r_fifo_in[i].read().data ) and 
     353                        if ( is_broadcast(r_fifo_in[i].read().data ) and
    354354                             m_broadcast_supported )   // broadcast required
    355355                        {
     
    398398                    req_in[i]  = 0xFFFFFFFF;                // no request
    399399                    if ( r_fifo_in[i].read().eop and
    400                          r_fifo_in[i].rok() and 
     400                         r_fifo_in[i].rok() and
    401401                         (get_out[r_index_in[i].read()] == i) )  // last flit transfered
    402402                    {
     
    416416                    break;
    417417                }
    418                 case INFSM_ALLOC_BC:  // output port allocated         
     418                case INFSM_ALLOC_BC:  // output port allocated
    419419                {
    420420                    data_in[i] = r_fifo_in[i].read();
     
    422422                    req_in[i]  = 0xFFFFFFFF;                // no request
    423423
    424                     if ( r_fifo_in[i].rok() and 
     424                    if ( r_fifo_in[i].rok() and
    425425                         get_out[r_index_in[i].read()] == i )  // last flit transfered
    426426                    {
    427                         if ( not r_fifo_in[i].read().eop ) 
     427                        if ( not r_fifo_in[i].read().eop )
    428428                        {
    429429                            std::cout << "ERROR in DSPIN_LOCAL_CROSSBAR " << name()
     
    438438            } // end switch
    439439        } // end for input ports
    440                                    
    441         // loop on the output ports (including global output port, 
     440
     441        // loop on the output ports (including global output port,
    442442        // with the convention index[global] = m_local_outputs)
    443443        // The r_alloc_out[j] and r_index_out[j] computation
    444444        // implements the round-robin allocation policy.
    445445        // These two registers implement a 2*N states FSM.
    446         for( size_t j = 0 ; j <= m_local_outputs ; j++ ) 
     446        for( size_t j = 0 ; j <= m_local_outputs ; j++ )
    447447        {
    448448            if( not r_alloc_out[j].read() )  // not allocated: possible new allocation
    449449            {
    450                 for( size_t k = r_index_out[j].read() + 1 ; 
    451                      k <= (r_index_out[j].read() + m_local_inputs + 1) ; 
    452                      k++ ) 
    453                 { 
     450                for( size_t k = r_index_out[j].read() + 1 ;
     451                     k <= (r_index_out[j].read() + m_local_inputs + 1) ;
     452                     k++ )
     453                {
    454454                    size_t i = k % (m_local_inputs + 1);
    455455
    456                     if( req_in[i] == j ) 
     456                    if( req_in[i] == j )
    457457                    {
    458458                        r_alloc_out[j] = true;
     
    461461                    }
    462462                } // end loop on input ports
    463             } 
     463            }
    464464            else                            // allocated: possible desallocation
    465465            {
    466466                if ( data_in[r_index_out[j]].eop and
    467                      r_fifo_out[j].wok() and 
    468                      put_in[r_index_out[j]] ) 
     467                     r_fifo_out[j].wok() and
     468                     put_in[r_index_out[j]] )
    469469                {
    470470                    r_alloc_out[j] = false;
     
    474474
    475475        // loop on input ports :
    476         // fifo_in_read[i] computation 
     476        // fifo_in_read[i] computation
    477477        // (computed here because it depends on get_out[])
    478         for( size_t i = 0 ; i <= m_local_inputs ; i++ ) 
    479         {
    480             if ( (r_fsm_in[i].read() == INFSM_REQ) or 
     478        for( size_t i = 0 ; i <= m_local_inputs ; i++ )
     479        {
     480            if ( (r_fsm_in[i].read() == INFSM_REQ) or
    481481                 (r_fsm_in[i].read() == INFSM_ALLOC) or
    482482                 ((r_fsm_in[i].read() == INFSM_ALLOC_BC) and (r_index_in[i].read() == 0)))
     
    485485            }
    486486            if ( (r_fsm_in[i].read() == INFSM_IDLE) and
    487                  is_broadcast( r_fifo_in[i].read().data ) and 
    488                  m_broadcast_supported )   
     487                 is_broadcast( r_fifo_in[i].read().data ) and
     488                 m_broadcast_supported )
    489489            {
    490490                fifo_in_read[i] = true;
     
    495495        // The fifo_out_write[j] and fifo_out_wdata[j] computation
    496496        // implements the output port mux
    497         for( size_t j = 0 ; j <= m_local_outputs ; j++ ) 
     497        for( size_t j = 0 ; j <= m_local_outputs ; j++ )
    498498        {
    499499            if( r_alloc_out[j] )  // output port allocated
     
    505505
    506506        //  input FIFOs update
    507         for(size_t i = 0 ; i <= m_local_inputs ; i++) 
     507        for(size_t i = 0 ; i <= m_local_inputs ; i++)
    508508        {
    509509            r_fifo_in[i].update(fifo_in_read[i],
     
    514514        //  output FIFOs update
    515515        for(size_t j = 0 ; j <= m_local_outputs ; j++)
    516         { 
     516        {
    517517            r_fifo_out[j].update(fifo_out_read[j],
    518518                                 fifo_out_write[j],
     
    525525    {
    526526        // input ports
    527         for(size_t i = 0 ; i < m_local_inputs ; i++) 
     527        for(size_t i = 0 ; i < m_local_inputs ; i++)
    528528        {
    529529            p_local_in[i].read = r_fifo_in[i].wok();
     
    532532
    533533        // output ports
    534         for(size_t j = 0 ; j < m_local_outputs ; j++) 
     534        for(size_t j = 0 ; j < m_local_outputs ; j++)
    535535        {
    536536            p_local_out[j].write = r_fifo_out[j].rok();
Note: See TracChangeset for help on using the changeset viewer.