Changeset 1036


Ignore:
Timestamp:
Mar 1, 2016, 6:01:20 PM (8 years ago)
Author:
alain
Message:

Introducing a new priority scheme to access the directory:
Give a fixed higher priority to the XRAM_RSP FSM.

Location:
trunk/modules/vci_mem_cache/caba/source
Files:
2 edited

Legend:

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

    r1035 r1036  
    972972
    973973      sc_signal<int>      r_alloc_dir_fsm;
     974      sc_signal<int>      r_alloc_dir_last;
    974975      sc_signal<unsigned> r_alloc_dir_reset_cpt;
    975976
  • trunk/modules/vci_mem_cache/caba/source/src/vci_mem_cache.cpp

    r1035 r1036  
    10181018            r_cleanup_fsm    = CLEANUP_IDLE;
    10191019            r_alloc_dir_fsm  = ALLOC_DIR_RESET;
     1020            r_alloc_dir_last = ALLOC_DIR_READ;
    10201021            r_alloc_heap_fsm = ALLOC_HEAP_RESET;
    10211022            r_alloc_trt_fsm  = ALLOC_TRT_READ;
     
    24642465            case CONFIG_HEAP_SCAN: // scan HEAP and send inval to CC_SEND FSM
    24652466            {
     2467                assert((r_alloc_heap_fsm.read() == ALLOC_HEAP_CONFIG) and
     2468                "MEMC ERROR in CONFIG_HEAP_SCAN state: bad HEAP allocation");
     2469
    24662470                HeapEntry entry = m_heap.read(r_config_heap_next.read());
    24672471                bool last_copy = (entry.next == r_config_heap_next.read());
     
    24732477
    24742478                assert ( (m_config_to_cc_send_inst_fifo.wok()) and
    2475                 "MEMC ERROR in CONFIG_HEAP_SCAN: The m_config_to_cc_send fifo should never overflow");
     2479                "MEMC ERROR in CONFIG_HEAP_SCAN: The m_config_to_cc_send fifo overflow");
    24762480
    24772481                r_config_heap_next = entry.next;
     
    25022506            case CONFIG_HEAP_LAST:  // HEAP housekeeping
    25032507            {
     2508                assert((r_alloc_heap_fsm.read() == ALLOC_HEAP_CONFIG) and
     2509                "MEMC ERROR in CONFIG_HEAP_LAST state: bad HEAP allocation");
     2510
    25042511                size_t free_pointer = m_heap.next_free_ptr();
    25052512                HeapEntry last_entry;
     
    25702577                    {
    25712578                        std::cout << "  <MEMC " << name() << " READ_IDLE> Read request"
    2572                             << " : address = " << std::hex << m_cmd_read_addr_fifo.read()
    2573                             << " / srcid = " << m_cmd_read_srcid_fifo.read()
    2574                             << " / trdid = " << m_cmd_read_trdid_fifo.read()
    2575                             << " / pktid = " << m_cmd_read_pktid_fifo.read()
    2576                             << " / nwords = " << std::dec << m_cmd_read_length_fifo.read() << std::endl;
     2579                                  << " : address = " << std::hex << m_cmd_read_addr_fifo.read()
     2580                                  << " / srcid = " << m_cmd_read_srcid_fifo.read()
     2581                                  << " / trdid = " << m_cmd_read_trdid_fifo.read()
     2582                                  << " / pktid = " << m_cmd_read_pktid_fifo.read()
     2583                                  << " / nwords = " << std::dec << m_cmd_read_length_fifo.read()
     2584                                  << std::endl;
    25772585                    }
    25782586#endif
     
    25922600                if (m_debug)
    25932601                {
    2594                     std::cout << "  <MEMC " << name() << " READ_DIR_REQ> Requesting DIR lock " << std::endl;
     2602                    std::cout << "  <MEMC " << name()
     2603                              << " READ_DIR_REQ> Requesting DIR lock " << std::endl;
    25952604                }
    25962605#endif
     
    26472656                {
    26482657                    std::cout << "  <MEMC " << name() << " READ_DIR_LOCK> Accessing directory: "
    2649                         << " address = " << std::hex << m_cmd_read_addr_fifo.read()
    2650                         << " / hit = " << std::dec << entry.valid
    2651                         << " / count = " <<std::dec << entry.count
    2652                         << " / is_cnt = " << entry.is_cnt;
     2658                              << " address = " << std::hex << m_cmd_read_addr_fifo.read()
     2659                              << " / hit = " << std::dec << entry.valid
     2660                              << " / count = " <<std::dec << entry.count
     2661                              << " / is_cnt = " << entry.is_cnt;
    26532662                    if ((m_cmd_read_pktid_fifo.read() & 0x7) == TYPE_LL)
    26542663                    {
     
    26652674            //////////////////
    26662675            case READ_DIR_HIT:    //  read data in cache & update the directory
    2667             //  we enter this state in 3 cases:
    2668             //  - the read request is uncachable
    2669             //  - the cache line is in counter mode
    2670             //  - the cache line is valid but not replicated
     2676                                  //  we enter this state in 3 cases:
     2677                                  //  - the read request is uncachable
     2678                                  //  - the cache line is in counter mode
     2679                                  //  - the cache line is valid but not replicated
    26712680            {
    26722681                assert((r_alloc_dir_fsm.read() == ALLOC_DIR_READ) and
     
    27242733                {
    27252734                    std::cout << "  <MEMC " << name() << " READ_DIR_HIT> Update directory entry:"
    2726                         << " addr = " << std::hex << m_cmd_read_addr_fifo.read()
    2727                         << " / set = " << std::dec << set
    2728                         << " / way = " << way
    2729                         << " / owner_id = " << std::hex << entry.owner.srcid
    2730                         << " / owner_ins = " << std::dec << entry.owner.inst
    2731                         << " / count = " << entry.count
    2732                         << " / is_cnt = " << entry.is_cnt << std::endl;
     2735                              << " addr = " << std::hex << m_cmd_read_addr_fifo.read()
     2736                              << " / set = " << std::dec << set
     2737                              << " / way = " << way
     2738                              << " / owner_id = " << std::hex << entry.owner.srcid
     2739                              << " / owner_ins = " << std::dec << entry.owner.inst
     2740                              << " / count = " << entry.count
     2741                              << " / is_cnt = " << entry.is_cnt << std::endl;
    27332742                }
    27342743#endif
     
    27402749            case READ_HEAP_REQ:    // Get the lock to the HEAP directory
    27412750            {
     2751                assert((r_alloc_dir_fsm.read() == ALLOC_DIR_READ) and
     2752                        "MEMC ERROR in READ_HEAP_REQ state: Bad DIR allocation");
     2753
    27422754                if (r_alloc_heap_fsm.read() == ALLOC_HEAP_READ)
    27432755                {
     
    27492761                {
    27502762                    std::cout << "  <MEMC " << name() << " READ_HEAP_REQ>"
    2751                         << " Requesting HEAP lock " << std::endl;
     2763                              << " Requesting HEAP lock " << std::endl;
    27522764                }
    27532765#endif
     
    27572769            ////////////////////
    27582770            case READ_HEAP_LOCK:   // read data in cache, update the directory
    2759             // and prepare the HEAP update
    2760             {
    2761                 if (r_alloc_heap_fsm.read() == ALLOC_HEAP_READ)
    2762                 {
    2763                     // enter counter mode when we reach the limit of copies or the heap is full
    2764                     bool go_cnt = (r_read_count.read() >= m_max_copies) or m_heap.is_full();
    2765 
    2766                     // read data in the cache
    2767                     size_t set = m_y[(addr_t) (m_cmd_read_addr_fifo.read())];
    2768                     size_t way = r_read_way.read();
    2769 
    2770                     m_cache_data.read_line(way, set, r_read_data);
    2771 
    2772                     // update the cache directory
    2773                     DirectoryEntry entry;
    2774                     entry.valid  = true;
    2775                     entry.is_cnt = go_cnt;
    2776                     entry.dirty  = r_read_dirty.read();
    2777                     entry.tag    = r_read_tag.read();
    2778                     entry.lock   = r_read_lock.read();
    2779                     entry.count  = r_read_count.read() + 1;
    2780 
    2781                     if (not go_cnt) // Not entering counter mode
    2782                     {
    2783                         entry.owner.srcid = r_read_copy.read();
    2784                         entry.owner.inst  = r_read_copy_inst.read();
    2785                         entry.ptr         = m_heap.next_free_ptr();   // set pointer on the heap
    2786                     }
    2787                     else    // Entering Counter mode
    2788                     {
    2789                         entry.owner.srcid = 0;
    2790                         entry.owner.inst  = false;
    2791                         entry.ptr         = 0;
    2792                     }
    2793 
    2794                     m_cache_directory.write(set, way, entry);
    2795 
    2796                     // prepare the heap update (add an entry, or clear the linked list)
    2797                     if (not go_cnt)      // not switching to counter mode
    2798                     {
    2799                         // We test if the next free entry in the heap is the last
    2800                         HeapEntry heap_entry = m_heap.next_free_entry();
    2801                         r_read_next_ptr      = heap_entry.next;
    2802                         r_read_last_free     = (heap_entry.next == m_heap.next_free_ptr());
    2803 
    2804                         r_read_fsm = READ_HEAP_WRITE; // add an entry in the HEAP
    2805                     }
    2806                     else // switching to counter mode
    2807                     {
    2808                         if (r_read_count.read() > 1) // heap must be cleared
     2771                                   // and prepare the HEAP update
     2772            {
     2773                assert((r_alloc_dir_fsm.read() == ALLOC_DIR_READ) and
     2774                        "MEMC ERROR in READ_HEAP_LOCK state: Bad DIR allocation");
     2775
     2776                assert((r_alloc_heap_fsm.read() == ALLOC_HEAP_READ) and
     2777                        "MEMC ERROR in READ_HEAP_LOCK state: Bad HEAP allocation");
     2778
     2779                // enter counter mode when we reach the limit of copies or the heap is full
     2780                bool go_cnt = (r_read_count.read() >= m_max_copies) or m_heap.is_full();
     2781
     2782                // read data in the cache
     2783                size_t set = m_y[(addr_t) (m_cmd_read_addr_fifo.read())];
     2784                size_t way = r_read_way.read();
     2785
     2786                m_cache_data.read_line(way, set, r_read_data);
     2787
     2788                // update the cache directory
     2789                DirectoryEntry entry;
     2790                entry.valid  = true;
     2791                entry.is_cnt = go_cnt;
     2792                entry.dirty  = r_read_dirty.read();
     2793                entry.tag    = r_read_tag.read();
     2794                entry.lock   = r_read_lock.read();
     2795                entry.count  = r_read_count.read() + 1;
     2796
     2797                if (not go_cnt) // Not entering counter mode
     2798                {
     2799                    entry.owner.srcid = r_read_copy.read();
     2800                    entry.owner.inst  = r_read_copy_inst.read();
     2801                    entry.ptr         = m_heap.next_free_ptr();   // set pointer on the heap
     2802                }
     2803                else    // Entering Counter mode
     2804                {
     2805                    entry.owner.srcid = 0;
     2806                    entry.owner.inst  = false;
     2807                    entry.ptr         = 0;
     2808                }
     2809
     2810                m_cache_directory.write(set, way, entry);
     2811
     2812                // prepare the heap update (add an entry, or clear the linked list)
     2813                if (not go_cnt)      // not switching to counter mode
     2814                {
     2815                    // We test if the next free entry in the heap is the last
     2816                    HeapEntry heap_entry = m_heap.next_free_entry();
     2817                    r_read_next_ptr      = heap_entry.next;
     2818                    r_read_last_free     = (heap_entry.next == m_heap.next_free_ptr());
     2819
     2820                    r_read_fsm = READ_HEAP_WRITE; // add an entry in the HEAP
     2821                }
     2822                else // switching to counter mode
     2823                {
     2824                    if (r_read_count.read() > 1) // heap must be cleared
     2825                    {
     2826                        HeapEntry next_entry = m_heap.read(r_read_ptr.read());
     2827                        r_read_next_ptr      = m_heap.next_free_ptr();
     2828                        m_heap.write_free_ptr(r_read_ptr.read());
     2829
     2830                        if (next_entry.next == r_read_ptr.read())    // last entry
    28092831                        {
    2810                             HeapEntry next_entry = m_heap.read(r_read_ptr.read());
    2811                             r_read_next_ptr      = m_heap.next_free_ptr();
    2812                             m_heap.write_free_ptr(r_read_ptr.read());
    2813 
    2814                             if (next_entry.next == r_read_ptr.read())    // last entry
    2815                             {
    2816                                 r_read_fsm = READ_HEAP_LAST;    // erase the entry
    2817                             }
    2818                             else                                        // not the last entry
    2819                             {
    2820                                 r_read_ptr = next_entry.next;
    2821                                 r_read_fsm = READ_HEAP_ERASE;   // erase the list
    2822                             }
     2832                            r_read_fsm = READ_HEAP_LAST;    // erase the entry
    28232833                        }
    2824                         else  // the heap is not used / nothing to do
     2834                        else                                        // not the last entry
    28252835                        {
    2826                             r_read_fsm = READ_RSP;
     2836                            r_read_ptr = next_entry.next;
     2837                            r_read_fsm = READ_HEAP_ERASE;   // erase the list
    28272838                        }
    28282839                    }
     2840                    else  // the heap is not used / nothing to do
     2841                    {
     2842                        r_read_fsm = READ_RSP;
     2843                    }
     2844                }
    28292845
    28302846#if DEBUG_MEMC_READ
    2831                     if (m_debug)
    2832                     {
    2833                         std::cout << "  <MEMC " << name() << " READ_HEAP_LOCK> Update directory:"
    2834                             << " tag = " << std::hex << entry.tag
    2835                             << " set = " << std::dec << set
    2836                             << " way = " << way
    2837                             << " count = " << entry.count
    2838                             << " is_cnt = " << entry.is_cnt << std::endl;
    2839                     }
    2840 #endif
    2841                 }
    2842                 else
    2843                 {
    2844                     std::cout << "VCI_MEM_CACHE ERROR " << name() << " READ_HEAP_LOCK"
    2845                         << "Bad HEAP allocation"   << std::endl;
    2846                     exit(0);
    2847                 }
     2847                if (m_debug)
     2848                {
     2849                    std::cout << "  <MEMC " << name() << " READ_HEAP_LOCK> Update directory:"
     2850                              << " tag = " << std::hex << entry.tag
     2851                              << " set = " << std::dec << set
     2852                              << " way = " << way
     2853                              << " count = " << entry.count
     2854                              << " is_cnt = " << entry.is_cnt << std::endl;
     2855                }
     2856#endif
    28482857                break;
    28492858            }
     
    28512860            case READ_HEAP_WRITE:       // add an entry in the heap
    28522861            {
    2853                 if (r_alloc_heap_fsm.read() == ALLOC_HEAP_READ)
    2854                 {
    2855                     HeapEntry heap_entry;
    2856                     heap_entry.owner.srcid = m_cmd_read_srcid_fifo.read();
    2857                     heap_entry.owner.inst  = ((m_cmd_read_pktid_fifo.read() & 0x2) != 0);
    2858 
    2859                     if (r_read_count.read() == 1)  // creation of a new linked list
    2860                     {
    2861                         heap_entry.next = m_heap.next_free_ptr();
    2862                     }
    2863                     else                         // head insertion in existing list
    2864                     {
    2865                         heap_entry.next = r_read_ptr.read();
    2866                     }
    2867                     m_heap.write_free_entry(heap_entry);
    2868                     m_heap.write_free_ptr(r_read_next_ptr.read());
    2869                     if (r_read_last_free.read())
    2870                     {
    2871                         m_heap.set_full();
    2872                     }
    2873 
    2874                     r_read_fsm = READ_RSP;
     2862                assert((r_alloc_heap_fsm.read() == ALLOC_HEAP_READ) and
     2863                        "MEMC ERROR in READ_HEAP_WRITE state: Bad HEAP allocation");
     2864
     2865                HeapEntry heap_entry;
     2866                heap_entry.owner.srcid = m_cmd_read_srcid_fifo.read();
     2867                heap_entry.owner.inst  = ((m_cmd_read_pktid_fifo.read() & 0x2) != 0);
     2868
     2869                if (r_read_count.read() == 1)  // creation of a new linked list
     2870                {
     2871                    heap_entry.next = m_heap.next_free_ptr();
     2872                }
     2873                else                         // head insertion in existing list
     2874                {
     2875                    heap_entry.next = r_read_ptr.read();
     2876                }
     2877                m_heap.write_free_entry(heap_entry);
     2878                m_heap.write_free_ptr(r_read_next_ptr.read());
     2879                if (r_read_last_free.read())
     2880                {
     2881                    m_heap.set_full();
     2882                }
     2883
     2884                r_read_fsm = READ_RSP;
    28752885
    28762886#if DEBUG_MEMC_READ
    2877                     if (m_debug)
    2878                     {
    2879                         std::cout << "  <MEMC " << name() << " READ_HEAP_WRITE> Add an entry in the heap:"
    2880                             << " owner_id = " << std::hex << heap_entry.owner.srcid
    2881                             << " owner_ins = " << std::dec << heap_entry.owner.inst << std::endl;
    2882                     }
    2883 #endif
    2884                 }
    2885                 else
    2886                 {
    2887                     std::cout << "VCI_MEM_CACHE ERROR " << name() << " READ_HEAP_WRITE"
    2888                         << "Bad HEAP allocation" << std::endl;
    2889                     exit(0);
    2890                 }
     2887                if (m_debug)
     2888                {
     2889                    std::cout << "  <MEMC " << name() << " READ_HEAP_WRITE> Add an entry in the heap:"
     2890                              << " owner_id = " << std::hex << heap_entry.owner.srcid
     2891                              << " owner_ins = " << std::dec << heap_entry.owner.inst << std::endl;
     2892                }
     2893#endif
    28912894                break;
    28922895            }
     
    28942897            case READ_HEAP_ERASE:
    28952898            {
    2896                 if (r_alloc_heap_fsm.read() == ALLOC_HEAP_READ)
    2897                 {
    2898                     HeapEntry next_entry = m_heap.read(r_read_ptr.read());
    2899                     if (next_entry.next == r_read_ptr.read())
    2900                     {
    2901                         r_read_fsm = READ_HEAP_LAST;
    2902                     }
    2903                     else
    2904                     {
    2905                         r_read_ptr = next_entry.next;
    2906                         r_read_fsm = READ_HEAP_ERASE;
    2907                     }
     2899                assert((r_alloc_heap_fsm.read() == ALLOC_HEAP_READ) and
     2900                        "MEMC ERROR in READ_HEAP_ERASE state: Bad HEAP allocation");
     2901
     2902                HeapEntry next_entry = m_heap.read(r_read_ptr.read());
     2903                if (next_entry.next == r_read_ptr.read())
     2904                {
     2905                    r_read_fsm = READ_HEAP_LAST;
    29082906                }
    29092907                else
    29102908                {
    2911                     std::cout << "VCI_MEM_CACHE ERROR " << name() << " READ_HEAP_ERASE"
    2912                         << "Bad HEAP allocation" << std::endl;
    2913                     exit(0);
     2909                    r_read_ptr = next_entry.next;
     2910                    r_read_fsm = READ_HEAP_ERASE;
    29142911                }
    29152912                break;
     
    29192916            case READ_HEAP_LAST:
    29202917            {
    2921                 if (r_alloc_heap_fsm.read() == ALLOC_HEAP_READ)
    2922                 {
    2923                     HeapEntry last_entry;
    2924                     last_entry.owner.srcid = 0;
    2925                     last_entry.owner.inst  = false;
    2926 
    2927                     if (m_heap.is_full())
    2928                     {
    2929                         last_entry.next = r_read_ptr.read();
    2930                         m_heap.unset_full();
    2931                     }
    2932                     else
    2933                     {
    2934                         last_entry.next = r_read_next_ptr.read();
    2935                     }
    2936                     m_heap.write(r_read_ptr.read(),last_entry);
    2937                     r_read_fsm = READ_RSP;
     2918                assert((r_alloc_heap_fsm.read() == ALLOC_HEAP_READ) and
     2919                        "MEMC ERROR in READ_HEAP_LAST state: Bad HEAP allocation");
     2920
     2921                HeapEntry last_entry;
     2922                last_entry.owner.srcid = 0;
     2923                last_entry.owner.inst  = false;
     2924
     2925                if (m_heap.is_full())
     2926                {
     2927                    last_entry.next = r_read_ptr.read();
     2928                    m_heap.unset_full();
    29382929                }
    29392930                else
    29402931                {
    2941                     std::cout << "VCI_MEM_CACHE ERROR " << name() << " READ_HEAP_LAST"
    2942                         << "Bad HEAP allocation" << std::endl;
    2943                     exit(0);
    2944                 }
     2932                    last_entry.next = r_read_next_ptr.read();
     2933                }
     2934                m_heap.write(r_read_ptr.read(),last_entry);
     2935                r_read_fsm = READ_RSP;
    29452936                break;
    29462937            }
     
    30062997                    {
    30072998                        std::cout << "  <MEMC " << name() << " READ_TRT_LOCK> Check TRT:"
    3008                             << " hit_read = " << hit_read
    3009                             << " / hit_write = " << hit_write
    3010                             << " / full = " << !wok << std::endl;
     2999                                  << " hit_read = " << hit_read
     3000                                  << " / hit_write = " << hit_write
     3001                                  << " / full = " << !wok << std::endl;
    30113002                    }
    30123003#endif
     
    30173008            case READ_TRT_SET: // register get transaction in TRT
    30183009            {
    3019                 if (r_alloc_trt_fsm.read() == ALLOC_TRT_READ)
    3020                 {
    3021                     m_trt.set(r_read_trt_index.read(),
    3022                             true,      // GET
    3023                             m_nline[(addr_t) (m_cmd_read_addr_fifo.read())],
    3024                             m_cmd_read_srcid_fifo.read(),
    3025                             m_cmd_read_trdid_fifo.read(),
    3026                             m_cmd_read_pktid_fifo.read(),
    3027                             true,      // proc read
    3028                             m_cmd_read_length_fifo.read(),
    3029                             m_x[(addr_t) (m_cmd_read_addr_fifo.read())],
    3030                             std::vector<be_t> (m_words, 0),
    3031                             std::vector<data_t> (m_words, 0),
    3032                             r_read_ll_key.read());
     3010                assert((r_alloc_trt_fsm.read() == ALLOC_TRT_READ) and
     3011                        "MEMC ERROR in READ_TRT_SET state: Bad TRT allocation");
     3012
     3013                m_trt.set(r_read_trt_index.read(),
     3014                          true,      // GET
     3015                          m_nline[(addr_t) (m_cmd_read_addr_fifo.read())],
     3016                          m_cmd_read_srcid_fifo.read(),
     3017                          m_cmd_read_trdid_fifo.read(),
     3018                          m_cmd_read_pktid_fifo.read(),
     3019                          true,      // proc read
     3020                          m_cmd_read_length_fifo.read(),
     3021                          m_x[(addr_t) (m_cmd_read_addr_fifo.read())],
     3022                          std::vector<be_t> (m_words, 0),
     3023                          std::vector<data_t> (m_words, 0),
     3024                          r_read_ll_key.read());
    30333025#if DEBUG_MEMC_READ
    3034                     if (m_debug)
    3035                     {
    3036                         std::cout << "  <MEMC " << name() << " READ_TRT_SET> Set a GET in TRT:"
    3037                                   << " address = " << std::hex << m_cmd_read_addr_fifo.read()
    3038                                   << " / srcid = " << std::hex << m_cmd_read_srcid_fifo.read()
    3039                                   << std::endl;
    3040                     }
    3041 #endif
    3042                     r_read_fsm = READ_TRT_REQ;
    3043                 }
     3026                if (m_debug)
     3027                {
     3028                    std::cout << "  <MEMC " << name() << " READ_TRT_SET> Set a GET in TRT:"
     3029                              << " address = " << std::hex << m_cmd_read_addr_fifo.read()
     3030                              << " / srcid = " << std::hex << m_cmd_read_srcid_fifo.read()
     3031                              << std::endl;
     3032                }
     3033#endif
     3034                r_read_fsm = READ_TRT_REQ;
    30443035                break;
    30453036            }
     
    32533244            {
    32543245                assert((r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE) and
    3255                         "MEMC ERROR in ALLOC_DIR_LOCK state: Bad DIR allocation");
     3246                        "MEMC ERROR in WRITE_DIR_LOCK state: Bad DIR allocation");
    32563247
    32573248                size_t way = 0;
     
    32963287            ///////////////////
    32973288            case WRITE_DIR_HIT:    // update the cache directory with Dirty bit
    3298             // and update data cache
     3289                                   // and update data cache
    32993290            {
    33003291                assert((r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE) and
    3301                         "MEMC ERROR in ALLOC_DIR_HIT state: Bad DIR allocation");
     3292                        "MEMC ERROR in WRITE_DIR_HIT state: Bad DIR allocation");
    33023293
    33033294                DirectoryEntry entry;
     
    33243315                // no_update is true when there is no need for coherence transaction
    33253316                bool no_update = ((r_write_count.read() == 0) or
    3326                         (owner and (r_write_count.read() == 1) and
    3327                          ((r_write_pktid.read() & 0x7) != TYPE_SC)));
     3317                                 (owner and (r_write_count.read() == 1) and
     3318                                 ((r_write_pktid.read() & 0x7) != TYPE_SC)));
    33283319
    33293320                // write data in the cache if no coherence transaction
     
    33333324                    if ((r_write_pktid.read() & 0x7) == TYPE_SC)
    33343325                    {
    3335                         m_llsc_table.sc(r_write_address.read(),
    3336                                 r_write_sc_key.read());
     3326                        m_llsc_table.sc(r_write_address.read(), r_write_sc_key.read());
    33373327                    }
    33383328
     
    33403330                    {
    33413331                        m_cache_data.write(way,
    3342                                 set,
    3343                                 word,
    3344                                 r_write_data[word].read(),
    3345                                 r_write_be[word].read());
     3332                                           set,
     3333                                           word,
     3334                                           r_write_data[word].read(),
     3335                                           r_write_be[word].read());
    33463336                    }
    33473337                }
     
    33593349                {
    33603350                    if (!r_write_to_cc_send_multi_req.read() and
    3361                             !r_write_to_cc_send_brdcast_req.read())
     3351                        !r_write_to_cc_send_brdcast_req.read())
    33623352                    {
    33633353                        r_write_fsm = WRITE_UPT_LOCK;
     
    33923382            case WRITE_UPT_LOCK:  // Try to register the update request in UPT
    33933383            {
     3384                assert((r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE) and
     3385                        "MEMC ERROR in WRITE_UPT_LOCK state: Bad DIR allocation");
     3386
    33943387                if (r_alloc_upt_fsm.read() == ALLOC_UPT_WRITE)
    33953388                {
     
    34053398
    34063399                    wok = m_upt.set(true,  // it's an update transaction
    3407                             false, // it's not a broadcast
    3408                             true,  // response required
    3409                             false, // no acknowledge required
    3410                             srcid,
    3411                             trdid,
    3412                             pktid,
    3413                             nline,
    3414                             nb_copies,
    3415                             index);
     3400                                    false, // it's not a broadcast
     3401                                    true,  // response required
     3402                                    false, // no acknowledge required
     3403                                    srcid,
     3404                                    trdid,
     3405                                    pktid,
     3406                                    nline,
     3407                                    nb_copies,
     3408                                    index);
    34163409
    34173410                    if (wok) // write data in cache
     
    34193412                        if ((r_write_pktid.read() & 0x7) == TYPE_SC)
    34203413                        {
    3421                             m_llsc_table.sc(r_write_address.read(),
    3422                                     r_write_sc_key.read());
     3414                            m_llsc_table.sc(r_write_address.read(), r_write_sc_key.read());
    34233415                        }
    34243416
     
    34263418                        {
    34273419                            m_cache_data.write(way,
    3428                                     set,
    3429                                     word,
    3430                                     r_write_data[word].read(),
    3431                                     r_write_be[word].read());
     3420                                               set,
     3421                                               word,
     3422                                               r_write_data[word].read(),
     3423                                               r_write_be[word].read());
    34323424                        }
    34333425                    }
     
    34593451                    {
    34603452                        std::cout << "  <MEMC " << name()
    3461                             << " WRITE_UPT_HEAP_LOCK> Get acces to the HEAP" << std::endl;
     3453                                  << " WRITE_UPT_HEAP_LOCK> Get acces to the HEAP"
     3454                                  << std::endl;
    34623455                    }
    34633456#endif
     
    34693462            //////////////////
    34703463            case WRITE_UPT_REQ:    // prepare the coherence transaction for the CC_SEND FSM
    3471             // and write the first copy in the FIFO
    3472             // send the request if only one copy
     3464                                   // and write the first copy in the FIFO
     3465                                   // send the request if only one copy
    34733466            {
    34743467                assert(not r_write_to_cc_send_multi_req.read() and
     
    37893782            case WRITE_MISS_TRT_SET:  // register a new transaction in TRT (Write Buffer)
    37903783            {
     3784                assert((r_alloc_trt_fsm.read() == ALLOC_TRT_WRITE) and
     3785                        "MEMC ERROR in WRITE_MISS_TRT_SET state: Bad TRT allocation");
     3786
    37913787                if (r_alloc_trt_fsm.read() == ALLOC_TRT_WRITE)
    37923788                {
     
    38273823            case WRITE_MISS_TRT_DATA: // update an entry in TRT (used as a Write Buffer)
    38283824            {
     3825                assert((r_alloc_trt_fsm.read() == ALLOC_TRT_WRITE) and
     3826                        "MEMC ERROR in WRITE_MISS_TRT_DATA state: Bad TRT allocation");
     3827
    38293828                if (r_alloc_trt_fsm.read() == ALLOC_TRT_WRITE)
    38303829                {
     
    40094008            ////////////////////////
    40104009            case WRITE_BC_DIR_INVAL:    // Register a put transaction in TRT
    4011             // and invalidate the line in directory
     4010                                        // and invalidate the line in directory
    40124011            {
    40134012                assert((r_alloc_dir_fsm.read() == ALLOC_DIR_WRITE) and
     
    43854384                        if (m_debug)
    43864385                        {
    4387                             std::cout << "  <MEMC " << name() << " IXR_CMD_WRITE_SEND> PUT request:" << std::hex
    4388                                 << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2) << std::endl;
     4386                            std::cout << "  <MEMC " << name()
     4387                                      << " IXR_CMD_WRITE_SEND> PUT request:" << std::hex
     4388                                      << " address = " << r_ixr_cmd_address.read() +
     4389                                           (r_ixr_cmd_word.read()<<2) << std::endl;
    43894390                        }
    43904391#endif
     
    43984399                        if (m_debug)
    43994400                        {
    4400                             std::cout << "  <MEMC " << name() << " IXR_CMD_WRITE_SEND> GET request:" << std::hex
    4401                                 << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2) << std::endl;
     4401                            std::cout << "  <MEMC " << name()
     4402                                      << " IXR_CMD_WRITE_SEND> GET request:" << std::hex
     4403                                      << " address = " << r_ixr_cmd_address.read() +
     4404                                           (r_ixr_cmd_word.read()<<2) << std::endl;
    44024405                        }
    44034406#endif
     
    44264429                        if (m_debug)
    44274430                        {
    4428                             std::cout << "  <MEMC " << name() << " IXR_CMD_CAS_SEND> PUT request:" << std::hex
    4429                                 << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read() << 2) << std::endl;
     4431                            std::cout << "  <MEMC " << name()
     4432                                      << " IXR_CMD_CAS_SEND> PUT request:" << std::hex
     4433                                      << " address = " << r_ixr_cmd_address.read() +
     4434                                           (r_ixr_cmd_word.read() << 2) << std::endl;
    44304435                        }
    44314436#endif
     
    44394444                        if (m_debug)
    44404445                        {
    4441                             std::cout << "  <MEMC " << name() << " IXR_CMD_CAS_SEND> GET request:" << std::hex
    4442                                 << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read() << 2) << std::endl;
     4446                            std::cout << "  <MEMC " << name()
     4447                                      << " IXR_CMD_CAS_SEND> GET request:" << std::hex
     4448                                      << " address = " << r_ixr_cmd_address.read() +
     4449                                           (r_ixr_cmd_word.read() << 2) << std::endl;
    44434450                        }
    44444451#endif
     
    44654472                    if (m_debug)
    44664473                    {
    4467                         std::cout << "  <MEMC " << name() << " IXR_CMD_XRAM_SEND> PUT request:" << std::hex
    4468                             << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read() << 2) << std::endl;
     4474                        std::cout << "  <MEMC " << name()
     4475                                  << " IXR_CMD_XRAM_SEND> PUT request:" << std::hex
     4476                                  << " address = " << r_ixr_cmd_address.read() +
     4477                                       (r_ixr_cmd_word.read() << 2) << std::endl;
    44694478                    }
    44704479#endif
     
    44904499                    if (m_debug)
    44914500                    {
    4492                         std::cout << "  <MEMC " << name() << " IXR_CMD_CONFIG_SEND> PUT request:" << std::hex
    4493                             << " address = " << r_ixr_cmd_address.read() + (r_ixr_cmd_word.read()<<2) << std::endl;
     4501                        std::cout << "  <MEMC " << name()
     4502                                  << " IXR_CMD_CONFIG_SEND> PUT request:" << std::hex
     4503                                  << " address = " << r_ixr_cmd_address.read() +
     4504                                       (r_ixr_cmd_word.read()<<2) << std::endl;
    44944505                    }
    44954506#endif
     
    45194530        // signal is set to inform the XRAM_RSP FSM.
    45204531        ///////////////////////////////////////////////////////////////////////////////
    4521 
    4522         //std::cout << std::endl << "ixr_rsp_fsm" << std::endl;
    45234532
    45244533        switch(r_ixr_rsp_fsm.read())
     
    58135822        ///////////////////////////////////////////////////////////////////////////////////
    58145823
    5815         //std::cout << std::endl << "cas_fsm" << std::endl;
    5816 
    58175824        switch (r_cas_fsm.read())
    58185825        {
    5819             ////////////
     5826            //////////////
    58205827            case CAS_IDLE:     // fill the local rdata buffers
    58215828            {
     
    58275834                    {
    58285835                        std::cout << "  <MEMC " << name() << " CAS_IDLE> CAS command: " << std::hex
    5829                             << " srcid = " <<  std::dec << m_cmd_cas_srcid_fifo.read()
    5830                             << " addr = " << std::hex << m_cmd_cas_addr_fifo.read()
    5831                             << " wdata = " << m_cmd_cas_wdata_fifo.read()
    5832                             << " eop = " << std::dec << m_cmd_cas_eop_fifo.read()
    5833                             << " cpt  = " << std::dec << r_cas_cpt.read() << std::endl;
     5836                                  << " srcid = " <<  std::dec << m_cmd_cas_srcid_fifo.read()
     5837                                  << " addr = " << std::hex << m_cmd_cas_addr_fifo.read()
     5838                                  << " wdata = " << m_cmd_cas_wdata_fifo.read()
     5839                                  << " eop = " << std::dec << m_cmd_cas_eop_fifo.read()
     5840                                  << " cpt  = " << std::dec << r_cas_cpt.read() << std::endl;
    58345841                    }
    58355842#endif
     
    58775884                if (m_debug)
    58785885                {
    5879                     std::cout << "  <MEMC " << name() << " CAS_DIR_REQ> Requesting DIR lock " << std::endl;
    5880                 }
    5881 #endif
    5882                 break;
    5883             }
    5884             /////////////////
     5886                    std::cout << "  <MEMC " << name()
     5887                              << " CAS_DIR_REQ> Requesting DIR lock " << std::endl;
     5888                }
     5889#endif
     5890                break;
     5891            }
     5892            //////////////////
    58855893            case CAS_DIR_LOCK:  // Read the directory
    58865894            {
     
    59065914                if (m_debug)
    59075915                {
    5908                     std::cout << "  <MEMC " << name() << " CAS_DIR_LOCK> Directory acces"
    5909                         << " / address = " << std::hex << m_cmd_cas_addr_fifo.read()
    5910                         << " / hit = " << std::dec << entry.valid
    5911                         << " / count = " << entry.count
    5912                         << " / is_cnt = " << entry.is_cnt << std::endl;
     5916                    std::cout << "  <MEMC " << name()
     5917                              << " CAS_DIR_LOCK> Directory acces"
     5918                              << " / address = " << std::hex << m_cmd_cas_addr_fifo.read()
     5919                              << " / hit = " << std::dec << entry.valid
     5920                              << " / count = " << entry.count
     5921                              << " / is_cnt = " << entry.is_cnt << std::endl;
    59135922                }
    59145923#endif
     
    59485957                if (m_debug)
    59495958                {
    5950                     std::cout << "  <MEMC " << name() << " CAS_DIR_HIT_READ> Read data from "
    5951                         << " cache and store it in buffer" << std::endl;
     5959                    std::cout << "  <MEMC " << name()
     5960                              << " CAS_DIR_HIT_READ> Read data from "
     5961                              << " cache and store it in buffer" << std::endl;
    59525962                }
    59535963#endif
     
    59755985                if (m_debug)
    59765986                {
    5977                     std::cout << "  <MEMC " << name() << " CAS_DIR_HIT_COMPARE> Compare old and new data"
    5978                         << " / expected value = " << std::hex << r_cas_rdata[0].read()
    5979                         << " / actual value = "   << std::hex << r_cas_data[word].read()
    5980                         << " / forced_fail = "    << std::dec << forced_fail << std::endl;
     5987                    std::cout << "  <MEMC " << name()
     5988                              << " CAS_DIR_HIT_COMPARE> Compare old and new data"
     5989                              << " / expected value = " << std::hex << r_cas_rdata[0].read()
     5990                              << " / actual value = "   << std::hex << r_cas_data[word].read()
     5991                              << " / forced_fail = "    << std::dec << forced_fail << std::endl;
    59815992                }
    59825993#endif
     
    60046015                        {
    60056016                            std::cout << "  <MEMC " << name() << " CAS_DIR_HIT_WRITE>"
    6006                                 << " Broacast Inval required"
    6007                                 << " / copies = " << r_cas_count.read() << std::endl;
     6017                                      << " Broacast Inval required"
     6018                                      << " / copies = " << r_cas_count.read() << std::endl;
    60086019                        }
    60096020#endif
     
    60176028                        if (m_debug)
    60186029                        {
    6019                             std::cout << "  <MEMC " << name() << " CAS_DIR_HIT_WRITE>"
    6020                                 << " Multi Inval required"
    6021                                 << " / copies = " << r_cas_count.read() << std::endl;
     6030                            std::cout << "  <MEMC " << name()
     6031                                      << " CAS_DIR_HIT_WRITE> Multi Inval required"
     6032                                      << " / copies = " << r_cas_count.read() << std::endl;
    60226033                        }
    60236034#endif
     
    60306041                        if (m_debug)
    60316042                        {
    6032                             std::cout << "  <MEMC " << name() << " CAS_DIR_HIT_WRITE>"
    6033                                 << " CC_SEND FSM busy: release all locks and retry" << std::endl;
     6043                            std::cout << "  <MEMC " << name()
     6044                                      << " CAS_DIR_HIT_WRITE> CC_SEND FSM busy: "
     6045                                      << "release all locks and retry" << std::endl;
    60346046                        }
    60356047#endif
     
    60546066                    if (m_debug)
    60556067                    {
    6056                         std::cout << "  <MEMC " << name() << " CAS_DIR_HIT_WRITE> Update cache:"
    6057                             << " way = " << std::dec << way
    6058                             << " / set = " << set
    6059                             << " / word = " << word
    6060                             << " / value = " << r_cas_wdata.read()
    6061                             << " / count = " << r_cas_count.read()
    6062                             << " / global_llsc_table access" << std::endl;
     6068                        std::cout << "  <MEMC " << name()
     6069                                  << " CAS_DIR_HIT_WRITE> Update cache:"
     6070                                  << " way = " << std::dec << way
     6071                                  << " / set = " << set
     6072                                  << " / word = " << word
     6073                                  << " / value = " << r_cas_wdata.read()
     6074                                  << " / count = " << r_cas_count.read()
     6075                                  << " / global_llsc_table access" << std::endl;
    60636076                    }
    60646077#endif
     
    60686081            /////////////////
    60696082            case CAS_UPT_LOCK:  // try to register the transaction in UPT
    6070             // and write data in cache if successful registration
    6071             // releases locks to retry later if UPT full
     6083                                // and write data in cache if successful registration
     6084                                // releases locks to retry later if UPT full
    60726085            {
    60736086                if (r_alloc_upt_fsm.read() == ALLOC_UPT_CAS)
     
    60826095
    60836096                    wok = m_upt.set(true,    // it's an update transaction
    6084                             false,   // it's not a broadcast
    6085                             true,    // response required
    6086                             false,   // no acknowledge required
    6087                             srcid,
    6088                             trdid,
    6089                             pktid,
    6090                             nline,
    6091                             nb_copies,
    6092                             index);
     6097                                    false,   // it's not a broadcast
     6098                                    true,    // response required
     6099                                    false,   // no acknowledge required
     6100                                    srcid,
     6101                                    trdid,
     6102                                    pktid,
     6103                                    nline,
     6104                                    nb_copies,
     6105                                    index);
    60936106                    if (wok)   // coherence transaction registered in UPT
    60946107                    {
     
    61166129                    {
    61176130                        std::cout << "  <MEMC " << name()
    6118                             << " CAS_UPT_LOCK> Register multi-update transaction in UPT"
    6119                             << " / wok = " << wok
    6120                             << " / address  = " << std::hex << nline * m_words * 4
    6121                             << " / count = " << nb_copies << std::endl;
     6131                                  << " CAS_UPT_LOCK> Register multi-update transaction in UPT"
     6132                                  << " / wok = " << wok
     6133                                  << " / address  = " << std::hex << nline * m_words * 4
     6134                                  << " / count = " << nb_copies << std::endl;
    61226135                    }
    61236136#endif
     
    61326145                if (m_debug)
    61336146                {
    6134                     std::cout << "  <MEMC " << name() << " CAS_WAIT> Release all locks" << std::endl;
     6147                    std::cout << "  <MEMC " << name()
     6148                              << " CAS_WAIT> Release all locks" << std::endl;
    61356149                }
    61366150#endif
     
    61396153            }
    61406154            //////////////////////
    6141             case CAS_UPT_HEAP_LOCK:  // lock the heap
     6155            case CAS_UPT_HEAP_LOCK:  // get the lock protecting the heap
    61426156            {
    61436157                if (r_alloc_heap_fsm.read() == ALLOC_HEAP_CAS)
     
    61486162                    {
    61496163                        std::cout << "  <MEMC " << name()
    6150                             << " CAS_UPT_HEAP_LOCK> Get access to the heap" << std::endl;
     6164                                  << " CAS_UPT_HEAP_LOCK> Get access to the heap" << std::endl;
    61516165                    }
    61526166#endif
     
    61596173            {
    61606174                assert((r_alloc_heap_fsm.read() == ALLOC_HEAP_CAS) and
    6161                         "VCI_MEM_CACHE ERROR : bad HEAP allocation");
     6175                        "MEMC ERROR in state CAS_UPT_REQ: bad HEAP allocation");
    61626176
    61636177                if (!r_cas_to_cc_send_multi_req.read() and !r_cas_to_cc_send_brdcast_req.read())
     
    62006214                    if (m_debug)
    62016215                    {
    6202                         std::cout << "  <MEMC " << name() << " CAS_UPT_REQ> Send the first update request to CC_SEND FSM "
    6203                             << " / address = " << std::hex << m_cmd_cas_addr_fifo.read()
    6204                             << " / wdata = " << std::hex << r_cas_wdata.read()
    6205                             << " / srcid = " << std::dec << r_cas_copy.read()
    6206                             << " / inst = " << std::dec << r_cas_copy_inst.read() << std::endl;
    6207                     }
    6208 #endif
    6209                 }
    6210                 break;
    6211             }
    6212             /////////////////
     6216                        std::cout << "  <MEMC " << name()
     6217                                  << " CAS_UPT_REQ> Send the first update request to CC_SEND FSM "
     6218                                  << " / address = " << std::hex << m_cmd_cas_addr_fifo.read()
     6219                                  << " / wdata = " << std::hex << r_cas_wdata.read()
     6220                                  << " / srcid = " << std::dec << r_cas_copy.read()
     6221                                  << " / inst = " << std::dec << r_cas_copy_inst.read() << std::endl;
     6222                    }
     6223#endif
     6224                }
     6225                break;
     6226            }
     6227            //////////////////
    62136228            case CAS_UPT_NEXT:     // send a multi-update request to CC_SEND FSM
    62146229            {
    62156230                assert((r_alloc_heap_fsm.read() == ALLOC_HEAP_CAS)
    6216                         and "VCI_MEM_CACHE ERROR : bad HEAP allocation");
     6231                        and "MEMC ERROR in state CAS_UPT_NEXT : bad HEAP allocation");
    62176232
    62186233                HeapEntry entry = m_heap.read(r_cas_ptr.read());
     
    62286243                        r_cas_to_cc_send_multi_req = true;
    62296244                        r_cas_fsm = CAS_IDLE;   // Response will be sent after receiving
    6230                         // all update responses
     6245                                                // all update responses
    62316246                        cmd_cas_fifo_get = true;
    62326247                        r_cas_cpt        = 0;
     
    62376252                if (m_debug)
    62386253                {
    6239                     std::cout << "  <MEMC " << name() << " CAS_UPT_NEXT> Send the next update request to CC_SEND FSM "
    6240                         << " / address = " << std::hex << m_cmd_cas_addr_fifo.read()
    6241                         << " / wdata = " << std::hex << r_cas_wdata.read()
    6242                         << " / srcid = " << std::dec << entry.owner.srcid
    6243                         << " / inst = " << std::dec << entry.owner.inst << std::endl;
     6254                    std::cout << "  <MEMC " << name()
     6255                              << " CAS_UPT_NEXT> Send the next update request to CC_SEND FSM "
     6256                              << " / address = " << std::hex << m_cmd_cas_addr_fifo.read()
     6257                              << " / wdata = " << std::hex << r_cas_wdata.read()
     6258                              << " / srcid = " << std::dec << entry.owner.srcid
     6259                              << " / inst = " << std::dec << entry.owner.inst << std::endl;
    62446260                }
    62456261#endif
     
    62696285                    if (m_debug)
    62706286                    {
    6271                         std::cout << "  <MEMC " << name() << " CAS_BC_TRT_LOCK> Check TRT"
    6272                             << " : wok = " << wok << " / index = " << wok_index << std::endl;
     6287                        std::cout << "  <MEMC " << name()
     6288                                  << " CAS_BC_TRT_LOCK> Check TRT"
     6289                                  << " : wok = " << wok
     6290                                  << " / index = " << wok_index << std::endl;
    62736291                    }
    62746292#endif
     
    62976315
    62986316                    wok = m_ivt.set(false,  // it's an inval transaction
    6299                             true,   // it's a broadcast
    6300                             true,   // response required
    6301                             false,  // no acknowledge required
    6302                             srcid,
    6303                             trdid,
    6304                             pktid,
    6305                             nline,
    6306                             nb_copies,
    6307                             index);
     6317                                    true,   // it's a broadcast
     6318                                    true,   // response required
     6319                                    false,  // no acknowledge required
     6320                                    srcid,
     6321                                    trdid,
     6322                                    pktid,
     6323                                    nline,
     6324                                    nb_copies,
     6325                                    index);
    63086326#if DEBUG_MEMC_CAS
    63096327                    if (m_debug and wok)
    63106328                    {
    6311                         std::cout << "  <MEMC " << name() << " CAS_BC_IVT_LOCK> Register broadcast inval in IVT"
    6312                             << " / copies = " << r_cas_count.read() << std::endl;
     6329                        std::cout << "  <MEMC " << name()
     6330                                  << " CAS_BC_IVT_LOCK> Register broadcast inval in IVT"
     6331                                  << " / copies = " << r_cas_count.read() << std::endl;
    63136332                    }
    63146333#endif
     
    63556374                }
    63566375                m_trt.set(r_cas_trt_index.read(),
    6357                         false,    // PUT request
    6358                         m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())],
    6359                         0,
    6360                         0,
    6361                         0,
    6362                         false,    // not a processor read
    6363                         0,
    6364                         0,
    6365                         std::vector<be_t> (m_words,0),
    6366                         data_vector);
     6376                          false,    // PUT request
     6377                          m_nline[(addr_t)(m_cmd_cas_addr_fifo.read())],
     6378                          0,
     6379                          0,
     6380                          0,
     6381                          false,    // not a processor read
     6382                          0,
     6383                          0,
     6384                          std::vector<be_t> (m_words,0),
     6385                          data_vector);
    63676386
    63686387                // invalidate directory entry
     
    63876406                if (m_debug)
    63886407                {
    6389                     std::cout << "  <MEMC " << name() << " CAS_BC_DIR_INVAL> Inval DIR & register in TRT:"
    6390                         << " address = " << m_cmd_cas_addr_fifo.read() << std::endl;
     6408                    std::cout << "  <MEMC " << name()
     6409                              << " CAS_BC_DIR_INVAL> Inval DIR & register in TRT:"
     6410                              << " address = " << m_cmd_cas_addr_fifo.read() << std::endl;
    63916411                }
    63926412#endif
     
    64126432                    {
    64136433                        std::cout << "  <MEMC " << name()
    6414                             << " CAS_BC_CC_SEND> Post a broadcast request to CC_SEND FSM" << std::endl;
     6434                                  << " CAS_BC_CC_SEND> Post a broadcast request to CC_SEND FSM"
     6435                                  << std::endl;
    64156436                    }
    64166437#endif
     
    64336454                    {
    64346455                        std::cout << "  <MEMC " << name()
    6435                             << " CAS_BC_XRAM_REQ> Request a PUT transaction to IXR_CMD FSM" << std::hex
    6436                             << " / address = " << (addr_t) m_cmd_cas_addr_fifo.read()
    6437                             << " / trt_index = " << r_cas_trt_index.read() << std::endl;
     6456                                  << " CAS_BC_XRAM_REQ> Request a PUT transaction to IXR_CMD FSM"
     6457                                  << std::hex << " / address = " << (addr_t) m_cmd_cas_addr_fifo.read()
     6458                                  << " / trt_index = " << r_cas_trt_index.read() << std::endl;
    64386459                    }
    64396460#endif
     
    64586479                    if (m_debug)
    64596480                        std::cout << "  <MEMC " << name()
    6460                             << " CAS_RSP_FAIL> Request TGT_RSP to send a failure response" << std::endl;
     6481                                  << " CAS_RSP_FAIL> Request TGT_RSP to send a failure response"
     6482                                  << std::endl;
    64616483#endif
    64626484                }
     
    64816503                    {
    64826504                        std::cout << "  <MEMC " << name()
    6483                             << " CAS_RSP_SUCCESS> Request TGT_RSP to send a success response" << std::endl;
     6505                                  << " CAS_RSP_SUCCESS> Request TGT_RSP to send a success response"
     6506                                  << std::endl;
    64846507                    }
    64856508#endif
     
    65036526                    {
    65046527                        std::cout << "  <MEMC " << name() << " CAS_MISS_TRT_LOCK> Check TRT state"
    6505                             << " / hit_read = "  << hit_read
    6506                             << " / hit_write = " << hit_write
    6507                             << " / wok = " << wok
    6508                             << " / index = " << index << std::endl;
     6528                                  << " / hit_read = "  << hit_read
     6529                                  << " / hit_write = " << hit_write
     6530                                  << " / wok = " << wok
     6531                                  << " / index = " << index << std::endl;
    65096532                    }
    65106533#endif
     
    65396562
    65406563                m_trt.set(r_cas_trt_index.read(),
    6541                         true,     // GET
    6542                         m_nline[(addr_t) m_cmd_cas_addr_fifo.read()],
    6543                         m_cmd_cas_srcid_fifo.read(),
    6544                         m_cmd_cas_trdid_fifo.read(),
    6545                         m_cmd_cas_pktid_fifo.read(),
    6546                         false,    // write request from processor
    6547                         0,
    6548                         0,
    6549                         std::vector<be_t>(m_words, 0),
    6550                         std::vector<data_t>(m_words, 0));
     6564                          true,     // GET
     6565                          m_nline[(addr_t) m_cmd_cas_addr_fifo.read()],
     6566                          m_cmd_cas_srcid_fifo.read(),
     6567                          m_cmd_cas_trdid_fifo.read(),
     6568                          m_cmd_cas_pktid_fifo.read(),
     6569                          false,    // write request from processor
     6570                          0,
     6571                          0,
     6572                          std::vector<be_t>(m_words, 0),
     6573                          std::vector<data_t>(m_words, 0));
    65516574
    65526575                r_cas_fsm = CAS_MISS_XRAM_REQ;
     
    65556578                if (m_debug)
    65566579                {
    6557                     std::cout << "  <MEMC " << name() << " CAS_MISS_TRT_SET> Register GET transaction in TRT"
    6558                         << " / address = " << std::hex << (addr_t)m_cmd_cas_addr_fifo.read()
    6559                         << " / trt_index = " << std::dec << r_cas_trt_index.read() << std::endl;
     6580                    std::cout << "  <MEMC " << name()
     6581                              << " CAS_MISS_TRT_SET> Register GET transaction in TRT"
     6582                              << " / address = " << std::hex << (addr_t)m_cmd_cas_addr_fifo.read()
     6583                              << " / trt_index = " << std::dec << r_cas_trt_index.read() << std::endl;
    65606584                }
    65616585#endif
     
    65746598                    if (m_debug)
    65756599                    {
    6576                         std::cout << "  <MEMC " << name() << " CAS_MISS_XRAM_REQ> Request a GET transaction"
    6577                             << " / address = " << std::hex << (addr_t) m_cmd_cas_addr_fifo.read()
    6578                             << " / trt_index = " << std::dec << r_cas_trt_index.read() << std::endl;
     6600                        std::cout << "  <MEMC " << name()
     6601                                  << " CAS_MISS_XRAM_REQ> Request a GET transaction"
     6602                                  << " / address = " << std::hex << (addr_t) m_cmd_cas_addr_fifo.read()
     6603                                  << " / trt_index = " << std::dec << r_cas_trt_index.read() << std::endl;
    65796604                    }
    65806605#endif
     
    78527877        ////////////////////////////////////////////////////////////////////////////////////
    78537878        // The ALLOC_DIR FSM allocates the access to the directory and
    7854         // the data cache with a round robin priority between 6 user FSMs :
    7855         // The cyclic ordering is CONFIG > READ > WRITE > CAS > CLEANUP > XRAM_RSP
    7856         // The ressource is always allocated.
     7879        // the data cache with a higher priority for the XRAM_RSP FSM,
     7880        // and a round robin priority between the five other FSMs :
     7881        // (the cyclic ordering is READ > WRITE > CAS > CONFIG > CLEANUP)
     7882        // To maximize the throughput, the ressource is always allocated.
     7883        // A new allocation is done when the owner FSM does not access the cache.
     7884        // - The r_alloc_dir_fsm register define the current owner.
     7885        // - The r_alloc_dir_last register define the previous owner for round robin.
    78577886        /////////////////////////////////////////////////////////////////////////////////////
    78587887
    7859         //std::cout << std::endl << "alloc_dir_fsm" << std::endl;
    7860 
     7888        // compute the request conditions for the 6 FSMs
     7889        bool dir_req_config   = (r_config_fsm.read() == CONFIG_DIR_REQ);
     7890        bool dir_req_read     = (r_read_fsm.read() == READ_DIR_REQ);
     7891        bool dir_req_write    = (r_write_fsm.read() == WRITE_DIR_REQ);
     7892        bool dir_req_cas      = (r_cas_fsm.read() == CAS_DIR_REQ);
     7893        bool dir_req_cleanup  = (r_cleanup_fsm.read() == CLEANUP_DIR_REQ);
     7894        bool dir_req_xram_rsp = (r_xram_rsp_fsm.read() == XRAM_RSP_DIR_LOCK);
     7895
     7896        // compute dir_allocate, that is actually a release condition:
     7897        // allocation can be done if the owner FSM doest not use the cache
     7898        bool dir_allocate = false;
     7899        int  dir_last;
    78617900        switch(r_alloc_dir_fsm.read())
    78627901        {
    7863             /////////////////////
    7864             case ALLOC_DIR_RESET: // Initializes the directory one SET per cycle.
    7865                                   // All the WAYS of a SET initialized in parallel
    7866 
    7867                 r_alloc_dir_reset_cpt.write(r_alloc_dir_reset_cpt.read() + 1);
     7902            case ALLOC_DIR_RESET: // Initializes the directory one cycle per set
     7903            {
     7904                r_alloc_dir_reset_cpt = r_alloc_dir_reset_cpt.read() + 1;
    78687905
    78697906                if (r_alloc_dir_reset_cpt.read() == (m_sets - 1))
     
    78737910                }
    78747911                break;
    7875 
    7876             //////////////////////
    7877             case ALLOC_DIR_CONFIG:    // allocated to CONFIG FSM
    7878                 if ((r_config_fsm.read() != CONFIG_DIR_REQ) and
    7879                     (r_config_fsm.read() != CONFIG_DIR_ACCESS) and
    7880                     (r_config_fsm.read() != CONFIG_TRT_LOCK) and
    7881                     (r_config_fsm.read() != CONFIG_TRT_SET) and
    7882                     (r_config_fsm.read() != CONFIG_IVT_LOCK))
    7883                 {
    7884                     if (r_read_fsm.read() == READ_DIR_REQ)
    7885                         r_alloc_dir_fsm = ALLOC_DIR_READ;
    7886 
    7887                     else if (r_write_fsm.read() == WRITE_DIR_REQ)
    7888                         r_alloc_dir_fsm = ALLOC_DIR_WRITE;
    7889 
    7890                     else if (r_cas_fsm.read() == CAS_DIR_REQ)
    7891                         r_alloc_dir_fsm = ALLOC_DIR_CAS;
    7892 
    7893                     else if (r_cleanup_fsm.read() == CLEANUP_DIR_REQ)
    7894                         r_alloc_dir_fsm = ALLOC_DIR_CLEANUP;
    7895 
    7896                     else if (r_xram_rsp_fsm.read() == XRAM_RSP_DIR_LOCK)
    7897                         r_alloc_dir_fsm = ALLOC_DIR_XRAM_RSP;
    7898                 }
    7899                 break;
    7900 
    7901             ////////////////////
    7902             case ALLOC_DIR_READ:    // allocated to READ FSM
    7903                 if (((r_read_fsm.read() != READ_DIR_REQ) and
    7904                      (r_read_fsm.read() != READ_DIR_LOCK) and
    7905                      (r_read_fsm.read() != READ_TRT_LOCK) and
     7912            }
     7913            case ALLOC_DIR_READ:    // owner is READ FSM
     7914            {
     7915                if (((r_read_fsm.read() != READ_DIR_REQ)   and
     7916                     (r_read_fsm.read() != READ_DIR_LOCK)  and
     7917                     (r_read_fsm.read() != READ_TRT_LOCK)  and
    79067918                     (r_read_fsm.read() != READ_HEAP_REQ))
    79077919                    or
     
    79097921                     (r_alloc_trt_fsm.read() == ALLOC_TRT_READ)))
    79107922                {
    7911                     if (r_write_fsm.read() == WRITE_DIR_REQ)
    7912                         r_alloc_dir_fsm = ALLOC_DIR_WRITE;
    7913 
    7914                     else if (r_cas_fsm.read() == CAS_DIR_REQ)
    7915                         r_alloc_dir_fsm = ALLOC_DIR_CAS;
    7916 
    7917                     else if (r_cleanup_fsm.read() == CLEANUP_DIR_REQ)
    7918                         r_alloc_dir_fsm = ALLOC_DIR_CLEANUP;
    7919 
    7920                     else if (r_xram_rsp_fsm.read() == XRAM_RSP_DIR_LOCK)
    7921                         r_alloc_dir_fsm = ALLOC_DIR_XRAM_RSP;
    7922 
    7923                     else if (r_config_fsm.read() == CONFIG_DIR_REQ)
    7924                         r_alloc_dir_fsm = ALLOC_DIR_CONFIG;
    7925                 }
    7926                 break;
    7927 
    7928             /////////////////////
    7929             case ALLOC_DIR_WRITE:    // allocated to WRITE FSM
    7930                 if (((r_write_fsm.read() != WRITE_DIR_REQ) and
    7931                      (r_write_fsm.read() != WRITE_DIR_LOCK) and
    7932                      (r_write_fsm.read() != WRITE_BC_DIR_READ) and
    7933                      (r_write_fsm.read() != WRITE_DIR_HIT) and
    7934                      (r_write_fsm.read() != WRITE_BC_TRT_LOCK) and
    7935                      (r_write_fsm.read() != WRITE_BC_IVT_LOCK) and
     7923                    dir_last     = ALLOC_DIR_READ;
     7924                    dir_allocate = true;
     7925                }
     7926                break;
     7927            }
     7928            case ALLOC_DIR_WRITE:    // owner is WRITE FSM
     7929            {
     7930                if (((r_write_fsm.read() != WRITE_DIR_REQ)       and
     7931                     (r_write_fsm.read() != WRITE_DIR_LOCK)      and
     7932                     (r_write_fsm.read() != WRITE_DIR_HIT)       and
     7933                     (r_write_fsm.read() != WRITE_UPT_LOCK)      and
     7934                     (r_write_fsm.read() != WRITE_BC_DIR_READ)   and
     7935                     (r_write_fsm.read() != WRITE_BC_TRT_LOCK)   and
     7936                     (r_write_fsm.read() != WRITE_BC_IVT_LOCK)   and
    79367937                     (r_write_fsm.read() != WRITE_MISS_TRT_LOCK) and
    7937                      (r_write_fsm.read() != WRITE_UPT_LOCK) and
    79387938                     (r_write_fsm.read() != WRITE_UPT_HEAP_LOCK))
    79397939                    or
     
    79447944                     (r_alloc_trt_fsm.read()  == ALLOC_TRT_WRITE)))
    79457945                {
    7946                     if (r_cas_fsm.read() == CAS_DIR_REQ)
    7947                         r_alloc_dir_fsm = ALLOC_DIR_CAS;
    7948 
    7949                     else if (r_cleanup_fsm.read() == CLEANUP_DIR_REQ)
    7950                         r_alloc_dir_fsm = ALLOC_DIR_CLEANUP;
    7951 
    7952                     else if (r_xram_rsp_fsm.read() == XRAM_RSP_DIR_LOCK)
    7953                         r_alloc_dir_fsm = ALLOC_DIR_XRAM_RSP;
    7954 
    7955                     else if (r_config_fsm.read() == CONFIG_DIR_REQ)
    7956                         r_alloc_dir_fsm = ALLOC_DIR_CONFIG;
    7957 
    7958                     else if (r_read_fsm.read() == READ_DIR_REQ)
    7959                         r_alloc_dir_fsm = ALLOC_DIR_READ;
    7960                 }
    7961                 break;
    7962 
    7963             ///////////////////
    7964             case ALLOC_DIR_CAS:    // allocated to CAS FSM
    7965                 if (((r_cas_fsm.read() != CAS_DIR_REQ) and
    7966                      (r_cas_fsm.read() != CAS_DIR_LOCK) and
    7967                      (r_cas_fsm.read() != CAS_DIR_HIT_READ) and
     7946                    dir_last     = ALLOC_DIR_WRITE;
     7947                    dir_allocate = true;
     7948                }
     7949                break;
     7950            }
     7951            case ALLOC_DIR_CAS:    // owner is CAS FSM
     7952            {
     7953                if (((r_cas_fsm.read() != CAS_DIR_REQ)         and
     7954                     (r_cas_fsm.read() != CAS_DIR_LOCK)        and
     7955                     (r_cas_fsm.read() != CAS_DIR_HIT_READ)    and
    79687956                     (r_cas_fsm.read() != CAS_DIR_HIT_COMPARE) and
    7969                      (r_cas_fsm.read() != CAS_DIR_HIT_WRITE) and
    7970                      (r_cas_fsm.read() != CAS_BC_TRT_LOCK) and
    7971                      (r_cas_fsm.read() != CAS_BC_IVT_LOCK) and
    7972                      (r_cas_fsm.read() != CAS_MISS_TRT_LOCK) and
    7973                      (r_cas_fsm.read() != CAS_UPT_LOCK) and
     7957                     (r_cas_fsm.read() != CAS_DIR_HIT_WRITE)   and
     7958                     (r_cas_fsm.read() != CAS_UPT_LOCK)        and
     7959                     (r_cas_fsm.read() != CAS_BC_TRT_LOCK)    and
     7960                     (r_cas_fsm.read() != CAS_BC_IVT_LOCK)    and
     7961                     (r_cas_fsm.read() != CAS_MISS_TRT_LOCK)  and
    79747962                     (r_cas_fsm.read() != CAS_UPT_HEAP_LOCK))
    79757963                    or
     
    79807968                      (r_alloc_trt_fsm.read() == ALLOC_TRT_CAS)))
    79817969                {
    7982                     if (r_cleanup_fsm.read() == CLEANUP_DIR_REQ)
    7983                        r_alloc_dir_fsm = ALLOC_DIR_CLEANUP;
    7984 
    7985                     else if (r_xram_rsp_fsm.read() == XRAM_RSP_DIR_LOCK)
    7986                         r_alloc_dir_fsm = ALLOC_DIR_XRAM_RSP;
    7987 
    7988                     else if (r_config_fsm.read() == CONFIG_DIR_REQ)
    7989                         r_alloc_dir_fsm = ALLOC_DIR_CONFIG;
    7990 
    7991                     else if (r_read_fsm.read() == READ_DIR_REQ)
    7992                         r_alloc_dir_fsm = ALLOC_DIR_READ;
    7993 
    7994                     else if (r_write_fsm.read() == WRITE_DIR_REQ)
    7995                         r_alloc_dir_fsm = ALLOC_DIR_WRITE;
    7996                 }
    7997                 break;
    7998 
    7999             ///////////////////////
    8000             case ALLOC_DIR_CLEANUP:    // allocated to CLEANUP FSM
     7970                    dir_last     = ALLOC_DIR_CAS;
     7971                    dir_allocate = true;
     7972                }
     7973                break;
     7974            }
     7975            case ALLOC_DIR_CONFIG:    // owner is CONFIG FSM
     7976            {
     7977                if ((r_config_fsm.read() != CONFIG_DIR_REQ)    and
     7978                    (r_config_fsm.read() != CONFIG_DIR_ACCESS) and
     7979                    (r_config_fsm.read() != CONFIG_TRT_LOCK)   and
     7980                    (r_config_fsm.read() != CONFIG_TRT_SET)    and
     7981                    (r_config_fsm.read() != CONFIG_IVT_LOCK))
     7982                {
     7983                    dir_last     = ALLOC_DIR_CONFIG;
     7984                    dir_allocate = true;
     7985                }
     7986                break;
     7987            }
     7988            case ALLOC_DIR_CLEANUP:    // owner is CLEANUP FSM
     7989            {
    80017990                if ((r_cleanup_fsm.read() != CLEANUP_DIR_REQ) and
    80027991                    (r_cleanup_fsm.read() != CLEANUP_DIR_LOCK) and
     
    80047993                    (r_cleanup_fsm.read() != CLEANUP_HEAP_LOCK))
    80057994                {
    8006                     if (r_xram_rsp_fsm.read() == XRAM_RSP_DIR_LOCK)
    8007                         r_alloc_dir_fsm = ALLOC_DIR_XRAM_RSP;
    8008 
    8009                     else if (r_config_fsm.read() == CONFIG_DIR_REQ)
    8010                         r_alloc_dir_fsm = ALLOC_DIR_CONFIG;
    8011 
    8012                     else if (r_read_fsm.read() == READ_DIR_REQ)
    8013                         r_alloc_dir_fsm = ALLOC_DIR_READ;
    8014 
    8015                     else if (r_write_fsm.read() == WRITE_DIR_REQ)
    8016                         r_alloc_dir_fsm = ALLOC_DIR_WRITE;
    8017 
    8018                     else if (r_cas_fsm.read() == CAS_DIR_REQ)
    8019                         r_alloc_dir_fsm = ALLOC_DIR_CAS;
    8020                 }
    8021                 break;
    8022 
    8023             ////////////////////////
    8024             case ALLOC_DIR_XRAM_RSP:    // allocated to XRAM_RSP FSM
     7995                    dir_last     = ALLOC_DIR_CLEANUP;
     7996                    dir_allocate = true;
     7997                }
     7998 
     7999                break;
     8000            }
     8001            case ALLOC_DIR_XRAM_RSP:    // owner is XRAM_RSP FSM
     8002            {
    80258003                if ((r_xram_rsp_fsm.read() != XRAM_RSP_DIR_LOCK) and
    80268004                    (r_xram_rsp_fsm.read() != XRAM_RSP_TRT_COPY) and
    80278005                    (r_xram_rsp_fsm.read() != XRAM_RSP_IVT_LOCK))
    80288006                {
    8029                     if (r_config_fsm.read() == CONFIG_DIR_REQ)
    8030                         r_alloc_dir_fsm = ALLOC_DIR_CONFIG;
    8031 
    8032                     else if (r_read_fsm.read() == READ_DIR_REQ)
    8033                         r_alloc_dir_fsm = ALLOC_DIR_READ;
    8034 
    8035                     else if (r_write_fsm.read() == WRITE_DIR_REQ)
    8036                         r_alloc_dir_fsm = ALLOC_DIR_WRITE;
    8037 
    8038                     else if (r_cas_fsm.read() == CAS_DIR_REQ)
    8039                         r_alloc_dir_fsm = ALLOC_DIR_CAS;
    8040 
    8041                     else if (r_cleanup_fsm.read() == CLEANUP_DIR_REQ)
    8042                         r_alloc_dir_fsm = ALLOC_DIR_CLEANUP;
    8043                 }
    8044                 break;
    8045 
    8046         } // end switch alloc_dir_fsm
     8007                    dir_last     = r_alloc_dir_last.read();
     8008                    dir_allocate = true;
     8009                }
     8010                break;
     8011            }
     8012        } // end switch r_alloc_dir_fsm
     8013
     8014        // set r_alloc_dir_fsm and r_alloc_dir_last registers if required
     8015        if ( dir_allocate )
     8016        {
     8017            // register last owner for round-robin allocation
     8018            r_alloc_dir_last = dir_last;
     8019
     8020            // higher priority for XRAM_FSM
     8021            if ( dir_req_xram_rsp ) r_alloc_dir_fsm = ALLOC_DIR_XRAM_RSP;
     8022
     8023            // round-robin priority for READ > WRITE > CAS > CONFIG > CLEANUP
     8024            else if ( dir_last == ALLOC_DIR_READ )
     8025            {
     8026                if      (dir_req_write)    r_alloc_dir_fsm = ALLOC_DIR_WRITE;
     8027                else if (dir_req_cas)      r_alloc_dir_fsm = ALLOC_DIR_CAS;
     8028                else if (dir_req_config)   r_alloc_dir_fsm = ALLOC_DIR_CONFIG;
     8029                else if (dir_req_cleanup)  r_alloc_dir_fsm = ALLOC_DIR_CLEANUP;
     8030                else if (dir_req_read)     r_alloc_dir_fsm = ALLOC_DIR_READ;
     8031            }
     8032            else if ( dir_last == ALLOC_DIR_WRITE )
     8033            {
     8034                if      (dir_req_cas)      r_alloc_dir_fsm = ALLOC_DIR_CAS;
     8035                else if (dir_req_config)   r_alloc_dir_fsm = ALLOC_DIR_CONFIG;
     8036                else if (dir_req_cleanup)  r_alloc_dir_fsm = ALLOC_DIR_CLEANUP;
     8037                else if (dir_req_read)     r_alloc_dir_fsm = ALLOC_DIR_READ;
     8038                else if (dir_req_write)    r_alloc_dir_fsm = ALLOC_DIR_WRITE;
     8039            }
     8040            else if ( dir_last == ALLOC_DIR_CAS )
     8041            {
     8042                if      (dir_req_config)   r_alloc_dir_fsm = ALLOC_DIR_CONFIG;
     8043                else if (dir_req_cleanup)  r_alloc_dir_fsm = ALLOC_DIR_CLEANUP;
     8044                else if (dir_req_read)     r_alloc_dir_fsm = ALLOC_DIR_READ;
     8045                else if (dir_req_write)    r_alloc_dir_fsm = ALLOC_DIR_WRITE;
     8046                else if (dir_req_cas)      r_alloc_dir_fsm = ALLOC_DIR_CAS;
     8047            }
     8048            else if ( dir_last == ALLOC_DIR_CONFIG )
     8049            {
     8050                if      (dir_req_cleanup)  r_alloc_dir_fsm = ALLOC_DIR_CLEANUP;
     8051                else if (dir_req_read)     r_alloc_dir_fsm = ALLOC_DIR_READ;
     8052                else if (dir_req_write)    r_alloc_dir_fsm = ALLOC_DIR_WRITE;
     8053                else if (dir_req_cas)      r_alloc_dir_fsm = ALLOC_DIR_CAS;
     8054                else if (dir_req_config)   r_alloc_dir_fsm = ALLOC_DIR_CONFIG;
     8055            }
     8056            else if ( dir_last == ALLOC_DIR_CLEANUP )
     8057            {
     8058                if      (dir_req_read)     r_alloc_dir_fsm = ALLOC_DIR_READ;
     8059                else if (dir_req_write)    r_alloc_dir_fsm = ALLOC_DIR_WRITE;
     8060                else if (dir_req_cas)      r_alloc_dir_fsm = ALLOC_DIR_CAS;
     8061                else if (dir_req_config)   r_alloc_dir_fsm = ALLOC_DIR_CONFIG;
     8062                else if (dir_req_cleanup)  r_alloc_dir_fsm = ALLOC_DIR_CLEANUP;
     8063            }
     8064        }  // end if dir_allocate
    80478065
    80488066        ////////////////////////////////////////////////////////////////////////////////////
     
    80618079        ///////////////////////////////////////////////////////////////////////////////////
    80628080
    8063         size_t index = 0;
    8064 
    8065         bool trt_req_read     = (r_read_fsm.read() == READ_TRT_LOCK) and
    8066                                 not m_trt.full(index);
    8067 
    8068         bool trt_req_write    = ((r_write_fsm.read() == WRITE_MISS_TRT_LOCK) or
    8069                                 (r_write_fsm.read() == WRITE_BC_TRT_LOCK)) and
    8070                                 not m_trt.full(index);
    8071 
    8072         bool trt_req_cas      = ((r_cas_fsm.read() == CAS_MISS_TRT_LOCK) or
    8073                                 (r_cas_fsm.read() == CAS_BC_TRT_LOCK)) and
    8074                                 not m_trt.full(index);
    8075 
    8076         bool trt_req_config   = (r_config_fsm.read() == CONFIG_TRT_LOCK) and
    8077                                 not m_trt.full(index);
    8078 
    8079         bool trt_req_ixr_cmd  = (r_ixr_cmd_fsm.read() == IXR_CMD_READ_TRT) or
     8081        // Compute requests for the 7 FSMS
     8082        bool trt_req_read     = (r_read_fsm.read() == READ_TRT_LOCK);
     8083        bool trt_req_write    = (r_write_fsm.read() == WRITE_MISS_TRT_LOCK) or
     8084                                (r_write_fsm.read() == WRITE_BC_TRT_LOCK);
     8085        bool trt_req_cas      = (r_cas_fsm.read() == CAS_MISS_TRT_LOCK) or
     8086                                (r_cas_fsm.read() == CAS_BC_TRT_LOCK);
     8087        bool trt_req_config   = (r_config_fsm.read() == CONFIG_TRT_LOCK);
     8088        bool trt_req_ixr_cmd  = (r_ixr_cmd_fsm.read() == IXR_CMD_READ_TRT)  or
    80808089                                (r_ixr_cmd_fsm.read() == IXR_CMD_WRITE_TRT) or
    8081                                 (r_ixr_cmd_fsm.read() == IXR_CMD_CAS_TRT) or
    8082                                 (r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_TRT) or
     8090                                (r_ixr_cmd_fsm.read() == IXR_CMD_CAS_TRT)   or
     8091                                (r_ixr_cmd_fsm.read() == IXR_CMD_XRAM_TRT)  or
    80838092                                (r_ixr_cmd_fsm.read() == IXR_CMD_CONFIG_TRT);
    8084 
    80858093        bool trt_req_ixr_rsp  = (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_ERASE) or
    80868094                                (r_ixr_rsp_fsm.read() == IXR_RSP_TRT_READ);
    8087 
    80888095        bool trt_req_xram_rsp = (r_xram_rsp_fsm.read() == XRAM_RSP_TRT_COPY);
    80898096
     8097        // Compute trt_allocate, that is actually a release condition:
     8098        // allocation can be done if owner FSM does not use the TRT
    80908099        bool trt_allocate = false;
    8091 
    8092         // compute allocation condition:
    8093         // allocation is done if owner FSM does not use the TRT
     8100        int  trt_last;
    80948101        switch(r_alloc_trt_fsm.read())
    80958102        {
     
    80988105                (r_read_fsm.read() != READ_TRT_SET))
    80998106            {
    8100                 r_alloc_trt_last = ALLOC_TRT_READ;
    8101                 trt_allocate     = true;
     8107                trt_last    = ALLOC_TRT_READ;
     8108                trt_allocate = true;
    81028109            }
    81038110            break;
     
    81108117                (r_write_fsm.read() != WRITE_BC_DIR_INVAL))
    81118118            {
    8112                 r_alloc_trt_last = ALLOC_TRT_WRITE;
    8113                 trt_allocate     = true;
     8119                trt_last    = ALLOC_TRT_WRITE;
     8120                trt_allocate = true;
    81148121            }
    81158122            break;
     
    81218128                (r_cas_fsm.read() != CAS_BC_DIR_INVAL))
    81228129            {
    8123                 r_alloc_trt_last = ALLOC_TRT_CAS;
    8124                 trt_allocate     = true;
     8130                trt_last    = ALLOC_TRT_CAS;
     8131                trt_allocate = true;
    81258132            }
    81268133            break;
     
    81298136                (r_config_fsm.read() != CONFIG_TRT_SET))
    81308137            {
    8131                 r_alloc_trt_last = ALLOC_TRT_CONFIG;
    8132                 trt_allocate     = true;
     8138                trt_last    = ALLOC_TRT_CONFIG;
     8139                trt_allocate = true;
    81338140            }
    81348141            break;
     
    81408147                (r_ixr_cmd_fsm.read() != IXR_CMD_CONFIG_TRT))
    81418148            {
    8142                 trt_allocate     = true;
     8149                trt_last     = r_alloc_trt_last.read();
     8150                trt_allocate = true;
    81438151            }
    81448152            break;
     
    81498157                (r_xram_rsp_fsm.read() != XRAM_RSP_TRT_DIRTY))
    81508158            {
    8151                 trt_allocate     = true;
     8159                trt_last     = r_alloc_trt_last.read();
     8160                trt_allocate = true;
    81528161            }
    81538162            break;
     
    81568165                (r_ixr_rsp_fsm.read() != IXR_RSP_TRT_READ))
    81578166            {
    8158                 trt_allocate     = true;
     8167                trt_last     = r_alloc_trt_last.read();
     8168                trt_allocate = true;
    81598169            }
    81608170        } // end switch on r_alloc_trt_fsm
    81618171
    8162         // allocate if required
     8172        // set r_alloc_trt_fsm and r_alloc_trt_last registers if required
    81638173        if ( trt_allocate )
    81648174        {
     8175            // register last owner for round-robin
     8176            r_alloc_trt_last = trt_last;
     8177
    81658178            // static priorities for XRAM_RSP > IXR_RSP > IXR_CMD
    81668179            if      ( trt_req_xram_rsp )     r_alloc_trt_fsm = ALLOC_TRT_XRAM_RSP;
     
    81698182
    81708183            // round robin priorities for READ / WRITE / CAS / CONFIG
    8171             else if ( r_alloc_trt_last.read() == ALLOC_TRT_READ )
     8184            else if ( trt_last == ALLOC_TRT_READ )
    81728185            {
    81738186                 if      ( trt_req_write  )  r_alloc_trt_fsm = ALLOC_TRT_WRITE;
     
    81768189                 else if ( trt_req_read   )  r_alloc_trt_fsm = ALLOC_TRT_READ;
    81778190            }
    8178             else if ( r_alloc_trt_last.read() == ALLOC_TRT_WRITE )
     8191            else if ( trt_last == ALLOC_TRT_WRITE )
    81798192            {
    81808193                 if      ( trt_req_cas    )  r_alloc_trt_fsm = ALLOC_TRT_CAS;
     
    81838196                 else if ( trt_req_write  )  r_alloc_trt_fsm = ALLOC_TRT_WRITE;
    81848197            }
    8185             else if ( r_alloc_trt_last.read() == ALLOC_TRT_CAS )
     8198            else if ( trt_last == ALLOC_TRT_CAS )
    81868199            {
    81878200                 if      ( trt_req_config )  r_alloc_trt_fsm = ALLOC_TRT_CONFIG;
     
    81908203                 else if ( trt_req_cas    )  r_alloc_trt_fsm = ALLOC_TRT_CAS;
    81918204            }
    8192             else if ( r_alloc_trt_last.read() == ALLOC_TRT_CONFIG )
     8205            else if ( trt_last == ALLOC_TRT_CONFIG )
    81938206            {
    81948207                 if      ( trt_req_read   )  r_alloc_trt_fsm = ALLOC_TRT_READ;
     
    82098222        /////////////////////////////////////////////////////////////////////////////////////
    82108223
    8211         //std::cout << std::endl << "alloc_heap_fsm" << std::endl;
     8224        // compute requests for the 6 FSMs
     8225        bool req_heap_read     = (r_read_fsm.read()     == READ_HEAP_REQ);
     8226        bool req_heap_write    = (r_write_fsm.read()    == WRITE_UPT_HEAP_LOCK);
     8227        bool req_heap_cas      = (r_cas_fsm.read()      == CAS_UPT_HEAP_LOCK);
     8228        bool req_heap_cleanup  = (r_cleanup_fsm.read()  == CLEANUP_HEAP_REQ);
     8229        bool req_heap_xram_rsp = (r_xram_rsp_fsm.read() == XRAM_RSP_HEAP_REQ);
     8230        bool req_heap_config   = (r_config_fsm.read()   == CONFIG_HEAP_REQ);
    82128231
    82138232        switch (r_alloc_heap_fsm.read())
    82148233        {
    8215             ////////////////////
     8234            //////////////////////
    82168235            case ALLOC_HEAP_RESET:
    82178236                // Initializes the heap one ENTRY each cycle.
     
    82278246                break;
    82288247
    8229                 ////////////////////
     8248            /////////////////////
    82308249            case ALLOC_HEAP_READ:
    8231                 if ((r_read_fsm.read() != READ_HEAP_REQ) and
    8232                         (r_read_fsm.read() != READ_HEAP_LOCK) and
    8233                         (r_read_fsm.read() != READ_HEAP_ERASE))
    8234                 {
    8235                     if (r_write_fsm.read() == WRITE_UPT_HEAP_LOCK)
    8236                         r_alloc_heap_fsm = ALLOC_HEAP_WRITE;
    8237 
    8238                     else if (r_cas_fsm.read() == CAS_UPT_HEAP_LOCK)
    8239                         r_alloc_heap_fsm = ALLOC_HEAP_CAS;
    8240 
    8241                     else if (r_cleanup_fsm.read() == CLEANUP_HEAP_REQ)
    8242                         r_alloc_heap_fsm = ALLOC_HEAP_CLEANUP;
    8243 
    8244                     else if (r_xram_rsp_fsm.read() == XRAM_RSP_HEAP_REQ)
    8245                         r_alloc_heap_fsm = ALLOC_HEAP_XRAM_RSP;
    8246 
    8247                     else if (r_config_fsm.read() == CONFIG_HEAP_REQ)
    8248                         r_alloc_heap_fsm = ALLOC_HEAP_CONFIG;
    8249                 }
    8250                 break;
    8251 
    8252                 /////////////////////
     8250                if ((r_read_fsm.read() != READ_HEAP_REQ)   and
     8251                    (r_read_fsm.read() != READ_HEAP_LOCK)  and
     8252                    (r_read_fsm.read() != READ_HEAP_ERASE))
     8253                {
     8254                    if      (req_heap_write)    r_alloc_heap_fsm = ALLOC_HEAP_WRITE;
     8255                    else if (req_heap_cas)      r_alloc_heap_fsm = ALLOC_HEAP_CAS;
     8256                    else if (req_heap_cleanup)  r_alloc_heap_fsm = ALLOC_HEAP_CLEANUP;
     8257                    else if (req_heap_xram_rsp) r_alloc_heap_fsm = ALLOC_HEAP_XRAM_RSP;
     8258                    else if (req_heap_config)   r_alloc_heap_fsm = ALLOC_HEAP_CONFIG;
     8259                }
     8260                break;
     8261
     8262            /////////////////////
    82538263            case ALLOC_HEAP_WRITE:
    82548264                if ((r_write_fsm.read() != WRITE_UPT_HEAP_LOCK) and
     
    82568266                        (r_write_fsm.read() != WRITE_UPT_NEXT))
    82578267                {
    8258                     if (r_cas_fsm.read() == CAS_UPT_HEAP_LOCK)
    8259                         r_alloc_heap_fsm = ALLOC_HEAP_CAS;
    8260 
    8261                     else if (r_cleanup_fsm.read() == CLEANUP_HEAP_REQ)
    8262                         r_alloc_heap_fsm = ALLOC_HEAP_CLEANUP;
    8263 
    8264                     else if (r_xram_rsp_fsm.read() == XRAM_RSP_HEAP_REQ)
    8265                         r_alloc_heap_fsm = ALLOC_HEAP_XRAM_RSP;
    8266 
    8267                     else if (r_config_fsm.read() == CONFIG_HEAP_REQ)
    8268                         r_alloc_heap_fsm = ALLOC_HEAP_CONFIG;
    8269 
    8270                     else if (r_read_fsm.read() == READ_HEAP_REQ)
    8271                         r_alloc_heap_fsm = ALLOC_HEAP_READ;
    8272                 }
    8273                 break;
    8274 
    8275                 ////////////////////
     8268                    if      (req_heap_cas)      r_alloc_heap_fsm = ALLOC_HEAP_CAS;
     8269                    else if (req_heap_cleanup)  r_alloc_heap_fsm = ALLOC_HEAP_CLEANUP;
     8270                    else if (req_heap_xram_rsp) r_alloc_heap_fsm = ALLOC_HEAP_XRAM_RSP;
     8271                    else if (req_heap_config)   r_alloc_heap_fsm = ALLOC_HEAP_CONFIG;
     8272                    else if (req_heap_read)     r_alloc_heap_fsm = ALLOC_HEAP_READ;
     8273                }
     8274                break;
     8275
     8276            ////////////////////
    82768277            case ALLOC_HEAP_CAS:
    82778278                if ((r_cas_fsm.read() != CAS_UPT_HEAP_LOCK) and
     
    82798280                        (r_cas_fsm.read() != CAS_UPT_NEXT))
    82808281                {
    8281                     if (r_cleanup_fsm.read() == CLEANUP_HEAP_REQ)
    8282                         r_alloc_heap_fsm = ALLOC_HEAP_CLEANUP;
    8283 
    8284                     else if (r_xram_rsp_fsm.read() == XRAM_RSP_HEAP_REQ)
    8285                         r_alloc_heap_fsm = ALLOC_HEAP_XRAM_RSP;
    8286 
    8287                     else if (r_config_fsm.read() == CONFIG_HEAP_REQ)
    8288                         r_alloc_heap_fsm = ALLOC_HEAP_CONFIG;
    8289 
    8290                     else if (r_read_fsm.read() == READ_HEAP_REQ)
    8291                         r_alloc_heap_fsm = ALLOC_HEAP_READ;
    8292 
    8293                     else if (r_write_fsm.read() == WRITE_UPT_HEAP_LOCK)
    8294                         r_alloc_heap_fsm = ALLOC_HEAP_WRITE;
    8295                 }
    8296                 break;
    8297 
    8298                 ///////////////////////
     8282                    if      (req_heap_cleanup)  r_alloc_heap_fsm = ALLOC_HEAP_CLEANUP;
     8283                    else if (req_heap_xram_rsp) r_alloc_heap_fsm = ALLOC_HEAP_XRAM_RSP;
     8284                    else if (req_heap_config)   r_alloc_heap_fsm = ALLOC_HEAP_CONFIG;
     8285                    else if (req_heap_read)     r_alloc_heap_fsm = ALLOC_HEAP_READ;
     8286                    else if (req_heap_write)    r_alloc_heap_fsm = ALLOC_HEAP_WRITE;
     8287                }
     8288                break;
     8289
     8290            ////////////////////////
    82998291            case ALLOC_HEAP_CLEANUP:
    83008292                if ((r_cleanup_fsm.read() != CLEANUP_HEAP_REQ) and
     
    83038295                        (r_cleanup_fsm.read() != CLEANUP_HEAP_CLEAN))
    83048296                {
    8305                     if (r_xram_rsp_fsm.read() == XRAM_RSP_HEAP_REQ)
    8306                         r_alloc_heap_fsm = ALLOC_HEAP_XRAM_RSP;
    8307 
    8308                     else if (r_config_fsm.read() == CONFIG_HEAP_REQ)
    8309                         r_alloc_heap_fsm = ALLOC_HEAP_CONFIG;
    8310 
    8311                     else if (r_read_fsm.read() == READ_HEAP_REQ)
    8312                         r_alloc_heap_fsm = ALLOC_HEAP_READ;
    8313 
    8314                     else if (r_write_fsm.read() == WRITE_UPT_HEAP_LOCK)
    8315                         r_alloc_heap_fsm = ALLOC_HEAP_WRITE;
    8316 
    8317                     else if (r_cas_fsm.read() == CAS_UPT_HEAP_LOCK)
    8318                         r_alloc_heap_fsm = ALLOC_HEAP_CAS;
    8319                 }
    8320                 break;
    8321 
    8322                 ////////////////////////
     8297                    if      (req_heap_xram_rsp) r_alloc_heap_fsm = ALLOC_HEAP_XRAM_RSP;
     8298                    else if (req_heap_config)   r_alloc_heap_fsm = ALLOC_HEAP_CONFIG;
     8299                    else if (req_heap_read)     r_alloc_heap_fsm = ALLOC_HEAP_READ;
     8300                    else if (req_heap_write)    r_alloc_heap_fsm = ALLOC_HEAP_WRITE;
     8301                    else if (req_heap_cas)      r_alloc_heap_fsm = ALLOC_HEAP_CAS;
     8302                }
     8303                break;
     8304
     8305            ////////////////////////
    83238306            case ALLOC_HEAP_XRAM_RSP:
    83248307                if ((r_xram_rsp_fsm.read() != XRAM_RSP_HEAP_REQ) and
    83258308                        (r_xram_rsp_fsm.read() != XRAM_RSP_HEAP_ERASE))
    83268309                {
    8327                     if (r_config_fsm.read() == CONFIG_HEAP_REQ)
    8328                         r_alloc_heap_fsm = ALLOC_HEAP_CONFIG;
    8329 
    8330                     else if (r_read_fsm.read() == READ_HEAP_REQ)
    8331                         r_alloc_heap_fsm = ALLOC_HEAP_READ;
    8332 
    8333                     else if (r_write_fsm.read() == WRITE_UPT_HEAP_LOCK)
    8334                         r_alloc_heap_fsm = ALLOC_HEAP_WRITE;
    8335 
    8336                     else if (r_cas_fsm.read() == CAS_UPT_HEAP_LOCK)
    8337                         r_alloc_heap_fsm = ALLOC_HEAP_CAS;
    8338 
    8339                     else if (r_cleanup_fsm.read() == CLEANUP_HEAP_REQ)
    8340                         r_alloc_heap_fsm = ALLOC_HEAP_CLEANUP;
    8341 
    8342                 }
    8343                 break;
    8344 
    8345                 ///////////////////////
     8310                    if      (req_heap_config)   r_alloc_heap_fsm = ALLOC_HEAP_CONFIG;
     8311                    else if (req_heap_read)     r_alloc_heap_fsm = ALLOC_HEAP_READ;
     8312                    else if (req_heap_write)    r_alloc_heap_fsm = ALLOC_HEAP_WRITE;
     8313                    else if (req_heap_cas)      r_alloc_heap_fsm = ALLOC_HEAP_CAS;
     8314                    else if (req_heap_cleanup)  r_alloc_heap_fsm = ALLOC_HEAP_CLEANUP;
     8315                }
     8316                break;
     8317
     8318            ///////////////////////
    83468319            case ALLOC_HEAP_CONFIG:
    83478320                if ((r_config_fsm.read() != CONFIG_HEAP_REQ) and
    83488321                        (r_config_fsm.read() != CONFIG_HEAP_SCAN))
    83498322                {
    8350                     if (r_read_fsm.read() == READ_HEAP_REQ)
    8351                         r_alloc_heap_fsm = ALLOC_HEAP_READ;
    8352 
    8353                     else if (r_write_fsm.read() == WRITE_UPT_HEAP_LOCK)
    8354                         r_alloc_heap_fsm = ALLOC_HEAP_WRITE;
    8355 
    8356                     else if (r_cas_fsm.read() == CAS_UPT_HEAP_LOCK)
    8357                         r_alloc_heap_fsm = ALLOC_HEAP_CAS;
    8358 
    8359                     else if (r_cleanup_fsm.read() == CLEANUP_HEAP_REQ)
    8360                         r_alloc_heap_fsm = ALLOC_HEAP_CLEANUP;
    8361 
    8362                     else if (r_xram_rsp_fsm.read() == XRAM_RSP_HEAP_REQ)
    8363                         r_alloc_heap_fsm = ALLOC_HEAP_XRAM_RSP;
     8323                    if      (req_heap_read)     r_alloc_heap_fsm = ALLOC_HEAP_READ;
     8324                    else if (req_heap_write)    r_alloc_heap_fsm = ALLOC_HEAP_WRITE;
     8325                    else if (req_heap_cas)      r_alloc_heap_fsm = ALLOC_HEAP_CAS;
     8326                    else if (req_heap_cleanup)  r_alloc_heap_fsm = ALLOC_HEAP_CLEANUP;
     8327                    else if (req_heap_xram_rsp) r_alloc_heap_fsm = ALLOC_HEAP_XRAM_RSP;
    83648328                }
    83658329                break;
     
    83678331        } // end switch alloc_heap_fsm
    83688332
    8369         //std::cout << std::endl << "fifo_update" << std::endl;
    83708333
    83718334        /////////////////////////////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.