Ignore:
Timestamp:
Dec 31, 2013, 12:53:47 PM (10 years ago)
Author:
almaless
Message:

tested using ALMOS

Location:
branches/RWT/modules/vci_mem_cache/caba/source
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/RWT/modules/vci_mem_cache/caba/source/include/vci_mem_cache.h

    r604 r611  
    454454      uint32_t     m_cpt_update_cost;    // Number of (flits * distance) for UPDT
    455455
    456       uint32_t     m_cpt_m_inval;        // Number of requests causing M_INV
    457       uint32_t     m_cpt_m_inval_local;  // Number of local M_INV transactions
    458       uint32_t     m_cpt_m_inval_remote; // Number of remote M_INV transactions
    459       uint32_t     m_cpt_m_inval_cost;   // Number of (flits * distance) for M_INV
    460 
    461       uint32_t     m_cpt_br_inval;       // Number of BROADCAST INVAL
     456      uint32_t     m_cpt_minval;         // Number of requests causing M_INV
     457      uint32_t     m_cpt_minval_local;   // Number of local M_INV transactions
     458      uint32_t     m_cpt_minval_remote; // Number of remote M_INV transactions
     459      uint32_t     m_cpt_minval_cost;    // Number of (flits * distance) for M_INV
     460
     461      uint32_t     m_cpt_binval;         // Number of BROADCAST INVAL
    462462
    463463      uint32_t     m_cpt_cleanup_local;  // Number of local CLEANUP transactions
     
    583583      sc_in<bool>                                 p_clk;
    584584      sc_in<bool>                                 p_resetn;
     585      sc_in<bool>                                 p_irq;
    585586      soclib::caba::VciTarget<vci_param_int>      p_vci_tgt;
    586587      soclib::caba::VciInitiator<vci_param_ext>   p_vci_ixr;
     
    645646      uint32_t req_distance(uint32_t req_srcid);
    646647      bool is_local_req(uint32_t req_srcid);
     648      int  read_instrumentation(uint32_t regr, uint32_t & rdata);
    647649
    648650      // Component attributes
     
    685687      // broadcast address
    686688      uint32_t                           m_broadcast_boundaries;
     689
     690      // configuration interface constants
     691      const uint32_t m_config_addr_mask;
     692      const uint32_t m_config_regr_width;
     693      const uint32_t m_config_func_width;
     694      const uint32_t m_config_regr_idx_mask;
     695      const uint32_t m_config_func_idx_mask;
    687696
    688697      // Fifo between TGT_CMD fsm and READ fsm
  • branches/RWT/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp

    r604 r611  
    412412        m_broadcast_boundaries(0x7C1F),
    413413
     414        // CONFIG interface
     415        m_config_addr_mask((1<<12)-1),
     416
     417        m_config_regr_width(7),
     418        m_config_func_width(3),
     419        m_config_regr_idx_mask((1<<m_config_regr_width)-1),
     420        m_config_func_idx_mask((1<<m_config_func_width)-1),
     421
    414422        //  FIFOs
    415423        m_cmd_read_addr_fifo("m_cmd_read_addr_fifo", 4),
     
    677685    }
    678686
     687    /////////////////////////////////////////////////////
     688    tmpl(int)::read_instrumentation(uint32_t regr, uint32_t & rdata)
     689    /////////////////////////////////////////////////////
     690    {
     691        int error = 0;
     692
     693        switch(regr)
     694        {
     695            ///////////////////////////////////////////////////////
     696            //       DIRECT instrumentation registers            //
     697            // Registers of 32 bits and therefore only LO is     //
     698            // implemented.                                      //
     699            //                                                   //
     700            // The HI may be used in future implementations      //
     701            ///////////////////////////////////////////////////////
     702
     703            // LOCAL
     704
     705            case MEMC_LOCAL_READ_LO   : rdata = m_cpt_read_local        ; break;
     706            case MEMC_LOCAL_WRITE_LO  : rdata = m_cpt_write_flits_local ; break;
     707            case MEMC_LOCAL_LL_LO     : rdata = m_cpt_ll_local          ; break;
     708            case MEMC_LOCAL_SC_LO     : rdata = m_cpt_sc_local          ; break;
     709            case MEMC_LOCAL_CAS_LO    : rdata = m_cpt_cas_local         ; break;
     710            case MEMC_LOCAL_READ_HI   :
     711            case MEMC_LOCAL_WRITE_HI  :
     712            case MEMC_LOCAL_LL_HI     :
     713            case MEMC_LOCAL_SC_HI     :
     714            case MEMC_LOCAL_CAS_HI    : rdata = 0; break;
     715
     716            // REMOTE
     717
     718            case MEMC_REMOTE_READ_LO  : rdata = m_cpt_read_remote        ; break;
     719            case MEMC_REMOTE_WRITE_LO : rdata = m_cpt_write_flits_remote ; break;
     720            case MEMC_REMOTE_LL_LO    : rdata = m_cpt_ll_remote          ; break;
     721            case MEMC_REMOTE_SC_LO    : rdata = m_cpt_sc_remote          ; break;
     722            case MEMC_REMOTE_CAS_LO   : rdata = m_cpt_cas_remote         ; break;
     723            case MEMC_REMOTE_READ_HI  :
     724            case MEMC_REMOTE_WRITE_HI :
     725            case MEMC_REMOTE_LL_HI    :
     726            case MEMC_REMOTE_SC_HI    :
     727            case MEMC_REMOTE_CAS_HI   : rdata = 0; break;
     728
     729            // COST
     730
     731            case MEMC_COST_READ_LO    : rdata = m_cpt_read_cost ; break;
     732            case MEMC_COST_WRITE_LO   : rdata = m_cpt_write_cost; break;
     733            case MEMC_COST_LL_LO      : rdata = m_cpt_ll_cost   ; break;
     734            case MEMC_COST_SC_LO      : rdata = m_cpt_sc_cost   ; break;
     735            case MEMC_COST_CAS_LO     : rdata = m_cpt_cas_cost  ; break;
     736            case MEMC_COST_READ_HI    :
     737            case MEMC_COST_WRITE_HI   :
     738            case MEMC_COST_LL_HI      :
     739            case MEMC_COST_SC_HI      :
     740            case MEMC_COST_CAS_HI     : rdata = 0; break;
     741
     742            ///////////////////////////////////////////////////////
     743            //       COHERENCE instrumentation registers         //
     744            // Registers of 32 bits and therefore only LO is     //
     745            // implemented.                                      //
     746            //                                                   //
     747            // The HI may be used in future implementations      //
     748            ///////////////////////////////////////////////////////
     749
     750            // LOCAL
     751
     752            case MEMC_LOCAL_MUPDATE_LO  : rdata = m_cpt_update_local ; break;
     753            case MEMC_LOCAL_MINVAL_LO   : rdata = m_cpt_minval_local ; break;
     754            case MEMC_LOCAL_CLEANUP_LO  : rdata = m_cpt_cleanup_local; break;
     755            case MEMC_LOCAL_MUPDATE_HI  :
     756            case MEMC_LOCAL_MINVAL_HI   :
     757            case MEMC_LOCAL_CLEANUP_HI  : rdata = 0; break;
     758
     759            // REMOTE
     760
     761            case MEMC_REMOTE_MUPDATE_LO : rdata = m_cpt_update_remote ; break;
     762            case MEMC_REMOTE_MINVAL_LO  : rdata = m_cpt_minval_remote ; break;
     763            case MEMC_REMOTE_CLEANUP_LO : rdata = m_cpt_cleanup_remote; break;
     764            case MEMC_REMOTE_MUPDATE_HI :
     765            case MEMC_REMOTE_MINVAL_HI  :
     766            case MEMC_REMOTE_CLEANUP_HI : rdata = 0; break;
     767
     768            // COST
     769
     770            case MEMC_COST_MUPDATE_LO   : rdata = m_cpt_update_cost   ; break;
     771            case MEMC_COST_MINVAL_LO    : rdata = m_cpt_minval_cost   ; break;
     772            case MEMC_COST_CLEANUP_LO   : rdata = m_cpt_cleanup_cost  ; break;
     773            case MEMC_COST_MUPDATE_HI   :
     774            case MEMC_COST_MINVAL_HI    :
     775            case MEMC_COST_CLEANUP_HI   : rdata = 0; break;
     776
     777            // TOTAL
     778
     779            case MEMC_TOTAL_MUPDATE_LO  : rdata = m_cpt_update ; break;
     780            case MEMC_TOTAL_MINVAL_LO   : rdata = m_cpt_minval ; break;
     781            case MEMC_TOTAL_BINVAL_LO   : rdata = m_cpt_binval ; break;
     782            case MEMC_TOTAL_MUPDATE_HI  :
     783            case MEMC_TOTAL_MINVAL_HI   :
     784            case MEMC_TOTAL_BINVAL_HI   : rdata = 0; break;
     785
     786            // unknown register
     787
     788            default                     : error = 1;
     789        }
     790
     791        return error;
     792    }
    679793
    680794    //////////////////////////////////////////////////
     
    746860                << "[022] UPDT COST (FLITS * DIST)  = " << m_cpt_update_cost << std::endl
    747861                << std::endl
    748                 << "[023] REQUESTS TRIG. M_INV      = " << m_cpt_m_inval << std::endl
    749                 << "[024] LOCAL M_INV               = " << m_cpt_m_inval_local << std::endl
    750                 << "[025] REMOTE M_INV              = " << m_cpt_m_inval_remote << std::endl
    751                 << "[026] M_INV COST (FLITS * DIST) = " << m_cpt_m_inval_cost << std::endl
     862                << "[023] REQUESTS TRIG. M_INV      = " << m_cpt_minval << std::endl
     863                << "[024] LOCAL M_INV               = " << m_cpt_minval_local << std::endl
     864                << "[025] REMOTE M_INV              = " << m_cpt_minval_remote << std::endl
     865                << "[026] M_INV COST (FLITS * DIST) = " << m_cpt_minval_cost << std::endl
    752866                << std::endl
    753                 << "[027] BROADCAT INVAL            = " << m_cpt_br_inval << std::endl
     867                << "[027] BROADCAT INVAL            = " << m_cpt_binval << std::endl
    754868                << std::endl
    755869                << "[028] LOCAL CLEANUP             = " << m_cpt_cleanup_local << std::endl
     
    800914                << "[117] AV. REMOTE UPDT PER UP REQ = " << (double) m_cpt_update_remote / m_cpt_update << std::endl
    801915                << std::endl
    802                 << "[118] INVAL MULTICAST RATE  = " << (double) m_cpt_m_inval / m_cpt_cycles << std::endl
    803                 << "[119] AVE. INVAL PER M_INV  = " << (double) (m_cpt_m_inval_local + m_cpt_m_inval_remote) / m_cpt_m_inval << std::endl
    804                 << "[120] AV. LOC INV PER M_INV = " << (double) m_cpt_m_inval_local / m_cpt_m_inval << std::endl
    805                 << "[121] AV. REM INV PER M_INV = " << (double) m_cpt_m_inval_remote / m_cpt_m_inval << std::endl
     916                << "[118] INVAL MULTICAST RATE  = " << (double) m_cpt_minval / m_cpt_cycles << std::endl
     917                << "[119] AVE. INVAL PER M_INV  = " << (double) (m_cpt_minval_local + m_cpt_minval_remote) / m_cpt_minval << std::endl
     918                << "[120] AV. LOC INV PER M_INV = " << (double) m_cpt_minval_local / m_cpt_minval << std::endl
     919                << "[121] AV. REM INV PER M_INV = " << (double) m_cpt_minval_remote / m_cpt_minval << std::endl
    806920                << std::endl
    807                 << "[122] INVAL BROADCAST RATE  = " << (double) m_cpt_br_inval / m_cpt_cycles << std::endl
     921                << "[122] INVAL BROADCAST RATE  = " << (double) m_cpt_binval / m_cpt_cycles << std::endl
    808922                << "[123] WRITE DIRTY RATE      = " << (double) m_cpt_write_dirty / m_cpt_cycles << std::endl
    809923                << std::endl
     
    10251139            m_cpt_update_remote      = 0;
    10261140            m_cpt_update_cost        = 0;
    1027             m_cpt_m_inval            = 0;
    1028             m_cpt_m_inval_local      = 0;
    1029             m_cpt_m_inval_remote     = 0;
    1030             m_cpt_m_inval_cost       = 0;
    1031             m_cpt_br_inval           = 0;
     1141            m_cpt_minval            = 0;
     1142            m_cpt_minval_local      = 0;
     1143            m_cpt_minval_remote     = 0;
     1144            m_cpt_minval_cost       = 0;
     1145            m_cpt_binval           = 0;
    10321146            m_cpt_cleanup_local      = 0;
    10331147            m_cpt_cleanup_remote     = 0;
     
    13081422            case TGT_CMD_CONFIG:    // execute config request and return response
    13091423                {
     1424                    ///////////////////////////////////////////////////////////
     1425                    //  Decoding CONFIG interface commands                   //
     1426                    //                                                       //
     1427                    //  VCI ADDRESS                                          //
     1428                    //  ================================================     //
     1429                    //  GLOBAL | LOCAL | ... | FUNC_IDX | REGS_IDX | 00      //
     1430                    //   IDX   |  IDX  |     | (3 bits) | (7 bits) |         //
     1431                    //  ================================================     //
     1432                    //                                                       //
     1433                    //  For instrumentation : FUNC_IDX = 0b001               //
     1434                    //                                                       //
     1435                    //  REGS_IDX                                             //
     1436                    //  ============================================         //
     1437                    //       Z     |    Y      |    X     |   W              //
     1438                    //    (1 bit)  | (2 bits)  | (3 bits) | (1 bit)          //
     1439                    //  ============================================         //
     1440                    //                                                       //
     1441                    //  Z : DIRECT / COHERENCE                               //
     1442                    //  Y : SUBTYPE ( LOCAL, REMOTE, OTHER )                 //
     1443                    //  X : REGISTER INDEX                                   //
     1444                    //  W : HI / LO                                          //
     1445                    //                                                       //
     1446                    //  For configuration: FUNC_IDX = 0b000                  //
     1447                    //                                                       //
     1448                    //  REGS_IDX                                             //
     1449                    //  ============================================         //
     1450                    //             RESERVED             |    X     |         //
     1451                    //             (4 bits)             | (3 bits) |         //
     1452                    //  ============================================         //
     1453                    //                                                       //
     1454                    //  X : REGISTER INDEX                                   //
     1455                    //                                                       //
     1456                    //  For WRITE MISS error signaling: FUNC = 0x010         //
     1457                    //                                                       //
     1458                    //  REGS_IDX                                             //
     1459                    //  ============================================         //
     1460                    //             RESERVED             |    X     |         //
     1461                    //             (4 bits)             | (3 bits) |         //
     1462                    //  ============================================         //
     1463                    //                                                       //
     1464                    //  X : REGISTER INDEX                                   //
     1465                    //                                                       //
     1466                    ///////////////////////////////////////////////////////////
     1467
     1468                    addr_t addr_lsb = p_vci_tgt.address.read() &
     1469                                      m_config_addr_mask;
     1470
     1471                    addr_t cell = (addr_lsb / vci_param_int::B);
     1472
     1473                    size_t regr = cell &
     1474                                  m_config_regr_idx_mask;
     1475
     1476                    size_t func = (cell >> m_config_regr_width) &
     1477                                  m_config_func_idx_mask;
     1478
     1479                    bool     need_rsp;
     1480                    int      error; 
     1481                    uint32_t rdata = 0;         // default value
     1482                    uint32_t wdata = p_vci_tgt.wdata.read();
     1483
     1484                    switch(func)
     1485                    {
     1486                        // memory operation
     1487                        case MEMC_CONFIG:
     1488                        {
     1489                            if ((p_vci_tgt.cmd.read() == vci_param_int::CMD_READ)         // get lock
     1490                                    and (regr == MEMC_LOCK))
     1491                            {
     1492                                rdata            = (uint32_t) r_config_lock.read();
     1493                                need_rsp         = true;
     1494                                error            = 0;
     1495                                r_config_lock    = true;
     1496                            }
     1497                            else if ((p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)  // release lock
     1498                                    and (regr == MEMC_LOCK))
     1499                            {
     1500                                need_rsp      = true;
     1501                                error         = 0;
     1502                                r_config_lock = false;
     1503                            }
     1504                            else if ((p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)   // set addr_lo
     1505                                    and (regr == MEMC_ADDR_LO))
     1506                            {
     1507                                assert( ((wdata % (m_words * vci_param_int::B)) == 0) and
     1508                                        "VCI_MEM_CACHE CONFIG ERROR: The buffer must be aligned on a cache line");
     1509
     1510                                need_rsp         = true;
     1511                                error            = 0;
     1512                                r_config_address = (r_config_address.read() & 0xFFFFFFFF00000000LL) |
     1513                                    ((addr_t)wdata);
     1514                            }
     1515                            else if ((p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)   // set addr_hi
     1516                                    and (regr == MEMC_ADDR_HI))
     1517
     1518                            {
     1519                                need_rsp         = true;
     1520                                error            = 0;
     1521                                r_config_address = (r_config_address.read() & 0x00000000FFFFFFFFLL) |
     1522                                    (((addr_t) wdata) << 32);
     1523                            }
     1524                            else if ((p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)   // set buf_lines
     1525                                    and (regr == MEMC_BUF_LENGTH))
     1526                            {
     1527                                need_rsp         = true;
     1528                                error            = 0;
     1529                                size_t lines     = wdata / (m_words << 2);
     1530                                if (wdata % (m_words << 2)) lines++;
     1531                                r_config_cmd_lines = lines;
     1532                                r_config_rsp_lines = 0;
     1533                            }
     1534                            else if ((p_vci_tgt.cmd.read() == vci_param_int::CMD_WRITE)   // set cmd type
     1535                                    and (regr == MEMC_CMD_TYPE))
     1536                            {
     1537                                need_rsp         = false;
     1538                                error            = 0;
     1539                                r_config_cmd     = wdata;
     1540
     1541                                // prepare delayed response from CONFIG FSM
     1542                                r_config_srcid   = p_vci_tgt.srcid.read();
     1543                                r_config_trdid   = p_vci_tgt.trdid.read();
     1544                                r_config_pktid   = p_vci_tgt.pktid.read();
     1545                            }
     1546                            else
     1547                            {
     1548                                need_rsp         = true;
     1549                                error            = 1;
     1550                            }
     1551
     1552                            break;
     1553                        }
     1554
     1555                        // instrumentation registers
     1556                        case MEMC_INSTRM:
     1557                        {
     1558                            need_rsp = true;
     1559
     1560                            if (p_vci_tgt.cmd.read() == vci_param_int::CMD_READ)
     1561                            {
     1562                                error = read_instrumentation(regr, rdata);
     1563                            }
     1564                            else
     1565                            {
     1566                                error = 1;
     1567                            }
     1568
     1569                            break;
     1570                        }
     1571
     1572                        //unknown function
     1573                        default:
     1574                        {
     1575                            need_rsp = true;
     1576                            error    = 1;
     1577
     1578                            break;
     1579                        }
     1580                    }
     1581
     1582                    if (need_rsp)
     1583                    {
     1584                        // blocked if previous pending request to TGT_RSP FSM
     1585                        if (r_tgt_cmd_to_tgt_rsp_req.read()) break;
     1586
     1587                        r_tgt_cmd_to_tgt_rsp_srcid = p_vci_tgt.srcid.read();
     1588                        r_tgt_cmd_to_tgt_rsp_trdid = p_vci_tgt.trdid.read();
     1589                        r_tgt_cmd_to_tgt_rsp_pktid = p_vci_tgt.pktid.read();
     1590                        r_tgt_cmd_to_tgt_rsp_req   = true;
     1591                        r_tgt_cmd_to_tgt_rsp_error = error;
     1592                        r_tgt_cmd_to_tgt_rsp_rdata = rdata;
     1593                    }
     1594
     1595                    r_tgt_cmd_fsm = TGT_CMD_IDLE;
     1596
     1597#if DEBUG_MEMC_TGT_CMD
     1598                    if (m_debug)
     1599                        std::cout << "  <MEMC " << name() << " TGT_CMD_CONFIG> Configuration request:"
     1600                            << " address = " << std::hex << p_vci_tgt.address.read()
     1601                            << " / func = " << func
     1602                            << " / regr = " << regr
     1603                            << " / rdata = " << rdata
     1604                            << " / wdata = " << p_vci_tgt.wdata.read()
     1605                            << " / need_rsp = " << need_rsp
     1606                            << " / error = " << error << std::endl;
     1607#endif
     1608                    break;
     1609                }
     1610
     1611#if 0
     1612            case TGT_CMD_CONFIG:    // execute config request and return response
     1613                {
    13101614                    addr_t   seg_base = m_seg[m_seg_config]->baseAddress();
    13111615                    addr_t   address  = p_vci_tgt.address.read();
     
    14051709                    break;
    14061710                }
     1711#endif                         // #if 0
    14071712                //////////////////
    14081713            case TGT_CMD_READ:    // Push a read request into read fifo
     
    71917496                        if (is_local_req(m_config_to_cc_send_srcid_fifo.read()))
    71927497                        {
    7193                             m_cpt_m_inval_local++;
     7498                            m_cpt_minval_local++;
    71947499                        }
    71957500                        else
    71967501                        {
    7197                             m_cpt_m_inval_remote++;
    7198                             m_cpt_m_inval_cost += req_distance(m_config_to_cc_send_srcid_fifo.read());
     7502                            m_cpt_minval_remote++;
     7503                            m_cpt_minval_cost += req_distance(m_config_to_cc_send_srcid_fifo.read());
    71997504                        }
    72007505                        // </Activity Counters>
     
    72047509                    if(r_config_to_cc_send_multi_req.read()) r_config_to_cc_send_multi_req = false;
    72057510                    // <Activity Counters>
    7206                     m_cpt_m_inval++;
     7511                    m_cpt_minval++;
    72077512                    // </Activity Counters>
    72087513                    r_cc_send_fsm = CC_SEND_CONFIG_IDLE;
     
    72367541                    if(not p_dspin_m2p.read) break;
    72377542                    // <Activity Counters>
    7238                     m_cpt_br_inval++;
     7543                    m_cpt_binval++;
    72397544                    // </Activity Counters>
    72407545                    r_config_to_cc_send_brdcast_req = false;
     
    72587563                        if (is_local_req(m_xram_rsp_to_cc_send_srcid_fifo.read()))
    72597564                        {
    7260                             m_cpt_m_inval_local++;
     7565                            m_cpt_minval_local++;
    72617566                        }
    72627567                        else
    72637568                        {
    7264                             m_cpt_m_inval_remote++;
    7265                             m_cpt_m_inval_cost += req_distance(m_xram_rsp_to_cc_send_srcid_fifo.read());
     7569                            m_cpt_minval_remote++;
     7570                            m_cpt_minval_cost += req_distance(m_xram_rsp_to_cc_send_srcid_fifo.read());
    72667571                        }
    72677572                        // </Activity Counters>
     
    72717576                    if(r_xram_rsp_to_cc_send_multi_req.read()) r_xram_rsp_to_cc_send_multi_req = false;
    72727577                    // <Activity Counters>
    7273                     m_cpt_m_inval++;
     7578                    m_cpt_minval++;
    72747579                    // </Activity Counters>
    72757580                    r_cc_send_fsm = CC_SEND_XRAM_RSP_IDLE;
     
    73037608                    if(not p_dspin_m2p.read) break;
    73047609                    // <Activity Counters>
    7305                     m_cpt_br_inval++;
     7610                    m_cpt_binval++;
    73067611                    // </Activity Counters>
    73077612                    r_xram_rsp_to_cc_send_brdcast_req = false;
     
    73887693
    73897694                    // <Activity Counters>
    7390                     m_cpt_br_inval++;
     7695                    m_cpt_binval++;
    73917696                    // </Activity Counters>
    73927697
     
    74777782                    if(not p_dspin_m2p.read) break;
    74787783                    // <Activity Counters>
    7479                     m_cpt_br_inval++;
     7784                    m_cpt_binval++;
    74807785                    // </Activity Counters>
    74817786
Note: See TracChangeset for help on using the changeset viewer.